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> |
e181191a | 20 | #include <linux/gpio.h> |
efdfeb07 | 21 | #include <linux/gpio/machine.h> |
e5c271ec PZ |
22 | #include <linux/gpio_keys.h> |
23 | #include <linux/input.h> | |
81447b2e | 24 | #include <linux/mfd/htc-pasic3.h> |
e5c271ec | 25 | #include <linux/mtd/physmap.h> |
350d115d | 26 | #include <linux/pda_power.h> |
3c6e8d05 | 27 | #include <linux/platform_data/gpio-htc-egpio.h> |
bd3208ba | 28 | #include <linux/pwm.h> |
85847a36 | 29 | #include <linux/pwm_backlight.h> |
6967cca8 | 30 | #include <linux/regulator/driver.h> |
e2f1b8b0 | 31 | #include <linux/regulator/fixed.h> |
6967cca8 | 32 | #include <linux/regulator/gpio-regulator.h> |
eb650b9e | 33 | #include <linux/regulator/machine.h> |
6489c611 | 34 | #include <linux/usb/gpio_vbus.h> |
f15fc9b1 | 35 | #include <linux/platform_data/i2c-pxa.h> |
e5c271ec | 36 | |
a09e64fb | 37 | #include <mach/hardware.h> |
e5c271ec PZ |
38 | #include <asm/mach-types.h> |
39 | #include <asm/mach/arch.h> | |
9f97da78 | 40 | #include <asm/system_info.h> |
51c62982 | 41 | |
4c25c5d2 | 42 | #include "pxa27x.h" |
a09e64fb | 43 | #include <mach/magician.h> |
293b2da1 AB |
44 | #include <linux/platform_data/video-pxafb.h> |
45 | #include <linux/platform_data/mmc-pxamci.h> | |
46 | #include <linux/platform_data/irda-pxaficp.h> | |
47 | #include <linux/platform_data/usb-ohci-pxa27x.h> | |
e5c271ec | 48 | |
ff5eff35 PC |
49 | #include <linux/regulator/max1586.h> |
50 | ||
31134b51 | 51 | #include <linux/platform_data/pxa2xx_udc.h> |
31134b51 | 52 | |
4c25c5d2 AB |
53 | #include "udc.h" |
54 | #include "pxa27x-udc.h" | |
85847a36 | 55 | #include "devices.h" |
e5c271ec PZ |
56 | #include "generic.h" |
57 | ||
7ade445c PC |
58 | #include <linux/spi/spi.h> |
59 | #include <linux/spi/pxa2xx_spi.h> | |
60 | #include <linux/spi/ads7846.h> | |
61 | ||
7a97010e | 62 | static unsigned long magician_pin_config[] __initdata = { |
b168281c PZ |
63 | |
64 | /* SDRAM and Static Memory I/O Signals */ | |
65 | GPIO20_nSDCS_2, | |
66 | GPIO21_nSDCS_3, | |
67 | GPIO15_nCS_1, | |
ccb6f9ae PC |
68 | GPIO78_nCS_2, /* PASIC3 */ |
69 | GPIO79_nCS_3, /* EGPIO CPLD */ | |
b168281c PZ |
70 | GPIO80_nCS_4, |
71 | GPIO33_nCS_5, | |
72 | ||
f36150b1 | 73 | /* I2C UDA1380 + OV9640 */ |
b168281c PZ |
74 | GPIO117_I2C_SCL, |
75 | GPIO118_I2C_SDA, | |
76 | ||
f36150b1 | 77 | /* PWM 0 - LCD backlight */ |
b168281c PZ |
78 | GPIO16_PWM0_OUT, |
79 | ||
f36150b1 | 80 | /* I2S UDA1380 capture */ |
b168281c PZ |
81 | GPIO28_I2S_BITCLK_OUT, |
82 | GPIO29_I2S_SDATA_IN, | |
83 | GPIO31_I2S_SYNC, | |
84 | GPIO113_I2S_SYSCLK, | |
85 | ||
f36150b1 | 86 | /* SSP 1 UDA1380 playback */ |
16c3ea43 PZ |
87 | GPIO23_SSP1_SCLK, |
88 | GPIO24_SSP1_SFRM, | |
89 | GPIO25_SSP1_TXD, | |
90 | ||
f36150b1 | 91 | /* SSP 2 TSC2046 touchscreen */ |
b168281c | 92 | GPIO19_SSP2_SCLK, |
7ade445c | 93 | MFP_CFG_OUT(GPIO14, AF0, DRIVE_HIGH), /* frame as GPIO */ |
b168281c PZ |
94 | GPIO89_SSP2_TXD, |
95 | GPIO88_SSP2_RXD, | |
96 | ||
f36150b1 | 97 | /* MMC/SD/SDHC slot */ |
b168281c PZ |
98 | GPIO32_MMC_CLK, |
99 | GPIO92_MMC_DAT_0, | |
100 | GPIO109_MMC_DAT_1, | |
101 | GPIO110_MMC_DAT_2, | |
102 | GPIO111_MMC_DAT_3, | |
103 | GPIO112_MMC_CMD, | |
104 | ||
105 | /* LCD */ | |
bedbda97 | 106 | GPIOxx_LCD_TFT_16BPP, |
b168281c | 107 | |
f36150b1 | 108 | /* QCI camera interface */ |
b168281c PZ |
109 | GPIO12_CIF_DD_7, |
110 | GPIO17_CIF_DD_6, | |
111 | GPIO50_CIF_DD_3, | |
112 | GPIO51_CIF_DD_2, | |
113 | GPIO52_CIF_DD_4, | |
114 | GPIO53_CIF_MCLK, | |
115 | GPIO54_CIF_PCLK, | |
116 | GPIO55_CIF_DD_1, | |
117 | GPIO81_CIF_DD_0, | |
118 | GPIO82_CIF_DD_5, | |
119 | GPIO84_CIF_FV, | |
120 | GPIO85_CIF_LV, | |
2f131958 PZ |
121 | |
122 | /* Magician specific input GPIOs */ | |
123 | GPIO9_GPIO, /* unknown */ | |
124 | GPIO10_GPIO, /* GSM_IRQ */ | |
125 | GPIO13_GPIO, /* CPLD_IRQ */ | |
126 | GPIO107_GPIO, /* DS1WM_IRQ */ | |
127 | GPIO108_GPIO, /* GSM_READY */ | |
128 | GPIO115_GPIO, /* nPEN_IRQ */ | |
b168281c PZ |
129 | }; |
130 | ||
e5c271ec | 131 | /* |
f36150b1 | 132 | * IrDA |
e5c271ec PZ |
133 | */ |
134 | ||
e5c271ec | 135 | static struct pxaficp_platform_data magician_ficp_info = { |
c4bd0172 MV |
136 | .gpio_pwdown = GPIO83_MAGICIAN_nIR_EN, |
137 | .transceiver_cap = IR_SIRMODE | IR_OFF, | |
0f073e3e | 138 | .gpio_pwdown_inverted = 0, |
e5c271ec PZ |
139 | }; |
140 | ||
141 | /* | |
142 | * GPIO Keys | |
143 | */ | |
144 | ||
51c10bbc PZ |
145 | #define INIT_KEY(_code, _gpio, _desc) \ |
146 | { \ | |
ccb6f9ae PC |
147 | .code = KEY_##_code, \ |
148 | .gpio = _gpio, \ | |
149 | .desc = _desc, \ | |
150 | .type = EV_KEY, \ | |
151 | .wakeup = 1, \ | |
51c10bbc PZ |
152 | } |
153 | ||
e5c271ec | 154 | static struct gpio_keys_button magician_button_table[] = { |
51c10bbc PZ |
155 | INIT_KEY(POWER, GPIO0_MAGICIAN_KEY_POWER, "Power button"), |
156 | INIT_KEY(ESC, GPIO37_MAGICIAN_KEY_HANGUP, "Hangup button"), | |
157 | INIT_KEY(F10, GPIO38_MAGICIAN_KEY_CONTACTS, "Contacts button"), | |
158 | INIT_KEY(CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, "Calendar button"), | |
159 | INIT_KEY(CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, "Camera button"), | |
160 | INIT_KEY(UP, GPIO93_MAGICIAN_KEY_UP, "Up button"), | |
161 | INIT_KEY(DOWN, GPIO94_MAGICIAN_KEY_DOWN, "Down button"), | |
162 | INIT_KEY(LEFT, GPIO95_MAGICIAN_KEY_LEFT, "Left button"), | |
163 | INIT_KEY(RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, "Right button"), | |
164 | INIT_KEY(KPENTER, GPIO97_MAGICIAN_KEY_ENTER, "Action button"), | |
165 | INIT_KEY(RECORD, GPIO98_MAGICIAN_KEY_RECORD, "Record button"), | |
166 | INIT_KEY(VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, "Volume up"), | |
167 | INIT_KEY(VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, "Volume down"), | |
168 | INIT_KEY(PHONE, GPIO102_MAGICIAN_KEY_PHONE, "Phone button"), | |
169 | INIT_KEY(PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, "Headset button"), | |
e5c271ec PZ |
170 | }; |
171 | ||
172 | static struct gpio_keys_platform_data gpio_keys_data = { | |
ccb6f9ae PC |
173 | .buttons = magician_button_table, |
174 | .nbuttons = ARRAY_SIZE(magician_button_table), | |
e5c271ec PZ |
175 | }; |
176 | ||
177 | static struct platform_device gpio_keys = { | |
ccb6f9ae PC |
178 | .name = "gpio-keys", |
179 | .dev = { | |
e5c271ec PZ |
180 | .platform_data = &gpio_keys_data, |
181 | }, | |
ccb6f9ae | 182 | .id = -1, |
e5c271ec PZ |
183 | }; |
184 | ||
70e357f8 PZ |
185 | /* |
186 | * EGPIO (Xilinx CPLD) | |
187 | * | |
f36150b1 PC |
188 | * 32-bit aligned 8-bit registers |
189 | * 16 possible registers (reg windows size), only 7 used: | |
190 | * 3x output, 1x irq, 3x input | |
70e357f8 PZ |
191 | */ |
192 | ||
193 | static struct resource egpio_resources[] = { | |
194 | [0] = { | |
ccb6f9ae PC |
195 | .start = PXA_CS3_PHYS, |
196 | .end = PXA_CS3_PHYS + 0x20 - 1, | |
197 | .flags = IORESOURCE_MEM, | |
70e357f8 PZ |
198 | }, |
199 | [1] = { | |
ccb6f9ae PC |
200 | .start = PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ), |
201 | .end = PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ), | |
202 | .flags = IORESOURCE_IRQ, | |
70e357f8 PZ |
203 | }, |
204 | }; | |
205 | ||
206 | static struct htc_egpio_chip egpio_chips[] = { | |
207 | [0] = { | |
ccb6f9ae PC |
208 | .reg_start = 0, |
209 | .gpio_base = MAGICIAN_EGPIO(0, 0), | |
210 | .num_gpios = 24, | |
211 | .direction = HTC_EGPIO_OUTPUT, | |
f36150b1 PC |
212 | /* |
213 | * Depends on modules configuration | |
214 | */ | |
ccb6f9ae | 215 | .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */ |
70e357f8 PZ |
216 | }, |
217 | [1] = { | |
ccb6f9ae PC |
218 | .reg_start = 4, |
219 | .gpio_base = MAGICIAN_EGPIO(4, 0), | |
220 | .num_gpios = 24, | |
221 | .direction = HTC_EGPIO_INPUT, | |
70e357f8 PZ |
222 | }, |
223 | }; | |
224 | ||
225 | static struct htc_egpio_platform_data egpio_info = { | |
ccb6f9ae PC |
226 | .reg_width = 8, |
227 | .bus_width = 32, | |
228 | .irq_base = IRQ_BOARD_START, | |
229 | .num_irqs = 4, | |
230 | .ack_register = 3, | |
231 | .chip = egpio_chips, | |
232 | .num_chips = ARRAY_SIZE(egpio_chips), | |
70e357f8 PZ |
233 | }; |
234 | ||
235 | static struct platform_device egpio = { | |
ccb6f9ae PC |
236 | .name = "htc-egpio", |
237 | .id = -1, | |
238 | .resource = egpio_resources, | |
239 | .num_resources = ARRAY_SIZE(egpio_resources), | |
70e357f8 PZ |
240 | .dev = { |
241 | .platform_data = &egpio_info, | |
242 | }, | |
243 | }; | |
244 | ||
e5c271ec | 245 | /* |
f36150b1 | 246 | * PXAFB LCD - Toppoly TD028STEB1 or Samsung LTP280QV |
e5c271ec PZ |
247 | */ |
248 | ||
249 | static struct pxafb_mode_info toppoly_modes[] = { | |
250 | { | |
ccb6f9ae PC |
251 | .pixclock = 96153, |
252 | .bpp = 16, | |
253 | .xres = 240, | |
254 | .yres = 320, | |
255 | .hsync_len = 11, | |
256 | .vsync_len = 3, | |
257 | .left_margin = 19, | |
258 | .upper_margin = 2, | |
259 | .right_margin = 10, | |
260 | .lower_margin = 2, | |
261 | .sync = 0, | |
e5c271ec PZ |
262 | }, |
263 | }; | |
264 | ||
e07ff8d8 PZ |
265 | static struct pxafb_mode_info samsung_modes[] = { |
266 | { | |
e7b97a4c | 267 | .pixclock = 226469, |
ccb6f9ae PC |
268 | .bpp = 16, |
269 | .xres = 240, | |
270 | .yres = 320, | |
271 | .hsync_len = 8, | |
272 | .vsync_len = 4, | |
273 | .left_margin = 9, | |
274 | .upper_margin = 4, | |
275 | .right_margin = 9, | |
276 | .lower_margin = 4, | |
277 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | |
e07ff8d8 PZ |
278 | }, |
279 | }; | |
280 | ||
281 | static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si) | |
282 | { | |
dedad4d2 | 283 | pr_debug("Toppoly LCD power: %s\n", on ? "on" : "off"); |
e07ff8d8 PZ |
284 | |
285 | if (on) { | |
e07ff8d8 | 286 | gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1); |
6001ae70 | 287 | gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1); |
e07ff8d8 PZ |
288 | udelay(2000); |
289 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); | |
290 | udelay(2000); | |
291 | /* FIXME: enable LCDC here */ | |
292 | udelay(2000); | |
6001ae70 | 293 | gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1); |
e07ff8d8 | 294 | udelay(2000); |
6001ae70 | 295 | gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1); |
e07ff8d8 | 296 | } else { |
e07ff8d8 | 297 | msleep(15); |
6001ae70 | 298 | gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0); |
e07ff8d8 | 299 | udelay(500); |
6001ae70 | 300 | gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0); |
e07ff8d8 | 301 | udelay(1000); |
6001ae70 | 302 | gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0); |
e07ff8d8 PZ |
303 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); |
304 | } | |
305 | } | |
306 | ||
307 | static void samsung_lcd_power(int on, struct fb_var_screeninfo *si) | |
308 | { | |
dedad4d2 | 309 | pr_debug("Samsung LCD power: %s\n", on ? "on" : "off"); |
e07ff8d8 PZ |
310 | |
311 | if (on) { | |
e07ff8d8 PZ |
312 | if (system_rev < 3) |
313 | gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1); | |
314 | else | |
315 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); | |
fa5407ad | 316 | mdelay(6); |
6001ae70 | 317 | gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1); |
fa5407ad | 318 | mdelay(6); /* Avdd -> Voff >5ms */ |
6001ae70 | 319 | gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1); |
fa5407ad | 320 | mdelay(16); /* Voff -> Von >(5+10)ms */ |
6001ae70 | 321 | gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1); |
e07ff8d8 | 322 | } else { |
6001ae70 | 323 | gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0); |
fa5407ad | 324 | mdelay(16); |
6001ae70 | 325 | gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0); |
fa5407ad | 326 | mdelay(6); |
6001ae70 | 327 | gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0); |
fa5407ad | 328 | mdelay(6); |
e07ff8d8 PZ |
329 | if (system_rev < 3) |
330 | gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0); | |
331 | else | |
332 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); | |
333 | } | |
334 | } | |
335 | ||
e5c271ec | 336 | static struct pxafb_mach_info toppoly_info = { |
ccb6f9ae PC |
337 | .modes = toppoly_modes, |
338 | .num_modes = 1, | |
339 | .fixed_modes = 1, | |
340 | .lcd_conn = LCD_COLOR_TFT_16BPP, | |
341 | .pxafb_lcd_power = toppoly_lcd_power, | |
e07ff8d8 PZ |
342 | }; |
343 | ||
344 | static struct pxafb_mach_info samsung_info = { | |
ccb6f9ae PC |
345 | .modes = samsung_modes, |
346 | .num_modes = 1, | |
347 | .fixed_modes = 1, | |
348 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL | | |
349 | LCD_ALTERNATE_MAPPING, | |
350 | .pxafb_lcd_power = samsung_lcd_power, | |
e5c271ec PZ |
351 | }; |
352 | ||
353 | /* | |
354 | * Backlight | |
355 | */ | |
356 | ||
bd3208ba TR |
357 | static struct pwm_lookup magician_pwm_lookup[] = { |
358 | PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 30923, | |
359 | PWM_POLARITY_NORMAL), | |
360 | }; | |
361 | ||
e2f1b8b0 PC |
362 | /* |
363 | * fixed regulator for pwm_backlight | |
364 | */ | |
365 | ||
366 | static struct regulator_consumer_supply pwm_backlight_supply[] = { | |
367 | REGULATOR_SUPPLY("power", "pwm_backlight"), | |
368 | }; | |
369 | ||
370 | ||
5db15f86 | 371 | static struct gpio magician_bl_gpios[] = { |
ccb6f9ae PC |
372 | { EGPIO_MAGICIAN_BL_POWER, GPIOF_DIR_OUT, "Backlight power" }, |
373 | { EGPIO_MAGICIAN_BL_POWER2, GPIOF_DIR_OUT, "Backlight power 2" }, | |
5db15f86 PZ |
374 | }; |
375 | ||
85847a36 | 376 | static int magician_backlight_init(struct device *dev) |
e5c271ec | 377 | { |
5db15f86 | 378 | return gpio_request_array(ARRAY_AND_SIZE(magician_bl_gpios)); |
85847a36 PZ |
379 | } |
380 | ||
2d51a521 | 381 | static int magician_backlight_notify(struct device *dev, int brightness) |
85847a36 | 382 | { |
539122ad | 383 | pr_debug("Brightness = %i\n", brightness); |
85847a36 PZ |
384 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER, brightness); |
385 | if (brightness >= 200) { | |
386 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1); | |
387 | return brightness - 72; | |
e5c271ec | 388 | } else { |
85847a36 PZ |
389 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0); |
390 | return brightness; | |
e5c271ec PZ |
391 | } |
392 | } | |
393 | ||
85847a36 PZ |
394 | static void magician_backlight_exit(struct device *dev) |
395 | { | |
5db15f86 | 396 | gpio_free_array(ARRAY_AND_SIZE(magician_bl_gpios)); |
85847a36 PZ |
397 | } |
398 | ||
f36150b1 PC |
399 | /* |
400 | * LCD PWM backlight (main) | |
401 | * | |
402 | * MP1521 frequency should be: | |
403 | * 100-400 Hz = 2 .5*10^6 - 10 *10^6 ns | |
404 | */ | |
405 | ||
85847a36 | 406 | static struct platform_pwm_backlight_data backlight_data = { |
ccb6f9ae PC |
407 | .max_brightness = 272, |
408 | .dft_brightness = 100, | |
409 | .enable_gpio = -1, | |
410 | .init = magician_backlight_init, | |
411 | .notify = magician_backlight_notify, | |
412 | .exit = magician_backlight_exit, | |
e5c271ec PZ |
413 | }; |
414 | ||
415 | static struct platform_device backlight = { | |
ccb6f9ae PC |
416 | .name = "pwm-backlight", |
417 | .id = -1, | |
418 | .dev = { | |
419 | .parent = &pxa27x_device_pwm0.dev, | |
420 | .platform_data = &backlight_data, | |
e5c271ec | 421 | }, |
e5c271ec PZ |
422 | }; |
423 | ||
81447b2e | 424 | /* |
f36150b1 | 425 | * GPIO LEDs, Phone keys backlight, vibra |
81447b2e PZ |
426 | */ |
427 | ||
a55facae | 428 | static struct gpio_led gpio_leds[] = { |
81447b2e PZ |
429 | { |
430 | .name = "magician::vibra", | |
431 | .default_trigger = "none", | |
432 | .gpio = GPIO22_MAGICIAN_VIBRA_EN, | |
433 | }, | |
434 | { | |
435 | .name = "magician::phone_bl", | |
05199ecb | 436 | .default_trigger = "backlight", |
81447b2e PZ |
437 | .gpio = GPIO103_MAGICIAN_LED_KP, |
438 | }, | |
439 | }; | |
440 | ||
441 | static struct gpio_led_platform_data gpio_led_info = { | |
442 | .leds = gpio_leds, | |
443 | .num_leds = ARRAY_SIZE(gpio_leds), | |
444 | }; | |
445 | ||
446 | static struct platform_device leds_gpio = { | |
ccb6f9ae PC |
447 | .name = "leds-gpio", |
448 | .id = -1, | |
449 | .dev = { | |
81447b2e PZ |
450 | .platform_data = &gpio_led_info, |
451 | }, | |
452 | }; | |
453 | ||
81447b2e PZ |
454 | /* |
455 | * PASIC3 with DS1WM | |
456 | */ | |
457 | ||
458 | static struct resource pasic3_resources[] = { | |
459 | [0] = { | |
ccb6f9ae | 460 | .start = PXA_CS2_PHYS, |
81447b2e | 461 | .end = PXA_CS2_PHYS + 0x1b, |
ccb6f9ae | 462 | .flags = IORESOURCE_MEM, |
81447b2e PZ |
463 | }, |
464 | /* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */ | |
465 | [1] = { | |
ccb6f9ae PC |
466 | .start = PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ), |
467 | .end = PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ), | |
468 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, | |
81447b2e PZ |
469 | } |
470 | }; | |
471 | ||
472 | static struct pasic3_platform_data pasic3_platform_data = { | |
28496be9 | 473 | .clock_rate = 4000000, |
81447b2e PZ |
474 | }; |
475 | ||
476 | static struct platform_device pasic3 = { | |
477 | .name = "pasic3", | |
478 | .id = -1, | |
479 | .num_resources = ARRAY_SIZE(pasic3_resources), | |
480 | .resource = pasic3_resources, | |
481 | .dev = { | |
482 | .platform_data = &pasic3_platform_data, | |
483 | }, | |
484 | }; | |
e5c271ec | 485 | |
31134b51 PC |
486 | /* |
487 | * PXA UDC | |
488 | */ | |
489 | ||
490 | static void magician_udc_command(int cmd) | |
491 | { | |
492 | if (cmd == PXA2XX_UDC_CMD_CONNECT) | |
493 | UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE; | |
494 | else if (cmd == PXA2XX_UDC_CMD_DISCONNECT) | |
495 | UP2OCR &= ~(UP2OCR_DPPUE | UP2OCR_DPPUBE); | |
496 | } | |
497 | ||
498 | static struct pxa2xx_udc_mach_info magician_udc_info __initdata = { | |
499 | .udc_command = magician_udc_command, | |
500 | .gpio_pullup = GPIO27_MAGICIAN_USBC_PUEN, | |
501 | }; | |
502 | ||
6489c611 | 503 | /* |
f36150b1 | 504 | * USB device VBus detection |
6489c611 PZ |
505 | */ |
506 | ||
507 | static struct resource gpio_vbus_resource = { | |
ccb6f9ae PC |
508 | .flags = IORESOURCE_IRQ, |
509 | .start = IRQ_MAGICIAN_VBUS, | |
510 | .end = IRQ_MAGICIAN_VBUS, | |
6489c611 PZ |
511 | }; |
512 | ||
513 | static struct gpio_vbus_mach_info gpio_vbus_info = { | |
ccb6f9ae | 514 | .gpio_pullup = GPIO27_MAGICIAN_USBC_PUEN, |
f78b3a12 | 515 | .gpio_vbus = EGPIO_MAGICIAN_CABLE_VBUS, |
6489c611 PZ |
516 | }; |
517 | ||
518 | static struct platform_device gpio_vbus = { | |
ccb6f9ae PC |
519 | .name = "gpio-vbus", |
520 | .id = -1, | |
521 | .num_resources = 1, | |
522 | .resource = &gpio_vbus_resource, | |
6489c611 PZ |
523 | .dev = { |
524 | .platform_data = &gpio_vbus_info, | |
525 | }, | |
526 | }; | |
527 | ||
350d115d PZ |
528 | /* |
529 | * External power | |
530 | */ | |
531 | ||
eac2eacc | 532 | static int magician_supply_init(struct device *dev) |
ff279202 | 533 | { |
eac2eacc PC |
534 | int ret = -1; |
535 | ||
536 | ret = gpio_request(EGPIO_MAGICIAN_CABLE_TYPE, "Cable is AC charger"); | |
537 | if (ret) { | |
538 | pr_err("Cannot request AC/USB charger GPIO (%i)\n", ret); | |
539 | goto err_ac; | |
540 | } | |
541 | ||
542 | ret = gpio_request(EGPIO_MAGICIAN_CABLE_INSERTED, "Cable inserted"); | |
543 | if (ret) { | |
544 | pr_err("Cannot request cable detection GPIO (%i)\n", ret); | |
545 | goto err_usb; | |
546 | } | |
547 | ||
548 | return 0; | |
549 | ||
550 | err_usb: | |
551 | gpio_free(EGPIO_MAGICIAN_CABLE_TYPE); | |
552 | err_ac: | |
553 | return ret; | |
554 | } | |
555 | ||
556 | static void magician_set_charge(int flags) | |
557 | { | |
558 | if (flags & PDA_POWER_CHARGE_AC) { | |
559 | pr_debug("Charging from AC\n"); | |
560 | gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 1); | |
561 | } else if (flags & PDA_POWER_CHARGE_USB) { | |
562 | pr_debug("Charging from USB\n"); | |
563 | gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 1); | |
564 | } else { | |
565 | pr_debug("Charging disabled\n"); | |
566 | gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 0); | |
567 | } | |
ff279202 PZ |
568 | } |
569 | ||
350d115d PZ |
570 | static int magician_is_ac_online(void) |
571 | { | |
eac2eacc PC |
572 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) && |
573 | gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE); /* AC=1 */ | |
574 | } | |
575 | ||
576 | static int magician_is_usb_online(void) | |
577 | { | |
578 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) && | |
579 | (!gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE)); /* USB=0 */ | |
350d115d PZ |
580 | } |
581 | ||
eac2eacc | 582 | static void magician_supply_exit(struct device *dev) |
ff279202 | 583 | { |
eac2eacc | 584 | gpio_free(EGPIO_MAGICIAN_CABLE_INSERTED); |
f78b3a12 | 585 | gpio_free(EGPIO_MAGICIAN_CABLE_TYPE); |
ff279202 PZ |
586 | } |
587 | ||
81447b2e PZ |
588 | static char *magician_supplicants[] = { |
589 | "ds2760-battery.0", "backup-battery" | |
590 | }; | |
591 | ||
350d115d | 592 | static struct pda_power_pdata power_supply_info = { |
eac2eacc PC |
593 | .init = magician_supply_init, |
594 | .exit = magician_supply_exit, | |
ccb6f9ae | 595 | .is_ac_online = magician_is_ac_online, |
eac2eacc PC |
596 | .is_usb_online = magician_is_usb_online, |
597 | .set_charge = magician_set_charge, | |
ccb6f9ae PC |
598 | .supplied_to = magician_supplicants, |
599 | .num_supplicants = ARRAY_SIZE(magician_supplicants), | |
350d115d PZ |
600 | }; |
601 | ||
602 | static struct resource power_supply_resources[] = { | |
603 | [0] = { | |
ccb6f9ae PC |
604 | .name = "ac", |
605 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | | |
606 | IORESOURCE_IRQ_LOWEDGE, | |
607 | .start = IRQ_MAGICIAN_VBUS, | |
608 | .end = IRQ_MAGICIAN_VBUS, | |
350d115d PZ |
609 | }, |
610 | [1] = { | |
ccb6f9ae PC |
611 | .name = "usb", |
612 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | | |
613 | IORESOURCE_IRQ_LOWEDGE, | |
614 | .start = IRQ_MAGICIAN_VBUS, | |
615 | .end = IRQ_MAGICIAN_VBUS, | |
350d115d PZ |
616 | }, |
617 | }; | |
618 | ||
619 | static struct platform_device power_supply = { | |
ccb6f9ae PC |
620 | .name = "pda-power", |
621 | .id = -1, | |
622 | .dev = { | |
350d115d PZ |
623 | .platform_data = &power_supply_info, |
624 | }, | |
ccb6f9ae PC |
625 | .resource = power_supply_resources, |
626 | .num_resources = ARRAY_SIZE(power_supply_resources), | |
350d115d PZ |
627 | }; |
628 | ||
eb650b9e PZ |
629 | /* |
630 | * Battery charger | |
631 | */ | |
632 | ||
633 | static struct regulator_consumer_supply bq24022_consumers[] = { | |
0bf189ab AL |
634 | REGULATOR_SUPPLY("vbus_draw", NULL), |
635 | REGULATOR_SUPPLY("ac_draw", NULL), | |
eb650b9e PZ |
636 | }; |
637 | ||
638 | static struct regulator_init_data bq24022_init_data = { | |
639 | .constraints = { | |
ccb6f9ae PC |
640 | .max_uA = 500000, |
641 | .valid_ops_mask = REGULATOR_CHANGE_CURRENT | | |
642 | REGULATOR_CHANGE_STATUS, | |
eb650b9e | 643 | }, |
ccb6f9ae PC |
644 | .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers), |
645 | .consumer_supplies = bq24022_consumers, | |
eb650b9e PZ |
646 | }; |
647 | ||
6967cca8 HS |
648 | static struct gpio bq24022_gpios[] = { |
649 | { EGPIO_MAGICIAN_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" }, | |
650 | }; | |
651 | ||
652 | static struct gpio_regulator_state bq24022_states[] = { | |
653 | { .value = 100000, .gpios = (0 << 0) }, | |
654 | { .value = 500000, .gpios = (1 << 0) }, | |
655 | }; | |
656 | ||
657 | static struct gpio_regulator_config bq24022_info = { | |
ccb6f9ae | 658 | .supply_name = "bq24022", |
6967cca8 | 659 | |
ccb6f9ae PC |
660 | .enable_gpio = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, |
661 | .enable_high = 0, | |
eac2eacc | 662 | .enabled_at_boot = 1, |
6967cca8 | 663 | |
ccb6f9ae PC |
664 | .gpios = bq24022_gpios, |
665 | .nr_gpios = ARRAY_SIZE(bq24022_gpios), | |
6967cca8 | 666 | |
ccb6f9ae PC |
667 | .states = bq24022_states, |
668 | .nr_states = ARRAY_SIZE(bq24022_states), | |
6967cca8 | 669 | |
ccb6f9ae PC |
670 | .type = REGULATOR_CURRENT, |
671 | .init_data = &bq24022_init_data, | |
eb650b9e PZ |
672 | }; |
673 | ||
674 | static struct platform_device bq24022 = { | |
ccb6f9ae PC |
675 | .name = "gpio-regulator", |
676 | .id = -1, | |
677 | .dev = { | |
eb650b9e PZ |
678 | .platform_data = &bq24022_info, |
679 | }, | |
680 | }; | |
350d115d | 681 | |
7ade445c PC |
682 | /* |
683 | * fixed regulator for ads7846 | |
684 | */ | |
685 | ||
686 | static struct regulator_consumer_supply ads7846_supply = | |
687 | REGULATOR_SUPPLY("vcc", "spi2.0"); | |
688 | ||
689 | static struct regulator_init_data vads7846_regulator = { | |
690 | .constraints = { | |
691 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, | |
692 | }, | |
693 | .num_consumer_supplies = 1, | |
694 | .consumer_supplies = &ads7846_supply, | |
695 | }; | |
696 | ||
697 | static struct fixed_voltage_config vads7846 = { | |
698 | .supply_name = "vads7846", | |
699 | .microvolts = 3300000, /* probably */ | |
7ade445c PC |
700 | .startup_delay = 0, |
701 | .init_data = &vads7846_regulator, | |
702 | }; | |
703 | ||
704 | static struct platform_device vads7846_device = { | |
705 | .name = "reg-fixed-voltage", | |
706 | .id = -1, | |
707 | .dev = { | |
708 | .platform_data = &vads7846, | |
709 | }, | |
710 | }; | |
711 | ||
ff5eff35 PC |
712 | /* |
713 | * Vcore regulator MAX1587A | |
714 | */ | |
715 | ||
716 | static struct regulator_consumer_supply magician_max1587a_consumers[] = { | |
717 | REGULATOR_SUPPLY("vcc_core", NULL), | |
718 | }; | |
719 | ||
720 | static struct regulator_init_data magician_max1587a_v3_info = { | |
721 | .constraints = { | |
722 | .name = "vcc_core range", | |
723 | .min_uV = 700000, | |
724 | .max_uV = 1475000, | |
725 | .always_on = 1, | |
726 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, | |
727 | }, | |
728 | .consumer_supplies = magician_max1587a_consumers, | |
729 | .num_consumer_supplies = ARRAY_SIZE(magician_max1587a_consumers), | |
730 | }; | |
731 | ||
732 | static struct max1586_subdev_data magician_max1587a_subdevs[] = { | |
733 | { | |
734 | .name = "vcc_core", | |
735 | .id = MAX1586_V3, | |
736 | .platform_data = &magician_max1587a_v3_info, | |
737 | } | |
738 | }; | |
739 | ||
740 | static struct max1586_platform_data magician_max1587a_info = { | |
741 | .subdevs = magician_max1587a_subdevs, | |
742 | .num_subdevs = ARRAY_SIZE(magician_max1587a_subdevs), | |
743 | /* | |
744 | * NOTICE measured directly on the PCB (board_id == 0x3a), but | |
745 | * if R24 is present, it will boost the voltage | |
746 | * (write 1.475V, get 1.645V and smoke) | |
747 | */ | |
748 | .v3_gain = MAX1586_GAIN_NO_R24, | |
749 | }; | |
750 | ||
751 | static struct i2c_board_info magician_pwr_i2c_board_info[] __initdata = { | |
752 | { | |
753 | I2C_BOARD_INFO("max1586", 0x14), | |
754 | .platform_data = &magician_max1587a_info, | |
755 | }, | |
756 | }; | |
757 | ||
bdb0c16a PZ |
758 | /* |
759 | * MMC/SD | |
760 | */ | |
761 | ||
762 | static int magician_mci_init(struct device *dev, | |
ccb6f9ae | 763 | irq_handler_t detect_irq, void *data) |
bdb0c16a | 764 | { |
ed7936f9 | 765 | return request_irq(IRQ_MAGICIAN_SD, detect_irq, 0, |
ccb6f9ae | 766 | "mmc card detect", data); |
bdb0c16a PZ |
767 | } |
768 | ||
769 | static void magician_mci_exit(struct device *dev, void *data) | |
770 | { | |
771 | free_irq(IRQ_MAGICIAN_SD, data); | |
772 | } | |
773 | ||
774 | static struct pxamci_platform_data magician_mci_info = { | |
ccb6f9ae PC |
775 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
776 | .init = magician_mci_init, | |
777 | .exit = magician_mci_exit, | |
7a648256 | 778 | .gpio_card_ro_invert = 1, |
bdb0c16a PZ |
779 | }; |
780 | ||
32d15448 LW |
781 | /* |
782 | * Write protect on EGPIO register 5 index 4, this is on the second HTC | |
783 | * EGPIO chip which starts at register 4, so we need offset 8+4=12 on that | |
784 | * particular chip. | |
785 | */ | |
786 | #define EGPIO_MAGICIAN_nSD_READONLY_OFFSET 12 | |
f54005b5 LW |
787 | /* |
788 | * Power on EGPIO register 2 index 0, so this is on the first HTC EGPIO chip | |
789 | * starting at register 0 so we need offset 2*8+0 = 16 on that chip. | |
790 | */ | |
791 | #define EGPIO_MAGICIAN_nSD_POWER_OFFSET 16 | |
32d15448 LW |
792 | |
793 | static struct gpiod_lookup_table magician_mci_gpio_table = { | |
794 | .dev_id = "pxa2xx-mci.0", | |
795 | .table = { | |
796 | GPIO_LOOKUP("htc-egpio-1", EGPIO_MAGICIAN_nSD_READONLY_OFFSET, | |
797 | "wp", GPIO_ACTIVE_HIGH), | |
f54005b5 LW |
798 | GPIO_LOOKUP("htc-egpio-0", EGPIO_MAGICIAN_nSD_POWER_OFFSET, |
799 | "power", GPIO_ACTIVE_HIGH), | |
32d15448 LW |
800 | { }, |
801 | }, | |
802 | }; | |
bdb0c16a | 803 | |
e5c271ec PZ |
804 | /* |
805 | * USB OHCI | |
806 | */ | |
807 | ||
e5c271ec | 808 | static struct pxaohci_platform_data magician_ohci_info = { |
097b5334 | 809 | .port_mode = PMM_PERPORT_MODE, |
2eb7414a PC |
810 | /* port1: CSR Bluetooth, port2: OTG with UDC */ |
811 | .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW, | |
097b5334 | 812 | .power_budget = 0, |
2eb7414a | 813 | .power_on_delay = 100, |
e5c271ec PZ |
814 | }; |
815 | ||
e5c271ec PZ |
816 | /* |
817 | * StrataFlash | |
818 | */ | |
819 | ||
fdb902b6 PC |
820 | static int magician_flash_init(struct platform_device *pdev) |
821 | { | |
822 | int ret = gpio_request(EGPIO_MAGICIAN_FLASH_VPP, "flash Vpp enable"); | |
823 | ||
824 | if (ret) { | |
825 | pr_err("Cannot request flash enable GPIO (%i)\n", ret); | |
826 | return ret; | |
827 | } | |
828 | ||
829 | ret = gpio_direction_output(EGPIO_MAGICIAN_FLASH_VPP, 1); | |
830 | if (ret) { | |
831 | pr_err("Cannot set direction for flash enable (%i)\n", ret); | |
832 | gpio_free(EGPIO_MAGICIAN_FLASH_VPP); | |
833 | } | |
834 | ||
835 | return ret; | |
836 | } | |
837 | ||
667f390b | 838 | static void magician_set_vpp(struct platform_device *pdev, int vpp) |
aa797590 PZ |
839 | { |
840 | gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp); | |
841 | } | |
842 | ||
fdb902b6 PC |
843 | static void magician_flash_exit(struct platform_device *pdev) |
844 | { | |
845 | gpio_free(EGPIO_MAGICIAN_FLASH_VPP); | |
846 | } | |
847 | ||
e5c271ec | 848 | static struct resource strataflash_resource = { |
ccb6f9ae PC |
849 | .start = PXA_CS0_PHYS, |
850 | .end = PXA_CS0_PHYS + SZ_64M - 1, | |
851 | .flags = IORESOURCE_MEM, | |
e5c271ec PZ |
852 | }; |
853 | ||
fdb902b6 PC |
854 | static struct mtd_partition magician_flash_parts[] = { |
855 | { | |
856 | .name = "Bootloader", | |
857 | .offset = 0x0, | |
858 | .size = 0x40000, | |
859 | .mask_flags = MTD_WRITEABLE, /* EXPERIMENTAL */ | |
860 | }, | |
861 | { | |
862 | .name = "Linux Kernel", | |
863 | .offset = 0x40000, | |
864 | .size = MTDPART_SIZ_FULL, | |
865 | }, | |
866 | }; | |
867 | ||
868 | /* | |
869 | * physmap-flash driver | |
870 | */ | |
871 | ||
e5c271ec | 872 | static struct physmap_flash_data strataflash_data = { |
ccb6f9ae | 873 | .width = 4, |
fdb902b6 | 874 | .init = magician_flash_init, |
ccb6f9ae | 875 | .set_vpp = magician_set_vpp, |
fdb902b6 PC |
876 | .exit = magician_flash_exit, |
877 | .parts = magician_flash_parts, | |
878 | .nr_parts = ARRAY_SIZE(magician_flash_parts), | |
e5c271ec PZ |
879 | }; |
880 | ||
881 | static struct platform_device strataflash = { | |
ccb6f9ae PC |
882 | .name = "physmap-flash", |
883 | .id = -1, | |
884 | .resource = &strataflash_resource, | |
885 | .num_resources = 1, | |
e5c271ec PZ |
886 | .dev = { |
887 | .platform_data = &strataflash_data, | |
888 | }, | |
889 | }; | |
890 | ||
f8f9d5ec | 891 | /* |
f36150b1 | 892 | * PXA I2C main controller |
f8f9d5ec PZ |
893 | */ |
894 | ||
895 | static struct i2c_pxa_platform_data i2c_info = { | |
0fb58abb PC |
896 | /* OV9640 I2C device doesn't support fast mode */ |
897 | .fast_mode = 0, | |
898 | }; | |
899 | ||
900 | /* | |
901 | * PXA I2C power controller | |
902 | */ | |
903 | ||
904 | static struct i2c_pxa_platform_data magician_i2c_power_info = { | |
905 | .fast_mode = 1, | |
f8f9d5ec PZ |
906 | }; |
907 | ||
7ade445c PC |
908 | /* |
909 | * Touchscreen | |
910 | */ | |
911 | ||
912 | static struct ads7846_platform_data ads7846_pdata = { | |
913 | .model = 7846, | |
914 | .x_plate_ohms = 317, | |
915 | .y_plate_ohms = 500, | |
916 | .pressure_max = 1023, /* with x plate ohms it will overflow 255 */ | |
917 | .debounce_max = 3, /* first readout is always bad */ | |
918 | .debounce_tol = 30, | |
919 | .debounce_rep = 0, | |
920 | .gpio_pendown = GPIO115_MAGICIAN_nPEN_IRQ, | |
921 | .keep_vref_on = 1, | |
922 | .wakeup = true, | |
923 | .vref_delay_usecs = 100, | |
924 | .penirq_recheck_delay_usecs = 100, | |
925 | }; | |
926 | ||
927 | struct pxa2xx_spi_chip tsc2046_chip_info = { | |
928 | .tx_threshold = 1, | |
929 | .rx_threshold = 2, | |
930 | .timeout = 64, | |
931 | /* NOTICE must be GPIO, incompatibility with hw PXA SPI framing */ | |
932 | .gpio_cs = GPIO14_MAGICIAN_TSC2046_CS, | |
933 | }; | |
934 | ||
935 | static struct pxa2xx_spi_master magician_spi_info = { | |
936 | .num_chipselect = 1, | |
937 | .enable_dma = 1, | |
938 | }; | |
939 | ||
940 | static struct spi_board_info ads7846_spi_board_info[] __initdata = { | |
941 | { | |
942 | .modalias = "ads7846", | |
943 | .bus_num = 2, | |
944 | .max_speed_hz = 2500000, | |
945 | .platform_data = &ads7846_pdata, | |
946 | .controller_data = &tsc2046_chip_info, | |
947 | .irq = PXA_GPIO_TO_IRQ(GPIO115_MAGICIAN_nPEN_IRQ), | |
948 | }, | |
949 | }; | |
950 | ||
e5c271ec PZ |
951 | /* |
952 | * Platform devices | |
953 | */ | |
954 | ||
955 | static struct platform_device *devices[] __initdata = { | |
956 | &gpio_keys, | |
70e357f8 | 957 | &egpio, |
e5c271ec | 958 | &backlight, |
81447b2e | 959 | &pasic3, |
eb650b9e | 960 | &bq24022, |
6489c611 | 961 | &gpio_vbus, |
350d115d | 962 | &power_supply, |
e5c271ec | 963 | &strataflash, |
81447b2e | 964 | &leds_gpio, |
7ade445c | 965 | &vads7846_device, |
e5c271ec PZ |
966 | }; |
967 | ||
5db15f86 | 968 | static struct gpio magician_global_gpios[] = { |
ccb6f9ae | 969 | { GPIO13_MAGICIAN_CPLD_IRQ, GPIOF_IN, "CPLD_IRQ" }, |
5db15f86 | 970 | { GPIO107_MAGICIAN_DS1WM_IRQ, GPIOF_IN, "DS1WM_IRQ" }, |
6001ae70 PC |
971 | |
972 | /* NOTICE valid LCD init sequence */ | |
973 | { GPIO106_MAGICIAN_LCD_DCDC_NRESET, GPIOF_OUT_INIT_LOW, "LCD DCDC nreset" }, | |
974 | { GPIO104_MAGICIAN_LCD_VOFF_EN, GPIOF_OUT_INIT_LOW, "LCD VOFF enable" }, | |
975 | { GPIO105_MAGICIAN_LCD_VON_EN, GPIOF_OUT_INIT_LOW, "LCD VON enable" }, | |
5db15f86 PZ |
976 | }; |
977 | ||
e5c271ec PZ |
978 | static void __init magician_init(void) |
979 | { | |
e07ff8d8 PZ |
980 | void __iomem *cpld; |
981 | int lcd_select; | |
a1999cd1 PZ |
982 | int err; |
983 | ||
b168281c | 984 | pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config)); |
5db15f86 PZ |
985 | err = gpio_request_array(ARRAY_AND_SIZE(magician_global_gpios)); |
986 | if (err) | |
7f63a752 | 987 | pr_err("magician: Failed to request global GPIOs: %d\n", err); |
b168281c | 988 | |
cc155c6f RK |
989 | pxa_set_ffuart_info(NULL); |
990 | pxa_set_btuart_info(NULL); | |
cc155c6f | 991 | |
bd3208ba | 992 | pwm_add_table(magician_pwm_lookup, ARRAY_SIZE(magician_pwm_lookup)); |
a1999cd1 | 993 | |
5db15f86 | 994 | pxa_set_ficp_info(&magician_ficp_info); |
0fb58abb | 995 | pxa27x_set_i2c_power_info(&magician_i2c_power_info); |
f8f9d5ec | 996 | pxa_set_i2c_info(&i2c_info); |
ff5eff35 PC |
997 | |
998 | i2c_register_board_info(1, | |
999 | ARRAY_AND_SIZE(magician_pwr_i2c_board_info)); | |
1000 | ||
32d15448 | 1001 | gpiod_add_lookup_table(&magician_mci_gpio_table); |
bdb0c16a | 1002 | pxa_set_mci_info(&magician_mci_info); |
e5c271ec | 1003 | pxa_set_ohci_info(&magician_ohci_info); |
31134b51 | 1004 | pxa_set_udc_info(&magician_udc_info); |
e07ff8d8 PZ |
1005 | |
1006 | /* Check LCD type we have */ | |
1007 | cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000); | |
1008 | if (cpld) { | |
ccb6f9ae PC |
1009 | u8 board_id = __raw_readb(cpld + 0x14); |
1010 | ||
a1999cd1 | 1011 | iounmap(cpld); |
e07ff8d8 PZ |
1012 | system_rev = board_id & 0x7; |
1013 | lcd_select = board_id & 0x8; | |
e07ff8d8 | 1014 | pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly"); |
5db15f86 | 1015 | if (lcd_select && (system_rev < 3)) |
6001ae70 | 1016 | /* NOTICE valid LCD init sequence */ |
5db15f86 | 1017 | gpio_request_one(GPIO75_MAGICIAN_SAMSUNG_POWER, |
6382a594 | 1018 | GPIOF_OUT_INIT_LOW, "Samsung LCD Power"); |
ccb6f9ae PC |
1019 | pxa_set_fb_info(NULL, |
1020 | lcd_select ? &samsung_info : &toppoly_info); | |
e07ff8d8 PZ |
1021 | } else |
1022 | pr_err("LCD detection: CPLD mapping failed\n"); | |
e2f1b8b0 | 1023 | |
7ade445c PC |
1024 | pxa2xx_set_spi_info(2, &magician_spi_info); |
1025 | spi_register_board_info(ARRAY_AND_SIZE(ads7846_spi_board_info)); | |
1026 | ||
e2f1b8b0 PC |
1027 | regulator_register_always_on(0, "power", pwm_backlight_supply, |
1028 | ARRAY_SIZE(pwm_backlight_supply), 5000000); | |
78afa4fc PC |
1029 | |
1030 | platform_add_devices(ARRAY_AND_SIZE(devices)); | |
e5c271ec PZ |
1031 | } |
1032 | ||
e5c271ec | 1033 | MACHINE_START(MAGICIAN, "HTC Magician") |
ccb6f9ae PC |
1034 | .atag_offset = 0x100, |
1035 | .map_io = pxa27x_map_io, | |
1036 | .nr_irqs = MAGICIAN_NR_IRQS, | |
1037 | .init_irq = pxa27x_init_irq, | |
1038 | .handle_irq = pxa27x_handle_irq, | |
1039 | .init_machine = magician_init, | |
6bb27d73 | 1040 | .init_time = pxa_timer_init, |
271a74fc | 1041 | .restart = pxa_restart, |
e5c271ec | 1042 | MACHINE_END |