[ARM] 3561/1: Poodle: Correct the MMC/SD power control
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-pxa / poodle.c
blob234877a09dfb3b61eb62953c67c080ce6f12b3b9
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>
41 #include <asm/hardware/scoop.h>
42 #include <asm/hardware/locomo.h>
43 #include <asm/mach/sharpsl_param.h>
45 #include "generic.h"
47 static struct resource poodle_scoop_resources[] = {
48 [0] = {
49 .start = 0x10800000,
50 .end = 0x10800fff,
51 .flags = IORESOURCE_MEM,
55 static struct scoop_config poodle_scoop_setup = {
56 .io_dir = POODLE_SCOOP_IO_DIR,
57 .io_out = POODLE_SCOOP_IO_OUT,
60 struct platform_device poodle_scoop_device = {
61 .name = "sharp-scoop",
62 .id = -1,
63 .dev = {
64 .platform_data = &poodle_scoop_setup,
66 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
67 .resource = poodle_scoop_resources,
70 static void poodle_pcmcia_init(void)
72 /* Setup default state of GPIO outputs
73 before we enable them as outputs. */
74 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
75 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
76 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
77 GPIO_bit(GPIO53_nPCE_2);
79 pxa_gpio_mode(GPIO48_nPOE_MD);
80 pxa_gpio_mode(GPIO49_nPWE_MD);
81 pxa_gpio_mode(GPIO50_nPIOR_MD);
82 pxa_gpio_mode(GPIO51_nPIOW_MD);
83 pxa_gpio_mode(GPIO55_nPREG_MD);
84 pxa_gpio_mode(GPIO56_nPWAIT_MD);
85 pxa_gpio_mode(GPIO57_nIOIS16_MD);
86 pxa_gpio_mode(GPIO52_nPCE_1_MD);
87 pxa_gpio_mode(GPIO53_nPCE_2_MD);
88 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
91 static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
93 .dev = &poodle_scoop_device.dev,
94 .irq = POODLE_IRQ_GPIO_CF_IRQ,
95 .cd_irq = POODLE_IRQ_GPIO_CF_CD,
96 .cd_irq_str = "PCMCIA0 CD",
100 static struct scoop_pcmcia_config poodle_pcmcia_config = {
101 .devs = &poodle_pcmcia_scoop[0],
102 .num_devs = 1,
103 .pcmcia_init = poodle_pcmcia_init,
106 EXPORT_SYMBOL(poodle_scoop_device);
109 /* LoCoMo device */
110 static struct resource locomo_resources[] = {
111 [0] = {
112 .start = 0x10000000,
113 .end = 0x10001fff,
114 .flags = IORESOURCE_MEM,
116 [1] = {
117 .start = IRQ_GPIO(10),
118 .end = IRQ_GPIO(10),
119 .flags = IORESOURCE_IRQ,
123 static struct platform_device locomo_device = {
124 .name = "locomo",
125 .id = 0,
126 .num_resources = ARRAY_SIZE(locomo_resources),
127 .resource = locomo_resources,
132 * MMC/SD Device
134 * The card detect interrupt isn't debounced so we delay it by 250ms
135 * to give the card a chance to fully insert/eject.
137 static struct pxamci_platform_data poodle_mci_platform_data;
139 static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data)
141 int err;
143 /* setup GPIO for PXA25x MMC controller */
144 pxa_gpio_mode(GPIO6_MMCCLK_MD);
145 pxa_gpio_mode(GPIO8_MMCCS0_MD);
146 pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
147 pxa_gpio_mode(POODLE_GPIO_nSD_WP | GPIO_IN);
148 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
149 pxa_gpio_mode(POODLE_GPIO_SD_PWR1 | GPIO_OUT);
151 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
153 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
154 SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING,
155 "MMC card detect", data);
156 if (err) {
157 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
158 return -1;
161 return 0;
164 static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
166 struct pxamci_platform_data* p_d = dev->platform_data;
168 if (( 1 << vdd) & p_d->ocr_mask) {
169 GPSR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
170 mdelay(2);
171 GPSR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
172 } else {
173 GPCR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
174 GPCR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
178 static int poodle_mci_get_ro(struct device *dev)
180 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
184 static void poodle_mci_exit(struct device *dev, void *data)
186 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
189 static struct pxamci_platform_data poodle_mci_platform_data = {
190 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
191 .init = poodle_mci_init,
192 .get_ro = poodle_mci_get_ro,
193 .setpower = poodle_mci_setpower,
194 .exit = poodle_mci_exit,
199 * Irda
201 static void poodle_irda_transceiver_mode(struct device *dev, int mode)
203 if (mode & IR_OFF) {
204 GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
205 } else {
206 GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
210 static struct pxaficp_platform_data poodle_ficp_platform_data = {
211 .transceiver_cap = IR_SIRMODE | IR_OFF,
212 .transceiver_mode = poodle_irda_transceiver_mode,
217 * USB Device Controller
219 static void poodle_udc_command(int cmd)
221 switch(cmd) {
222 case PXA2XX_UDC_CMD_CONNECT:
223 GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
224 break;
225 case PXA2XX_UDC_CMD_DISCONNECT:
226 GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
227 break;
231 static struct pxa2xx_udc_mach_info udc_info __initdata = {
232 /* no connect GPIO; poodle can't tell connection status */
233 .udc_command = poodle_udc_command,
237 /* PXAFB device */
238 static struct pxafb_mach_info poodle_fb_info __initdata = {
239 .pixclock = 144700,
241 .xres = 320,
242 .yres = 240,
243 .bpp = 16,
245 .hsync_len = 7,
246 .left_margin = 11,
247 .right_margin = 30,
249 .vsync_len = 2,
250 .upper_margin = 2,
251 .lower_margin = 0,
252 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
254 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
255 .lccr3 = 0,
257 .pxafb_backlight_power = NULL,
258 .pxafb_lcd_power = NULL,
261 static struct platform_device *devices[] __initdata = {
262 &locomo_device,
263 &poodle_scoop_device,
266 static void poodle_poweroff(void)
268 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
269 arm_machine_restart('h');
272 static void poodle_restart(char mode)
274 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
275 arm_machine_restart('h');
278 static void __init poodle_init(void)
280 int ret = 0;
282 pm_power_off = poodle_poweroff;
283 arm_pm_restart = poodle_restart;
285 /* setup sleep mode values */
286 PWER = 0x00000002;
287 PFER = 0x00000000;
288 PRER = 0x00000002;
289 PGSR0 = 0x00008000;
290 PGSR1 = 0x003F0202;
291 PGSR2 = 0x0001C000;
292 PCFR |= PCFR_OPDE;
294 /* cpu initialize */
295 /* Pgsr Register */
296 PGSR0 = 0x0146dd80;
297 PGSR1 = 0x03bf0890;
298 PGSR2 = 0x0001c000;
300 /* Alternate Register */
301 GAFR0_L = 0x01001000;
302 GAFR0_U = 0x591a8010;
303 GAFR1_L = 0x900a8451;
304 GAFR1_U = 0xaaa5aaaa;
305 GAFR2_L = 0x8aaaaaaa;
306 GAFR2_U = 0x00000002;
308 /* Direction Register */
309 GPDR0 = 0xd3f0904c;
310 GPDR1 = 0xfcffb7d3;
311 GPDR2 = 0x0001ffff;
313 /* Output Register */
314 GPCR0 = 0x00000000;
315 GPCR1 = 0x00000000;
316 GPCR2 = 0x00000000;
318 GPSR0 = 0x00400000;
319 GPSR1 = 0x00000000;
320 GPSR2 = 0x00000000;
322 set_pxa_fb_info(&poodle_fb_info);
323 pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
324 pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
325 pxa_set_udc_info(&udc_info);
326 pxa_set_mci_info(&poodle_mci_platform_data);
327 pxa_set_ficp_info(&poodle_ficp_platform_data);
329 platform_scoop_config = &poodle_pcmcia_config;
331 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
332 if (ret) {
333 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
337 static void __init fixup_poodle(struct machine_desc *desc,
338 struct tag *tags, char **cmdline, struct meminfo *mi)
340 sharpsl_save_param();
341 mi->nr_banks=1;
342 mi->bank[0].start = 0xa0000000;
343 mi->bank[0].node = 0;
344 mi->bank[0].size = (32*1024*1024);
347 MACHINE_START(POODLE, "SHARP Poodle")
348 .phys_io = 0x40000000,
349 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
350 .fixup = fixup_poodle,
351 .map_io = pxa_map_io,
352 .init_irq = pxa_init_irq,
353 .timer = &pxa_timer,
354 .init_machine = poodle_init,
355 MACHINE_END