Commit | Line | Data |
---|---|---|
e5c271ec PZ |
1 | /* |
2 | * Support for HTC Magician PDA phones: | |
3 | * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110 | |
4 | * and T-Mobile MDA Compact. | |
5 | * | |
6 | * Copyright (c) 2006-2007 Philipp Zabel | |
7 | * | |
8 | * Based on hx4700.c, spitz.c and others. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License version 2 as | |
12 | * published by the Free Software Foundation. | |
13 | * | |
14 | */ | |
15 | ||
16 | #include <linux/kernel.h> | |
17 | #include <linux/init.h> | |
18 | #include <linux/platform_device.h> | |
e07ff8d8 | 19 | #include <linux/delay.h> |
e5c271ec PZ |
20 | #include <linux/gpio_keys.h> |
21 | #include <linux/input.h> | |
70e357f8 | 22 | #include <linux/mfd/htc-egpio.h> |
81447b2e | 23 | #include <linux/mfd/htc-pasic3.h> |
e5c271ec PZ |
24 | #include <linux/mtd/mtd.h> |
25 | #include <linux/mtd/map.h> | |
26 | #include <linux/mtd/physmap.h> | |
350d115d | 27 | #include <linux/pda_power.h> |
e5c271ec PZ |
28 | |
29 | #include <asm/gpio.h> | |
30 | #include <asm/hardware.h> | |
31 | #include <asm/mach-types.h> | |
32 | #include <asm/mach/arch.h> | |
33 | #include <asm/arch/magician.h> | |
b168281c | 34 | #include <asm/arch/mfp-pxa27x.h> |
e5c271ec | 35 | #include <asm/arch/pxa-regs.h> |
0b0a9df6 | 36 | #include <asm/arch/pxa2xx-regs.h> |
e5c271ec | 37 | #include <asm/arch/pxafb.h> |
e6816f34 | 38 | #include <asm/arch/i2c.h> |
bdb0c16a | 39 | #include <asm/arch/mmc.h> |
e5c271ec PZ |
40 | #include <asm/arch/irda.h> |
41 | #include <asm/arch/ohci.h> | |
42 | ||
43 | #include "generic.h" | |
44 | ||
b168281c PZ |
45 | static unsigned long magician_pin_config[] = { |
46 | ||
47 | /* SDRAM and Static Memory I/O Signals */ | |
48 | GPIO20_nSDCS_2, | |
49 | GPIO21_nSDCS_3, | |
50 | GPIO15_nCS_1, | |
51 | GPIO78_nCS_2, /* PASIC3 */ | |
52 | GPIO79_nCS_3, /* EGPIO CPLD */ | |
53 | GPIO80_nCS_4, | |
54 | GPIO33_nCS_5, | |
55 | ||
56 | /* I2C */ | |
57 | GPIO117_I2C_SCL, | |
58 | GPIO118_I2C_SDA, | |
59 | ||
60 | /* PWM 0 */ | |
61 | GPIO16_PWM0_OUT, | |
62 | ||
63 | /* I2S */ | |
64 | GPIO28_I2S_BITCLK_OUT, | |
65 | GPIO29_I2S_SDATA_IN, | |
66 | GPIO31_I2S_SYNC, | |
67 | GPIO113_I2S_SYSCLK, | |
68 | ||
69 | /* SSP 2 */ | |
70 | GPIO19_SSP2_SCLK, | |
71 | GPIO14_SSP2_SFRM, | |
72 | GPIO89_SSP2_TXD, | |
73 | GPIO88_SSP2_RXD, | |
74 | ||
75 | /* MMC */ | |
76 | GPIO32_MMC_CLK, | |
77 | GPIO92_MMC_DAT_0, | |
78 | GPIO109_MMC_DAT_1, | |
79 | GPIO110_MMC_DAT_2, | |
80 | GPIO111_MMC_DAT_3, | |
81 | GPIO112_MMC_CMD, | |
82 | ||
83 | /* LCD */ | |
84 | GPIO58_LCD_LDD_0, | |
85 | GPIO59_LCD_LDD_1, | |
86 | GPIO60_LCD_LDD_2, | |
87 | GPIO61_LCD_LDD_3, | |
88 | GPIO62_LCD_LDD_4, | |
89 | GPIO63_LCD_LDD_5, | |
90 | GPIO64_LCD_LDD_6, | |
91 | GPIO65_LCD_LDD_7, | |
92 | GPIO66_LCD_LDD_8, | |
93 | GPIO67_LCD_LDD_9, | |
94 | GPIO68_LCD_LDD_10, | |
95 | GPIO69_LCD_LDD_11, | |
96 | GPIO70_LCD_LDD_12, | |
97 | GPIO71_LCD_LDD_13, | |
98 | GPIO72_LCD_LDD_14, | |
99 | GPIO73_LCD_LDD_15, | |
100 | GPIO74_LCD_FCLK, | |
101 | GPIO75_LCD_LCLK, | |
102 | GPIO76_LCD_PCLK, | |
103 | GPIO77_LCD_BIAS, | |
104 | ||
105 | /* QCI */ | |
106 | GPIO12_CIF_DD_7, | |
107 | GPIO17_CIF_DD_6, | |
108 | GPIO50_CIF_DD_3, | |
109 | GPIO51_CIF_DD_2, | |
110 | GPIO52_CIF_DD_4, | |
111 | GPIO53_CIF_MCLK, | |
112 | GPIO54_CIF_PCLK, | |
113 | GPIO55_CIF_DD_1, | |
114 | GPIO81_CIF_DD_0, | |
115 | GPIO82_CIF_DD_5, | |
116 | GPIO84_CIF_FV, | |
117 | GPIO85_CIF_LV, | |
2f131958 PZ |
118 | |
119 | /* Magician specific input GPIOs */ | |
120 | GPIO9_GPIO, /* unknown */ | |
121 | GPIO10_GPIO, /* GSM_IRQ */ | |
122 | GPIO13_GPIO, /* CPLD_IRQ */ | |
123 | GPIO107_GPIO, /* DS1WM_IRQ */ | |
124 | GPIO108_GPIO, /* GSM_READY */ | |
125 | GPIO115_GPIO, /* nPEN_IRQ */ | |
b168281c PZ |
126 | }; |
127 | ||
e5c271ec PZ |
128 | /* |
129 | * IRDA | |
130 | */ | |
131 | ||
132 | static void magician_irda_transceiver_mode(struct device *dev, int mode) | |
133 | { | |
134 | gpio_set_value(GPIO83_MAGICIAN_nIR_EN, mode & IR_OFF); | |
135 | } | |
136 | ||
137 | static struct pxaficp_platform_data magician_ficp_info = { | |
138 | .transceiver_cap = IR_SIRMODE | IR_OFF, | |
139 | .transceiver_mode = magician_irda_transceiver_mode, | |
140 | }; | |
141 | ||
142 | /* | |
143 | * GPIO Keys | |
144 | */ | |
145 | ||
146 | static struct gpio_keys_button magician_button_table[] = { | |
147 | {KEY_POWER, GPIO0_MAGICIAN_KEY_POWER, 0, "Power button"}, | |
148 | {KEY_ESC, GPIO37_MAGICIAN_KEY_HANGUP, 0, "Hangup button"}, | |
149 | {KEY_F10, GPIO38_MAGICIAN_KEY_CONTACTS, 0, "Contacts button"}, | |
150 | {KEY_CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, 0, "Calendar button"}, | |
151 | {KEY_CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, 0, "Camera button"}, | |
152 | {KEY_UP, GPIO93_MAGICIAN_KEY_UP, 0, "Up button"}, | |
153 | {KEY_DOWN, GPIO94_MAGICIAN_KEY_DOWN, 0, "Down button"}, | |
154 | {KEY_LEFT, GPIO95_MAGICIAN_KEY_LEFT, 0, "Left button"}, | |
155 | {KEY_RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, 0, "Right button"}, | |
156 | {KEY_KPENTER, GPIO97_MAGICIAN_KEY_ENTER, 0, "Action button"}, | |
157 | {KEY_RECORD, GPIO98_MAGICIAN_KEY_RECORD, 0, "Record button"}, | |
158 | {KEY_VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, 0, "Volume up"}, | |
159 | {KEY_VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, 0, "Volume down"}, | |
160 | {KEY_PHONE, GPIO102_MAGICIAN_KEY_PHONE, 0, "Phone button"}, | |
161 | {KEY_PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, 0, "Headset button"}, | |
162 | }; | |
163 | ||
164 | static struct gpio_keys_platform_data gpio_keys_data = { | |
165 | .buttons = magician_button_table, | |
166 | .nbuttons = ARRAY_SIZE(magician_button_table), | |
167 | }; | |
168 | ||
169 | static struct platform_device gpio_keys = { | |
170 | .name = "gpio-keys", | |
171 | .dev = { | |
172 | .platform_data = &gpio_keys_data, | |
173 | }, | |
174 | .id = -1, | |
175 | }; | |
176 | ||
70e357f8 PZ |
177 | |
178 | /* | |
179 | * EGPIO (Xilinx CPLD) | |
180 | * | |
181 | * 7 32-bit aligned 8-bit registers: 3x output, 1x irq, 3x input | |
182 | */ | |
183 | ||
184 | static struct resource egpio_resources[] = { | |
185 | [0] = { | |
186 | .start = PXA_CS3_PHYS, | |
187 | .end = PXA_CS3_PHYS + 0x20, | |
188 | .flags = IORESOURCE_MEM, | |
189 | }, | |
190 | [1] = { | |
191 | .start = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ), | |
192 | .end = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ), | |
193 | .flags = IORESOURCE_IRQ, | |
194 | }, | |
195 | }; | |
196 | ||
197 | static struct htc_egpio_chip egpio_chips[] = { | |
198 | [0] = { | |
199 | .reg_start = 0, | |
200 | .gpio_base = MAGICIAN_EGPIO(0, 0), | |
201 | .num_gpios = 24, | |
202 | .direction = HTC_EGPIO_OUTPUT, | |
203 | .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */ | |
204 | }, | |
205 | [1] = { | |
206 | .reg_start = 4, | |
207 | .gpio_base = MAGICIAN_EGPIO(4, 0), | |
208 | .num_gpios = 24, | |
209 | .direction = HTC_EGPIO_INPUT, | |
210 | }, | |
211 | }; | |
212 | ||
213 | static struct htc_egpio_platform_data egpio_info = { | |
214 | .reg_width = 8, | |
215 | .bus_width = 32, | |
216 | .irq_base = IRQ_BOARD_START, | |
217 | .num_irqs = 4, | |
218 | .ack_register = 3, | |
219 | .chip = egpio_chips, | |
220 | .num_chips = ARRAY_SIZE(egpio_chips), | |
221 | }; | |
222 | ||
223 | static struct platform_device egpio = { | |
224 | .name = "htc-egpio", | |
225 | .id = -1, | |
226 | .resource = egpio_resources, | |
227 | .num_resources = ARRAY_SIZE(egpio_resources), | |
228 | .dev = { | |
229 | .platform_data = &egpio_info, | |
230 | }, | |
231 | }; | |
232 | ||
e5c271ec | 233 | /* |
e07ff8d8 | 234 | * LCD - Toppoly TD028STEB1 or Samsung LTP280QV |
e5c271ec PZ |
235 | */ |
236 | ||
237 | static struct pxafb_mode_info toppoly_modes[] = { | |
238 | { | |
239 | .pixclock = 96153, | |
240 | .bpp = 16, | |
241 | .xres = 240, | |
242 | .yres = 320, | |
243 | .hsync_len = 11, | |
244 | .vsync_len = 3, | |
245 | .left_margin = 19, | |
246 | .upper_margin = 2, | |
247 | .right_margin = 10, | |
248 | .lower_margin = 2, | |
249 | .sync = 0, | |
250 | }, | |
251 | }; | |
252 | ||
e07ff8d8 PZ |
253 | static struct pxafb_mode_info samsung_modes[] = { |
254 | { | |
255 | .pixclock = 96153, | |
256 | .bpp = 16, | |
257 | .xres = 240, | |
258 | .yres = 320, | |
259 | .hsync_len = 8, | |
260 | .vsync_len = 4, | |
261 | .left_margin = 9, | |
262 | .upper_margin = 4, | |
263 | .right_margin = 9, | |
264 | .lower_margin = 4, | |
265 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | |
266 | }, | |
267 | }; | |
268 | ||
269 | static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si) | |
270 | { | |
271 | pr_debug("Toppoly LCD power\n"); | |
272 | ||
273 | if (on) { | |
274 | pr_debug("on\n"); | |
275 | gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1); | |
276 | gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1); | |
277 | udelay(2000); | |
278 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); | |
279 | udelay(2000); | |
280 | /* FIXME: enable LCDC here */ | |
281 | udelay(2000); | |
282 | gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1); | |
283 | udelay(2000); | |
284 | gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1); | |
285 | } else { | |
286 | pr_debug("off\n"); | |
287 | msleep(15); | |
288 | gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0); | |
289 | udelay(500); | |
290 | gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0); | |
291 | udelay(1000); | |
292 | gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0); | |
293 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); | |
294 | } | |
295 | } | |
296 | ||
297 | static void samsung_lcd_power(int on, struct fb_var_screeninfo *si) | |
298 | { | |
299 | pr_debug("Samsung LCD power\n"); | |
300 | ||
301 | if (on) { | |
302 | pr_debug("on\n"); | |
303 | if (system_rev < 3) | |
304 | gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1); | |
305 | else | |
306 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); | |
307 | mdelay(10); | |
308 | gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1); | |
309 | mdelay(10); | |
310 | gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1); | |
311 | mdelay(30); | |
312 | gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1); | |
313 | mdelay(10); | |
314 | } else { | |
315 | pr_debug("off\n"); | |
316 | mdelay(10); | |
317 | gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0); | |
318 | mdelay(30); | |
319 | gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0); | |
320 | mdelay(10); | |
321 | gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0); | |
322 | mdelay(10); | |
323 | if (system_rev < 3) | |
324 | gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0); | |
325 | else | |
326 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); | |
327 | } | |
328 | } | |
329 | ||
e5c271ec | 330 | static struct pxafb_mach_info toppoly_info = { |
e07ff8d8 PZ |
331 | .modes = toppoly_modes, |
332 | .num_modes = 1, | |
333 | .fixed_modes = 1, | |
334 | .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act, | |
335 | .lccr3 = LCCR3_PixRsEdg, | |
336 | .pxafb_lcd_power = toppoly_lcd_power, | |
337 | }; | |
338 | ||
339 | static struct pxafb_mach_info samsung_info = { | |
340 | .modes = samsung_modes, | |
341 | .num_modes = 1, | |
342 | .fixed_modes = 1, | |
343 | .lccr0 = LCCR0_LDDALT | LCCR0_Color | LCCR0_Sngl | LCCR0_Act, | |
344 | .lccr3 = LCCR3_PixFlEdg, | |
345 | .pxafb_lcd_power = samsung_lcd_power, | |
e5c271ec PZ |
346 | }; |
347 | ||
348 | /* | |
349 | * Backlight | |
350 | */ | |
351 | ||
352 | static void magician_set_bl_intensity(int intensity) | |
353 | { | |
354 | if (intensity) { | |
355 | PWM_CTRL0 = 1; | |
356 | PWM_PERVAL0 = 0xc8; | |
60802188 PZ |
357 | if (intensity > 0xc7) { |
358 | PWM_PWDUTY0 = intensity - 0x48; | |
359 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1); | |
360 | } else { | |
361 | PWM_PWDUTY0 = intensity; | |
362 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0); | |
363 | } | |
364 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 1); | |
e5c271ec PZ |
365 | pxa_set_cken(CKEN_PWM0, 1); |
366 | } else { | |
60802188 PZ |
367 | /* PWM_PWDUTY0 = intensity; */ |
368 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 0); | |
e5c271ec PZ |
369 | pxa_set_cken(CKEN_PWM0, 0); |
370 | } | |
371 | } | |
372 | ||
373 | static struct generic_bl_info backlight_info = { | |
374 | .default_intensity = 0x64, | |
375 | .limit_mask = 0x0b, | |
60802188 | 376 | .max_intensity = 0xc7+0x48, |
e5c271ec PZ |
377 | .set_bl_intensity = magician_set_bl_intensity, |
378 | }; | |
379 | ||
380 | static struct platform_device backlight = { | |
df56eacd | 381 | .name = "generic-bl", |
e5c271ec PZ |
382 | .dev = { |
383 | .platform_data = &backlight_info, | |
384 | }, | |
385 | .id = -1, | |
386 | }; | |
387 | ||
81447b2e PZ |
388 | /* |
389 | * LEDs | |
390 | */ | |
391 | ||
392 | struct gpio_led gpio_leds[] = { | |
393 | { | |
394 | .name = "magician::vibra", | |
395 | .default_trigger = "none", | |
396 | .gpio = GPIO22_MAGICIAN_VIBRA_EN, | |
397 | }, | |
398 | { | |
399 | .name = "magician::phone_bl", | |
400 | .default_trigger = "none", | |
401 | .gpio = GPIO103_MAGICIAN_LED_KP, | |
402 | }, | |
403 | }; | |
404 | ||
405 | static struct gpio_led_platform_data gpio_led_info = { | |
406 | .leds = gpio_leds, | |
407 | .num_leds = ARRAY_SIZE(gpio_leds), | |
408 | }; | |
409 | ||
410 | static struct platform_device leds_gpio = { | |
411 | .name = "leds-gpio", | |
412 | .id = -1, | |
413 | .dev = { | |
414 | .platform_data = &gpio_led_info, | |
415 | }, | |
416 | }; | |
417 | ||
418 | static struct pasic3_led pasic3_leds[] = { | |
419 | { | |
420 | .led = { | |
421 | .name = "magician:red", | |
422 | .default_trigger = "ds2760-battery.0-charging", | |
423 | }, | |
424 | .hw_num = 0, | |
425 | .bit2 = PASIC3_BIT2_LED0, | |
426 | .mask = PASIC3_MASK_LED0, | |
427 | }, | |
428 | { | |
429 | .led = { | |
430 | .name = "magician:green", | |
431 | .default_trigger = "ds2760-battery.0-charging-or-full", | |
432 | }, | |
433 | .hw_num = 1, | |
434 | .bit2 = PASIC3_BIT2_LED1, | |
435 | .mask = PASIC3_MASK_LED1, | |
436 | }, | |
437 | { | |
438 | .led = { | |
439 | .name = "magician:blue", | |
440 | .default_trigger = "bluetooth", | |
441 | }, | |
442 | .hw_num = 2, | |
443 | .bit2 = PASIC3_BIT2_LED2, | |
444 | .mask = PASIC3_MASK_LED2, | |
445 | }, | |
446 | }; | |
447 | ||
448 | static struct platform_device pasic3; | |
449 | ||
e03e0590 | 450 | static struct pasic3_leds_machinfo pasic3_leds_info = { |
81447b2e PZ |
451 | .num_leds = ARRAY_SIZE(pasic3_leds), |
452 | .power_gpio = EGPIO_MAGICIAN_LED_POWER, | |
453 | .leds = pasic3_leds, | |
454 | }; | |
455 | ||
456 | /* | |
457 | * PASIC3 with DS1WM | |
458 | */ | |
459 | ||
460 | static struct resource pasic3_resources[] = { | |
461 | [0] = { | |
462 | .start = PXA_CS2_PHYS, | |
463 | .end = PXA_CS2_PHYS + 0x1b, | |
464 | .flags = IORESOURCE_MEM, | |
465 | }, | |
466 | /* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */ | |
467 | [1] = { | |
468 | .start = gpio_to_irq(GPIO107_MAGICIAN_DS1WM_IRQ), | |
469 | .end = gpio_to_irq(GPIO107_MAGICIAN_DS1WM_IRQ), | |
470 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, | |
471 | } | |
472 | }; | |
473 | ||
474 | static struct pasic3_platform_data pasic3_platform_data = { | |
475 | .bus_shift = 2, | |
476 | .led_pdata = &pasic3_leds_info, | |
477 | .clock_rate = 4000000, | |
478 | }; | |
479 | ||
480 | static struct platform_device pasic3 = { | |
481 | .name = "pasic3", | |
482 | .id = -1, | |
483 | .num_resources = ARRAY_SIZE(pasic3_resources), | |
484 | .resource = pasic3_resources, | |
485 | .dev = { | |
486 | .platform_data = &pasic3_platform_data, | |
487 | }, | |
488 | }; | |
e5c271ec | 489 | |
350d115d PZ |
490 | /* |
491 | * External power | |
492 | */ | |
493 | ||
494 | static int magician_is_ac_online(void) | |
495 | { | |
496 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC); | |
497 | } | |
498 | ||
499 | static int magician_is_usb_online(void) | |
500 | { | |
501 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_USB); | |
502 | } | |
503 | ||
504 | static void magician_set_charge(int flags) | |
505 | { | |
506 | gpio_set_value(GPIO30_MAGICIAN_nCHARGE_EN, !flags); | |
507 | gpio_set_value(EGPIO_MAGICIAN_CHARGE_EN, flags); | |
508 | } | |
509 | ||
81447b2e PZ |
510 | static char *magician_supplicants[] = { |
511 | "ds2760-battery.0", "backup-battery" | |
512 | }; | |
513 | ||
350d115d | 514 | static struct pda_power_pdata power_supply_info = { |
81447b2e PZ |
515 | .is_ac_online = magician_is_ac_online, |
516 | .is_usb_online = magician_is_usb_online, | |
517 | .set_charge = magician_set_charge, | |
518 | .supplied_to = magician_supplicants, | |
519 | .num_supplicants = ARRAY_SIZE(magician_supplicants), | |
350d115d PZ |
520 | }; |
521 | ||
522 | static struct resource power_supply_resources[] = { | |
523 | [0] = { | |
524 | .name = "ac", | |
525 | .flags = IORESOURCE_IRQ, | |
526 | .start = IRQ_MAGICIAN_AC, | |
527 | .end = IRQ_MAGICIAN_AC, | |
528 | }, | |
529 | [1] = { | |
530 | .name = "usb", | |
531 | .flags = IORESOURCE_IRQ, | |
532 | .start = IRQ_MAGICIAN_AC, | |
533 | .end = IRQ_MAGICIAN_AC, | |
534 | }, | |
535 | }; | |
536 | ||
537 | static struct platform_device power_supply = { | |
538 | .name = "pda-power", | |
539 | .id = -1, | |
540 | .dev = { | |
541 | .platform_data = &power_supply_info, | |
542 | }, | |
543 | .resource = power_supply_resources, | |
544 | .num_resources = ARRAY_SIZE(power_supply_resources), | |
545 | }; | |
546 | ||
547 | ||
bdb0c16a PZ |
548 | /* |
549 | * MMC/SD | |
550 | */ | |
551 | ||
552 | static int magician_mci_init(struct device *dev, | |
553 | irq_handler_t detect_irq, void *data) | |
554 | { | |
a1999cd1 PZ |
555 | int err; |
556 | ||
557 | err = request_irq(IRQ_MAGICIAN_SD, detect_irq, | |
bdb0c16a PZ |
558 | IRQF_DISABLED | IRQF_SAMPLE_RANDOM, |
559 | "MMC card detect", data); | |
a1999cd1 PZ |
560 | if (err) |
561 | goto err_request_irq; | |
562 | err = gpio_request(EGPIO_MAGICIAN_SD_POWER, "SD_POWER"); | |
563 | if (err) | |
564 | goto err_request_power; | |
565 | err = gpio_request(EGPIO_MAGICIAN_nSD_READONLY, "nSD_READONLY"); | |
566 | if (err) | |
567 | goto err_request_readonly; | |
568 | ||
569 | return 0; | |
570 | ||
571 | err_request_readonly: | |
572 | gpio_free(EGPIO_MAGICIAN_SD_POWER); | |
573 | err_request_power: | |
574 | free_irq(IRQ_MAGICIAN_SD, data); | |
575 | err_request_irq: | |
576 | return err; | |
bdb0c16a PZ |
577 | } |
578 | ||
579 | static void magician_mci_setpower(struct device *dev, unsigned int vdd) | |
580 | { | |
581 | struct pxamci_platform_data *pdata = dev->platform_data; | |
582 | ||
583 | gpio_set_value(EGPIO_MAGICIAN_SD_POWER, (1 << vdd) & pdata->ocr_mask); | |
584 | } | |
585 | ||
586 | static int magician_mci_get_ro(struct device *dev) | |
587 | { | |
588 | return (!gpio_get_value(EGPIO_MAGICIAN_nSD_READONLY)); | |
589 | } | |
590 | ||
591 | static void magician_mci_exit(struct device *dev, void *data) | |
592 | { | |
a1999cd1 PZ |
593 | gpio_free(EGPIO_MAGICIAN_nSD_READONLY); |
594 | gpio_free(EGPIO_MAGICIAN_SD_POWER); | |
bdb0c16a PZ |
595 | free_irq(IRQ_MAGICIAN_SD, data); |
596 | } | |
597 | ||
598 | static struct pxamci_platform_data magician_mci_info = { | |
599 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, | |
600 | .init = magician_mci_init, | |
601 | .get_ro = magician_mci_get_ro, | |
602 | .setpower = magician_mci_setpower, | |
603 | .exit = magician_mci_exit, | |
604 | }; | |
605 | ||
606 | ||
e5c271ec PZ |
607 | /* |
608 | * USB OHCI | |
609 | */ | |
610 | ||
611 | static int magician_ohci_init(struct device *dev) | |
612 | { | |
613 | UHCHR = (UHCHR | UHCHR_SSEP2 | UHCHR_PCPL | UHCHR_CGR) & | |
614 | ~(UHCHR_SSEP1 | UHCHR_SSEP3 | UHCHR_SSE); | |
615 | ||
616 | return 0; | |
617 | } | |
618 | ||
619 | static struct pxaohci_platform_data magician_ohci_info = { | |
620 | .port_mode = PMM_PERPORT_MODE, | |
621 | .init = magician_ohci_init, | |
622 | .power_budget = 0, | |
623 | }; | |
624 | ||
625 | ||
626 | /* | |
627 | * StrataFlash | |
628 | */ | |
629 | ||
aa797590 PZ |
630 | static void magician_set_vpp(struct map_info *map, int vpp) |
631 | { | |
632 | gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp); | |
633 | } | |
634 | ||
e5c271ec PZ |
635 | #define PXA_CS_SIZE 0x04000000 |
636 | ||
637 | static struct resource strataflash_resource = { | |
638 | .start = PXA_CS0_PHYS, | |
639 | .end = PXA_CS0_PHYS + PXA_CS_SIZE - 1, | |
640 | .flags = IORESOURCE_MEM, | |
641 | }; | |
642 | ||
643 | static struct physmap_flash_data strataflash_data = { | |
644 | .width = 4, | |
aa797590 | 645 | .set_vpp = magician_set_vpp, |
e5c271ec PZ |
646 | }; |
647 | ||
648 | static struct platform_device strataflash = { | |
649 | .name = "physmap-flash", | |
650 | .id = -1, | |
e5c271ec | 651 | .resource = &strataflash_resource, |
70e357f8 | 652 | .num_resources = 1, |
e5c271ec PZ |
653 | .dev = { |
654 | .platform_data = &strataflash_data, | |
655 | }, | |
656 | }; | |
657 | ||
658 | /* | |
659 | * Platform devices | |
660 | */ | |
661 | ||
662 | static struct platform_device *devices[] __initdata = { | |
663 | &gpio_keys, | |
70e357f8 | 664 | &egpio, |
e5c271ec | 665 | &backlight, |
81447b2e | 666 | &pasic3, |
350d115d | 667 | &power_supply, |
e5c271ec | 668 | &strataflash, |
81447b2e | 669 | &leds_gpio, |
e5c271ec PZ |
670 | }; |
671 | ||
672 | static void __init magician_init(void) | |
673 | { | |
e07ff8d8 PZ |
674 | void __iomem *cpld; |
675 | int lcd_select; | |
a1999cd1 PZ |
676 | int err; |
677 | ||
678 | gpio_request(GPIO13_MAGICIAN_CPLD_IRQ, "CPLD_IRQ"); | |
679 | gpio_request(GPIO107_MAGICIAN_DS1WM_IRQ, "DS1WM_IRQ"); | |
e07ff8d8 | 680 | |
b168281c PZ |
681 | pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config)); |
682 | ||
e5c271ec | 683 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
a1999cd1 PZ |
684 | |
685 | err = gpio_request(GPIO83_MAGICIAN_nIR_EN, "nIR_EN"); | |
686 | if (!err) { | |
687 | gpio_direction_output(GPIO83_MAGICIAN_nIR_EN, 1); | |
688 | pxa_set_ficp_info(&magician_ficp_info); | |
689 | } | |
e6816f34 | 690 | pxa_set_i2c_info(NULL); |
bdb0c16a | 691 | pxa_set_mci_info(&magician_mci_info); |
e5c271ec | 692 | pxa_set_ohci_info(&magician_ohci_info); |
e07ff8d8 PZ |
693 | |
694 | /* Check LCD type we have */ | |
695 | cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000); | |
696 | if (cpld) { | |
697 | u8 board_id = __raw_readb(cpld+0x14); | |
a1999cd1 | 698 | iounmap(cpld); |
e07ff8d8 PZ |
699 | system_rev = board_id & 0x7; |
700 | lcd_select = board_id & 0x8; | |
e07ff8d8 | 701 | pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly"); |
a1999cd1 PZ |
702 | if (lcd_select && (system_rev < 3)) { |
703 | gpio_request(GPIO75_MAGICIAN_SAMSUNG_POWER, "SAMSUNG_POWER"); | |
704 | gpio_direction_output(GPIO75_MAGICIAN_SAMSUNG_POWER, 0); | |
705 | } | |
706 | gpio_request(GPIO104_MAGICIAN_LCD_POWER_1, "LCD_POWER_1"); | |
707 | gpio_request(GPIO105_MAGICIAN_LCD_POWER_2, "LCD_POWER_2"); | |
708 | gpio_request(GPIO106_MAGICIAN_LCD_POWER_3, "LCD_POWER_3"); | |
709 | gpio_direction_output(GPIO104_MAGICIAN_LCD_POWER_1, 0); | |
710 | gpio_direction_output(GPIO105_MAGICIAN_LCD_POWER_2, 0); | |
711 | gpio_direction_output(GPIO106_MAGICIAN_LCD_POWER_3, 0); | |
e07ff8d8 PZ |
712 | set_pxa_fb_info(lcd_select ? &samsung_info : &toppoly_info); |
713 | } else | |
714 | pr_err("LCD detection: CPLD mapping failed\n"); | |
e5c271ec PZ |
715 | } |
716 | ||
717 | ||
718 | MACHINE_START(MAGICIAN, "HTC Magician") | |
719 | .phys_io = 0x40000000, | |
720 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
721 | .boot_params = 0xa0000100, | |
722 | .map_io = pxa_map_io, | |
723 | .init_irq = pxa27x_init_irq, | |
724 | .init_machine = magician_init, | |
725 | .timer = &pxa_timer, | |
726 | MACHINE_END |