blob: 1d516d317e899ae7c2484c27373e5dce0bb90ad1 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23#include <asm/hardware.h>
24#include <asm/mach-types.h>
25#include <asm/irq.h>
26#include <asm/setup.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010027#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31#include <asm/mach/irq.h>
32
33#include <asm/arch/pxa-regs.h>
Richard Purdie13b9d472005-09-15 14:53:22 +010034#include <asm/arch/mmc.h>
35#include <asm/arch/udc.h>
Richard Purdie8e4b8712005-10-30 14:38:52 +000036#include <asm/arch/irda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <asm/arch/poodle.h>
38#include <asm/arch/pxafb.h>
39
40#include <asm/hardware/scoop.h>
41#include <asm/hardware/locomo.h>
42#include <asm/mach/sharpsl_param.h>
43
44#include "generic.h"
45
46static struct resource poodle_scoop_resources[] = {
47 [0] = {
48 .start = 0x10800000,
49 .end = 0x10800fff,
50 .flags = IORESOURCE_MEM,
51 },
52};
53
54static struct scoop_config poodle_scoop_setup = {
55 .io_dir = POODLE_SCOOP_IO_DIR,
56 .io_out = POODLE_SCOOP_IO_OUT,
57};
58
59struct platform_device poodle_scoop_device = {
60 .name = "sharp-scoop",
61 .id = -1,
62 .dev = {
63 .platform_data = &poodle_scoop_setup,
64 },
65 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
66 .resource = poodle_scoop_resources,
67};
68
Richard Purdiea63ae442005-11-08 19:15:43 +000069static void poodle_pcmcia_init(void)
70{
71 /* Setup default state of GPIO outputs
72 before we enable them as outputs. */
73 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
74 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
75 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
76 GPIO_bit(GPIO53_nPCE_2);
77
78 pxa_gpio_mode(GPIO48_nPOE_MD);
79 pxa_gpio_mode(GPIO49_nPWE_MD);
80 pxa_gpio_mode(GPIO50_nPIOR_MD);
81 pxa_gpio_mode(GPIO51_nPIOW_MD);
82 pxa_gpio_mode(GPIO55_nPREG_MD);
83 pxa_gpio_mode(GPIO56_nPWAIT_MD);
84 pxa_gpio_mode(GPIO57_nIOIS16_MD);
85 pxa_gpio_mode(GPIO52_nPCE_1_MD);
86 pxa_gpio_mode(GPIO53_nPCE_2_MD);
87 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
88}
89
Richard Purdie0ce76252005-09-05 20:49:54 +010090static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
91{
92 .dev = &poodle_scoop_device.dev,
93 .irq = POODLE_IRQ_GPIO_CF_IRQ,
94 .cd_irq = POODLE_IRQ_GPIO_CF_CD,
95 .cd_irq_str = "PCMCIA0 CD",
96},
97};
98
Richard Purdiea63ae442005-11-08 19:15:43 +000099static struct scoop_pcmcia_config poodle_pcmcia_config = {
100 .devs = &poodle_pcmcia_scoop[0],
101 .num_devs = 1,
102 .pcmcia_init = poodle_pcmcia_init,
103};
104
105EXPORT_SYMBOL(poodle_scoop_device);
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108/* LoCoMo device */
109static struct resource locomo_resources[] = {
110 [0] = {
111 .start = 0x10000000,
112 .end = 0x10001fff,
113 .flags = IORESOURCE_MEM,
114 },
115 [1] = {
116 .start = IRQ_GPIO(10),
117 .end = IRQ_GPIO(10),
118 .flags = IORESOURCE_IRQ,
119 },
120};
121
122static struct platform_device locomo_device = {
123 .name = "locomo",
124 .id = 0,
125 .num_resources = ARRAY_SIZE(locomo_resources),
126 .resource = locomo_resources,
127};
128
Richard Purdie13b9d472005-09-15 14:53:22 +0100129
130/*
131 * MMC/SD Device
132 *
133 * The card detect interrupt isn't debounced so we delay it by 250ms
134 * to give the card a chance to fully insert/eject.
135 */
136static struct pxamci_platform_data poodle_mci_platform_data;
137
138static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data)
139{
140 int err;
141
142 /* setup GPIO for PXA25x MMC controller */
143 pxa_gpio_mode(GPIO6_MMCCLK_MD);
144 pxa_gpio_mode(GPIO8_MMCCS0_MD);
145 pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
146 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
147
148 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
149
Russell King9ded96f2006-01-08 01:02:07 -0800150 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
151 SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING,
152 "MMC card detect", data);
Richard Purdie13b9d472005-09-15 14:53:22 +0100153 if (err) {
154 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
155 return -1;
156 }
157
Richard Purdie13b9d472005-09-15 14:53:22 +0100158 return 0;
159}
160
161static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
162{
163 struct pxamci_platform_data* p_d = dev->platform_data;
164
165 if (( 1 << vdd) & p_d->ocr_mask)
166 GPSR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
167 else
168 GPCR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
169}
170
171static void poodle_mci_exit(struct device *dev, void *data)
172{
173 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
174}
175
176static struct pxamci_platform_data poodle_mci_platform_data = {
177 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
178 .init = poodle_mci_init,
179 .setpower = poodle_mci_setpower,
180 .exit = poodle_mci_exit,
181};
182
183
184/*
Richard Purdie8e4b8712005-10-30 14:38:52 +0000185 * Irda
186 */
187static void poodle_irda_transceiver_mode(struct device *dev, int mode)
188{
189 if (mode & IR_OFF) {
190 GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
191 } else {
192 GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
193 }
194}
195
196static struct pxaficp_platform_data poodle_ficp_platform_data = {
197 .transceiver_cap = IR_SIRMODE | IR_OFF,
198 .transceiver_mode = poodle_irda_transceiver_mode,
199};
200
201
202/*
Richard Purdie13b9d472005-09-15 14:53:22 +0100203 * USB Device Controller
204 */
205static void poodle_udc_command(int cmd)
206{
207 switch(cmd) {
208 case PXA2XX_UDC_CMD_CONNECT:
209 GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
210 break;
211 case PXA2XX_UDC_CMD_DISCONNECT:
212 GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
213 break;
214 }
215}
216
217static struct pxa2xx_udc_mach_info udc_info __initdata = {
218 /* no connect GPIO; poodle can't tell connection status */
219 .udc_command = poodle_udc_command,
220};
221
222
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223/* PXAFB device */
224static struct pxafb_mach_info poodle_fb_info __initdata = {
225 .pixclock = 144700,
226
227 .xres = 320,
228 .yres = 240,
229 .bpp = 16,
230
231 .hsync_len = 7,
232 .left_margin = 11,
233 .right_margin = 30,
234
235 .vsync_len = 2,
236 .upper_margin = 2,
237 .lower_margin = 0,
238 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
239
240 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
241 .lccr3 = 0,
242
243 .pxafb_backlight_power = NULL,
244 .pxafb_lcd_power = NULL,
245};
246
247static struct platform_device *devices[] __initdata = {
248 &locomo_device,
249 &poodle_scoop_device,
250};
251
Richard Purdie74617fb2006-06-19 19:57:12 +0100252static void poodle_poweroff(void)
253{
254 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
255 arm_machine_restart('h');
256}
257
258static void poodle_restart(char mode)
259{
260 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
261 arm_machine_restart('h');
262}
263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264static void __init poodle_init(void)
265{
266 int ret = 0;
267
Richard Purdie74617fb2006-06-19 19:57:12 +0100268 pm_power_off = poodle_poweroff;
269 arm_pm_restart = poodle_restart;
270
Richard Purdief29d2452005-09-15 14:53:22 +0100271 /* setup sleep mode values */
272 PWER = 0x00000002;
273 PFER = 0x00000000;
274 PRER = 0x00000002;
275 PGSR0 = 0x00008000;
276 PGSR1 = 0x003F0202;
277 PGSR2 = 0x0001C000;
278 PCFR |= PCFR_OPDE;
279
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 /* cpu initialize */
281 /* Pgsr Register */
282 PGSR0 = 0x0146dd80;
283 PGSR1 = 0x03bf0890;
284 PGSR2 = 0x0001c000;
285
286 /* Alternate Register */
287 GAFR0_L = 0x01001000;
288 GAFR0_U = 0x591a8010;
289 GAFR1_L = 0x900a8451;
290 GAFR1_U = 0xaaa5aaaa;
291 GAFR2_L = 0x8aaaaaaa;
292 GAFR2_U = 0x00000002;
293
294 /* Direction Register */
295 GPDR0 = 0xd3f0904c;
296 GPDR1 = 0xfcffb7d3;
297 GPDR2 = 0x0001ffff;
298
299 /* Output Register */
300 GPCR0 = 0x00000000;
301 GPCR1 = 0x00000000;
302 GPCR2 = 0x00000000;
303
304 GPSR0 = 0x00400000;
305 GPSR1 = 0x00000000;
306 GPSR2 = 0x00000000;
307
308 set_pxa_fb_info(&poodle_fb_info);
Richard Purdie13b9d472005-09-15 14:53:22 +0100309 pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000310 pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
Richard Purdie13b9d472005-09-15 14:53:22 +0100311 pxa_set_udc_info(&udc_info);
312 pxa_set_mci_info(&poodle_mci_platform_data);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000313 pxa_set_ficp_info(&poodle_ficp_platform_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
Richard Purdiea63ae442005-11-08 19:15:43 +0000315 platform_scoop_config = &poodle_pcmcia_config;
Richard Purdie0ce76252005-09-05 20:49:54 +0100316
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
318 if (ret) {
319 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
320 }
321}
322
323static void __init fixup_poodle(struct machine_desc *desc,
324 struct tag *tags, char **cmdline, struct meminfo *mi)
325{
326 sharpsl_save_param();
Richard Purdieb2e6f752006-04-02 17:11:00 +0100327 mi->nr_banks=1;
328 mi->bank[0].start = 0xa0000000;
329 mi->bank[0].node = 0;
330 mi->bank[0].size = (32*1024*1024);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331}
332
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333MACHINE_START(POODLE, "SHARP Poodle")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100334 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100335 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100336 .fixup = fixup_poodle,
Richard Purdief29d2452005-09-15 14:53:22 +0100337 .map_io = pxa_map_io,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100338 .init_irq = pxa_init_irq,
339 .timer = &pxa_timer,
340 .init_machine = poodle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341MACHINE_END