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.
6 * Copyright (c) 2006-2007 Philipp Zabel
8 * Based on hx4700.c, spitz.c and others.
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.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/delay.h>
20 #include <linux/gpio.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/input.h>
23 #include <linux/mfd/htc-pasic3.h>
24 #include <linux/mtd/physmap.h>
25 #include <linux/pda_power.h>
26 #include <linux/platform_data/gpio-htc-egpio.h>
27 #include <linux/pwm.h>
28 #include <linux/pwm_backlight.h>
29 #include <linux/regulator/driver.h>
30 #include <linux/regulator/fixed.h>
31 #include <linux/regulator/gpio-regulator.h>
32 #include <linux/regulator/machine.h>
33 #include <linux/usb/gpio_vbus.h>
34 #include <linux/platform_data/i2c-pxa.h>
36 #include <mach/hardware.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/system_info.h>
42 #include <mach/magician.h>
43 #include <linux/platform_data/video-pxafb.h>
44 #include <linux/platform_data/mmc-pxamci.h>
45 #include <linux/platform_data/irda-pxaficp.h>
46 #include <linux/platform_data/usb-ohci-pxa27x.h>
48 #include <linux/regulator/max1586.h>
50 #include <linux/platform_data/pxa2xx_udc.h>
53 #include "pxa27x-udc.h"
57 #include <linux/spi/spi.h>
58 #include <linux/spi/pxa2xx_spi.h>
59 #include <linux/spi/ads7846.h>
61 static unsigned long magician_pin_config
[] __initdata
= {
63 /* SDRAM and Static Memory I/O Signals */
67 GPIO78_nCS_2
, /* PASIC3 */
68 GPIO79_nCS_3
, /* EGPIO CPLD */
72 /* I2C UDA1380 + OV9640 */
76 /* PWM 0 - LCD backlight */
79 /* I2S UDA1380 capture */
80 GPIO28_I2S_BITCLK_OUT
,
85 /* SSP 1 UDA1380 playback */
90 /* SSP 2 TSC2046 touchscreen */
92 MFP_CFG_OUT(GPIO14
, AF0
, DRIVE_HIGH
), /* frame as GPIO */
96 /* MMC/SD/SDHC slot */
105 GPIOxx_LCD_TFT_16BPP
,
107 /* QCI camera interface */
121 /* Magician specific input GPIOs */
122 GPIO9_GPIO
, /* unknown */
123 GPIO10_GPIO
, /* GSM_IRQ */
124 GPIO13_GPIO
, /* CPLD_IRQ */
125 GPIO107_GPIO
, /* DS1WM_IRQ */
126 GPIO108_GPIO
, /* GSM_READY */
127 GPIO115_GPIO
, /* nPEN_IRQ */
134 static struct pxaficp_platform_data magician_ficp_info
= {
135 .gpio_pwdown
= GPIO83_MAGICIAN_nIR_EN
,
136 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
137 .gpio_pwdown_inverted
= 0,
144 #define INIT_KEY(_code, _gpio, _desc) \
146 .code = KEY_##_code, \
153 static struct gpio_keys_button magician_button_table
[] = {
154 INIT_KEY(POWER
, GPIO0_MAGICIAN_KEY_POWER
, "Power button"),
155 INIT_KEY(ESC
, GPIO37_MAGICIAN_KEY_HANGUP
, "Hangup button"),
156 INIT_KEY(F10
, GPIO38_MAGICIAN_KEY_CONTACTS
, "Contacts button"),
157 INIT_KEY(CALENDAR
, GPIO90_MAGICIAN_KEY_CALENDAR
, "Calendar button"),
158 INIT_KEY(CAMERA
, GPIO91_MAGICIAN_KEY_CAMERA
, "Camera button"),
159 INIT_KEY(UP
, GPIO93_MAGICIAN_KEY_UP
, "Up button"),
160 INIT_KEY(DOWN
, GPIO94_MAGICIAN_KEY_DOWN
, "Down button"),
161 INIT_KEY(LEFT
, GPIO95_MAGICIAN_KEY_LEFT
, "Left button"),
162 INIT_KEY(RIGHT
, GPIO96_MAGICIAN_KEY_RIGHT
, "Right button"),
163 INIT_KEY(KPENTER
, GPIO97_MAGICIAN_KEY_ENTER
, "Action button"),
164 INIT_KEY(RECORD
, GPIO98_MAGICIAN_KEY_RECORD
, "Record button"),
165 INIT_KEY(VOLUMEUP
, GPIO100_MAGICIAN_KEY_VOL_UP
, "Volume up"),
166 INIT_KEY(VOLUMEDOWN
, GPIO101_MAGICIAN_KEY_VOL_DOWN
, "Volume down"),
167 INIT_KEY(PHONE
, GPIO102_MAGICIAN_KEY_PHONE
, "Phone button"),
168 INIT_KEY(PLAY
, GPIO99_MAGICIAN_HEADPHONE_IN
, "Headset button"),
171 static struct gpio_keys_platform_data gpio_keys_data
= {
172 .buttons
= magician_button_table
,
173 .nbuttons
= ARRAY_SIZE(magician_button_table
),
176 static struct platform_device gpio_keys
= {
179 .platform_data
= &gpio_keys_data
,
185 * EGPIO (Xilinx CPLD)
187 * 32-bit aligned 8-bit registers
188 * 16 possible registers (reg windows size), only 7 used:
189 * 3x output, 1x irq, 3x input
192 static struct resource egpio_resources
[] = {
194 .start
= PXA_CS3_PHYS
,
195 .end
= PXA_CS3_PHYS
+ 0x20 - 1,
196 .flags
= IORESOURCE_MEM
,
199 .start
= PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ
),
200 .end
= PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ
),
201 .flags
= IORESOURCE_IRQ
,
205 static struct htc_egpio_chip egpio_chips
[] = {
208 .gpio_base
= MAGICIAN_EGPIO(0, 0),
210 .direction
= HTC_EGPIO_OUTPUT
,
212 * Depends on modules configuration
214 .initial_values
= 0x40, /* EGPIO_MAGICIAN_GSM_RESET */
218 .gpio_base
= MAGICIAN_EGPIO(4, 0),
220 .direction
= HTC_EGPIO_INPUT
,
224 static struct htc_egpio_platform_data egpio_info
= {
227 .irq_base
= IRQ_BOARD_START
,
231 .num_chips
= ARRAY_SIZE(egpio_chips
),
234 static struct platform_device egpio
= {
237 .resource
= egpio_resources
,
238 .num_resources
= ARRAY_SIZE(egpio_resources
),
240 .platform_data
= &egpio_info
,
245 * PXAFB LCD - Toppoly TD028STEB1 or Samsung LTP280QV
248 static struct pxafb_mode_info toppoly_modes
[] = {
264 static struct pxafb_mode_info samsung_modes
[] = {
276 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
280 static void toppoly_lcd_power(int on
, struct fb_var_screeninfo
*si
)
282 pr_debug("Toppoly LCD power: %s\n", on
? "on" : "off");
285 gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER
, 1);
286 gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET
, 1);
288 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER
, 1);
290 /* FIXME: enable LCDC here */
292 gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN
, 1);
294 gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN
, 1);
297 gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN
, 0);
299 gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN
, 0);
301 gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET
, 0);
302 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER
, 0);
306 static void samsung_lcd_power(int on
, struct fb_var_screeninfo
*si
)
308 pr_debug("Samsung LCD power: %s\n", on
? "on" : "off");
312 gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER
, 1);
314 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER
, 1);
316 gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET
, 1);
317 mdelay(6); /* Avdd -> Voff >5ms */
318 gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN
, 1);
319 mdelay(16); /* Voff -> Von >(5+10)ms */
320 gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN
, 1);
322 gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN
, 0);
324 gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN
, 0);
326 gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET
, 0);
329 gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER
, 0);
331 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER
, 0);
335 static struct pxafb_mach_info toppoly_info
= {
336 .modes
= toppoly_modes
,
339 .lcd_conn
= LCD_COLOR_TFT_16BPP
,
340 .pxafb_lcd_power
= toppoly_lcd_power
,
343 static struct pxafb_mach_info samsung_info
= {
344 .modes
= samsung_modes
,
347 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
|
348 LCD_ALTERNATE_MAPPING
,
349 .pxafb_lcd_power
= samsung_lcd_power
,
356 static struct pwm_lookup magician_pwm_lookup
[] = {
357 PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL
, 30923,
358 PWM_POLARITY_NORMAL
),
362 * fixed regulator for pwm_backlight
365 static struct regulator_consumer_supply pwm_backlight_supply
[] = {
366 REGULATOR_SUPPLY("power", "pwm_backlight"),
370 static struct gpio magician_bl_gpios
[] = {
371 { EGPIO_MAGICIAN_BL_POWER
, GPIOF_DIR_OUT
, "Backlight power" },
372 { EGPIO_MAGICIAN_BL_POWER2
, GPIOF_DIR_OUT
, "Backlight power 2" },
375 static int magician_backlight_init(struct device
*dev
)
377 return gpio_request_array(ARRAY_AND_SIZE(magician_bl_gpios
));
380 static int magician_backlight_notify(struct device
*dev
, int brightness
)
382 pr_debug("Brightness = %i\n", brightness
);
383 gpio_set_value(EGPIO_MAGICIAN_BL_POWER
, brightness
);
384 if (brightness
>= 200) {
385 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2
, 1);
386 return brightness
- 72;
388 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2
, 0);
393 static void magician_backlight_exit(struct device
*dev
)
395 gpio_free_array(ARRAY_AND_SIZE(magician_bl_gpios
));
399 * LCD PWM backlight (main)
401 * MP1521 frequency should be:
402 * 100-400 Hz = 2 .5*10^6 - 10 *10^6 ns
405 static struct platform_pwm_backlight_data backlight_data
= {
406 .max_brightness
= 272,
407 .dft_brightness
= 100,
409 .init
= magician_backlight_init
,
410 .notify
= magician_backlight_notify
,
411 .exit
= magician_backlight_exit
,
414 static struct platform_device backlight
= {
415 .name
= "pwm-backlight",
418 .parent
= &pxa27x_device_pwm0
.dev
,
419 .platform_data
= &backlight_data
,
424 * GPIO LEDs, Phone keys backlight, vibra
427 static struct gpio_led gpio_leds
[] = {
429 .name
= "magician::vibra",
430 .default_trigger
= "none",
431 .gpio
= GPIO22_MAGICIAN_VIBRA_EN
,
434 .name
= "magician::phone_bl",
435 .default_trigger
= "backlight",
436 .gpio
= GPIO103_MAGICIAN_LED_KP
,
440 static struct gpio_led_platform_data gpio_led_info
= {
442 .num_leds
= ARRAY_SIZE(gpio_leds
),
445 static struct platform_device leds_gpio
= {
449 .platform_data
= &gpio_led_info
,
457 static struct resource pasic3_resources
[] = {
459 .start
= PXA_CS2_PHYS
,
460 .end
= PXA_CS2_PHYS
+ 0x1b,
461 .flags
= IORESOURCE_MEM
,
463 /* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */
465 .start
= PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ
),
466 .end
= PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ
),
467 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
471 static struct pasic3_platform_data pasic3_platform_data
= {
472 .clock_rate
= 4000000,
475 static struct platform_device pasic3
= {
478 .num_resources
= ARRAY_SIZE(pasic3_resources
),
479 .resource
= pasic3_resources
,
481 .platform_data
= &pasic3_platform_data
,
489 static void magician_udc_command(int cmd
)
491 if (cmd
== PXA2XX_UDC_CMD_CONNECT
)
492 UP2OCR
|= UP2OCR_DPPUE
| UP2OCR_DPPUBE
;
493 else if (cmd
== PXA2XX_UDC_CMD_DISCONNECT
)
494 UP2OCR
&= ~(UP2OCR_DPPUE
| UP2OCR_DPPUBE
);
497 static struct pxa2xx_udc_mach_info magician_udc_info __initdata
= {
498 .udc_command
= magician_udc_command
,
499 .gpio_pullup
= GPIO27_MAGICIAN_USBC_PUEN
,
503 * USB device VBus detection
506 static struct resource gpio_vbus_resource
= {
507 .flags
= IORESOURCE_IRQ
,
508 .start
= IRQ_MAGICIAN_VBUS
,
509 .end
= IRQ_MAGICIAN_VBUS
,
512 static struct gpio_vbus_mach_info gpio_vbus_info
= {
513 .gpio_pullup
= GPIO27_MAGICIAN_USBC_PUEN
,
514 .gpio_vbus
= EGPIO_MAGICIAN_CABLE_VBUS
,
517 static struct platform_device gpio_vbus
= {
521 .resource
= &gpio_vbus_resource
,
523 .platform_data
= &gpio_vbus_info
,
531 static int magician_supply_init(struct device
*dev
)
535 ret
= gpio_request(EGPIO_MAGICIAN_CABLE_TYPE
, "Cable is AC charger");
537 pr_err("Cannot request AC/USB charger GPIO (%i)\n", ret
);
541 ret
= gpio_request(EGPIO_MAGICIAN_CABLE_INSERTED
, "Cable inserted");
543 pr_err("Cannot request cable detection GPIO (%i)\n", ret
);
550 gpio_free(EGPIO_MAGICIAN_CABLE_TYPE
);
555 static void magician_set_charge(int flags
)
557 if (flags
& PDA_POWER_CHARGE_AC
) {
558 pr_debug("Charging from AC\n");
559 gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE
, 1);
560 } else if (flags
& PDA_POWER_CHARGE_USB
) {
561 pr_debug("Charging from USB\n");
562 gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE
, 1);
564 pr_debug("Charging disabled\n");
565 gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE
, 0);
569 static int magician_is_ac_online(void)
571 return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED
) &&
572 gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE
); /* AC=1 */
575 static int magician_is_usb_online(void)
577 return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED
) &&
578 (!gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE
)); /* USB=0 */
581 static void magician_supply_exit(struct device
*dev
)
583 gpio_free(EGPIO_MAGICIAN_CABLE_INSERTED
);
584 gpio_free(EGPIO_MAGICIAN_CABLE_TYPE
);
587 static char *magician_supplicants
[] = {
588 "ds2760-battery.0", "backup-battery"
591 static struct pda_power_pdata power_supply_info
= {
592 .init
= magician_supply_init
,
593 .exit
= magician_supply_exit
,
594 .is_ac_online
= magician_is_ac_online
,
595 .is_usb_online
= magician_is_usb_online
,
596 .set_charge
= magician_set_charge
,
597 .supplied_to
= magician_supplicants
,
598 .num_supplicants
= ARRAY_SIZE(magician_supplicants
),
601 static struct resource power_supply_resources
[] = {
604 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
|
605 IORESOURCE_IRQ_LOWEDGE
,
606 .start
= IRQ_MAGICIAN_VBUS
,
607 .end
= IRQ_MAGICIAN_VBUS
,
611 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
|
612 IORESOURCE_IRQ_LOWEDGE
,
613 .start
= IRQ_MAGICIAN_VBUS
,
614 .end
= IRQ_MAGICIAN_VBUS
,
618 static struct platform_device power_supply
= {
622 .platform_data
= &power_supply_info
,
624 .resource
= power_supply_resources
,
625 .num_resources
= ARRAY_SIZE(power_supply_resources
),
632 static struct regulator_consumer_supply bq24022_consumers
[] = {
633 REGULATOR_SUPPLY("vbus_draw", NULL
),
634 REGULATOR_SUPPLY("ac_draw", NULL
),
637 static struct regulator_init_data bq24022_init_data
= {
640 .valid_ops_mask
= REGULATOR_CHANGE_CURRENT
|
641 REGULATOR_CHANGE_STATUS
,
643 .num_consumer_supplies
= ARRAY_SIZE(bq24022_consumers
),
644 .consumer_supplies
= bq24022_consumers
,
647 static struct gpio bq24022_gpios
[] = {
648 { EGPIO_MAGICIAN_BQ24022_ISET2
, GPIOF_OUT_INIT_LOW
, "bq24022_iset2" },
651 static struct gpio_regulator_state bq24022_states
[] = {
652 { .value
= 100000, .gpios
= (0 << 0) },
653 { .value
= 500000, .gpios
= (1 << 0) },
656 static struct gpio_regulator_config bq24022_info
= {
657 .supply_name
= "bq24022",
659 .enable_gpio
= GPIO30_MAGICIAN_BQ24022_nCHARGE_EN
,
661 .enabled_at_boot
= 1,
663 .gpios
= bq24022_gpios
,
664 .nr_gpios
= ARRAY_SIZE(bq24022_gpios
),
666 .states
= bq24022_states
,
667 .nr_states
= ARRAY_SIZE(bq24022_states
),
669 .type
= REGULATOR_CURRENT
,
670 .init_data
= &bq24022_init_data
,
673 static struct platform_device bq24022
= {
674 .name
= "gpio-regulator",
677 .platform_data
= &bq24022_info
,
682 * fixed regulator for ads7846
685 static struct regulator_consumer_supply ads7846_supply
=
686 REGULATOR_SUPPLY("vcc", "spi2.0");
688 static struct regulator_init_data vads7846_regulator
= {
690 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
692 .num_consumer_supplies
= 1,
693 .consumer_supplies
= &ads7846_supply
,
696 static struct fixed_voltage_config vads7846
= {
697 .supply_name
= "vads7846",
698 .microvolts
= 3300000, /* probably */
701 .init_data
= &vads7846_regulator
,
704 static struct platform_device vads7846_device
= {
705 .name
= "reg-fixed-voltage",
708 .platform_data
= &vads7846
,
713 * Vcore regulator MAX1587A
716 static struct regulator_consumer_supply magician_max1587a_consumers
[] = {
717 REGULATOR_SUPPLY("vcc_core", NULL
),
720 static struct regulator_init_data magician_max1587a_v3_info
= {
722 .name
= "vcc_core range",
726 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
728 .consumer_supplies
= magician_max1587a_consumers
,
729 .num_consumer_supplies
= ARRAY_SIZE(magician_max1587a_consumers
),
732 static struct max1586_subdev_data magician_max1587a_subdevs
[] = {
736 .platform_data
= &magician_max1587a_v3_info
,
740 static struct max1586_platform_data magician_max1587a_info
= {
741 .subdevs
= magician_max1587a_subdevs
,
742 .num_subdevs
= ARRAY_SIZE(magician_max1587a_subdevs
),
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)
748 .v3_gain
= MAX1586_GAIN_NO_R24
,
751 static struct i2c_board_info magician_pwr_i2c_board_info
[] __initdata
= {
753 I2C_BOARD_INFO("max1586", 0x14),
754 .platform_data
= &magician_max1587a_info
,
762 static int magician_mci_init(struct device
*dev
,
763 irq_handler_t detect_irq
, void *data
)
765 return request_irq(IRQ_MAGICIAN_SD
, detect_irq
, 0,
766 "mmc card detect", data
);
769 static void magician_mci_exit(struct device
*dev
, void *data
)
771 free_irq(IRQ_MAGICIAN_SD
, data
);
774 static struct pxamci_platform_data magician_mci_info
= {
775 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
776 .init
= magician_mci_init
,
777 .exit
= magician_mci_exit
,
778 .gpio_card_detect
= -1,
779 .gpio_card_ro
= EGPIO_MAGICIAN_nSD_READONLY
,
780 .gpio_card_ro_invert
= 1,
781 .gpio_power
= EGPIO_MAGICIAN_SD_POWER
,
789 static struct pxaohci_platform_data magician_ohci_info
= {
790 .port_mode
= PMM_PERPORT_MODE
,
791 /* port1: CSR Bluetooth, port2: OTG with UDC */
792 .flags
= ENABLE_PORT1
| ENABLE_PORT2
| POWER_CONTROL_LOW
,
794 .power_on_delay
= 100,
801 static int magician_flash_init(struct platform_device
*pdev
)
803 int ret
= gpio_request(EGPIO_MAGICIAN_FLASH_VPP
, "flash Vpp enable");
806 pr_err("Cannot request flash enable GPIO (%i)\n", ret
);
810 ret
= gpio_direction_output(EGPIO_MAGICIAN_FLASH_VPP
, 1);
812 pr_err("Cannot set direction for flash enable (%i)\n", ret
);
813 gpio_free(EGPIO_MAGICIAN_FLASH_VPP
);
819 static void magician_set_vpp(struct platform_device
*pdev
, int vpp
)
821 gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP
, vpp
);
824 static void magician_flash_exit(struct platform_device
*pdev
)
826 gpio_free(EGPIO_MAGICIAN_FLASH_VPP
);
829 static struct resource strataflash_resource
= {
830 .start
= PXA_CS0_PHYS
,
831 .end
= PXA_CS0_PHYS
+ SZ_64M
- 1,
832 .flags
= IORESOURCE_MEM
,
835 static struct mtd_partition magician_flash_parts
[] = {
837 .name
= "Bootloader",
840 .mask_flags
= MTD_WRITEABLE
, /* EXPERIMENTAL */
843 .name
= "Linux Kernel",
845 .size
= MTDPART_SIZ_FULL
,
850 * physmap-flash driver
853 static struct physmap_flash_data strataflash_data
= {
855 .init
= magician_flash_init
,
856 .set_vpp
= magician_set_vpp
,
857 .exit
= magician_flash_exit
,
858 .parts
= magician_flash_parts
,
859 .nr_parts
= ARRAY_SIZE(magician_flash_parts
),
862 static struct platform_device strataflash
= {
863 .name
= "physmap-flash",
865 .resource
= &strataflash_resource
,
868 .platform_data
= &strataflash_data
,
873 * PXA I2C main controller
876 static struct i2c_pxa_platform_data i2c_info
= {
877 /* OV9640 I2C device doesn't support fast mode */
882 * PXA I2C power controller
885 static struct i2c_pxa_platform_data magician_i2c_power_info
= {
893 static struct ads7846_platform_data ads7846_pdata
= {
897 .pressure_max
= 1023, /* with x plate ohms it will overflow 255 */
898 .debounce_max
= 3, /* first readout is always bad */
901 .gpio_pendown
= GPIO115_MAGICIAN_nPEN_IRQ
,
904 .vref_delay_usecs
= 100,
905 .penirq_recheck_delay_usecs
= 100,
908 struct pxa2xx_spi_chip tsc2046_chip_info
= {
912 /* NOTICE must be GPIO, incompatibility with hw PXA SPI framing */
913 .gpio_cs
= GPIO14_MAGICIAN_TSC2046_CS
,
916 static struct pxa2xx_spi_master magician_spi_info
= {
921 static struct spi_board_info ads7846_spi_board_info
[] __initdata
= {
923 .modalias
= "ads7846",
925 .max_speed_hz
= 2500000,
926 .platform_data
= &ads7846_pdata
,
927 .controller_data
= &tsc2046_chip_info
,
928 .irq
= PXA_GPIO_TO_IRQ(GPIO115_MAGICIAN_nPEN_IRQ
),
936 static struct platform_device
*devices
[] __initdata
= {
949 static struct gpio magician_global_gpios
[] = {
950 { GPIO13_MAGICIAN_CPLD_IRQ
, GPIOF_IN
, "CPLD_IRQ" },
951 { GPIO107_MAGICIAN_DS1WM_IRQ
, GPIOF_IN
, "DS1WM_IRQ" },
953 /* NOTICE valid LCD init sequence */
954 { GPIO106_MAGICIAN_LCD_DCDC_NRESET
, GPIOF_OUT_INIT_LOW
, "LCD DCDC nreset" },
955 { GPIO104_MAGICIAN_LCD_VOFF_EN
, GPIOF_OUT_INIT_LOW
, "LCD VOFF enable" },
956 { GPIO105_MAGICIAN_LCD_VON_EN
, GPIOF_OUT_INIT_LOW
, "LCD VON enable" },
959 static void __init
magician_init(void)
965 pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config
));
966 err
= gpio_request_array(ARRAY_AND_SIZE(magician_global_gpios
));
968 pr_err("magician: Failed to request global GPIOs: %d\n", err
);
970 pxa_set_ffuart_info(NULL
);
971 pxa_set_btuart_info(NULL
);
973 pwm_add_table(magician_pwm_lookup
, ARRAY_SIZE(magician_pwm_lookup
));
975 pxa_set_ficp_info(&magician_ficp_info
);
976 pxa27x_set_i2c_power_info(&magician_i2c_power_info
);
977 pxa_set_i2c_info(&i2c_info
);
979 i2c_register_board_info(1,
980 ARRAY_AND_SIZE(magician_pwr_i2c_board_info
));
982 pxa_set_mci_info(&magician_mci_info
);
983 pxa_set_ohci_info(&magician_ohci_info
);
984 pxa_set_udc_info(&magician_udc_info
);
986 /* Check LCD type we have */
987 cpld
= ioremap_nocache(PXA_CS3_PHYS
, 0x1000);
989 u8 board_id
= __raw_readb(cpld
+ 0x14);
992 system_rev
= board_id
& 0x7;
993 lcd_select
= board_id
& 0x8;
994 pr_info("LCD type: %s\n", lcd_select
? "Samsung" : "Toppoly");
995 if (lcd_select
&& (system_rev
< 3))
996 /* NOTICE valid LCD init sequence */
997 gpio_request_one(GPIO75_MAGICIAN_SAMSUNG_POWER
,
998 GPIOF_OUT_INIT_LOW
, "Samsung LCD Power");
999 pxa_set_fb_info(NULL
,
1000 lcd_select
? &samsung_info
: &toppoly_info
);
1002 pr_err("LCD detection: CPLD mapping failed\n");
1004 pxa2xx_set_spi_info(2, &magician_spi_info
);
1005 spi_register_board_info(ARRAY_AND_SIZE(ads7846_spi_board_info
));
1007 regulator_register_always_on(0, "power", pwm_backlight_supply
,
1008 ARRAY_SIZE(pwm_backlight_supply
), 5000000);
1010 platform_add_devices(ARRAY_AND_SIZE(devices
));
1013 MACHINE_START(MAGICIAN
, "HTC Magician")
1014 .atag_offset
= 0x100,
1015 .map_io
= pxa27x_map_io
,
1016 .nr_irqs
= MAGICIAN_NR_IRQS
,
1017 .init_irq
= pxa27x_init_irq
,
1018 .handle_irq
= pxa27x_handle_irq
,
1019 .init_machine
= magician_init
,
1020 .init_time
= pxa_timer_init
,
1021 .restart
= pxa_restart
,