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