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