[SCSI] qla1280: convert to use the data buffer accessors
[linux-2.6/verdex.git] / arch / powerpc / platforms / 52xx / efika.c
bloba0da70c8b502ad803fc8c36a593a765cbd09ee95
1 /*
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 <linux/utsrelease.h>
14 #include <linux/pci.h>
15 #include <linux/of.h>
16 #include <asm/prom.h>
17 #include <asm/time.h>
18 #include <asm/machdep.h>
19 #include <asm/rtas.h>
20 #include <asm/mpc52xx.h>
22 #define EFIKA_PLATFORM_NAME "Efika"
25 /* ------------------------------------------------------------------------ */
26 /* PCI accesses thru RTAS */
27 /* ------------------------------------------------------------------------ */
29 #ifdef CONFIG_PCI
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,
35 int len, u32 * val)
37 struct pci_controller *hose = bus->sysdata;
38 unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
39 | (((bus->number - hose->first_busno) & 0xff) << 16)
40 | (hose->global_number << 24);
41 int ret = -1;
42 int rval;
44 rval = rtas_call(rtas_token("read-pci-config"), 2, 2, &ret, addr, len);
45 *val = ret;
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 = bus->sysdata;
53 unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
54 | (((bus->number - hose->first_busno) & 0xff) << 16)
55 | (hose->global_number << 24);
56 int rval;
58 rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL,
59 addr, len, val);
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)
71 const int *bus_range;
72 int len;
73 struct pci_controller *hose;
74 struct device_node *root;
75 struct device_node *pcictrl;
77 root = of_find_node_by_path("/");
78 if (root == NULL) {
79 printk(KERN_WARNING EFIKA_PLATFORM_NAME
80 ": Unable to find the root node\n");
81 return;
84 for (pcictrl = NULL;;) {
85 pcictrl = of_get_next_child(root, pcictrl);
86 if ((pcictrl == NULL) || (strcmp(pcictrl->name, "pci") == 0))
87 break;
90 of_node_put(root);
92 if (pcictrl == NULL) {
93 printk(KERN_WARNING EFIKA_PLATFORM_NAME
94 ": Unable to find the PCI bridge node\n");
95 return;
98 bus_range = of_get_property(pcictrl, "bus-range", &len);
99 if (bus_range == NULL || len < 2 * sizeof(int)) {
100 printk(KERN_WARNING EFIKA_PLATFORM_NAME
101 ": Can't get bus-range for %s\n", pcictrl->full_name);
102 return;
105 if (bus_range[1] == bus_range[0])
106 printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI bus %d",
107 bus_range[0]);
108 else
109 printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI buses %d..%d",
110 bus_range[0], bus_range[1]);
111 printk(" controlled by %s\n", pcictrl->full_name);
112 printk("\n");
114 hose = pcibios_alloc_controller(of_node_get(pcictrl));
115 if (!hose) {
116 printk(KERN_WARNING EFIKA_PLATFORM_NAME
117 ": Can't allocate PCI controller structure for %s\n",
118 pcictrl->full_name);
119 return;
122 hose->first_busno = bus_range[0];
123 hose->last_busno = bus_range[1];
124 hose->ops = &rtas_pci_ops;
126 pci_process_bridge_OF_ranges(hose, pcictrl, 0);
129 #else
130 static void __init efika_pcisetup(void)
132 #endif
136 /* ------------------------------------------------------------------------ */
137 /* Platform setup */
138 /* ------------------------------------------------------------------------ */
140 static void efika_show_cpuinfo(struct seq_file *m)
142 struct device_node *root;
143 const char *revision;
144 const char *codegendescription;
145 const char *codegenvendor;
147 root = of_find_node_by_path("/");
148 if (!root)
149 return;
151 revision = of_get_property(root, "revision", NULL);
152 codegendescription = of_get_property(root, "CODEGEN,description", NULL);
153 codegenvendor = of_get_property(root, "CODEGEN,vendor", NULL);
155 if (codegendescription)
156 seq_printf(m, "machine\t\t: %s\n", codegendescription);
157 else
158 seq_printf(m, "machine\t\t: Efika\n");
160 if (revision)
161 seq_printf(m, "revision\t: %s\n", revision);
163 if (codegenvendor)
164 seq_printf(m, "vendor\t\t: %s\n", codegenvendor);
166 of_node_put(root);
169 #ifdef CONFIG_PM
170 static void efika_suspend_prepare(void __iomem *mbar)
172 u8 pin = 4; /* GPIO_WKUP_4 (GPIO_PSC6_0 - IRDA_RX) */
173 u8 level = 1; /* wakeup on high level */
174 /* IOW. to wake it up, short pins 1 and 3 on IRDA connector */
175 mpc52xx_set_wakeup_gpio(pin, level);
177 #endif
179 static void __init efika_setup_arch(void)
181 rtas_initialize();
183 efika_pcisetup();
185 #ifdef CONFIG_PM
186 mpc52xx_suspend.board_suspend_prepare = efika_suspend_prepare;
187 mpc52xx_pm_init();
188 #endif
190 if (ppc_md.progress)
191 ppc_md.progress("Linux/PPC " UTS_RELEASE " running on Efika ;-)\n", 0x0);
194 static int __init efika_probe(void)
196 char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
197 "model", NULL);
199 if (model == NULL)
200 return 0;
201 if (strcmp(model, "EFIKA5K2"))
202 return 0;
204 ISA_DMA_THRESHOLD = ~0L;
205 DMA_MODE_READ = 0x44;
206 DMA_MODE_WRITE = 0x48;
208 return 1;
211 define_machine(efika)
213 .name = EFIKA_PLATFORM_NAME,
214 .probe = efika_probe,
215 .setup_arch = efika_setup_arch,
216 .init = mpc52xx_declare_of_platform_devices,
217 .show_cpuinfo = efika_show_cpuinfo,
218 .init_IRQ = mpc52xx_init_irq,
219 .get_irq = mpc52xx_get_irq,
220 .restart = rtas_restart,
221 .power_off = rtas_power_off,
222 .halt = rtas_halt,
223 .set_rtc_time = rtas_set_rtc_time,
224 .get_rtc_time = rtas_get_rtc_time,
225 .progress = rtas_progress,
226 .get_boot_time = rtas_get_boot_time,
227 .calibrate_decr = generic_calibrate_decr,
228 #ifdef CONFIG_PCI
229 .phys_mem_access_prot = pci_phys_mem_access_prot,
230 #endif