Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Support for Sharp SL-C7xx PDAs | |
3 | * Models: SL-C700 (Corgi), SL-C750 (Shepherd), SL-C760 (Husky) | |
4 | * | |
5 | * Copyright (c) 2004-2005 Richard Purdie | |
6 | * | |
7 | * Based on Sharp's 2.4 kernel patches/lubbock.c | |
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 | */ | |
14 | ||
15 | #include <linux/kernel.h> | |
16 | #include <linux/init.h> | |
d052d1be | 17 | #include <linux/platform_device.h> |
1da177e4 LT |
18 | #include <linux/major.h> |
19 | #include <linux/fs.h> | |
20 | #include <linux/interrupt.h> | |
21 | #include <linux/mmc/host.h> | |
4a9295cc | 22 | #include <linux/mtd/physmap.h> |
74617fb6 | 23 | #include <linux/pm.h> |
9d708752 | 24 | #include <linux/gpio.h> |
c3f8f650 | 25 | #include <linux/backlight.h> |
fced80c7 | 26 | #include <linux/io.h> |
edb403fb EM |
27 | #include <linux/spi/spi.h> |
28 | #include <linux/spi/ads7846.h> | |
29 | #include <linux/spi/corgi_lcd.h> | |
6af7a8eb | 30 | #include <linux/mtd/sharpsl.h> |
ca4d6cfc | 31 | #include <video/w100fb.h> |
1da177e4 LT |
32 | |
33 | #include <asm/setup.h> | |
34 | #include <asm/memory.h> | |
35 | #include <asm/mach-types.h> | |
a09e64fb | 36 | #include <mach/hardware.h> |
1da177e4 | 37 | #include <asm/irq.h> |
74617fb6 | 38 | #include <asm/system.h> |
1da177e4 LT |
39 | |
40 | #include <asm/mach/arch.h> | |
41 | #include <asm/mach/map.h> | |
42 | #include <asm/mach/irq.h> | |
43 | ||
a09e64fb RK |
44 | #include <mach/pxa-regs.h> |
45 | #include <mach/pxa2xx-regs.h> | |
9ae808d8 | 46 | #include <mach/mfp-pxa25x.h> |
f8787fdc | 47 | #include <mach/i2c.h> |
a09e64fb RK |
48 | #include <mach/irda.h> |
49 | #include <mach/mmc.h> | |
50 | #include <mach/udc.h> | |
edb403fb | 51 | #include <mach/pxa2xx_spi.h> |
a09e64fb RK |
52 | #include <mach/corgi.h> |
53 | #include <mach/sharpsl.h> | |
1da177e4 LT |
54 | |
55 | #include <asm/mach/sharpsl_param.h> | |
56 | #include <asm/hardware/scoop.h> | |
1da177e4 LT |
57 | |
58 | #include "generic.h" | |
46c41e62 | 59 | #include "devices.h" |
50a5de44 | 60 | #include "sharpsl.h" |
1da177e4 | 61 | |
9ae808d8 EM |
62 | static unsigned long corgi_pin_config[] __initdata = { |
63 | /* Static Memory I/O */ | |
64 | GPIO78_nCS_2, /* w100fb */ | |
65 | GPIO80_nCS_4, /* scoop */ | |
66 | ||
67 | /* SSP1 */ | |
68 | GPIO23_SSP1_SCLK, | |
69 | GPIO25_SSP1_TXD, | |
70 | GPIO26_SSP1_RXD, | |
71 | GPIO24_GPIO, /* CORGI_GPIO_ADS7846_CS - SFRM as chip select */ | |
72 | ||
73 | /* I2S */ | |
74 | GPIO28_I2S_BITCLK_OUT, | |
75 | GPIO29_I2S_SDATA_IN, | |
76 | GPIO30_I2S_SDATA_OUT, | |
77 | GPIO31_I2S_SYNC, | |
78 | GPIO32_I2S_SYSCLK, | |
79 | ||
80 | /* Infra-Red */ | |
81 | GPIO47_FICP_TXD, | |
82 | GPIO46_FICP_RXD, | |
83 | ||
84 | /* FFUART */ | |
85 | GPIO40_FFUART_DTR, | |
86 | GPIO41_FFUART_RTS, | |
87 | GPIO39_FFUART_TXD, | |
88 | GPIO37_FFUART_DSR, | |
89 | GPIO34_FFUART_RXD, | |
90 | GPIO35_FFUART_CTS, | |
91 | ||
92 | /* PC Card */ | |
93 | GPIO48_nPOE, | |
94 | GPIO49_nPWE, | |
95 | GPIO50_nPIOR, | |
96 | GPIO51_nPIOW, | |
97 | GPIO52_nPCE_1, | |
98 | GPIO53_nPCE_2, | |
99 | GPIO54_nPSKTSEL, | |
100 | GPIO55_nPREG, | |
101 | GPIO56_nPWAIT, | |
102 | GPIO57_nIOIS16, | |
103 | ||
104 | /* MMC */ | |
105 | GPIO6_MMC_CLK, | |
106 | GPIO8_MMC_CS0, | |
107 | ||
108 | /* GPIO */ | |
109 | GPIO9_GPIO, /* CORGI_GPIO_nSD_DETECT */ | |
110 | GPIO7_GPIO, /* CORGI_GPIO_nSD_WP */ | |
111 | GPIO33_GPIO, /* CORGI_GPIO_SD_PWR */ | |
112 | GPIO22_GPIO, /* CORGI_GPIO_IR_ON */ | |
113 | GPIO44_GPIO, /* CORGI_GPIO_HSYNC */ | |
114 | ||
115 | GPIO1_GPIO | WAKEUP_ON_EDGE_RISE, | |
116 | }; | |
1da177e4 LT |
117 | |
118 | /* | |
119 | * Corgi SCOOP Device | |
120 | */ | |
121 | static struct resource corgi_scoop_resources[] = { | |
122 | [0] = { | |
123 | .start = 0x10800000, | |
124 | .end = 0x10800fff, | |
125 | .flags = IORESOURCE_MEM, | |
126 | }, | |
127 | }; | |
128 | ||
129 | static struct scoop_config corgi_scoop_setup = { | |
130 | .io_dir = CORGI_SCOOP_IO_DIR, | |
131 | .io_out = CORGI_SCOOP_IO_OUT, | |
6168cda9 | 132 | .gpio_base = CORGI_SCOOP_GPIO_BASE, |
1da177e4 LT |
133 | }; |
134 | ||
a63ae442 RP |
135 | struct platform_device corgiscoop_device = { |
136 | .name = "sharp-scoop", | |
137 | .id = -1, | |
138 | .dev = { | |
139 | .platform_data = &corgi_scoop_setup, | |
140 | }, | |
141 | .num_resources = ARRAY_SIZE(corgi_scoop_resources), | |
142 | .resource = corgi_scoop_resources, | |
143 | }; | |
144 | ||
0ce7625f RP |
145 | static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = { |
146 | { | |
147 | .dev = &corgiscoop_device.dev, | |
148 | .irq = CORGI_IRQ_GPIO_CF_IRQ, | |
149 | .cd_irq = CORGI_IRQ_GPIO_CF_CD, | |
150 | .cd_irq_str = "PCMCIA0 CD", | |
151 | }, | |
152 | }; | |
153 | ||
a63ae442 RP |
154 | static struct scoop_pcmcia_config corgi_pcmcia_config = { |
155 | .devs = &corgi_pcmcia_scoop[0], | |
156 | .num_devs = 1, | |
1da177e4 LT |
157 | }; |
158 | ||
a63ae442 RP |
159 | EXPORT_SYMBOL(corgiscoop_device); |
160 | ||
ca4d6cfc RP |
161 | static struct w100_mem_info corgi_fb_mem = { |
162 | .ext_cntl = 0x00040003, | |
163 | .sdram_mode_reg = 0x00650021, | |
164 | .ext_timing_cntl = 0x10002a4a, | |
165 | .io_cntl = 0x7ff87012, | |
166 | .size = 0x1fffff, | |
167 | }; | |
168 | ||
169 | static struct w100_gen_regs corgi_fb_regs = { | |
170 | .lcd_format = 0x00000003, | |
171 | .lcdd_cntl1 = 0x01CC0000, | |
172 | .lcdd_cntl2 = 0x0003FFFF, | |
173 | .genlcd_cntl1 = 0x00FFFF0D, | |
174 | .genlcd_cntl2 = 0x003F3003, | |
175 | .genlcd_cntl3 = 0x000102aa, | |
176 | }; | |
177 | ||
178 | static struct w100_gpio_regs corgi_fb_gpio = { | |
179 | .init_data1 = 0x000000bf, | |
180 | .init_data2 = 0x00000000, | |
181 | .gpio_dir1 = 0x00000000, | |
182 | .gpio_oe1 = 0x03c0feff, | |
183 | .gpio_dir2 = 0x00000000, | |
184 | .gpio_oe2 = 0x00000000, | |
185 | }; | |
186 | ||
187 | static struct w100_mode corgi_fb_modes[] = { | |
188 | { | |
189 | .xres = 480, | |
190 | .yres = 640, | |
191 | .left_margin = 0x56, | |
192 | .right_margin = 0x55, | |
193 | .upper_margin = 0x03, | |
194 | .lower_margin = 0x00, | |
195 | .crtc_ss = 0x82360056, | |
196 | .crtc_ls = 0xA0280000, | |
197 | .crtc_gs = 0x80280028, | |
198 | .crtc_vpos_gs = 0x02830002, | |
199 | .crtc_rev = 0x00400008, | |
200 | .crtc_dclk = 0xA0000000, | |
201 | .crtc_gclk = 0x8015010F, | |
202 | .crtc_goe = 0x80100110, | |
203 | .crtc_ps1_active = 0x41060010, | |
204 | .pll_freq = 75, | |
205 | .fast_pll_freq = 100, | |
206 | .sysclk_src = CLK_SRC_PLL, | |
207 | .sysclk_divider = 0, | |
208 | .pixclk_src = CLK_SRC_PLL, | |
209 | .pixclk_divider = 2, | |
210 | .pixclk_divider_rotated = 6, | |
211 | },{ | |
212 | .xres = 240, | |
213 | .yres = 320, | |
214 | .left_margin = 0x27, | |
215 | .right_margin = 0x2e, | |
216 | .upper_margin = 0x01, | |
217 | .lower_margin = 0x00, | |
218 | .crtc_ss = 0x81170027, | |
219 | .crtc_ls = 0xA0140000, | |
220 | .crtc_gs = 0xC0140014, | |
221 | .crtc_vpos_gs = 0x00010141, | |
222 | .crtc_rev = 0x00400008, | |
223 | .crtc_dclk = 0xA0000000, | |
224 | .crtc_gclk = 0x8015010F, | |
225 | .crtc_goe = 0x80100110, | |
226 | .crtc_ps1_active = 0x41060010, | |
227 | .pll_freq = 0, | |
228 | .fast_pll_freq = 0, | |
229 | .sysclk_src = CLK_SRC_XTAL, | |
230 | .sysclk_divider = 0, | |
231 | .pixclk_src = CLK_SRC_XTAL, | |
232 | .pixclk_divider = 1, | |
233 | .pixclk_divider_rotated = 1, | |
234 | }, | |
235 | ||
236 | }; | |
237 | ||
238 | static struct w100fb_mach_info corgi_fb_info = { | |
ca4d6cfc RP |
239 | .init_mode = INIT_MODE_ROTATED, |
240 | .mem = &corgi_fb_mem, | |
241 | .regs = &corgi_fb_regs, | |
242 | .modelist = &corgi_fb_modes[0], | |
243 | .num_modes = 2, | |
244 | .gpio = &corgi_fb_gpio, | |
245 | .xtal_freq = 12500000, | |
246 | .xtal_dbl = 0, | |
247 | }; | |
248 | ||
249 | static struct resource corgi_fb_resources[] = { | |
250 | [0] = { | |
251 | .start = 0x08000000, | |
252 | .end = 0x08ffffff, | |
253 | .flags = IORESOURCE_MEM, | |
254 | }, | |
255 | }; | |
256 | ||
257 | static struct platform_device corgifb_device = { | |
258 | .name = "w100fb", | |
259 | .id = -1, | |
260 | .num_resources = ARRAY_SIZE(corgi_fb_resources), | |
261 | .resource = corgi_fb_resources, | |
262 | .dev = { | |
263 | .platform_data = &corgi_fb_info, | |
ca4d6cfc RP |
264 | }, |
265 | ||
266 | }; | |
267 | ||
f7ceff34 RP |
268 | /* |
269 | * Corgi Keyboard Device | |
270 | */ | |
271 | static struct platform_device corgikbd_device = { | |
272 | .name = "corgi-keyboard", | |
273 | .id = -1, | |
274 | }; | |
275 | ||
3179108d RP |
276 | /* |
277 | * Corgi LEDs | |
278 | */ | |
60cf711d EM |
279 | static struct gpio_led corgi_gpio_leds[] = { |
280 | { | |
281 | .name = "corgi:amber:charge", | |
282 | .default_trigger = "sharpsl-charge", | |
283 | .gpio = CORGI_GPIO_LED_ORANGE, | |
284 | }, | |
285 | { | |
286 | .name = "corgi:green:mail", | |
287 | .default_trigger = "nand-disk", | |
288 | .gpio = CORGI_GPIO_LED_GREEN, | |
513b6e1a RP |
289 | }, |
290 | }; | |
291 | ||
60cf711d EM |
292 | static struct gpio_led_platform_data corgi_gpio_leds_info = { |
293 | .leds = corgi_gpio_leds, | |
294 | .num_leds = ARRAY_SIZE(corgi_gpio_leds), | |
513b6e1a RP |
295 | }; |
296 | ||
3179108d | 297 | static struct platform_device corgiled_device = { |
60cf711d | 298 | .name = "leds-gpio", |
3179108d | 299 | .id = -1, |
f7ceff34 | 300 | .dev = { |
60cf711d | 301 | .platform_data = &corgi_gpio_leds_info, |
f7ceff34 | 302 | }, |
f7ceff34 RP |
303 | }; |
304 | ||
1da177e4 LT |
305 | /* |
306 | * MMC/SD Device | |
307 | * | |
aa6c2e79 | 308 | * The card detect interrupt isn't debounced so we delay it by 250ms |
1da177e4 LT |
309 | * to give the card a chance to fully insert/eject. |
310 | */ | |
aa6c2e79 | 311 | static struct pxamci_platform_data corgi_mci_platform_data; |
1da177e4 | 312 | |
40220c1a | 313 | static int corgi_mci_init(struct device *dev, irq_handler_t corgi_detect_int, void *data) |
1da177e4 LT |
314 | { |
315 | int err; | |
316 | ||
9d708752 EM |
317 | err = gpio_request(CORGI_GPIO_nSD_DETECT, "nSD_DETECT"); |
318 | if (err) | |
319 | goto err_out; | |
1da177e4 | 320 | |
9d708752 | 321 | err = gpio_request(CORGI_GPIO_nSD_WP, "nSD_WP"); |
2687bd38 | 322 | if (err) |
9d708752 | 323 | goto err_free_1; |
1da177e4 | 324 | |
9d708752 | 325 | err = gpio_request(CORGI_GPIO_SD_PWR, "SD_PWR"); |
2687bd38 | 326 | if (err) |
9d708752 EM |
327 | goto err_free_2; |
328 | ||
329 | gpio_direction_input(CORGI_GPIO_nSD_DETECT); | |
330 | gpio_direction_input(CORGI_GPIO_nSD_WP); | |
331 | gpio_direction_output(CORGI_GPIO_SD_PWR, 0); | |
1da177e4 | 332 | |
9d708752 EM |
333 | corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250); |
334 | ||
335 | err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int, | |
336 | IRQF_DISABLED | IRQF_TRIGGER_RISING | | |
337 | IRQF_TRIGGER_FALLING, | |
338 | "MMC card detect", data); | |
339 | if (err) { | |
340 | pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n", | |
341 | __func__); | |
342 | goto err_free_3; | |
343 | } | |
344 | return 0; | |
345 | ||
346 | err_free_3: | |
347 | gpio_free(CORGI_GPIO_SD_PWR); | |
348 | err_free_2: | |
349 | gpio_free(CORGI_GPIO_nSD_WP); | |
350 | err_free_1: | |
351 | gpio_free(CORGI_GPIO_nSD_DETECT); | |
352 | err_out: | |
2687bd38 | 353 | return err; |
1da177e4 LT |
354 | } |
355 | ||
356 | static void corgi_mci_setpower(struct device *dev, unsigned int vdd) | |
357 | { | |
358 | struct pxamci_platform_data* p_d = dev->platform_data; | |
359 | ||
9d708752 | 360 | gpio_set_value(CORGI_GPIO_SD_PWR, ((1 << vdd) & p_d->ocr_mask)); |
1da177e4 LT |
361 | } |
362 | ||
3870ee8c RP |
363 | static int corgi_mci_get_ro(struct device *dev) |
364 | { | |
9d708752 | 365 | return gpio_get_value(CORGI_GPIO_nSD_WP); |
3870ee8c RP |
366 | } |
367 | ||
1da177e4 LT |
368 | static void corgi_mci_exit(struct device *dev, void *data) |
369 | { | |
370 | free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data); | |
9d708752 EM |
371 | gpio_free(CORGI_GPIO_SD_PWR); |
372 | gpio_free(CORGI_GPIO_nSD_WP); | |
373 | gpio_free(CORGI_GPIO_nSD_DETECT); | |
1da177e4 LT |
374 | } |
375 | ||
376 | static struct pxamci_platform_data corgi_mci_platform_data = { | |
377 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, | |
378 | .init = corgi_mci_init, | |
3870ee8c | 379 | .get_ro = corgi_mci_get_ro, |
1da177e4 LT |
380 | .setpower = corgi_mci_setpower, |
381 | .exit = corgi_mci_exit, | |
382 | }; | |
383 | ||
384 | ||
ca1140b5 RP |
385 | /* |
386 | * Irda | |
387 | */ | |
388 | static void corgi_irda_transceiver_mode(struct device *dev, int mode) | |
389 | { | |
9d708752 | 390 | gpio_set_value(CORGI_GPIO_IR_ON, mode & IR_OFF); |
0fc3ff31 | 391 | pxa2xx_transceiver_mode(dev, mode); |
ca1140b5 RP |
392 | } |
393 | ||
9d708752 EM |
394 | static int corgi_irda_startup(struct device *dev) |
395 | { | |
396 | int err; | |
397 | ||
398 | err = gpio_request(CORGI_GPIO_IR_ON, "IR_ON"); | |
399 | if (err) | |
400 | return err; | |
401 | ||
402 | gpio_direction_output(CORGI_GPIO_IR_ON, 1); | |
403 | return 0; | |
404 | } | |
405 | ||
406 | static void corgi_irda_shutdown(struct device *dev) | |
407 | { | |
408 | gpio_free(CORGI_GPIO_IR_ON); | |
409 | } | |
410 | ||
ca1140b5 | 411 | static struct pxaficp_platform_data corgi_ficp_platform_data = { |
9d708752 EM |
412 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
413 | .transceiver_mode = corgi_irda_transceiver_mode, | |
414 | .startup = corgi_irda_startup, | |
415 | .shutdown = corgi_irda_shutdown, | |
ca1140b5 RP |
416 | }; |
417 | ||
f7ceff34 | 418 | |
1da177e4 LT |
419 | /* |
420 | * USB Device Controller | |
421 | */ | |
1da177e4 LT |
422 | static struct pxa2xx_udc_mach_info udc_info __initdata = { |
423 | /* no connect GPIO; corgi can't tell connection status */ | |
b2bbb20b | 424 | .gpio_pullup = CORGI_GPIO_USB_PULLUP, |
1da177e4 LT |
425 | }; |
426 | ||
edb403fb EM |
427 | #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MASTER) |
428 | static struct pxa2xx_spi_master corgi_spi_info = { | |
429 | .num_chipselect = 3, | |
430 | }; | |
431 | ||
432 | static struct ads7846_platform_data corgi_ads7846_info = { | |
433 | .model = 7846, | |
434 | .vref_delay_usecs = 100, | |
435 | .x_plate_ohms = 419, | |
436 | .y_plate_ohms = 486, | |
437 | .gpio_pendown = CORGI_GPIO_TP_INT, | |
438 | }; | |
439 | ||
440 | static void corgi_ads7846_cs(u32 command) | |
441 | { | |
442 | gpio_set_value(CORGI_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT)); | |
443 | } | |
444 | ||
445 | static struct pxa2xx_spi_chip corgi_ads7846_chip = { | |
446 | .cs_control = corgi_ads7846_cs, | |
447 | }; | |
448 | ||
edb403fb EM |
449 | static void corgi_bl_kick_battery(void) |
450 | { | |
451 | void (*kick_batt)(void); | |
452 | ||
453 | kick_batt = symbol_get(sharpsl_battery_kick); | |
454 | if (kick_batt) { | |
455 | kick_batt(); | |
456 | symbol_put(sharpsl_battery_kick); | |
457 | } | |
458 | } | |
459 | ||
460 | static struct corgi_lcd_platform_data corgi_lcdcon_info = { | |
461 | .init_mode = CORGI_LCD_MODE_VGA, | |
462 | .max_intensity = 0x2f, | |
463 | .default_intensity = 0x1f, | |
464 | .limit_mask = 0x0b, | |
ff7a4c71 EM |
465 | .gpio_backlight_cont = CORGI_GPIO_BACKLIGHT_CONT, |
466 | .gpio_backlight_on = -1, | |
edb403fb EM |
467 | .kick_battery = corgi_bl_kick_battery, |
468 | }; | |
469 | ||
470 | static void corgi_lcdcon_cs(u32 command) | |
471 | { | |
472 | gpio_set_value(CORGI_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT)); | |
473 | } | |
474 | ||
475 | static struct pxa2xx_spi_chip corgi_lcdcon_chip = { | |
476 | .cs_control = corgi_lcdcon_cs, | |
477 | }; | |
478 | ||
479 | static void corgi_max1111_cs(u32 command) | |
480 | { | |
481 | gpio_set_value(CORGI_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT)); | |
482 | } | |
483 | ||
484 | static struct pxa2xx_spi_chip corgi_max1111_chip = { | |
485 | .cs_control = corgi_max1111_cs, | |
486 | }; | |
487 | ||
488 | static struct spi_board_info corgi_spi_devices[] = { | |
489 | { | |
490 | .modalias = "ads7846", | |
491 | .max_speed_hz = 1200000, | |
492 | .bus_num = 1, | |
493 | .chip_select = 0, | |
494 | .platform_data = &corgi_ads7846_info, | |
495 | .controller_data= &corgi_ads7846_chip, | |
496 | .irq = gpio_to_irq(CORGI_GPIO_TP_INT), | |
497 | }, { | |
498 | .modalias = "corgi-lcd", | |
499 | .max_speed_hz = 50000, | |
500 | .bus_num = 1, | |
501 | .chip_select = 1, | |
502 | .platform_data = &corgi_lcdcon_info, | |
503 | .controller_data= &corgi_lcdcon_chip, | |
504 | }, { | |
505 | .modalias = "max1111", | |
506 | .max_speed_hz = 450000, | |
507 | .bus_num = 1, | |
508 | .chip_select = 2, | |
509 | .controller_data= &corgi_max1111_chip, | |
510 | }, | |
511 | }; | |
512 | ||
513 | static void __init corgi_init_spi(void) | |
514 | { | |
515 | int err; | |
516 | ||
517 | err = gpio_request(CORGI_GPIO_ADS7846_CS, "ADS7846_CS"); | |
518 | if (err) | |
519 | return; | |
520 | ||
521 | err = gpio_request(CORGI_GPIO_LCDCON_CS, "LCDCON_CS"); | |
522 | if (err) | |
523 | goto err_free_1; | |
524 | ||
525 | err = gpio_request(CORGI_GPIO_MAX1111_CS, "MAX1111_CS"); | |
526 | if (err) | |
527 | goto err_free_2; | |
528 | ||
529 | gpio_direction_output(CORGI_GPIO_ADS7846_CS, 1); | |
530 | gpio_direction_output(CORGI_GPIO_LCDCON_CS, 1); | |
531 | gpio_direction_output(CORGI_GPIO_MAX1111_CS, 1); | |
532 | ||
533 | pxa2xx_set_spi_info(1, &corgi_spi_info); | |
534 | spi_register_board_info(ARRAY_AND_SIZE(corgi_spi_devices)); | |
535 | return; | |
536 | ||
537 | err_free_2: | |
538 | gpio_free(CORGI_GPIO_LCDCON_CS); | |
539 | err_free_1: | |
540 | gpio_free(CORGI_GPIO_ADS7846_CS); | |
541 | } | |
542 | #else | |
543 | static inline void corgi_init_spi(void) {} | |
544 | #endif | |
1da177e4 | 545 | |
6af7a8eb DB |
546 | static struct mtd_partition sharpsl_nand_partitions[] = { |
547 | { | |
548 | .name = "System Area", | |
549 | .offset = 0, | |
550 | .size = 7 * 1024 * 1024, | |
551 | }, | |
552 | { | |
553 | .name = "Root Filesystem", | |
554 | .offset = 7 * 1024 * 1024, | |
555 | .size = 25 * 1024 * 1024, | |
556 | }, | |
557 | { | |
558 | .name = "Home Filesystem", | |
559 | .offset = MTDPART_OFS_APPEND, | |
560 | .size = MTDPART_SIZ_FULL, | |
561 | }, | |
562 | }; | |
563 | ||
564 | static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; | |
565 | ||
566 | static struct nand_bbt_descr sharpsl_bbt = { | |
567 | .options = 0, | |
568 | .offs = 4, | |
569 | .len = 2, | |
570 | .pattern = scan_ff_pattern | |
571 | }; | |
572 | ||
573 | static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = { | |
574 | .badblock_pattern = &sharpsl_bbt, | |
575 | .partitions = sharpsl_nand_partitions, | |
576 | .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions), | |
577 | }; | |
578 | ||
579 | static struct resource sharpsl_nand_resources[] = { | |
580 | { | |
581 | .start = 0x0C000000, | |
582 | .end = 0x0C000FFF, | |
583 | .flags = IORESOURCE_MEM, | |
584 | }, | |
585 | }; | |
586 | ||
587 | static struct platform_device sharpsl_nand_device = { | |
588 | .name = "sharpsl-nand", | |
589 | .id = -1, | |
590 | .resource = sharpsl_nand_resources, | |
591 | .num_resources = ARRAY_SIZE(sharpsl_nand_resources), | |
592 | .dev.platform_data = &sharpsl_nand_platform_data, | |
593 | }; | |
594 | ||
4a9295cc DB |
595 | static struct mtd_partition sharpsl_rom_parts[] = { |
596 | { | |
597 | .name ="Boot PROM Filesystem", | |
598 | .offset = 0x00120000, | |
599 | .size = MTDPART_SIZ_FULL, | |
600 | }, | |
601 | }; | |
602 | ||
603 | static struct physmap_flash_data sharpsl_rom_data = { | |
604 | .width = 2, | |
605 | .nr_parts = ARRAY_SIZE(sharpsl_rom_parts), | |
606 | .parts = sharpsl_rom_parts, | |
607 | }; | |
608 | ||
609 | static struct resource sharpsl_rom_resources[] = { | |
610 | { | |
611 | .start = 0x00000000, | |
612 | .end = 0x007fffff, | |
613 | .flags = IORESOURCE_MEM, | |
614 | }, | |
615 | }; | |
616 | ||
617 | static struct platform_device sharpsl_rom_device = { | |
618 | .name = "physmap-flash", | |
619 | .id = -1, | |
620 | .resource = sharpsl_rom_resources, | |
621 | .num_resources = ARRAY_SIZE(sharpsl_rom_resources), | |
622 | .dev.platform_data = &sharpsl_rom_data, | |
623 | }; | |
624 | ||
1da177e4 LT |
625 | static struct platform_device *devices[] __initdata = { |
626 | &corgiscoop_device, | |
1da177e4 | 627 | &corgifb_device, |
f7ceff34 | 628 | &corgikbd_device, |
3179108d | 629 | &corgiled_device, |
6af7a8eb | 630 | &sharpsl_nand_device, |
4a9295cc | 631 | &sharpsl_rom_device, |
1da177e4 LT |
632 | }; |
633 | ||
74617fb6 RP |
634 | static void corgi_poweroff(void) |
635 | { | |
74617fb6 RP |
636 | if (!machine_is_corgi()) |
637 | /* Green LED off tells the bootloader to halt */ | |
6168cda9 EM |
638 | gpio_set_value(CORGI_GPIO_LED_GREEN, 0); |
639 | ||
74617fb6 RP |
640 | arm_machine_restart('h'); |
641 | } | |
642 | ||
643 | static void corgi_restart(char mode) | |
644 | { | |
74617fb6 RP |
645 | if (!machine_is_corgi()) |
646 | /* Green LED on tells the bootloader to reboot */ | |
6168cda9 EM |
647 | gpio_set_value(CORGI_GPIO_LED_GREEN, 1); |
648 | ||
74617fb6 RP |
649 | arm_machine_restart('h'); |
650 | } | |
651 | ||
1da177e4 LT |
652 | static void __init corgi_init(void) |
653 | { | |
74617fb6 RP |
654 | pm_power_off = corgi_poweroff; |
655 | arm_pm_restart = corgi_restart; | |
656 | ||
fdce05bb RP |
657 | /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ |
658 | PCFR |= PCFR_OPDE; | |
659 | ||
9ae808d8 | 660 | pxa2xx_mfp_config(ARRAY_AND_SIZE(corgi_pin_config)); |
50a5de44 | 661 | |
edb403fb | 662 | corgi_init_spi(); |
ca1140b5 | 663 | |
1da177e4 LT |
664 | pxa_set_udc_info(&udc_info); |
665 | pxa_set_mci_info(&corgi_mci_platform_data); | |
ca1140b5 | 666 | pxa_set_ficp_info(&corgi_ficp_platform_data); |
f8787fdc | 667 | pxa_set_i2c_info(NULL); |
1da177e4 | 668 | |
a63ae442 | 669 | platform_scoop_config = &corgi_pcmcia_config; |
0ce7625f | 670 | |
6af7a8eb DB |
671 | if (machine_is_husky()) |
672 | sharpsl_nand_partitions[1].size = 53 * 1024 * 1024; | |
673 | ||
1da177e4 LT |
674 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
675 | } | |
676 | ||
677 | static void __init fixup_corgi(struct machine_desc *desc, | |
678 | struct tag *tags, char **cmdline, struct meminfo *mi) | |
679 | { | |
680 | sharpsl_save_param(); | |
681 | mi->nr_banks=1; | |
682 | mi->bank[0].start = 0xa0000000; | |
683 | mi->bank[0].node = 0; | |
684 | if (machine_is_corgi()) | |
685 | mi->bank[0].size = (32*1024*1024); | |
686 | else | |
687 | mi->bank[0].size = (64*1024*1024); | |
688 | } | |
689 | ||
1da177e4 LT |
690 | #ifdef CONFIG_MACH_CORGI |
691 | MACHINE_START(CORGI, "SHARP Corgi") | |
e9dea0c6 | 692 | .phys_io = 0x40000000, |
68070bde | 693 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
e9dea0c6 | 694 | .fixup = fixup_corgi, |
fdce05bb | 695 | .map_io = pxa_map_io, |
cd49104d | 696 | .init_irq = pxa25x_init_irq, |
e9dea0c6 RK |
697 | .init_machine = corgi_init, |
698 | .timer = &pxa_timer, | |
1da177e4 LT |
699 | MACHINE_END |
700 | #endif | |
701 | ||
702 | #ifdef CONFIG_MACH_SHEPHERD | |
703 | MACHINE_START(SHEPHERD, "SHARP Shepherd") | |
e9dea0c6 | 704 | .phys_io = 0x40000000, |
68070bde | 705 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
e9dea0c6 | 706 | .fixup = fixup_corgi, |
fdce05bb | 707 | .map_io = pxa_map_io, |
cd49104d | 708 | .init_irq = pxa25x_init_irq, |
e9dea0c6 RK |
709 | .init_machine = corgi_init, |
710 | .timer = &pxa_timer, | |
1da177e4 LT |
711 | MACHINE_END |
712 | #endif | |
713 | ||
714 | #ifdef CONFIG_MACH_HUSKY | |
715 | MACHINE_START(HUSKY, "SHARP Husky") | |
e9dea0c6 | 716 | .phys_io = 0x40000000, |
68070bde | 717 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
e9dea0c6 | 718 | .fixup = fixup_corgi, |
fdce05bb | 719 | .map_io = pxa_map_io, |
cd49104d | 720 | .init_irq = pxa25x_init_irq, |
e9dea0c6 RK |
721 | .init_machine = corgi_init, |
722 | .timer = &pxa_timer, | |
1da177e4 LT |
723 | MACHINE_END |
724 | #endif | |
725 |