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>
18 #include <asm/machdep.h>
20 #include <asm/mpc52xx.h>
22 #define EFIKA_PLATFORM_NAME "Efika"
25 /* ------------------------------------------------------------------------ */
26 /* PCI accesses thru RTAS */
27 /* ------------------------------------------------------------------------ */
32 * Access functions for PCI config space using RTAS calls.
34 static int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
37 struct pci_controller *hose = pci_bus_to_host(bus);
38 unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
39 | (((bus->number - hose->first_busno) & 0xff) << 16)
40 | (hose->global_number << 24);
44 rval = rtas_call(rtas_function_token(RTAS_FN_READ_PCI_CONFIG), 2, 2, &ret, addr, len);
46 return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
49 static int rtas_write_config(struct pci_bus *bus, unsigned int devfn,
50 int offset, int len, u32 val)
52 struct pci_controller *hose = pci_bus_to_host(bus);
53 unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
54 | (((bus->number - hose->first_busno) & 0xff) << 16)
55 | (hose->global_number << 24);
58 rval = rtas_call(rtas_function_token(RTAS_FN_WRITE_PCI_CONFIG), 3, 1, NULL,
60 return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
63 static struct pci_ops rtas_pci_ops = {
64 .read = rtas_read_config,
65 .write = rtas_write_config,
69 static void __init efika_pcisetup(void)
73 struct pci_controller *hose;
74 struct device_node *root;
75 struct device_node *pcictrl;
77 root = of_find_node_by_path("/");
79 printk(KERN_WARNING EFIKA_PLATFORM_NAME
80 ": Unable to find the root node\n");
84 for_each_child_of_node(root, pcictrl)
85 if (of_node_name_eq(pcictrl, "pci"))
90 if (pcictrl == NULL) {
91 printk(KERN_WARNING EFIKA_PLATFORM_NAME
92 ": Unable to find the PCI bridge node\n");
96 bus_range = of_get_property(pcictrl, "bus-range", &len);
97 if (bus_range == NULL || len < 2 * sizeof(int)) {
98 printk(KERN_WARNING EFIKA_PLATFORM_NAME
99 ": Can't get bus-range for %pOF\n", pcictrl);
103 if (bus_range[1] == bus_range[0])
104 printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI bus %d",
107 printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI buses %d..%d",
108 bus_range[0], bus_range[1]);
109 printk(" controlled by %pOF\n", pcictrl);
112 hose = pcibios_alloc_controller(pcictrl);
114 printk(KERN_WARNING EFIKA_PLATFORM_NAME
115 ": Can't allocate PCI controller structure for %pOF\n",
120 hose->first_busno = bus_range[0];
121 hose->last_busno = bus_range[1];
122 hose->ops = &rtas_pci_ops;
124 pci_process_bridge_OF_ranges(hose, pcictrl, 0);
127 of_node_put(pcictrl);
131 static void __init efika_pcisetup(void)
137 /* ------------------------------------------------------------------------ */
139 /* ------------------------------------------------------------------------ */
141 static void efika_show_cpuinfo(struct seq_file *m)
143 struct device_node *root;
144 const char *revision;
145 const char *codegendescription;
146 const char *codegenvendor;
148 root = of_find_node_by_path("/");
152 revision = of_get_property(root, "revision", NULL);
153 codegendescription = of_get_property(root, "CODEGEN,description", NULL);
154 codegenvendor = of_get_property(root, "CODEGEN,vendor", NULL);
156 if (codegendescription)
157 seq_printf(m, "machine\t\t: %s\n", codegendescription);
159 seq_printf(m, "machine\t\t: Efika\n");
162 seq_printf(m, "revision\t: %s\n", revision);
165 seq_printf(m, "vendor\t\t: %s\n", codegenvendor);
171 static void efika_suspend_prepare(void __iomem *mbar)
173 u8 pin = 4; /* GPIO_WKUP_4 (GPIO_PSC6_0 - IRDA_RX) */
174 u8 level = 1; /* wakeup on high level */
175 /* IOW. to wake it up, short pins 1 and 3 on IRDA connector */
176 mpc52xx_set_wakeup_gpio(pin, level);
180 static void __init efika_setup_arch(void)
184 /* Map important registers from the internal memory map */
185 mpc52xx_map_common_devices();
188 mpc52xx_suspend.board_suspend_prepare = efika_suspend_prepare;
193 ppc_md.progress("Linux/PPC " UTS_RELEASE " running on Efika ;-)\n", 0x0);
196 static int __init efika_probe(void)
198 const char *model = of_get_property(of_root, "model", NULL);
202 if (strcmp(model, "EFIKA5K2"))
205 DMA_MODE_READ = 0x44;
206 DMA_MODE_WRITE = 0x48;
208 pm_power_off = rtas_power_off;
213 define_machine(efika)
215 .name = EFIKA_PLATFORM_NAME,
216 .probe = efika_probe,
217 .setup_arch = efika_setup_arch,
218 .discover_phbs = efika_pcisetup,
219 .init = mpc52xx_declare_of_platform_devices,
220 .show_cpuinfo = efika_show_cpuinfo,
221 .init_IRQ = mpc52xx_init_irq,
222 .get_irq = mpc52xx_get_irq,
223 .restart = rtas_restart,
225 .set_rtc_time = rtas_set_rtc_time,
226 .get_rtc_time = rtas_get_rtc_time,
227 .progress = rtas_progress,
228 .get_boot_time = rtas_get_boot_time,
230 .phys_mem_access_prot = pci_phys_mem_access_prot,