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