Alignment in mv643xx_eth
[linux-2.6/mini2440.git] / arch / arm / mach-pxa / poodle.c
blob34fb80b37023090147e43c1870591f6a829f6758
1 /*
2 * linux/arch/arm/mach-pxa/poodle.c
4 * Support for the SHARP Poodle Board.
6 * Based on:
7 * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 * Change Log
14 * 12-Dec-2002 Sharp Corporation for Poodle
15 * John Lenz <lenz@cs.wisc.edu> updates to 2.6
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
20 #include <linux/fb.h>
21 #include <linux/pm.h>
22 #include <linux/delay.h>
24 #include <asm/hardware.h>
25 #include <asm/mach-types.h>
26 #include <asm/irq.h>
27 #include <asm/setup.h>
28 #include <asm/system.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/irq.h>
34 #include <asm/arch/pxa-regs.h>
35 #include <asm/arch/mmc.h>
36 #include <asm/arch/udc.h>
37 #include <asm/arch/irda.h>
38 #include <asm/arch/poodle.h>
39 #include <asm/arch/pxafb.h>
40 #include <asm/arch/sharpsl.h>
41 #include <asm/arch/ssp.h>
43 #include <asm/hardware/scoop.h>
44 #include <asm/hardware/locomo.h>
45 #include <asm/mach/sharpsl_param.h>
47 #include "generic.h"
48 #include "sharpsl.h"
50 static struct resource poodle_scoop_resources[] = {
51 [0] = {
52 .start = 0x10800000,
53 .end = 0x10800fff,
54 .flags = IORESOURCE_MEM,
58 static struct scoop_config poodle_scoop_setup = {
59 .io_dir = POODLE_SCOOP_IO_DIR,
60 .io_out = POODLE_SCOOP_IO_OUT,
63 struct platform_device poodle_scoop_device = {
64 .name = "sharp-scoop",
65 .id = -1,
66 .dev = {
67 .platform_data = &poodle_scoop_setup,
69 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
70 .resource = poodle_scoop_resources,
73 static void poodle_pcmcia_init(void)
75 /* Setup default state of GPIO outputs
76 before we enable them as outputs. */
77 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
78 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
79 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
80 GPIO_bit(GPIO53_nPCE_2);
82 pxa_gpio_mode(GPIO48_nPOE_MD);
83 pxa_gpio_mode(GPIO49_nPWE_MD);
84 pxa_gpio_mode(GPIO50_nPIOR_MD);
85 pxa_gpio_mode(GPIO51_nPIOW_MD);
86 pxa_gpio_mode(GPIO55_nPREG_MD);
87 pxa_gpio_mode(GPIO56_nPWAIT_MD);
88 pxa_gpio_mode(GPIO57_nIOIS16_MD);
89 pxa_gpio_mode(GPIO52_nPCE_1_MD);
90 pxa_gpio_mode(GPIO53_nPCE_2_MD);
91 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
94 static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
96 .dev = &poodle_scoop_device.dev,
97 .irq = POODLE_IRQ_GPIO_CF_IRQ,
98 .cd_irq = POODLE_IRQ_GPIO_CF_CD,
99 .cd_irq_str = "PCMCIA0 CD",
103 static struct scoop_pcmcia_config poodle_pcmcia_config = {
104 .devs = &poodle_pcmcia_scoop[0],
105 .num_devs = 1,
106 .pcmcia_init = poodle_pcmcia_init,
109 EXPORT_SYMBOL(poodle_scoop_device);
112 /* LoCoMo device */
113 static struct resource locomo_resources[] = {
114 [0] = {
115 .start = 0x10000000,
116 .end = 0x10001fff,
117 .flags = IORESOURCE_MEM,
119 [1] = {
120 .start = IRQ_GPIO(10),
121 .end = IRQ_GPIO(10),
122 .flags = IORESOURCE_IRQ,
126 struct platform_device poodle_locomo_device = {
127 .name = "locomo",
128 .id = 0,
129 .num_resources = ARRAY_SIZE(locomo_resources),
130 .resource = locomo_resources,
133 EXPORT_SYMBOL(poodle_locomo_device);
136 * Poodle SSP Device
139 struct platform_device poodle_ssp_device = {
140 .name = "corgi-ssp",
141 .id = -1,
144 struct corgissp_machinfo poodle_ssp_machinfo = {
145 .port = 1,
146 .cs_lcdcon = -1,
147 .cs_ads7846 = -1,
148 .cs_max1111 = -1,
149 .clk_lcdcon = 2,
150 .clk_ads7846 = 36,
151 .clk_max1111 = 2,
156 * Poodle Touch Screen Device
158 static struct resource poodlets_resources[] = {
159 [0] = {
160 .start = POODLE_IRQ_GPIO_TP_INT,
161 .end = POODLE_IRQ_GPIO_TP_INT,
162 .flags = IORESOURCE_IRQ,
166 static unsigned long poodle_get_hsync_len(void)
168 return 0;
171 static void poodle_null_hsync(void)
175 static struct corgits_machinfo poodle_ts_machinfo = {
176 .get_hsync_len = poodle_get_hsync_len,
177 .put_hsync = poodle_null_hsync,
178 .wait_hsync = poodle_null_hsync,
181 static struct platform_device poodle_ts_device = {
182 .name = "corgi-ts",
183 .dev = {
184 .platform_data = &poodle_ts_machinfo,
186 .id = -1,
187 .num_resources = ARRAY_SIZE(poodlets_resources),
188 .resource = poodlets_resources,
193 * MMC/SD Device
195 * The card detect interrupt isn't debounced so we delay it by 250ms
196 * to give the card a chance to fully insert/eject.
198 static struct pxamci_platform_data poodle_mci_platform_data;
200 static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
202 int err;
204 /* setup GPIO for PXA25x MMC controller */
205 pxa_gpio_mode(GPIO6_MMCCLK_MD);
206 pxa_gpio_mode(GPIO8_MMCCS0_MD);
207 pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
208 pxa_gpio_mode(POODLE_GPIO_nSD_WP | GPIO_IN);
209 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
210 pxa_gpio_mode(POODLE_GPIO_SD_PWR1 | GPIO_OUT);
212 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
214 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
215 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
216 "MMC card detect", data);
217 if (err) {
218 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
219 return -1;
222 return 0;
225 static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
227 struct pxamci_platform_data* p_d = dev->platform_data;
229 if (( 1 << vdd) & p_d->ocr_mask) {
230 GPSR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
231 mdelay(2);
232 GPSR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
233 } else {
234 GPCR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
235 GPCR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
239 static int poodle_mci_get_ro(struct device *dev)
241 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
245 static void poodle_mci_exit(struct device *dev, void *data)
247 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
250 static struct pxamci_platform_data poodle_mci_platform_data = {
251 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
252 .init = poodle_mci_init,
253 .get_ro = poodle_mci_get_ro,
254 .setpower = poodle_mci_setpower,
255 .exit = poodle_mci_exit,
260 * Irda
262 static void poodle_irda_transceiver_mode(struct device *dev, int mode)
264 if (mode & IR_OFF) {
265 GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
266 } else {
267 GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
271 static struct pxaficp_platform_data poodle_ficp_platform_data = {
272 .transceiver_cap = IR_SIRMODE | IR_OFF,
273 .transceiver_mode = poodle_irda_transceiver_mode,
278 * USB Device Controller
280 static void poodle_udc_command(int cmd)
282 switch(cmd) {
283 case PXA2XX_UDC_CMD_CONNECT:
284 GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
285 break;
286 case PXA2XX_UDC_CMD_DISCONNECT:
287 GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
288 break;
292 static struct pxa2xx_udc_mach_info udc_info __initdata = {
293 /* no connect GPIO; poodle can't tell connection status */
294 .udc_command = poodle_udc_command,
298 /* PXAFB device */
299 static struct pxafb_mode_info poodle_fb_mode = {
300 .pixclock = 144700,
301 .xres = 320,
302 .yres = 240,
303 .bpp = 16,
304 .hsync_len = 7,
305 .left_margin = 11,
306 .right_margin = 30,
307 .vsync_len = 2,
308 .upper_margin = 2,
309 .lower_margin = 0,
310 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
313 static struct pxafb_mach_info poodle_fb_info = {
314 .modes = &poodle_fb_mode,
315 .num_modes = 1,
316 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
317 .lccr3 = 0,
320 static struct platform_device *devices[] __initdata = {
321 &poodle_locomo_device,
322 &poodle_scoop_device,
323 &poodle_ssp_device,
324 &poodle_ts_device,
327 static void poodle_poweroff(void)
329 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
330 arm_machine_restart('h');
333 static void poodle_restart(char mode)
335 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
336 arm_machine_restart('h');
339 static void __init poodle_init(void)
341 int ret = 0;
343 pm_power_off = poodle_poweroff;
344 arm_pm_restart = poodle_restart;
346 /* setup sleep mode values */
347 PWER = 0x00000002;
348 PFER = 0x00000000;
349 PRER = 0x00000002;
350 PGSR0 = 0x00008000;
351 PGSR1 = 0x003F0202;
352 PGSR2 = 0x0001C000;
353 PCFR |= PCFR_OPDE;
355 /* cpu initialize */
356 /* Pgsr Register */
357 PGSR0 = 0x0146dd80;
358 PGSR1 = 0x03bf0890;
359 PGSR2 = 0x0001c000;
361 /* Alternate Register */
362 GAFR0_L = 0x01001000;
363 GAFR0_U = 0x591a8010;
364 GAFR1_L = 0x900a8451;
365 GAFR1_U = 0xaaa5aaaa;
366 GAFR2_L = 0x8aaaaaaa;
367 GAFR2_U = 0x00000002;
369 /* Direction Register */
370 GPDR0 = 0xd3f0904c;
371 GPDR1 = 0xfcffb7d3;
372 GPDR2 = 0x0001ffff;
374 /* Output Register */
375 GPCR0 = 0x00000000;
376 GPCR1 = 0x00000000;
377 GPCR2 = 0x00000000;
379 GPSR0 = 0x00400000;
380 GPSR1 = 0x00000000;
381 GPSR2 = 0x00000000;
383 set_pxa_fb_parent(&poodle_locomo_device.dev);
384 set_pxa_fb_info(&poodle_fb_info);
385 pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
386 pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
387 pxa_set_udc_info(&udc_info);
388 pxa_set_mci_info(&poodle_mci_platform_data);
389 pxa_set_ficp_info(&poodle_ficp_platform_data);
391 platform_scoop_config = &poodle_pcmcia_config;
393 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
394 if (ret) {
395 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
397 corgi_ssp_set_machinfo(&poodle_ssp_machinfo);
400 static void __init fixup_poodle(struct machine_desc *desc,
401 struct tag *tags, char **cmdline, struct meminfo *mi)
403 sharpsl_save_param();
404 mi->nr_banks=1;
405 mi->bank[0].start = 0xa0000000;
406 mi->bank[0].node = 0;
407 mi->bank[0].size = (32*1024*1024);
410 MACHINE_START(POODLE, "SHARP Poodle")
411 .phys_io = 0x40000000,
412 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
413 .fixup = fixup_poodle,
414 .map_io = pxa_map_io,
415 .init_irq = pxa_init_irq,
416 .timer = &pxa_timer,
417 .init_machine = poodle_init,
418 MACHINE_END