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/init.h>
13 #include <generated/utsrelease.h>
14 #include <linux/pci.h>
19 #include <asm/machdep.h>
21 #include <asm/mpc52xx.h>
23 #define EFIKA_PLATFORM_NAME "Efika"
26 /* ------------------------------------------------------------------------ */
27 /* PCI accesses thru RTAS */
28 /* ------------------------------------------------------------------------ */
33 * Access functions for PCI config space using RTAS calls.
35 static int rtas_read_config(struct pci_bus
*bus
, unsigned int devfn
, int offset
,
38 struct pci_controller
*hose
= pci_bus_to_host(bus
);
39 unsigned long addr
= (offset
& 0xff) | ((devfn
& 0xff) << 8)
40 | (((bus
->number
- hose
->first_busno
) & 0xff) << 16)
41 | (hose
->global_number
<< 24);
45 rval
= rtas_call(rtas_token("read-pci-config"), 2, 2, &ret
, addr
, len
);
47 return rval
? PCIBIOS_DEVICE_NOT_FOUND
: PCIBIOS_SUCCESSFUL
;
50 static int rtas_write_config(struct pci_bus
*bus
, unsigned int devfn
,
51 int offset
, int len
, u32 val
)
53 struct pci_controller
*hose
= pci_bus_to_host(bus
);
54 unsigned long addr
= (offset
& 0xff) | ((devfn
& 0xff) << 8)
55 | (((bus
->number
- hose
->first_busno
) & 0xff) << 16)
56 | (hose
->global_number
<< 24);
59 rval
= rtas_call(rtas_token("write-pci-config"), 3, 1, NULL
,
61 return rval
? PCIBIOS_DEVICE_NOT_FOUND
: PCIBIOS_SUCCESSFUL
;
64 static struct pci_ops rtas_pci_ops
= {
65 .read
= rtas_read_config
,
66 .write
= rtas_write_config
,
70 static void __init
efika_pcisetup(void)
74 struct pci_controller
*hose
;
75 struct device_node
*root
;
76 struct device_node
*pcictrl
;
78 root
= of_find_node_by_path("/");
80 printk(KERN_WARNING EFIKA_PLATFORM_NAME
81 ": Unable to find the root node\n");
85 for (pcictrl
= NULL
;;) {
86 pcictrl
= of_get_next_child(root
, pcictrl
);
87 if ((pcictrl
== NULL
) || (strcmp(pcictrl
->name
, "pci") == 0))
93 if (pcictrl
== NULL
) {
94 printk(KERN_WARNING EFIKA_PLATFORM_NAME
95 ": Unable to find the PCI bridge node\n");
99 bus_range
= of_get_property(pcictrl
, "bus-range", &len
);
100 if (bus_range
== NULL
|| len
< 2 * sizeof(int)) {
101 printk(KERN_WARNING EFIKA_PLATFORM_NAME
102 ": Can't get bus-range for %pOF\n", pcictrl
);
106 if (bus_range
[1] == bus_range
[0])
107 printk(KERN_INFO EFIKA_PLATFORM_NAME
": PCI bus %d",
110 printk(KERN_INFO EFIKA_PLATFORM_NAME
": PCI buses %d..%d",
111 bus_range
[0], bus_range
[1]);
112 printk(" controlled by %pOF\n", pcictrl
);
115 hose
= pcibios_alloc_controller(pcictrl
);
117 printk(KERN_WARNING EFIKA_PLATFORM_NAME
118 ": Can't allocate PCI controller structure for %pOF\n",
123 hose
->first_busno
= bus_range
[0];
124 hose
->last_busno
= bus_range
[1];
125 hose
->ops
= &rtas_pci_ops
;
127 pci_process_bridge_OF_ranges(hose
, pcictrl
, 0);
130 of_node_put(pcictrl
);
134 static void __init
efika_pcisetup(void)
140 /* ------------------------------------------------------------------------ */
142 /* ------------------------------------------------------------------------ */
144 static void efika_show_cpuinfo(struct seq_file
*m
)
146 struct device_node
*root
;
147 const char *revision
;
148 const char *codegendescription
;
149 const char *codegenvendor
;
151 root
= of_find_node_by_path("/");
155 revision
= of_get_property(root
, "revision", NULL
);
156 codegendescription
= of_get_property(root
, "CODEGEN,description", NULL
);
157 codegenvendor
= of_get_property(root
, "CODEGEN,vendor", NULL
);
159 if (codegendescription
)
160 seq_printf(m
, "machine\t\t: %s\n", codegendescription
);
162 seq_printf(m
, "machine\t\t: Efika\n");
165 seq_printf(m
, "revision\t: %s\n", revision
);
168 seq_printf(m
, "vendor\t\t: %s\n", codegenvendor
);
174 static void efika_suspend_prepare(void __iomem
*mbar
)
176 u8 pin
= 4; /* GPIO_WKUP_4 (GPIO_PSC6_0 - IRDA_RX) */
177 u8 level
= 1; /* wakeup on high level */
178 /* IOW. to wake it up, short pins 1 and 3 on IRDA connector */
179 mpc52xx_set_wakeup_gpio(pin
, level
);
183 static void __init
efika_setup_arch(void)
187 /* Map important registers from the internal memory map */
188 mpc52xx_map_common_devices();
193 mpc52xx_suspend
.board_suspend_prepare
= efika_suspend_prepare
;
198 ppc_md
.progress("Linux/PPC " UTS_RELEASE
" running on Efika ;-)\n", 0x0);
201 static int __init
efika_probe(void)
203 const char *model
= of_get_property(of_root
, "model", NULL
);
207 if (strcmp(model
, "EFIKA5K2"))
210 ISA_DMA_THRESHOLD
= ~0L;
211 DMA_MODE_READ
= 0x44;
212 DMA_MODE_WRITE
= 0x48;
214 pm_power_off
= rtas_power_off
;
219 define_machine(efika
)
221 .name
= EFIKA_PLATFORM_NAME
,
222 .probe
= efika_probe
,
223 .setup_arch
= efika_setup_arch
,
224 .init
= mpc52xx_declare_of_platform_devices
,
225 .show_cpuinfo
= efika_show_cpuinfo
,
226 .init_IRQ
= mpc52xx_init_irq
,
227 .get_irq
= mpc52xx_get_irq
,
228 .restart
= rtas_restart
,
230 .set_rtc_time
= rtas_set_rtc_time
,
231 .get_rtc_time
= rtas_get_rtc_time
,
232 .progress
= rtas_progress
,
233 .get_boot_time
= rtas_get_boot_time
,
234 .calibrate_decr
= generic_calibrate_decr
,
236 .phys_mem_access_prot
= pci_phys_mem_access_prot
,