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> | |
d052d1be | 16 | #include <linux/platform_device.h> |
0dd28f1d | 17 | #include <linux/delay.h> |
f6919eb4 | 18 | #include <linux/gpio_keys.h> |
dd5980d6 | 19 | #include <linux/gpio.h> |
4fe3224f | 20 | #include <linux/leds.h> |
e5d3bf3c | 21 | #include <linux/mtd/physmap.h> |
f72de663 EM |
22 | #include <linux/i2c.h> |
23 | #include <linux/i2c/pca953x.h> | |
859b7963 EM |
24 | #include <linux/spi/spi.h> |
25 | #include <linux/spi/ads7846.h> | |
26 | #include <linux/spi/corgi_lcd.h> | |
6af7a8eb | 27 | #include <linux/mtd/sharpsl.h> |
93dd29a8 | 28 | #include <linux/input/matrix_keypad.h> |
0dd28f1d RP |
29 | |
30 | #include <asm/setup.h> | |
0dd28f1d | 31 | #include <asm/mach-types.h> |
0dd28f1d | 32 | #include <asm/mach/arch.h> |
f0ba4017 DES |
33 | #include <asm/mach/sharpsl_param.h> |
34 | #include <asm/hardware/scoop.h> | |
35 | ||
0dd28f1d | 36 | |
51c62982 | 37 | #include <mach/pxa27x.h> |
a09e64fb | 38 | #include <mach/pxa27x-udc.h> |
afd2fc02 | 39 | #include <mach/reset.h> |
f0a83701 | 40 | #include <plat/i2c.h> |
a09e64fb RK |
41 | #include <mach/irda.h> |
42 | #include <mach/mmc.h> | |
43 | #include <mach/ohci.h> | |
a09e64fb | 44 | #include <mach/pxafb.h> |
859b7963 | 45 | #include <mach/pxa2xx_spi.h> |
a09e64fb | 46 | #include <mach/spitz.h> |
0dd28f1d RP |
47 | |
48 | #include "generic.h" | |
46c41e62 | 49 | #include "devices.h" |
0dd28f1d RP |
50 | #include "sharpsl.h" |
51 | ||
5e96adec EM |
52 | static unsigned long spitz_pin_config[] __initdata = { |
53 | /* Chip Selects */ | |
54 | GPIO78_nCS_2, /* SCOOP #2 */ | |
faf2f0ab | 55 | GPIO79_nCS_3, /* NAND */ |
5e96adec EM |
56 | GPIO80_nCS_4, /* SCOOP #1 */ |
57 | ||
58 | /* LCD - 16bpp Active TFT */ | |
bedbda97 | 59 | GPIOxx_LCD_TFT_16BPP, |
5e96adec EM |
60 | |
61 | /* PC Card */ | |
62 | GPIO48_nPOE, | |
63 | GPIO49_nPWE, | |
64 | GPIO50_nPIOR, | |
65 | GPIO51_nPIOW, | |
66 | GPIO85_nPCE_1, | |
67 | GPIO54_nPCE_2, | |
5e96adec EM |
68 | GPIO55_nPREG, |
69 | GPIO56_nPWAIT, | |
70 | GPIO57_nIOIS16, | |
faf2f0ab | 71 | GPIO104_PSKTSEL, |
5e96adec | 72 | |
772885c1 PZ |
73 | /* I2S */ |
74 | GPIO28_I2S_BITCLK_OUT, | |
75 | GPIO29_I2S_SDATA_IN, | |
76 | GPIO30_I2S_SDATA_OUT, | |
77 | GPIO31_I2S_SYNC, | |
78 | ||
5e96adec EM |
79 | /* MMC */ |
80 | GPIO32_MMC_CLK, | |
81 | GPIO112_MMC_CMD, | |
82 | GPIO92_MMC_DAT_0, | |
83 | GPIO109_MMC_DAT_1, | |
84 | GPIO110_MMC_DAT_2, | |
85 | GPIO111_MMC_DAT_3, | |
86 | ||
87 | /* GPIOs */ | |
88 | GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */ | |
b6eede11 | 89 | GPIO16_GPIO, /* SPITZ_GPIO_SYNC */ |
5e96adec EM |
90 | GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */ |
91 | GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */ | |
92 | GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */ | |
93 | GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */ | |
94 | GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */ | |
95 | GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */ | |
96 | GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */ | |
97 | GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */ | |
98 | ||
93dd29a8 EM |
99 | /* GPIO matrix keypad */ |
100 | GPIO88_GPIO, /* column 0 */ | |
101 | GPIO23_GPIO, /* column 1 */ | |
102 | GPIO24_GPIO, /* column 2 */ | |
103 | GPIO25_GPIO, /* column 3 */ | |
104 | GPIO26_GPIO, /* column 4 */ | |
105 | GPIO27_GPIO, /* column 5 */ | |
106 | GPIO52_GPIO, /* column 6 */ | |
107 | GPIO103_GPIO, /* column 7 */ | |
108 | GPIO107_GPIO, /* column 8 */ | |
109 | GPIO108_GPIO, /* column 9 */ | |
110 | GPIO114_GPIO, /* column 10 */ | |
111 | GPIO12_GPIO, /* row 0 */ | |
112 | GPIO17_GPIO, /* row 1 */ | |
113 | GPIO91_GPIO, /* row 2 */ | |
114 | GPIO34_GPIO, /* row 3 */ | |
115 | GPIO36_GPIO, /* row 4 */ | |
116 | GPIO38_GPIO, /* row 5 */ | |
117 | GPIO39_GPIO, /* row 6 */ | |
118 | ||
6f584cfa EM |
119 | /* I2C */ |
120 | GPIO117_I2C_SCL, | |
121 | GPIO118_I2C_SDA, | |
122 | ||
b6eede11 EM |
123 | GPIO0_GPIO | WAKEUP_ON_EDGE_RISE, /* SPITZ_GPIO_KEY_INT */ |
124 | GPIO1_GPIO | WAKEUP_ON_EDGE_FALL, /* SPITZ_GPIO_RESET */ | |
5e96adec EM |
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 | 248 | /* |
0dd28f1d | 249 | * Spitz Keyboard Device |
0dd28f1d | 250 | */ |
93dd29a8 EM |
251 | #define SPITZ_KEY_CALENDAR KEY_F1 |
252 | #define SPITZ_KEY_ADDRESS KEY_F2 | |
253 | #define SPITZ_KEY_FN KEY_F3 | |
254 | #define SPITZ_KEY_CANCEL KEY_F4 | |
255 | #define SPITZ_KEY_EXOK KEY_F5 | |
256 | #define SPITZ_KEY_EXCANCEL KEY_F6 | |
257 | #define SPITZ_KEY_EXJOGDOWN KEY_F7 | |
258 | #define SPITZ_KEY_EXJOGUP KEY_F8 | |
259 | #define SPITZ_KEY_JAP1 KEY_LEFTALT | |
260 | #define SPITZ_KEY_JAP2 KEY_RIGHTCTRL | |
261 | #define SPITZ_KEY_SYNC KEY_F9 | |
262 | #define SPITZ_KEY_MAIL KEY_F10 | |
263 | #define SPITZ_KEY_OK KEY_F11 | |
264 | #define SPITZ_KEY_MENU KEY_F12 | |
265 | ||
266 | static const uint32_t spitzkbd_keymap[] = { | |
267 | KEY(0, 0, KEY_LEFTCTRL), | |
268 | KEY(0, 1, KEY_1), | |
269 | KEY(0, 2, KEY_3), | |
270 | KEY(0, 3, KEY_5), | |
271 | KEY(0, 4, KEY_6), | |
272 | KEY(0, 5, KEY_7), | |
273 | KEY(0, 6, KEY_9), | |
274 | KEY(0, 7, KEY_0), | |
275 | KEY(0, 8, KEY_BACKSPACE), | |
276 | KEY(0, 9, SPITZ_KEY_EXOK), /* EXOK */ | |
277 | KEY(0, 10, SPITZ_KEY_EXCANCEL), /* EXCANCEL */ | |
278 | KEY(1, 1, KEY_2), | |
279 | KEY(1, 2, KEY_4), | |
280 | KEY(1, 3, KEY_R), | |
281 | KEY(1, 4, KEY_Y), | |
282 | KEY(1, 5, KEY_8), | |
283 | KEY(1, 6, KEY_I), | |
284 | KEY(1, 7, KEY_O), | |
285 | KEY(1, 8, KEY_P), | |
286 | KEY(1, 9, SPITZ_KEY_EXJOGDOWN), /* EXJOGDOWN */ | |
287 | KEY(1, 10, SPITZ_KEY_EXJOGUP), /* EXJOGUP */ | |
288 | KEY(2, 0, KEY_TAB), | |
289 | KEY(2, 1, KEY_Q), | |
290 | KEY(2, 2, KEY_E), | |
291 | KEY(2, 3, KEY_T), | |
292 | KEY(2, 4, KEY_G), | |
293 | KEY(2, 5, KEY_U), | |
294 | KEY(2, 6, KEY_J), | |
295 | KEY(2, 7, KEY_K), | |
296 | KEY(3, 0, SPITZ_KEY_ADDRESS), /* ADDRESS */ | |
297 | KEY(3, 1, KEY_W), | |
298 | KEY(3, 2, KEY_S), | |
299 | KEY(3, 3, KEY_F), | |
300 | KEY(3, 4, KEY_V), | |
301 | KEY(3, 5, KEY_H), | |
302 | KEY(3, 6, KEY_M), | |
303 | KEY(3, 7, KEY_L), | |
304 | KEY(3, 9, KEY_RIGHTSHIFT), | |
305 | KEY(4, 0, SPITZ_KEY_CALENDAR), /* CALENDAR */ | |
306 | KEY(4, 1, KEY_A), | |
307 | KEY(4, 2, KEY_D), | |
308 | KEY(4, 3, KEY_C), | |
309 | KEY(4, 4, KEY_B), | |
310 | KEY(4, 5, KEY_N), | |
311 | KEY(4, 6, KEY_DOT), | |
312 | KEY(4, 8, KEY_ENTER), | |
313 | KEY(4, 9, KEY_LEFTSHIFT), | |
314 | KEY(5, 0, SPITZ_KEY_MAIL), /* MAIL */ | |
315 | KEY(5, 1, KEY_Z), | |
316 | KEY(5, 2, KEY_X), | |
317 | KEY(5, 3, KEY_MINUS), | |
318 | KEY(5, 4, KEY_SPACE), | |
319 | KEY(5, 5, KEY_COMMA), | |
320 | KEY(5, 7, KEY_UP), | |
321 | KEY(5, 10, SPITZ_KEY_FN), /* FN */ | |
322 | KEY(6, 0, KEY_SYSRQ), | |
323 | KEY(6, 1, SPITZ_KEY_JAP1), /* JAP1 */ | |
324 | KEY(6, 2, SPITZ_KEY_JAP2), /* JAP2 */ | |
325 | KEY(6, 3, SPITZ_KEY_CANCEL), /* CANCEL */ | |
326 | KEY(6, 4, SPITZ_KEY_OK), /* OK */ | |
327 | KEY(6, 5, SPITZ_KEY_MENU), /* MENU */ | |
328 | KEY(6, 6, KEY_LEFT), | |
329 | KEY(6, 7, KEY_DOWN), | |
330 | KEY(6, 8, KEY_RIGHT), | |
331 | }; | |
332 | ||
333 | static const struct matrix_keymap_data spitzkbd_keymap_data = { | |
334 | .keymap = spitzkbd_keymap, | |
335 | .keymap_size = ARRAY_SIZE(spitzkbd_keymap), | |
336 | }; | |
337 | ||
338 | static const uint32_t spitzkbd_row_gpios[] = | |
339 | { 12, 17, 91, 34, 36, 38, 39 }; | |
340 | static const uint32_t spitzkbd_col_gpios[] = | |
341 | { 88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114 }; | |
342 | ||
343 | static struct matrix_keypad_platform_data spitzkbd_pdata = { | |
344 | .keymap_data = &spitzkbd_keymap_data, | |
345 | .row_gpios = spitzkbd_row_gpios, | |
346 | .col_gpios = spitzkbd_col_gpios, | |
347 | .num_row_gpios = ARRAY_SIZE(spitzkbd_row_gpios), | |
348 | .num_col_gpios = ARRAY_SIZE(spitzkbd_col_gpios), | |
349 | .col_scan_delay_us = 10, | |
350 | .debounce_ms = 10, | |
351 | .wakeup = 1, | |
352 | }; | |
353 | ||
0dd28f1d | 354 | static struct platform_device spitzkbd_device = { |
93dd29a8 | 355 | .name = "matrix-keypad", |
0dd28f1d | 356 | .id = -1, |
93dd29a8 EM |
357 | .dev = { |
358 | .platform_data = &spitzkbd_pdata, | |
359 | }, | |
0dd28f1d RP |
360 | }; |
361 | ||
0dd28f1d | 362 | |
f6919eb4 SB |
363 | static struct gpio_keys_button spitz_gpio_keys[] = { |
364 | { | |
365 | .type = EV_PWR, | |
366 | .code = KEY_SUSPEND, | |
367 | .gpio = SPITZ_GPIO_ON_KEY, | |
b53f7710 | 368 | .desc = "On Off", |
f6919eb4 SB |
369 | .wakeup = 1, |
370 | }, | |
371 | /* Two buttons detecting the lid state */ | |
372 | { | |
373 | .type = EV_SW, | |
374 | .code = 0, | |
375 | .gpio = SPITZ_GPIO_SWA, | |
d13fecd0 | 376 | .desc = "Display Down", |
f6919eb4 SB |
377 | }, |
378 | { | |
379 | .type = EV_SW, | |
380 | .code = 1, | |
381 | .gpio = SPITZ_GPIO_SWB, | |
d13fecd0 | 382 | .desc = "Lid Closed", |
f6919eb4 SB |
383 | }, |
384 | }; | |
385 | ||
386 | static struct gpio_keys_platform_data spitz_gpio_keys_platform_data = { | |
387 | .buttons = spitz_gpio_keys, | |
388 | .nbuttons = ARRAY_SIZE(spitz_gpio_keys), | |
389 | }; | |
390 | ||
391 | static struct platform_device spitz_gpio_keys_device = { | |
392 | .name = "gpio-keys", | |
393 | .id = -1, | |
394 | .dev = { | |
395 | .platform_data = &spitz_gpio_keys_platform_data, | |
396 | }, | |
397 | }; | |
398 | ||
399 | ||
0dd28f1d | 400 | /* |
3179108d | 401 | * Spitz LEDs |
0dd28f1d | 402 | */ |
4fe3224f EM |
403 | static struct gpio_led spitz_gpio_leds[] = { |
404 | { | |
405 | .name = "spitz:amber:charge", | |
406 | .default_trigger = "sharpsl-charge", | |
407 | .gpio = SPITZ_GPIO_LED_ORANGE, | |
408 | }, | |
409 | { | |
410 | .name = "spitz:green:hddactivity", | |
411 | .default_trigger = "ide-disk", | |
412 | .gpio = SPITZ_GPIO_LED_GREEN, | |
0dd28f1d | 413 | }, |
0dd28f1d RP |
414 | }; |
415 | ||
4fe3224f EM |
416 | static struct gpio_led_platform_data spitz_gpio_leds_info = { |
417 | .leds = spitz_gpio_leds, | |
418 | .num_leds = ARRAY_SIZE(spitz_gpio_leds), | |
0dd28f1d RP |
419 | }; |
420 | ||
3179108d | 421 | static struct platform_device spitzled_device = { |
4fe3224f | 422 | .name = "leds-gpio", |
3179108d | 423 | .id = -1, |
4fe3224f EM |
424 | .dev = { |
425 | .platform_data = &spitz_gpio_leds_info, | |
426 | }, | |
3179108d RP |
427 | }; |
428 | ||
859b7963 EM |
429 | #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) |
430 | static struct pxa2xx_spi_master spitz_spi_info = { | |
431 | .num_chipselect = 3, | |
432 | }; | |
ca4d6cfc | 433 | |
3e36c0de EM |
434 | static void spitz_wait_for_hsync(void) |
435 | { | |
436 | while (gpio_get_value(SPITZ_GPIO_HSYNC)) | |
437 | cpu_relax(); | |
438 | ||
439 | while (!gpio_get_value(SPITZ_GPIO_HSYNC)) | |
440 | cpu_relax(); | |
441 | } | |
442 | ||
859b7963 EM |
443 | static struct ads7846_platform_data spitz_ads7846_info = { |
444 | .model = 7846, | |
445 | .vref_delay_usecs = 100, | |
446 | .x_plate_ohms = 419, | |
447 | .y_plate_ohms = 486, | |
3318c4bd | 448 | .pressure_max = 1024, |
859b7963 | 449 | .gpio_pendown = SPITZ_GPIO_TP_INT, |
3e36c0de | 450 | .wait_for_sync = spitz_wait_for_hsync, |
859b7963 | 451 | }; |
ca4d6cfc | 452 | |
859b7963 | 453 | static struct pxa2xx_spi_chip spitz_ads7846_chip = { |
46580c03 | 454 | .gpio_cs = SPITZ_GPIO_ADS7846_CS, |
859b7963 | 455 | }; |
ca4d6cfc | 456 | |
859b7963 | 457 | static void spitz_bl_kick_battery(void) |
ca4d6cfc | 458 | { |
859b7963 | 459 | void (*kick_batt)(void); |
ca4d6cfc | 460 | |
859b7963 EM |
461 | kick_batt = symbol_get(sharpsl_battery_kick); |
462 | if (kick_batt) { | |
463 | kick_batt(); | |
464 | symbol_put(sharpsl_battery_kick); | |
ca4d6cfc | 465 | } |
ca4d6cfc RP |
466 | } |
467 | ||
859b7963 EM |
468 | static struct corgi_lcd_platform_data spitz_lcdcon_info = { |
469 | .init_mode = CORGI_LCD_MODE_VGA, | |
470 | .max_intensity = 0x2f, | |
471 | .default_intensity = 0x1f, | |
472 | .limit_mask = 0x0b, | |
ff7a4c71 EM |
473 | .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT, |
474 | .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON, | |
859b7963 EM |
475 | .kick_battery = spitz_bl_kick_battery, |
476 | }; | |
ca4d6cfc | 477 | |
859b7963 | 478 | static struct pxa2xx_spi_chip spitz_lcdcon_chip = { |
46580c03 | 479 | .gpio_cs = SPITZ_GPIO_LCDCON_CS, |
0dd28f1d RP |
480 | }; |
481 | ||
859b7963 | 482 | static struct pxa2xx_spi_chip spitz_max1111_chip = { |
46580c03 | 483 | .gpio_cs = SPITZ_GPIO_MAX1111_CS, |
0dd28f1d RP |
484 | }; |
485 | ||
859b7963 EM |
486 | static struct spi_board_info spitz_spi_devices[] = { |
487 | { | |
488 | .modalias = "ads7846", | |
489 | .max_speed_hz = 1200000, | |
490 | .bus_num = 2, | |
491 | .chip_select = 0, | |
492 | .platform_data = &spitz_ads7846_info, | |
493 | .controller_data= &spitz_ads7846_chip, | |
494 | .irq = gpio_to_irq(SPITZ_GPIO_TP_INT), | |
495 | }, { | |
496 | .modalias = "corgi-lcd", | |
497 | .max_speed_hz = 50000, | |
498 | .bus_num = 2, | |
499 | .chip_select = 1, | |
500 | .platform_data = &spitz_lcdcon_info, | |
501 | .controller_data= &spitz_lcdcon_chip, | |
502 | }, { | |
503 | .modalias = "max1111", | |
504 | .max_speed_hz = 450000, | |
505 | .bus_num = 2, | |
506 | .chip_select = 2, | |
507 | .controller_data= &spitz_max1111_chip, | |
0dd28f1d | 508 | }, |
0dd28f1d RP |
509 | }; |
510 | ||
859b7963 EM |
511 | static void __init spitz_init_spi(void) |
512 | { | |
ff7a4c71 EM |
513 | if (machine_is_akita()) { |
514 | spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT; | |
515 | spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON; | |
516 | } | |
517 | ||
859b7963 EM |
518 | pxa2xx_set_spi_info(2, &spitz_spi_info); |
519 | spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); | |
859b7963 EM |
520 | } |
521 | #else | |
522 | static inline void spitz_init_spi(void) {} | |
523 | #endif | |
0dd28f1d RP |
524 | |
525 | /* | |
526 | * MMC/SD Device | |
527 | * | |
528 | * The card detect interrupt isn't debounced so we delay it by 250ms | |
529 | * to give the card a chance to fully insert/eject. | |
530 | */ | |
0dd28f1d RP |
531 | static void spitz_mci_setpower(struct device *dev, unsigned int vdd) |
532 | { | |
533 | struct pxamci_platform_data* p_d = dev->platform_data; | |
534 | ||
a63ae442 RP |
535 | if (( 1 << vdd) & p_d->ocr_mask) |
536 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004); | |
537 | else | |
538 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000); | |
0dd28f1d RP |
539 | } |
540 | ||
0dd28f1d | 541 | static struct pxamci_platform_data spitz_mci_platform_data = { |
f97cab28 | 542 | .detect_delay_ms = 250, |
7a648256 RJ |
543 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
544 | .setpower = spitz_mci_setpower, | |
545 | .gpio_card_detect = SPITZ_GPIO_nSD_DETECT, | |
546 | .gpio_card_ro = SPITZ_GPIO_nSD_WP, | |
547 | .gpio_power = -1, | |
0dd28f1d RP |
548 | }; |
549 | ||
550 | ||
3125c68d RP |
551 | /* |
552 | * USB Host (OHCI) | |
553 | */ | |
554 | static int spitz_ohci_init(struct device *dev) | |
555 | { | |
dd5980d6 | 556 | int err; |
3125c68d | 557 | |
dd5980d6 EM |
558 | err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST"); |
559 | if (err) | |
560 | return err; | |
3125c68d | 561 | |
5e96adec EM |
562 | /* Only Port 2 is connected |
563 | * Setup USB Port 2 Output Control Register | |
564 | */ | |
3125c68d | 565 | UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; |
3125c68d | 566 | |
097b5334 | 567 | return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1); |
3125c68d RP |
568 | } |
569 | ||
a81b3868 DES |
570 | static void spitz_ohci_exit(struct device *dev) |
571 | { | |
572 | gpio_free(SPITZ_GPIO_USB_HOST); | |
573 | } | |
574 | ||
3125c68d RP |
575 | static struct pxaohci_platform_data spitz_ohci_platform_data = { |
576 | .port_mode = PMM_NPS_MODE, | |
577 | .init = spitz_ohci_init, | |
a81b3868 | 578 | .exit = spitz_ohci_exit, |
097b5334 | 579 | .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION, |
0c27c5d5 | 580 | .power_budget = 150, |
3125c68d RP |
581 | }; |
582 | ||
583 | ||
dc07845d RP |
584 | /* |
585 | * Irda | |
586 | */ | |
94cabd00 | 587 | |
dc07845d | 588 | static struct pxaficp_platform_data spitz_ficp_platform_data = { |
c4bd0172 | 589 | /* .gpio_pwdown is set in spitz_init() and akita_init() accordingly */ |
fff14720 | 590 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
dc07845d RP |
591 | }; |
592 | ||
593 | ||
0dd28f1d RP |
594 | /* |
595 | * Spitz PXA Framebuffer | |
596 | */ | |
d14b272b RP |
597 | |
598 | static struct pxafb_mode_info spitz_pxafb_modes[] = { | |
599 | { | |
600 | .pixclock = 19231, | |
601 | .xres = 480, | |
602 | .yres = 640, | |
603 | .bpp = 16, | |
604 | .hsync_len = 40, | |
605 | .left_margin = 46, | |
606 | .right_margin = 125, | |
607 | .vsync_len = 3, | |
608 | .upper_margin = 1, | |
609 | .lower_margin = 0, | |
610 | .sync = 0, | |
611 | },{ | |
612 | .pixclock = 134617, | |
613 | .xres = 240, | |
614 | .yres = 320, | |
615 | .bpp = 16, | |
616 | .hsync_len = 20, | |
617 | .left_margin = 20, | |
618 | .right_margin = 46, | |
619 | .vsync_len = 2, | |
620 | .upper_margin = 1, | |
621 | .lower_margin = 0, | |
622 | .sync = 0, | |
623 | }, | |
624 | }; | |
625 | ||
626 | static struct pxafb_mach_info spitz_pxafb_info = { | |
627 | .modes = &spitz_pxafb_modes[0], | |
628 | .num_modes = 2, | |
629 | .fixed_modes = 1, | |
79009a06 | 630 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING, |
0dd28f1d RP |
631 | }; |
632 | ||
6af7a8eb DB |
633 | static struct mtd_partition sharpsl_nand_partitions[] = { |
634 | { | |
635 | .name = "System Area", | |
636 | .offset = 0, | |
637 | .size = 7 * 1024 * 1024, | |
638 | }, | |
639 | { | |
640 | .name = "Root Filesystem", | |
641 | .offset = 7 * 1024 * 1024, | |
642 | }, | |
643 | { | |
644 | .name = "Home Filesystem", | |
645 | .offset = MTDPART_OFS_APPEND, | |
646 | .size = MTDPART_SIZ_FULL, | |
647 | }, | |
648 | }; | |
649 | ||
650 | static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; | |
651 | ||
652 | static struct nand_bbt_descr sharpsl_bbt = { | |
653 | .options = 0, | |
654 | .offs = 4, | |
655 | .len = 2, | |
656 | .pattern = scan_ff_pattern | |
657 | }; | |
658 | ||
659 | static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = { | |
660 | .badblock_pattern = &sharpsl_bbt, | |
661 | .partitions = sharpsl_nand_partitions, | |
662 | .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions), | |
663 | }; | |
664 | ||
665 | static struct resource sharpsl_nand_resources[] = { | |
666 | { | |
667 | .start = 0x0C000000, | |
668 | .end = 0x0C000FFF, | |
669 | .flags = IORESOURCE_MEM, | |
670 | }, | |
671 | }; | |
672 | ||
673 | static struct platform_device sharpsl_nand_device = { | |
674 | .name = "sharpsl-nand", | |
675 | .id = -1, | |
676 | .resource = sharpsl_nand_resources, | |
677 | .num_resources = ARRAY_SIZE(sharpsl_nand_resources), | |
678 | .dev.platform_data = &sharpsl_nand_platform_data, | |
679 | }; | |
680 | ||
0dd28f1d | 681 | |
e5d3bf3c DB |
682 | static struct mtd_partition sharpsl_rom_parts[] = { |
683 | { | |
684 | .name ="Boot PROM Filesystem", | |
685 | .offset = 0x00140000, | |
686 | .size = MTDPART_SIZ_FULL, | |
687 | }, | |
688 | }; | |
689 | ||
690 | static struct physmap_flash_data sharpsl_rom_data = { | |
691 | .width = 2, | |
692 | .nr_parts = ARRAY_SIZE(sharpsl_rom_parts), | |
693 | .parts = sharpsl_rom_parts, | |
694 | }; | |
695 | ||
696 | static struct resource sharpsl_rom_resources[] = { | |
697 | { | |
698 | .start = 0x00000000, | |
699 | .end = 0x007fffff, | |
700 | .flags = IORESOURCE_MEM, | |
701 | }, | |
702 | }; | |
703 | ||
704 | static struct platform_device sharpsl_rom_device = { | |
705 | .name = "physmap-flash", | |
706 | .id = -1, | |
707 | .resource = sharpsl_rom_resources, | |
708 | .num_resources = ARRAY_SIZE(sharpsl_rom_resources), | |
709 | .dev.platform_data = &sharpsl_rom_data, | |
710 | }; | |
711 | ||
0dd28f1d RP |
712 | static struct platform_device *devices[] __initdata = { |
713 | &spitzscoop_device, | |
0dd28f1d | 714 | &spitzkbd_device, |
f6919eb4 | 715 | &spitz_gpio_keys_device, |
3179108d | 716 | &spitzled_device, |
6af7a8eb | 717 | &sharpsl_nand_device, |
e5d3bf3c | 718 | &sharpsl_rom_device, |
0dd28f1d RP |
719 | }; |
720 | ||
74617fb6 RP |
721 | static void spitz_poweroff(void) |
722 | { | |
be093beb | 723 | arm_machine_restart('g', NULL); |
74617fb6 RP |
724 | } |
725 | ||
be093beb | 726 | static void spitz_restart(char mode, const char *cmd) |
74617fb6 RP |
727 | { |
728 | /* Bootloader magic for a reboot */ | |
729 | if((MSC0 & 0xffff0000) == 0x7ff00000) | |
730 | MSC0 = (MSC0 & 0xffff) | 0x7ee00000; | |
731 | ||
732 | spitz_poweroff(); | |
733 | } | |
734 | ||
0dd28f1d RP |
735 | static void __init common_init(void) |
736 | { | |
216e3b7a | 737 | init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0); |
74617fb6 RP |
738 | pm_power_off = spitz_poweroff; |
739 | arm_pm_restart = spitz_restart; | |
740 | ||
6af7a8eb DB |
741 | if (machine_is_spitz()) { |
742 | sharpsl_nand_partitions[1].size = 5 * 1024 * 1024; | |
743 | } else if (machine_is_akita()) { | |
744 | sharpsl_nand_partitions[1].size = 58 * 1024 * 1024; | |
745 | } else if (machine_is_borzoi()) { | |
746 | sharpsl_nand_partitions[1].size = 32 * 1024 * 1024; | |
747 | } | |
748 | ||
0dd28f1d RP |
749 | PMCR = 0x00; |
750 | ||
0dd28f1d RP |
751 | /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ |
752 | PCFR |= PCFR_OPDE; | |
753 | ||
5e96adec | 754 | pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config)); |
0dd28f1d | 755 | |
cc155c6f RK |
756 | pxa_set_ffuart_info(NULL); |
757 | pxa_set_btuart_info(NULL); | |
758 | pxa_set_stuart_info(NULL); | |
759 | ||
859b7963 | 760 | spitz_init_spi(); |
0dd28f1d RP |
761 | |
762 | platform_add_devices(devices, ARRAY_SIZE(devices)); | |
763 | pxa_set_mci_info(&spitz_mci_platform_data); | |
3125c68d | 764 | pxa_set_ohci_info(&spitz_ohci_platform_data); |
dc07845d | 765 | pxa_set_ficp_info(&spitz_ficp_platform_data); |
0dd28f1d | 766 | set_pxa_fb_info(&spitz_pxafb_info); |
f8787fdc | 767 | pxa_set_i2c_info(NULL); |
0dd28f1d RP |
768 | } |
769 | ||
5e0fa3f6 SB |
770 | #if defined(CONFIG_MACH_AKITA) || defined(CONFIG_MACH_BORZOI) |
771 | static struct nand_bbt_descr sharpsl_akita_bbt = { | |
772 | .options = 0, | |
773 | .offs = 4, | |
774 | .len = 1, | |
775 | .pattern = scan_ff_pattern | |
776 | }; | |
777 | ||
778 | static struct nand_ecclayout akita_oobinfo = { | |
779 | .eccbytes = 24, | |
780 | .eccpos = { | |
781 | 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11, | |
782 | 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23, | |
783 | 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37}, | |
784 | .oobfree = {{0x08, 0x09}} | |
785 | }; | |
786 | #endif | |
787 | ||
ca4d6cfc | 788 | #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI) |
0dd28f1d RP |
789 | static void __init spitz_init(void) |
790 | { | |
c4bd0172 MV |
791 | spitz_ficp_platform_data.gpio_pwdown = SPITZ_GPIO_IR_ON; |
792 | ||
81065518 | 793 | #ifdef CONFIG_MACH_BORZOI |
5e0fa3f6 SB |
794 | if (machine_is_borzoi()) { |
795 | sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt; | |
796 | sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo; | |
797 | } | |
81065518 | 798 | #endif |
5e0fa3f6 | 799 | |
a63ae442 RP |
800 | platform_scoop_config = &spitz_pcmcia_config; |
801 | ||
0dd28f1d RP |
802 | common_init(); |
803 | ||
804 | platform_device_register(&spitzscoop2_device); | |
805 | } | |
ca4d6cfc | 806 | #endif |
0dd28f1d | 807 | |
94cabd00 RP |
808 | #ifdef CONFIG_MACH_AKITA |
809 | /* | |
810 | * Akita IO Expander | |
811 | */ | |
f72de663 EM |
812 | static struct pca953x_platform_data akita_ioexp = { |
813 | .gpio_base = AKITA_IOEXP_GPIO_BASE, | |
94cabd00 RP |
814 | }; |
815 | ||
f72de663 EM |
816 | static struct i2c_board_info akita_i2c_board_info[] = { |
817 | { | |
818 | .type = "max7310", | |
819 | .addr = 0x18, | |
820 | .platform_data = &akita_ioexp, | |
d30e5d89 MV |
821 | }, { |
822 | .type = "wm8750", | |
823 | .addr = 0x1b, | |
f72de663 EM |
824 | }, |
825 | }; | |
ca4d6cfc | 826 | |
94cabd00 RP |
827 | static void __init akita_init(void) |
828 | { | |
c4bd0172 | 829 | spitz_ficp_platform_data.gpio_pwdown = AKITA_GPIO_IR_ON; |
94cabd00 | 830 | |
6af7a8eb DB |
831 | sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt; |
832 | sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo; | |
833 | ||
94cabd00 RP |
834 | /* We just pretend the second element of the array doesn't exist */ |
835 | spitz_pcmcia_config.num_devs = 1; | |
836 | platform_scoop_config = &spitz_pcmcia_config; | |
94cabd00 | 837 | |
f72de663 | 838 | i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info)); |
94cabd00 | 839 | |
94cabd00 RP |
840 | common_init(); |
841 | } | |
842 | #endif | |
843 | ||
0dd28f1d RP |
844 | static void __init fixup_spitz(struct machine_desc *desc, |
845 | struct tag *tags, char **cmdline, struct meminfo *mi) | |
846 | { | |
847 | sharpsl_save_param(); | |
848 | mi->nr_banks = 1; | |
849 | mi->bank[0].start = 0xa0000000; | |
0dd28f1d RP |
850 | mi->bank[0].size = (64*1024*1024); |
851 | } | |
852 | ||
853 | #ifdef CONFIG_MACH_SPITZ | |
854 | MACHINE_START(SPITZ, "SHARP Spitz") | |
0dd28f1d RP |
855 | .phys_io = 0x40000000, |
856 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
857 | .fixup = fixup_spitz, | |
858 | .map_io = pxa_map_io, | |
cd49104d | 859 | .init_irq = pxa27x_init_irq, |
0dd28f1d RP |
860 | .init_machine = spitz_init, |
861 | .timer = &pxa_timer, | |
862 | MACHINE_END | |
863 | #endif | |
864 | ||
865 | #ifdef CONFIG_MACH_BORZOI | |
866 | MACHINE_START(BORZOI, "SHARP Borzoi") | |
0dd28f1d RP |
867 | .phys_io = 0x40000000, |
868 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
869 | .fixup = fixup_spitz, | |
870 | .map_io = pxa_map_io, | |
cd49104d | 871 | .init_irq = pxa27x_init_irq, |
0dd28f1d RP |
872 | .init_machine = spitz_init, |
873 | .timer = &pxa_timer, | |
874 | MACHINE_END | |
875 | #endif | |
94cabd00 RP |
876 | |
877 | #ifdef CONFIG_MACH_AKITA | |
878 | MACHINE_START(AKITA, "SHARP Akita") | |
94cabd00 RP |
879 | .phys_io = 0x40000000, |
880 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
881 | .fixup = fixup_spitz, | |
882 | .map_io = pxa_map_io, | |
cd49104d | 883 | .init_irq = pxa27x_init_irq, |
94cabd00 RP |
884 | .init_machine = akita_init, |
885 | .timer = &pxa_timer, | |
886 | MACHINE_END | |
887 | #endif |