blob: 234877a09dfb3b61eb62953c67c080ce6f12b3b9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-pxa/poodle.c
3 *
4 * Support for the SHARP Poodle Board.
5 *
6 * Based on:
7 * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
8 *
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.
12 *
13 * Change Log
14 * 12-Dec-2002 Sharp Corporation for Poodle
15 * John Lenz <lenz@cs.wisc.edu> updates to 2.6
16 */
17#include <linux/kernel.h>
18#include <linux/init.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010019#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/fb.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010021#include <linux/pm.h>
Richard Purdie88660352006-06-19 19:58:51 +010022#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24#include <asm/hardware.h>
25#include <asm/mach-types.h>
26#include <asm/irq.h>
27#include <asm/setup.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010028#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/irq.h>
33
34#include <asm/arch/pxa-regs.h>
Richard Purdie13b9d472005-09-15 14:53:22 +010035#include <asm/arch/mmc.h>
36#include <asm/arch/udc.h>
Richard Purdie8e4b8712005-10-30 14:38:52 +000037#include <asm/arch/irda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include <asm/arch/poodle.h>
39#include <asm/arch/pxafb.h>
40
41#include <asm/hardware/scoop.h>
42#include <asm/hardware/locomo.h>
43#include <asm/mach/sharpsl_param.h>
44
45#include "generic.h"
46
47static struct resource poodle_scoop_resources[] = {
48 [0] = {
49 .start = 0x10800000,
50 .end = 0x10800fff,
51 .flags = IORESOURCE_MEM,
52 },
53};
54
55static struct scoop_config poodle_scoop_setup = {
56 .io_dir = POODLE_SCOOP_IO_DIR,
57 .io_out = POODLE_SCOOP_IO_OUT,
58};
59
60struct platform_device poodle_scoop_device = {
61 .name = "sharp-scoop",
62 .id = -1,
63 .dev = {
64 .platform_data = &poodle_scoop_setup,
65 },
66 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
67 .resource = poodle_scoop_resources,
68};
69
Richard Purdiea63ae442005-11-08 19:15:43 +000070static void poodle_pcmcia_init(void)
71{
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);
78
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);
89}
90
Richard Purdie0ce76252005-09-05 20:49:54 +010091static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
92{
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",
97},
98};
99
Richard Purdiea63ae442005-11-08 19:15:43 +0000100static struct scoop_pcmcia_config poodle_pcmcia_config = {
101 .devs = &poodle_pcmcia_scoop[0],
102 .num_devs = 1,
103 .pcmcia_init = poodle_pcmcia_init,
104};
105
106EXPORT_SYMBOL(poodle_scoop_device);
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
109/* LoCoMo device */
110static struct resource locomo_resources[] = {
111 [0] = {
112 .start = 0x10000000,
113 .end = 0x10001fff,
114 .flags = IORESOURCE_MEM,
115 },
116 [1] = {
117 .start = IRQ_GPIO(10),
118 .end = IRQ_GPIO(10),
119 .flags = IORESOURCE_IRQ,
120 },
121};
122
123static struct platform_device locomo_device = {
124 .name = "locomo",
125 .id = 0,
126 .num_resources = ARRAY_SIZE(locomo_resources),
127 .resource = locomo_resources,
128};
129
Richard Purdie13b9d472005-09-15 14:53:22 +0100130
131/*
132 * MMC/SD Device
133 *
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.
136 */
137static struct pxamci_platform_data poodle_mci_platform_data;
138
139static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data)
140{
141 int err;
142
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);
Richard Purdie88660352006-06-19 19:58:51 +0100147 pxa_gpio_mode(POODLE_GPIO_nSD_WP | GPIO_IN);
Richard Purdie13b9d472005-09-15 14:53:22 +0100148 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
Richard Purdie88660352006-06-19 19:58:51 +0100149 pxa_gpio_mode(POODLE_GPIO_SD_PWR1 | GPIO_OUT);
Richard Purdie13b9d472005-09-15 14:53:22 +0100150
151 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
152
Russell King9ded96f2006-01-08 01:02:07 -0800153 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);
Richard Purdie13b9d472005-09-15 14:53:22 +0100156 if (err) {
157 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
158 return -1;
159 }
160
Richard Purdie13b9d472005-09-15 14:53:22 +0100161 return 0;
162}
163
164static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
165{
166 struct pxamci_platform_data* p_d = dev->platform_data;
167
Richard Purdie88660352006-06-19 19:58:51 +0100168 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);
175 }
Richard Purdie13b9d472005-09-15 14:53:22 +0100176}
177
Richard Purdie88660352006-06-19 19:58:51 +0100178static int poodle_mci_get_ro(struct device *dev)
179{
180 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
181}
182
183
Richard Purdie13b9d472005-09-15 14:53:22 +0100184static void poodle_mci_exit(struct device *dev, void *data)
185{
186 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
187}
188
189static struct pxamci_platform_data poodle_mci_platform_data = {
190 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
191 .init = poodle_mci_init,
Richard Purdie88660352006-06-19 19:58:51 +0100192 .get_ro = poodle_mci_get_ro,
Richard Purdie13b9d472005-09-15 14:53:22 +0100193 .setpower = poodle_mci_setpower,
194 .exit = poodle_mci_exit,
195};
196
197
198/*
Richard Purdie8e4b8712005-10-30 14:38:52 +0000199 * Irda
200 */
201static void poodle_irda_transceiver_mode(struct device *dev, int mode)
202{
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);
207 }
208}
209
210static struct pxaficp_platform_data poodle_ficp_platform_data = {
211 .transceiver_cap = IR_SIRMODE | IR_OFF,
212 .transceiver_mode = poodle_irda_transceiver_mode,
213};
214
215
216/*
Richard Purdie13b9d472005-09-15 14:53:22 +0100217 * USB Device Controller
218 */
219static void poodle_udc_command(int cmd)
220{
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;
228 }
229}
230
231static struct pxa2xx_udc_mach_info udc_info __initdata = {
232 /* no connect GPIO; poodle can't tell connection status */
233 .udc_command = poodle_udc_command,
234};
235
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237/* PXAFB device */
238static struct pxafb_mach_info poodle_fb_info __initdata = {
239 .pixclock = 144700,
240
241 .xres = 320,
242 .yres = 240,
243 .bpp = 16,
244
245 .hsync_len = 7,
246 .left_margin = 11,
247 .right_margin = 30,
248
249 .vsync_len = 2,
250 .upper_margin = 2,
251 .lower_margin = 0,
252 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
253
254 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
255 .lccr3 = 0,
256
257 .pxafb_backlight_power = NULL,
258 .pxafb_lcd_power = NULL,
259};
260
261static struct platform_device *devices[] __initdata = {
262 &locomo_device,
263 &poodle_scoop_device,
264};
265
Richard Purdie74617fb2006-06-19 19:57:12 +0100266static void poodle_poweroff(void)
267{
268 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
269 arm_machine_restart('h');
270}
271
272static void poodle_restart(char mode)
273{
274 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
275 arm_machine_restart('h');
276}
277
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278static void __init poodle_init(void)
279{
280 int ret = 0;
281
Richard Purdie74617fb2006-06-19 19:57:12 +0100282 pm_power_off = poodle_poweroff;
283 arm_pm_restart = poodle_restart;
284
Richard Purdief29d2452005-09-15 14:53:22 +0100285 /* 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;
293
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 /* cpu initialize */
295 /* Pgsr Register */
296 PGSR0 = 0x0146dd80;
297 PGSR1 = 0x03bf0890;
298 PGSR2 = 0x0001c000;
299
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;
307
308 /* Direction Register */
309 GPDR0 = 0xd3f0904c;
310 GPDR1 = 0xfcffb7d3;
311 GPDR2 = 0x0001ffff;
312
313 /* Output Register */
314 GPCR0 = 0x00000000;
315 GPCR1 = 0x00000000;
316 GPCR2 = 0x00000000;
317
318 GPSR0 = 0x00400000;
319 GPSR1 = 0x00000000;
320 GPSR2 = 0x00000000;
321
322 set_pxa_fb_info(&poodle_fb_info);
Richard Purdie13b9d472005-09-15 14:53:22 +0100323 pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000324 pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
Richard Purdie13b9d472005-09-15 14:53:22 +0100325 pxa_set_udc_info(&udc_info);
326 pxa_set_mci_info(&poodle_mci_platform_data);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000327 pxa_set_ficp_info(&poodle_ficp_platform_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Richard Purdiea63ae442005-11-08 19:15:43 +0000329 platform_scoop_config = &poodle_pcmcia_config;
Richard Purdie0ce76252005-09-05 20:49:54 +0100330
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
332 if (ret) {
333 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
334 }
335}
336
337static void __init fixup_poodle(struct machine_desc *desc,
338 struct tag *tags, char **cmdline, struct meminfo *mi)
339{
340 sharpsl_save_param();
Richard Purdieb2e6f752006-04-02 17:11:00 +0100341 mi->nr_banks=1;
342 mi->bank[0].start = 0xa0000000;
343 mi->bank[0].node = 0;
344 mi->bank[0].size = (32*1024*1024);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345}
346
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347MACHINE_START(POODLE, "SHARP Poodle")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100348 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100349 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100350 .fixup = fixup_poodle,
Richard Purdief29d2452005-09-15 14:53:22 +0100351 .map_io = pxa_map_io,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100352 .init_irq = pxa_init_irq,
353 .timer = &pxa_timer,
354 .init_machine = poodle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355MACHINE_END