Commit | Line | Data |
---|---|---|
0dd28f1d RP |
1 | /* |
2 | * Support for Sharp SL-Cxx00 Series of PDAs | |
3 | * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi) | |
4 | * | |
5 | * Copyright (c) 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> |
0dd28f1d RP |
18 | #include <linux/delay.h> |
19 | #include <linux/major.h> | |
20 | #include <linux/fs.h> | |
21 | #include <linux/interrupt.h> | |
dd5980d6 | 22 | #include <linux/gpio.h> |
4fe3224f | 23 | #include <linux/leds.h> |
0dd28f1d | 24 | #include <linux/mmc/host.h> |
74617fb6 | 25 | #include <linux/pm.h> |
c3f8f650 | 26 | #include <linux/backlight.h> |
f72de663 EM |
27 | #include <linux/i2c.h> |
28 | #include <linux/i2c/pca953x.h> | |
859b7963 EM |
29 | #include <linux/spi/spi.h> |
30 | #include <linux/spi/ads7846.h> | |
31 | #include <linux/spi/corgi_lcd.h> | |
0dd28f1d RP |
32 | |
33 | #include <asm/setup.h> | |
34 | #include <asm/memory.h> | |
35 | #include <asm/mach-types.h> | |
a09e64fb | 36 | #include <mach/hardware.h> |
0dd28f1d RP |
37 | #include <asm/irq.h> |
38 | #include <asm/io.h> | |
74617fb6 | 39 | #include <asm/system.h> |
0dd28f1d RP |
40 | |
41 | #include <asm/mach/arch.h> | |
42 | #include <asm/mach/map.h> | |
43 | #include <asm/mach/irq.h> | |
44 | ||
a09e64fb RK |
45 | #include <mach/pxa-regs.h> |
46 | #include <mach/pxa2xx-regs.h> | |
5e96adec | 47 | #include <mach/mfp-pxa27x.h> |
a09e64fb | 48 | #include <mach/pxa27x-udc.h> |
afd2fc02 | 49 | #include <mach/reset.h> |
f8787fdc | 50 | #include <mach/i2c.h> |
a09e64fb RK |
51 | #include <mach/irda.h> |
52 | #include <mach/mmc.h> | |
53 | #include <mach/ohci.h> | |
54 | #include <mach/udc.h> | |
55 | #include <mach/pxafb.h> | |
859b7963 | 56 | #include <mach/pxa2xx_spi.h> |
a09e64fb RK |
57 | #include <mach/spitz.h> |
58 | #include <mach/sharpsl.h> | |
0dd28f1d RP |
59 | |
60 | #include <asm/mach/sharpsl_param.h> | |
61 | #include <asm/hardware/scoop.h> | |
62 | ||
63 | #include "generic.h" | |
46c41e62 | 64 | #include "devices.h" |
0dd28f1d RP |
65 | #include "sharpsl.h" |
66 | ||
5e96adec EM |
67 | static unsigned long spitz_pin_config[] __initdata = { |
68 | /* Chip Selects */ | |
69 | GPIO78_nCS_2, /* SCOOP #2 */ | |
70 | GPIO80_nCS_4, /* SCOOP #1 */ | |
71 | ||
72 | /* LCD - 16bpp Active TFT */ | |
73 | GPIO58_LCD_LDD_0, | |
74 | GPIO59_LCD_LDD_1, | |
75 | GPIO60_LCD_LDD_2, | |
76 | GPIO61_LCD_LDD_3, | |
77 | GPIO62_LCD_LDD_4, | |
78 | GPIO63_LCD_LDD_5, | |
79 | GPIO64_LCD_LDD_6, | |
80 | GPIO65_LCD_LDD_7, | |
81 | GPIO66_LCD_LDD_8, | |
82 | GPIO67_LCD_LDD_9, | |
83 | GPIO68_LCD_LDD_10, | |
84 | GPIO69_LCD_LDD_11, | |
85 | GPIO70_LCD_LDD_12, | |
86 | GPIO71_LCD_LDD_13, | |
87 | GPIO72_LCD_LDD_14, | |
88 | GPIO73_LCD_LDD_15, | |
89 | GPIO74_LCD_FCLK, | |
90 | GPIO75_LCD_LCLK, | |
91 | GPIO76_LCD_PCLK, | |
92 | ||
93 | /* PC Card */ | |
94 | GPIO48_nPOE, | |
95 | GPIO49_nPWE, | |
96 | GPIO50_nPIOR, | |
97 | GPIO51_nPIOW, | |
98 | GPIO85_nPCE_1, | |
99 | GPIO54_nPCE_2, | |
100 | GPIO79_PSKTSEL, | |
101 | GPIO55_nPREG, | |
102 | GPIO56_nPWAIT, | |
103 | GPIO57_nIOIS16, | |
104 | ||
105 | /* MMC */ | |
106 | GPIO32_MMC_CLK, | |
107 | GPIO112_MMC_CMD, | |
108 | GPIO92_MMC_DAT_0, | |
109 | GPIO109_MMC_DAT_1, | |
110 | GPIO110_MMC_DAT_2, | |
111 | GPIO111_MMC_DAT_3, | |
112 | ||
113 | /* GPIOs */ | |
114 | GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */ | |
115 | GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */ | |
116 | GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */ | |
117 | GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */ | |
118 | GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */ | |
119 | GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */ | |
120 | GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */ | |
121 | GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */ | |
122 | GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */ | |
123 | ||
124 | GPIO1_GPIO | WAKEUP_ON_EDGE_RISE, | |
125 | }; | |
126 | ||
0dd28f1d RP |
127 | /* |
128 | * Spitz SCOOP Device #1 | |
129 | */ | |
130 | static struct resource spitz_scoop_resources[] = { | |
131 | [0] = { | |
132 | .start = 0x10800000, | |
133 | .end = 0x10800fff, | |
134 | .flags = IORESOURCE_MEM, | |
135 | }, | |
136 | }; | |
137 | ||
138 | static struct scoop_config spitz_scoop_setup = { | |
fff14720 | 139 | .io_dir = SPITZ_SCP_IO_DIR, |
0dd28f1d | 140 | .io_out = SPITZ_SCP_IO_OUT, |
fff14720 EM |
141 | .suspend_clr = SPITZ_SCP_SUS_CLR, |
142 | .suspend_set = SPITZ_SCP_SUS_SET, | |
143 | .gpio_base = SPITZ_SCP_GPIO_BASE, | |
0dd28f1d RP |
144 | }; |
145 | ||
146 | struct platform_device spitzscoop_device = { | |
147 | .name = "sharp-scoop", | |
148 | .id = 0, | |
149 | .dev = { | |
150 | .platform_data = &spitz_scoop_setup, | |
151 | }, | |
152 | .num_resources = ARRAY_SIZE(spitz_scoop_resources), | |
153 | .resource = spitz_scoop_resources, | |
154 | }; | |
155 | ||
156 | /* | |
157 | * Spitz SCOOP Device #2 | |
158 | */ | |
159 | static struct resource spitz_scoop2_resources[] = { | |
160 | [0] = { | |
161 | .start = 0x08800040, | |
162 | .end = 0x08800fff, | |
163 | .flags = IORESOURCE_MEM, | |
164 | }, | |
165 | }; | |
166 | ||
167 | static struct scoop_config spitz_scoop2_setup = { | |
fff14720 | 168 | .io_dir = SPITZ_SCP2_IO_DIR, |
0dd28f1d | 169 | .io_out = SPITZ_SCP2_IO_OUT, |
fff14720 EM |
170 | .suspend_clr = SPITZ_SCP2_SUS_CLR, |
171 | .suspend_set = SPITZ_SCP2_SUS_SET, | |
172 | .gpio_base = SPITZ_SCP2_GPIO_BASE, | |
0dd28f1d RP |
173 | }; |
174 | ||
175 | struct platform_device spitzscoop2_device = { | |
176 | .name = "sharp-scoop", | |
177 | .id = 1, | |
178 | .dev = { | |
179 | .platform_data = &spitz_scoop2_setup, | |
180 | }, | |
181 | .num_resources = ARRAY_SIZE(spitz_scoop2_resources), | |
182 | .resource = spitz_scoop2_resources, | |
183 | }; | |
184 | ||
a63ae442 RP |
185 | #define SPITZ_PWR_SD 0x01 |
186 | #define SPITZ_PWR_CF 0x02 | |
187 | ||
188 | /* Power control is shared with between one of the CF slots and SD */ | |
189 | static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr) | |
190 | { | |
191 | unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR); | |
192 | ||
193 | if (new_cpr & 0x0007) { | |
fff14720 | 194 | gpio_set_value(SPITZ_GPIO_CF_POWER, 1); |
a63ae442 RP |
195 | if (!(cpr & 0x0002) && !(cpr & 0x0004)) |
196 | mdelay(5); | |
197 | if (device == SPITZ_PWR_CF) | |
198 | cpr |= 0x0002; | |
199 | if (device == SPITZ_PWR_SD) | |
200 | cpr |= 0x0004; | |
201 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); | |
202 | } else { | |
203 | if (device == SPITZ_PWR_CF) | |
204 | cpr &= ~0x0002; | |
205 | if (device == SPITZ_PWR_SD) | |
206 | cpr &= ~0x0004; | |
a63ae442 | 207 | if (!(cpr & 0x0002) && !(cpr & 0x0004)) { |
945b9579 | 208 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000); |
a63ae442 | 209 | mdelay(1); |
fff14720 | 210 | gpio_set_value(SPITZ_GPIO_CF_POWER, 0); |
945b9579 RP |
211 | } else { |
212 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); | |
a63ae442 RP |
213 | } |
214 | } | |
215 | } | |
216 | ||
a63ae442 RP |
217 | static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr) |
218 | { | |
219 | /* Only need to override behaviour for slot 0 */ | |
220 | if (nr == 0) | |
221 | spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr); | |
222 | else | |
223 | write_scoop_reg(scoop, SCOOP_CPR, cpr); | |
224 | } | |
225 | ||
0dd28f1d RP |
226 | static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = { |
227 | { | |
228 | .dev = &spitzscoop_device.dev, | |
229 | .irq = SPITZ_IRQ_GPIO_CF_IRQ, | |
230 | .cd_irq = SPITZ_IRQ_GPIO_CF_CD, | |
231 | .cd_irq_str = "PCMCIA0 CD", | |
232 | },{ | |
233 | .dev = &spitzscoop2_device.dev, | |
234 | .irq = SPITZ_IRQ_GPIO_CF2_IRQ, | |
235 | .cd_irq = -1, | |
236 | }, | |
237 | }; | |
238 | ||
a63ae442 RP |
239 | static struct scoop_pcmcia_config spitz_pcmcia_config = { |
240 | .devs = &spitz_pcmcia_scoop[0], | |
241 | .num_devs = 2, | |
a63ae442 RP |
242 | .power_ctrl = spitz_pcmcia_pwr, |
243 | }; | |
244 | ||
245 | EXPORT_SYMBOL(spitzscoop_device); | |
246 | EXPORT_SYMBOL(spitzscoop2_device); | |
247 | ||
0dd28f1d RP |
248 | /* |
249 | * Spitz Keyboard Device | |
250 | */ | |
251 | static struct platform_device spitzkbd_device = { | |
252 | .name = "spitz-keyboard", | |
253 | .id = -1, | |
254 | }; | |
255 | ||
256 | ||
3179108d RP |
257 | /* |
258 | * Spitz LEDs | |
259 | */ | |
4fe3224f EM |
260 | static struct gpio_led spitz_gpio_leds[] = { |
261 | { | |
262 | .name = "spitz:amber:charge", | |
263 | .default_trigger = "sharpsl-charge", | |
264 | .gpio = SPITZ_GPIO_LED_ORANGE, | |
265 | }, | |
266 | { | |
267 | .name = "spitz:green:hddactivity", | |
268 | .default_trigger = "ide-disk", | |
269 | .gpio = SPITZ_GPIO_LED_GREEN, | |
270 | }, | |
271 | }; | |
272 | ||
273 | static struct gpio_led_platform_data spitz_gpio_leds_info = { | |
274 | .leds = spitz_gpio_leds, | |
275 | .num_leds = ARRAY_SIZE(spitz_gpio_leds), | |
276 | }; | |
277 | ||
3179108d | 278 | static struct platform_device spitzled_device = { |
4fe3224f | 279 | .name = "leds-gpio", |
3179108d | 280 | .id = -1, |
4fe3224f EM |
281 | .dev = { |
282 | .platform_data = &spitz_gpio_leds_info, | |
283 | }, | |
3179108d RP |
284 | }; |
285 | ||
859b7963 EM |
286 | #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) |
287 | static struct pxa2xx_spi_master spitz_spi_info = { | |
288 | .num_chipselect = 3, | |
289 | }; | |
ca4d6cfc | 290 | |
859b7963 EM |
291 | static struct ads7846_platform_data spitz_ads7846_info = { |
292 | .model = 7846, | |
293 | .vref_delay_usecs = 100, | |
294 | .x_plate_ohms = 419, | |
295 | .y_plate_ohms = 486, | |
296 | .gpio_pendown = SPITZ_GPIO_TP_INT, | |
297 | }; | |
ca4d6cfc | 298 | |
859b7963 | 299 | static void spitz_ads7846_cs(u32 command) |
ca4d6cfc | 300 | { |
859b7963 | 301 | gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT)); |
ca4d6cfc RP |
302 | } |
303 | ||
859b7963 EM |
304 | static struct pxa2xx_spi_chip spitz_ads7846_chip = { |
305 | .cs_control = spitz_ads7846_cs, | |
306 | }; | |
ca4d6cfc | 307 | |
859b7963 | 308 | static void spitz_notify_intensity(int intensity) |
ca4d6cfc | 309 | { |
859b7963 | 310 | if (machine_is_spitz() || machine_is_borzoi()) { |
fff14720 EM |
311 | gpio_set_value(SPITZ_GPIO_BACKLIGHT_CONT, !(intensity & 0x20)); |
312 | gpio_set_value(SPITZ_GPIO_BACKLIGHT_ON, intensity); | |
859b7963 EM |
313 | return; |
314 | } | |
ca4d6cfc | 315 | |
859b7963 | 316 | if (machine_is_akita()) { |
f72de663 EM |
317 | gpio_set_value(AKITA_GPIO_BACKLIGHT_CONT, !(intensity & 0x20)); |
318 | gpio_set_value(AKITA_GPIO_BACKLIGHT_ON, intensity); | |
859b7963 EM |
319 | return; |
320 | } | |
ca4d6cfc RP |
321 | } |
322 | ||
859b7963 | 323 | static void spitz_bl_kick_battery(void) |
ca4d6cfc | 324 | { |
859b7963 | 325 | void (*kick_batt)(void); |
ca4d6cfc | 326 | |
859b7963 EM |
327 | kick_batt = symbol_get(sharpsl_battery_kick); |
328 | if (kick_batt) { | |
329 | kick_batt(); | |
330 | symbol_put(sharpsl_battery_kick); | |
331 | } | |
ca4d6cfc RP |
332 | } |
333 | ||
859b7963 EM |
334 | static struct corgi_lcd_platform_data spitz_lcdcon_info = { |
335 | .init_mode = CORGI_LCD_MODE_VGA, | |
336 | .max_intensity = 0x2f, | |
337 | .default_intensity = 0x1f, | |
338 | .limit_mask = 0x0b, | |
339 | .notify = spitz_notify_intensity, | |
340 | .kick_battery = spitz_bl_kick_battery, | |
341 | }; | |
ca4d6cfc | 342 | |
859b7963 | 343 | static void spitz_lcdcon_cs(u32 command) |
ca4d6cfc | 344 | { |
859b7963 | 345 | gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT)); |
ca4d6cfc RP |
346 | } |
347 | ||
859b7963 EM |
348 | static struct pxa2xx_spi_chip spitz_lcdcon_chip = { |
349 | .cs_control = spitz_lcdcon_cs, | |
0dd28f1d RP |
350 | }; |
351 | ||
859b7963 EM |
352 | static void spitz_max1111_cs(u32 command) |
353 | { | |
354 | gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT)); | |
355 | } | |
356 | ||
357 | static struct pxa2xx_spi_chip spitz_max1111_chip = { | |
358 | .cs_control = spitz_max1111_cs, | |
0dd28f1d RP |
359 | }; |
360 | ||
859b7963 EM |
361 | static struct spi_board_info spitz_spi_devices[] = { |
362 | { | |
363 | .modalias = "ads7846", | |
364 | .max_speed_hz = 1200000, | |
365 | .bus_num = 2, | |
366 | .chip_select = 0, | |
367 | .platform_data = &spitz_ads7846_info, | |
368 | .controller_data= &spitz_ads7846_chip, | |
369 | .irq = gpio_to_irq(SPITZ_GPIO_TP_INT), | |
370 | }, { | |
371 | .modalias = "corgi-lcd", | |
372 | .max_speed_hz = 50000, | |
373 | .bus_num = 2, | |
374 | .chip_select = 1, | |
375 | .platform_data = &spitz_lcdcon_info, | |
376 | .controller_data= &spitz_lcdcon_chip, | |
377 | }, { | |
378 | .modalias = "max1111", | |
379 | .max_speed_hz = 450000, | |
380 | .bus_num = 2, | |
381 | .chip_select = 2, | |
382 | .controller_data= &spitz_max1111_chip, | |
0dd28f1d | 383 | }, |
0dd28f1d RP |
384 | }; |
385 | ||
859b7963 EM |
386 | static void __init spitz_init_spi(void) |
387 | { | |
388 | int err; | |
389 | ||
390 | err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS"); | |
391 | if (err) | |
392 | return; | |
393 | ||
394 | err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS"); | |
395 | if (err) | |
396 | goto err_free_1; | |
397 | ||
398 | err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS"); | |
399 | if (err) | |
400 | goto err_free_2; | |
401 | ||
402 | pxa2xx_set_spi_info(2, &spitz_spi_info); | |
403 | spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); | |
404 | return; | |
405 | ||
406 | err_free_2: | |
407 | gpio_free(SPITZ_GPIO_LCDCON_CS); | |
408 | err_free_1: | |
409 | gpio_free(SPITZ_GPIO_ADS7846_CS); | |
410 | } | |
411 | #else | |
412 | static inline void spitz_init_spi(void) {} | |
413 | #endif | |
0dd28f1d RP |
414 | |
415 | /* | |
416 | * MMC/SD Device | |
417 | * | |
418 | * The card detect interrupt isn't debounced so we delay it by 250ms | |
419 | * to give the card a chance to fully insert/eject. | |
420 | */ | |
421 | ||
422 | static struct pxamci_platform_data spitz_mci_platform_data; | |
423 | ||
40220c1a | 424 | static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data) |
0dd28f1d RP |
425 | { |
426 | int err; | |
427 | ||
dd5980d6 EM |
428 | err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT"); |
429 | if (err) | |
430 | goto err_out; | |
431 | ||
432 | err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP"); | |
433 | if (err) | |
434 | goto err_free_1; | |
435 | ||
436 | gpio_direction_input(SPITZ_GPIO_nSD_DETECT); | |
437 | gpio_direction_input(SPITZ_GPIO_nSD_WP); | |
0dd28f1d RP |
438 | |
439 | spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250); | |
440 | ||
9ded96f2 | 441 | err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, |
dd5980d6 EM |
442 | IRQF_DISABLED | IRQF_TRIGGER_RISING | |
443 | IRQF_TRIGGER_FALLING, | |
9ded96f2 | 444 | "MMC card detect", data); |
dd5980d6 EM |
445 | if (err) { |
446 | pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n", | |
447 | __func__); | |
448 | goto err_free_2; | |
449 | } | |
450 | return 0; | |
0dd28f1d | 451 | |
dd5980d6 EM |
452 | err_free_2: |
453 | gpio_free(SPITZ_GPIO_nSD_WP); | |
454 | err_free_1: | |
455 | gpio_free(SPITZ_GPIO_nSD_DETECT); | |
456 | err_out: | |
2687bd38 | 457 | return err; |
0dd28f1d RP |
458 | } |
459 | ||
0dd28f1d RP |
460 | static void spitz_mci_setpower(struct device *dev, unsigned int vdd) |
461 | { | |
462 | struct pxamci_platform_data* p_d = dev->platform_data; | |
463 | ||
a63ae442 RP |
464 | if (( 1 << vdd) & p_d->ocr_mask) |
465 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004); | |
466 | else | |
467 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000); | |
0dd28f1d RP |
468 | } |
469 | ||
470 | static int spitz_mci_get_ro(struct device *dev) | |
471 | { | |
dd5980d6 | 472 | return gpio_get_value(SPITZ_GPIO_nSD_WP); |
0dd28f1d RP |
473 | } |
474 | ||
475 | static void spitz_mci_exit(struct device *dev, void *data) | |
476 | { | |
477 | free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data); | |
dd5980d6 EM |
478 | gpio_free(SPITZ_GPIO_nSD_WP); |
479 | gpio_free(SPITZ_GPIO_nSD_DETECT); | |
0dd28f1d RP |
480 | } |
481 | ||
482 | static struct pxamci_platform_data spitz_mci_platform_data = { | |
483 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, | |
484 | .init = spitz_mci_init, | |
485 | .get_ro = spitz_mci_get_ro, | |
486 | .setpower = spitz_mci_setpower, | |
487 | .exit = spitz_mci_exit, | |
488 | }; | |
489 | ||
490 | ||
3125c68d RP |
491 | /* |
492 | * USB Host (OHCI) | |
493 | */ | |
494 | static int spitz_ohci_init(struct device *dev) | |
495 | { | |
dd5980d6 EM |
496 | int err; |
497 | ||
498 | err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST"); | |
499 | if (err) | |
500 | return err; | |
501 | ||
5e96adec EM |
502 | /* Only Port 2 is connected |
503 | * Setup USB Port 2 Output Control Register | |
504 | */ | |
3125c68d RP |
505 | UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; |
506 | ||
dd5980d6 | 507 | gpio_direction_output(SPITZ_GPIO_USB_HOST, 1); |
3125c68d RP |
508 | |
509 | UHCHR = (UHCHR) & | |
510 | ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); | |
511 | ||
512 | UHCRHDA |= UHCRHDA_NOCP; | |
513 | ||
514 | return 0; | |
515 | } | |
516 | ||
517 | static struct pxaohci_platform_data spitz_ohci_platform_data = { | |
518 | .port_mode = PMM_NPS_MODE, | |
519 | .init = spitz_ohci_init, | |
0c27c5d5 | 520 | .power_budget = 150, |
3125c68d RP |
521 | }; |
522 | ||
523 | ||
dc07845d RP |
524 | /* |
525 | * Irda | |
526 | */ | |
fff14720 EM |
527 | static int spitz_irda_startup(struct device *dev) |
528 | { | |
529 | int rc; | |
530 | ||
531 | rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on"); | |
532 | if (rc) | |
533 | goto err; | |
534 | ||
535 | rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1); | |
536 | if (rc) | |
537 | goto err_dir; | |
538 | ||
539 | return 0; | |
540 | ||
541 | err_dir: | |
542 | gpio_free(SPITZ_GPIO_IR_ON); | |
543 | err: | |
544 | return rc; | |
545 | } | |
546 | ||
547 | static void spitz_irda_shutdown(struct device *dev) | |
548 | { | |
549 | gpio_free(SPITZ_GPIO_IR_ON); | |
550 | } | |
551 | ||
dc07845d RP |
552 | static void spitz_irda_transceiver_mode(struct device *dev, int mode) |
553 | { | |
fff14720 | 554 | gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF); |
0fc3ff31 | 555 | pxa2xx_transceiver_mode(dev, mode); |
dc07845d RP |
556 | } |
557 | ||
94cabd00 RP |
558 | #ifdef CONFIG_MACH_AKITA |
559 | static void akita_irda_transceiver_mode(struct device *dev, int mode) | |
560 | { | |
f72de663 | 561 | gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF); |
0fc3ff31 | 562 | pxa2xx_transceiver_mode(dev, mode); |
94cabd00 RP |
563 | } |
564 | #endif | |
565 | ||
dc07845d | 566 | static struct pxaficp_platform_data spitz_ficp_platform_data = { |
fff14720 EM |
567 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
568 | .transceiver_mode = spitz_irda_transceiver_mode, | |
569 | .startup = spitz_irda_startup, | |
570 | .shutdown = spitz_irda_shutdown, | |
dc07845d RP |
571 | }; |
572 | ||
573 | ||
0dd28f1d RP |
574 | /* |
575 | * Spitz PXA Framebuffer | |
576 | */ | |
d14b272b RP |
577 | |
578 | static struct pxafb_mode_info spitz_pxafb_modes[] = { | |
579 | { | |
580 | .pixclock = 19231, | |
581 | .xres = 480, | |
582 | .yres = 640, | |
583 | .bpp = 16, | |
584 | .hsync_len = 40, | |
585 | .left_margin = 46, | |
586 | .right_margin = 125, | |
587 | .vsync_len = 3, | |
588 | .upper_margin = 1, | |
589 | .lower_margin = 0, | |
590 | .sync = 0, | |
591 | },{ | |
592 | .pixclock = 134617, | |
593 | .xres = 240, | |
594 | .yres = 320, | |
595 | .bpp = 16, | |
596 | .hsync_len = 20, | |
597 | .left_margin = 20, | |
598 | .right_margin = 46, | |
599 | .vsync_len = 2, | |
600 | .upper_margin = 1, | |
601 | .lower_margin = 0, | |
602 | .sync = 0, | |
603 | }, | |
604 | }; | |
605 | ||
606 | static struct pxafb_mach_info spitz_pxafb_info = { | |
607 | .modes = &spitz_pxafb_modes[0], | |
608 | .num_modes = 2, | |
609 | .fixed_modes = 1, | |
79009a06 | 610 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING, |
0dd28f1d RP |
611 | }; |
612 | ||
613 | ||
614 | static struct platform_device *devices[] __initdata = { | |
615 | &spitzscoop_device, | |
0dd28f1d | 616 | &spitzkbd_device, |
3179108d | 617 | &spitzled_device, |
0dd28f1d RP |
618 | }; |
619 | ||
74617fb6 RP |
620 | static void spitz_poweroff(void) |
621 | { | |
86159a98 | 622 | arm_machine_restart('g'); |
74617fb6 RP |
623 | } |
624 | ||
625 | static void spitz_restart(char mode) | |
626 | { | |
627 | /* Bootloader magic for a reboot */ | |
628 | if((MSC0 & 0xffff0000) == 0x7ff00000) | |
629 | MSC0 = (MSC0 & 0xffff) | 0x7ee00000; | |
630 | ||
631 | spitz_poweroff(); | |
632 | } | |
633 | ||
0dd28f1d RP |
634 | static void __init common_init(void) |
635 | { | |
86159a98 | 636 | init_gpio_reset(SPITZ_GPIO_ON_RESET); |
74617fb6 RP |
637 | pm_power_off = spitz_poweroff; |
638 | arm_pm_restart = spitz_restart; | |
639 | ||
0dd28f1d RP |
640 | PMCR = 0x00; |
641 | ||
0dd28f1d RP |
642 | /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ |
643 | PCFR |= PCFR_OPDE; | |
644 | ||
5e96adec | 645 | pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config)); |
0dd28f1d | 646 | |
859b7963 | 647 | spitz_init_spi(); |
0dd28f1d RP |
648 | |
649 | platform_add_devices(devices, ARRAY_SIZE(devices)); | |
650 | pxa_set_mci_info(&spitz_mci_platform_data); | |
3125c68d | 651 | pxa_set_ohci_info(&spitz_ohci_platform_data); |
dc07845d | 652 | pxa_set_ficp_info(&spitz_ficp_platform_data); |
0dd28f1d | 653 | set_pxa_fb_info(&spitz_pxafb_info); |
f8787fdc | 654 | pxa_set_i2c_info(NULL); |
0dd28f1d RP |
655 | } |
656 | ||
ca4d6cfc | 657 | #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI) |
0dd28f1d RP |
658 | static void __init spitz_init(void) |
659 | { | |
a63ae442 RP |
660 | platform_scoop_config = &spitz_pcmcia_config; |
661 | ||
0dd28f1d RP |
662 | common_init(); |
663 | ||
664 | platform_device_register(&spitzscoop2_device); | |
665 | } | |
ca4d6cfc | 666 | #endif |
0dd28f1d | 667 | |
94cabd00 RP |
668 | #ifdef CONFIG_MACH_AKITA |
669 | /* | |
670 | * Akita IO Expander | |
671 | */ | |
f72de663 EM |
672 | static struct pca953x_platform_data akita_ioexp = { |
673 | .gpio_base = AKITA_IOEXP_GPIO_BASE, | |
94cabd00 RP |
674 | }; |
675 | ||
f72de663 EM |
676 | static struct i2c_board_info akita_i2c_board_info[] = { |
677 | { | |
678 | .type = "max7310", | |
679 | .addr = 0x18, | |
680 | .platform_data = &akita_ioexp, | |
681 | }, | |
682 | }; | |
bd8f103e | 683 | |
94cabd00 RP |
684 | static void __init akita_init(void) |
685 | { | |
686 | spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode; | |
687 | ||
688 | /* We just pretend the second element of the array doesn't exist */ | |
689 | spitz_pcmcia_config.num_devs = 1; | |
690 | platform_scoop_config = &spitz_pcmcia_config; | |
94cabd00 | 691 | |
f72de663 EM |
692 | pxa_set_i2c_info(NULL); |
693 | i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info)); | |
94cabd00 | 694 | |
94cabd00 RP |
695 | common_init(); |
696 | } | |
697 | #endif | |
698 | ||
0dd28f1d RP |
699 | static void __init fixup_spitz(struct machine_desc *desc, |
700 | struct tag *tags, char **cmdline, struct meminfo *mi) | |
701 | { | |
702 | sharpsl_save_param(); | |
703 | mi->nr_banks = 1; | |
704 | mi->bank[0].start = 0xa0000000; | |
705 | mi->bank[0].node = 0; | |
706 | mi->bank[0].size = (64*1024*1024); | |
707 | } | |
708 | ||
709 | #ifdef CONFIG_MACH_SPITZ | |
710 | MACHINE_START(SPITZ, "SHARP Spitz") | |
0dd28f1d RP |
711 | .phys_io = 0x40000000, |
712 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
713 | .fixup = fixup_spitz, | |
714 | .map_io = pxa_map_io, | |
cd49104d | 715 | .init_irq = pxa27x_init_irq, |
0dd28f1d RP |
716 | .init_machine = spitz_init, |
717 | .timer = &pxa_timer, | |
718 | MACHINE_END | |
719 | #endif | |
720 | ||
721 | #ifdef CONFIG_MACH_BORZOI | |
722 | MACHINE_START(BORZOI, "SHARP Borzoi") | |
0dd28f1d RP |
723 | .phys_io = 0x40000000, |
724 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
725 | .fixup = fixup_spitz, | |
726 | .map_io = pxa_map_io, | |
cd49104d | 727 | .init_irq = pxa27x_init_irq, |
0dd28f1d RP |
728 | .init_machine = spitz_init, |
729 | .timer = &pxa_timer, | |
730 | MACHINE_END | |
731 | #endif | |
94cabd00 RP |
732 | |
733 | #ifdef CONFIG_MACH_AKITA | |
734 | MACHINE_START(AKITA, "SHARP Akita") | |
94cabd00 RP |
735 | .phys_io = 0x40000000, |
736 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
737 | .fixup = fixup_spitz, | |
738 | .map_io = pxa_map_io, | |
cd49104d | 739 | .init_irq = pxa27x_init_irq, |
94cabd00 RP |
740 | .init_machine = akita_init, |
741 | .timer = &pxa_timer, | |
742 | MACHINE_END | |
743 | #endif |