2 * Efika 5K2 platform code
3 * Some code really inspired from the lite5200b platform.
5 * Copyright (C) 2006 bplan GmbH
7 * This file is licensed under the terms of the GNU General Public License
8 * version 2. This program is licensed "as is" without any warranty of any
9 * kind, whether express or implied.
12 #include <linux/errno.h>
13 #include <linux/kernel.h>
14 #include <linux/slab.h>
15 #include <linux/reboot.h>
16 #include <linux/init.h>
17 #include <linux/utsrelease.h>
18 #include <linux/seq_file.h>
19 #include <linux/string.h>
20 #include <linux/root_dev.h>
21 #include <linux/initrd.h>
22 #include <linux/timer.h>
23 #include <linux/pci.h>
27 #include <asm/sections.h>
28 #include <asm/pci-bridge.h>
29 #include <asm/pgtable.h>
32 #include <asm/machdep.h>
34 #include <asm/of_device.h>
35 #include <asm/of_platform.h>
36 #include <asm/mpc52xx.h>
39 #define EFIKA_PLATFORM_NAME "Efika"
42 /* ------------------------------------------------------------------------ */
43 /* PCI accesses thru RTAS */
44 /* ------------------------------------------------------------------------ */
49 * Access functions for PCI config space using RTAS calls.
51 static int rtas_read_config(struct pci_bus
*bus
, unsigned int devfn
, int offset
,
54 struct pci_controller
*hose
= bus
->sysdata
;
55 unsigned long addr
= (offset
& 0xff) | ((devfn
& 0xff) << 8)
56 | (((bus
->number
- hose
->first_busno
) & 0xff) << 16)
57 | (hose
->index
<< 24);
61 rval
= rtas_call(rtas_token("read-pci-config"), 2, 2, &ret
, addr
, len
);
63 return rval
? PCIBIOS_DEVICE_NOT_FOUND
: PCIBIOS_SUCCESSFUL
;
66 static int rtas_write_config(struct pci_bus
*bus
, unsigned int devfn
,
67 int offset
, int len
, u32 val
)
69 struct pci_controller
*hose
= bus
->sysdata
;
70 unsigned long addr
= (offset
& 0xff) | ((devfn
& 0xff) << 8)
71 | (((bus
->number
- hose
->first_busno
) & 0xff) << 16)
72 | (hose
->index
<< 24);
75 rval
= rtas_call(rtas_token("write-pci-config"), 3, 1, NULL
,
77 return rval
? PCIBIOS_DEVICE_NOT_FOUND
: PCIBIOS_SUCCESSFUL
;
80 static struct pci_ops rtas_pci_ops
= {
86 void __init
efika_pcisetup(void)
90 struct pci_controller
*hose
;
91 struct device_node
*root
;
92 struct device_node
*pcictrl
;
94 root
= of_find_node_by_path("/");
96 printk(KERN_WARNING EFIKA_PLATFORM_NAME
97 ": Unable to find the root node\n");
101 for (pcictrl
= NULL
;;) {
102 pcictrl
= of_get_next_child(root
, pcictrl
);
103 if ((pcictrl
== NULL
) || (strcmp(pcictrl
->name
, "pci") == 0))
109 if (pcictrl
== NULL
) {
110 printk(KERN_WARNING EFIKA_PLATFORM_NAME
111 ": Unable to find the PCI bridge node\n");
115 bus_range
= of_get_property(pcictrl
, "bus-range", &len
);
116 if (bus_range
== NULL
|| len
< 2 * sizeof(int)) {
117 printk(KERN_WARNING EFIKA_PLATFORM_NAME
118 ": Can't get bus-range for %s\n", pcictrl
->full_name
);
122 if (bus_range
[1] == bus_range
[0])
123 printk(KERN_INFO EFIKA_PLATFORM_NAME
": PCI bus %d",
126 printk(KERN_INFO EFIKA_PLATFORM_NAME
": PCI buses %d..%d",
127 bus_range
[0], bus_range
[1]);
128 printk(" controlled by %s\n", pcictrl
->full_name
);
131 hose
= pcibios_alloc_controller();
133 printk(KERN_WARNING EFIKA_PLATFORM_NAME
134 ": Can't allocate PCI controller structure for %s\n",
139 hose
->arch_data
= of_node_get(pcictrl
);
140 hose
->first_busno
= bus_range
[0];
141 hose
->last_busno
= bus_range
[1];
142 hose
->ops
= &rtas_pci_ops
;
144 pci_process_bridge_OF_ranges(hose
, pcictrl
, 0);
148 void __init
efika_pcisetup(void)
154 /* ------------------------------------------------------------------------ */
156 /* ------------------------------------------------------------------------ */
158 static void efika_show_cpuinfo(struct seq_file
*m
)
160 struct device_node
*root
;
161 const char *revision
;
162 const char *codegendescription
;
163 const char *codegenvendor
;
165 root
= of_find_node_by_path("/");
169 revision
= of_get_property(root
, "revision", NULL
);
170 codegendescription
= of_get_property(root
, "CODEGEN,description", NULL
);
171 codegenvendor
= of_get_property(root
, "CODEGEN,vendor", NULL
);
173 if (codegendescription
)
174 seq_printf(m
, "machine\t\t: %s\n", codegendescription
);
176 seq_printf(m
, "machine\t\t: Efika\n");
179 seq_printf(m
, "revision\t: %s\n", revision
);
182 seq_printf(m
, "vendor\t\t: %s\n", codegenvendor
);
188 static void efika_suspend_prepare(void __iomem
*mbar
)
190 u8 pin
= 4; /* GPIO_WKUP_4 (GPIO_PSC6_0 - IRDA_RX) */
191 u8 level
= 1; /* wakeup on high level */
192 /* IOW. to wake it up, short pins 1 and 3 on IRDA connector */
193 mpc52xx_set_wakeup_gpio(pin
, level
);
197 static void __init
efika_setup_arch(void)
201 #ifdef CONFIG_BLK_DEV_INITRD
202 initrd_below_start_ok
= 1;
205 ROOT_DEV
= Root_RAM0
;
208 ROOT_DEV
= Root_SDA2
; /* sda2 (sda1 is for the kernel) */
213 mpc52xx_suspend
.board_suspend_prepare
= efika_suspend_prepare
;
218 ppc_md
.progress("Linux/PPC " UTS_RELEASE
" running on Efika ;-)\n", 0x0);
221 static int __init
efika_probe(void)
223 char *model
= of_get_flat_dt_prop(of_get_flat_dt_root(),
228 if (strcmp(model
, "EFIKA5K2"))
231 ISA_DMA_THRESHOLD
= ~0L;
232 DMA_MODE_READ
= 0x44;
233 DMA_MODE_WRITE
= 0x48;
238 define_machine(efika
)
240 .name
= EFIKA_PLATFORM_NAME
,
241 .probe
= efika_probe
,
242 .setup_arch
= efika_setup_arch
,
243 .init
= mpc52xx_declare_of_platform_devices
,
244 .show_cpuinfo
= efika_show_cpuinfo
,
245 .init_IRQ
= mpc52xx_init_irq
,
246 .get_irq
= mpc52xx_get_irq
,
247 .restart
= rtas_restart
,
248 .power_off
= rtas_power_off
,
250 .set_rtc_time
= rtas_set_rtc_time
,
251 .get_rtc_time
= rtas_get_rtc_time
,
252 .progress
= rtas_progress
,
253 .get_boot_time
= rtas_get_boot_time
,
254 .calibrate_decr
= generic_calibrate_decr
,
256 .phys_mem_access_prot
= pci_phys_mem_access_prot
,