1 // SPDX-License-Identifier: GPL-2.0-only
3 * Support for HTC Magician PDA phones:
4 * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110
5 * and T-Mobile MDA Compact.
7 * Copyright (c) 2006-2007 Philipp Zabel
9 * Based on hx4700.c, spitz.c and others.
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/platform_data/i2c-pxa.h>
32 #include <mach/hardware.h>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35 #include <asm/system_info.h>
38 #include <mach/magician.h>
39 #include <linux/platform_data/video-pxafb.h>
40 #include <linux/platform_data/mmc-pxamci.h>
41 #include <linux/platform_data/irda-pxaficp.h>
42 #include <linux/platform_data/usb-ohci-pxa27x.h>
44 #include <linux/regulator/max1586.h>
46 #include <linux/platform_data/pxa2xx_udc.h>
49 #include "pxa27x-udc.h"
53 #include <linux/spi/spi.h>
54 #include <linux/spi/pxa2xx_spi.h>
55 #include <linux/spi/ads7846.h>
57 static unsigned long magician_pin_config[] __initdata = {
59 /* SDRAM and Static Memory I/O Signals */
63 GPIO78_nCS_2, /* PASIC3 */
64 GPIO79_nCS_3, /* EGPIO CPLD */
68 /* I2C UDA1380 + OV9640 */
72 /* PWM 0 - LCD backlight */
75 /* I2S UDA1380 capture */
76 GPIO28_I2S_BITCLK_OUT,
81 /* SSP 1 UDA1380 playback */
86 /* SSP 2 TSC2046 touchscreen */
88 MFP_CFG_OUT(GPIO14, AF0, DRIVE_HIGH), /* frame as GPIO */
92 /* MMC/SD/SDHC slot */
101 GPIOxx_LCD_TFT_16BPP,
103 /* QCI camera interface */
117 /* Magician specific input GPIOs */
118 GPIO9_GPIO, /* unknown */
119 GPIO10_GPIO, /* GSM_IRQ */
120 GPIO13_GPIO, /* CPLD_IRQ */
121 GPIO107_GPIO, /* DS1WM_IRQ */
122 GPIO108_GPIO, /* GSM_READY */
123 GPIO115_GPIO, /* nPEN_IRQ */
130 static struct pxaficp_platform_data magician_ficp_info = {
131 .gpio_pwdown = GPIO83_MAGICIAN_nIR_EN,
132 .transceiver_cap = IR_SIRMODE | IR_OFF,
133 .gpio_pwdown_inverted = 0,
140 #define INIT_KEY(_code, _gpio, _desc) \
142 .code = KEY_##_code, \
149 static struct gpio_keys_button magician_button_table[] = {
150 INIT_KEY(POWER, GPIO0_MAGICIAN_KEY_POWER, "Power button"),
151 INIT_KEY(ESC, GPIO37_MAGICIAN_KEY_HANGUP, "Hangup button"),
152 INIT_KEY(F10, GPIO38_MAGICIAN_KEY_CONTACTS, "Contacts button"),
153 INIT_KEY(CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, "Calendar button"),
154 INIT_KEY(CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, "Camera button"),
155 INIT_KEY(UP, GPIO93_MAGICIAN_KEY_UP, "Up button"),
156 INIT_KEY(DOWN, GPIO94_MAGICIAN_KEY_DOWN, "Down button"),
157 INIT_KEY(LEFT, GPIO95_MAGICIAN_KEY_LEFT, "Left button"),
158 INIT_KEY(RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, "Right button"),
159 INIT_KEY(KPENTER, GPIO97_MAGICIAN_KEY_ENTER, "Action button"),
160 INIT_KEY(RECORD, GPIO98_MAGICIAN_KEY_RECORD, "Record button"),
161 INIT_KEY(VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, "Volume up"),
162 INIT_KEY(VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, "Volume down"),
163 INIT_KEY(PHONE, GPIO102_MAGICIAN_KEY_PHONE, "Phone button"),
164 INIT_KEY(PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, "Headset button"),
167 static struct gpio_keys_platform_data gpio_keys_data = {
168 .buttons = magician_button_table,
169 .nbuttons = ARRAY_SIZE(magician_button_table),
172 static struct platform_device gpio_keys = {
175 .platform_data = &gpio_keys_data,
181 * EGPIO (Xilinx CPLD)
183 * 32-bit aligned 8-bit registers
184 * 16 possible registers (reg windows size), only 7 used:
185 * 3x output, 1x irq, 3x input
188 static struct resource egpio_resources[] = {
190 .start = PXA_CS3_PHYS,
191 .end = PXA_CS3_PHYS + 0x20 - 1,
192 .flags = IORESOURCE_MEM,
195 .start = PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ),
196 .end = PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ),
197 .flags = IORESOURCE_IRQ,
201 static struct htc_egpio_chip egpio_chips[] = {
204 .gpio_base = MAGICIAN_EGPIO(0, 0),
206 .direction = HTC_EGPIO_OUTPUT,
208 * Depends on modules configuration
210 .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */
214 .gpio_base = MAGICIAN_EGPIO(4, 0),
216 .direction = HTC_EGPIO_INPUT,
220 static struct htc_egpio_platform_data egpio_info = {
223 .irq_base = IRQ_BOARD_START,
227 .num_chips = ARRAY_SIZE(egpio_chips),
230 static struct platform_device egpio = {
233 .resource = egpio_resources,
234 .num_resources = ARRAY_SIZE(egpio_resources),
236 .platform_data = &egpio_info,
241 * PXAFB LCD - Toppoly TD028STEB1 or Samsung LTP280QV
244 static struct pxafb_mode_info toppoly_modes[] = {
260 static struct pxafb_mode_info samsung_modes[] = {
272 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
276 static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si)
278 pr_debug("Toppoly LCD power: %s\n", on ? "on" : "off");
281 gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1);
282 gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1);
284 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
286 /* FIXME: enable LCDC here */
288 gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1);
290 gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1);
293 gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0);
295 gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0);
297 gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0);
298 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
302 static void samsung_lcd_power(int on, struct fb_var_screeninfo *si)
304 pr_debug("Samsung LCD power: %s\n", on ? "on" : "off");
308 gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1);
310 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
312 gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1);
313 mdelay(6); /* Avdd -> Voff >5ms */
314 gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1);
315 mdelay(16); /* Voff -> Von >(5+10)ms */
316 gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1);
318 gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0);
320 gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0);
322 gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0);
325 gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0);
327 gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
331 static struct pxafb_mach_info toppoly_info = {
332 .modes = toppoly_modes,
335 .lcd_conn = LCD_COLOR_TFT_16BPP,
336 .pxafb_lcd_power = toppoly_lcd_power,
339 static struct pxafb_mach_info samsung_info = {
340 .modes = samsung_modes,
343 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
344 LCD_ALTERNATE_MAPPING,
345 .pxafb_lcd_power = samsung_lcd_power,
352 static struct pwm_lookup magician_pwm_lookup[] = {
353 PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 30923,
354 PWM_POLARITY_NORMAL),
358 * fixed regulator for pwm_backlight
361 static struct regulator_consumer_supply pwm_backlight_supply[] = {
362 REGULATOR_SUPPLY("power", "pwm_backlight"),
366 static struct gpio magician_bl_gpios[] = {
367 { EGPIO_MAGICIAN_BL_POWER, GPIOF_DIR_OUT, "Backlight power" },
368 { EGPIO_MAGICIAN_BL_POWER2, GPIOF_DIR_OUT, "Backlight power 2" },
371 static int magician_backlight_init(struct device *dev)
373 return gpio_request_array(ARRAY_AND_SIZE(magician_bl_gpios));
376 static int magician_backlight_notify(struct device *dev, int brightness)
378 pr_debug("Brightness = %i\n", brightness);
379 gpio_set_value(EGPIO_MAGICIAN_BL_POWER, brightness);
380 if (brightness >= 200) {
381 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1);
382 return brightness - 72;
384 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0);
389 static void magician_backlight_exit(struct device *dev)
391 gpio_free_array(ARRAY_AND_SIZE(magician_bl_gpios));
395 * LCD PWM backlight (main)
397 * MP1521 frequency should be:
398 * 100-400 Hz = 2 .5*10^6 - 10 *10^6 ns
401 static struct platform_pwm_backlight_data backlight_data = {
402 .max_brightness = 272,
403 .dft_brightness = 100,
405 .init = magician_backlight_init,
406 .notify = magician_backlight_notify,
407 .exit = magician_backlight_exit,
410 static struct platform_device backlight = {
411 .name = "pwm-backlight",
414 .parent = &pxa27x_device_pwm0.dev,
415 .platform_data = &backlight_data,
420 * GPIO LEDs, Phone keys backlight, vibra
423 static struct gpio_led gpio_leds[] = {
425 .name = "magician::vibra",
426 .default_trigger = "none",
427 .gpio = GPIO22_MAGICIAN_VIBRA_EN,
430 .name = "magician::phone_bl",
431 .default_trigger = "backlight",
432 .gpio = GPIO103_MAGICIAN_LED_KP,
436 static struct gpio_led_platform_data gpio_led_info = {
438 .num_leds = ARRAY_SIZE(gpio_leds),
441 static struct platform_device leds_gpio = {
445 .platform_data = &gpio_led_info,
453 static struct resource pasic3_resources[] = {
455 .start = PXA_CS2_PHYS,
456 .end = PXA_CS2_PHYS + 0x1b,
457 .flags = IORESOURCE_MEM,
459 /* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */
461 .start = PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ),
462 .end = PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ),
463 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
467 static struct pasic3_platform_data pasic3_platform_data = {
468 .clock_rate = 4000000,
471 static struct platform_device pasic3 = {
474 .num_resources = ARRAY_SIZE(pasic3_resources),
475 .resource = pasic3_resources,
477 .platform_data = &pasic3_platform_data,
485 static void magician_udc_command(int cmd)
487 if (cmd == PXA2XX_UDC_CMD_CONNECT)
488 UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
489 else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
490 UP2OCR &= ~(UP2OCR_DPPUE | UP2OCR_DPPUBE);
493 static struct pxa2xx_udc_mach_info magician_udc_info __initdata = {
494 .udc_command = magician_udc_command,
495 .gpio_pullup = GPIO27_MAGICIAN_USBC_PUEN,
499 * USB device VBus detection
502 static struct resource gpio_vbus_resource = {
503 .flags = IORESOURCE_IRQ,
504 .start = IRQ_MAGICIAN_VBUS,
505 .end = IRQ_MAGICIAN_VBUS,
508 static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
509 .dev_id = "gpio-vbus",
512 * EGPIO on register 4 index 1, the second EGPIO chip
513 * starts at register 4 so this will be at index 1 on that
516 GPIO_LOOKUP("htc-egpio-1", 1,
517 "vbus", GPIO_ACTIVE_HIGH),
518 GPIO_LOOKUP("gpio-pxa", GPIO27_MAGICIAN_USBC_PUEN,
519 "pullup", GPIO_ACTIVE_HIGH),
524 static struct platform_device gpio_vbus = {
528 .resource = &gpio_vbus_resource,
535 static int magician_supply_init(struct device *dev)
539 ret = gpio_request(EGPIO_MAGICIAN_CABLE_TYPE, "Cable is AC charger");
541 pr_err("Cannot request AC/USB charger GPIO (%i)\n", ret);
545 ret = gpio_request(EGPIO_MAGICIAN_CABLE_INSERTED, "Cable inserted");
547 pr_err("Cannot request cable detection GPIO (%i)\n", ret);
554 gpio_free(EGPIO_MAGICIAN_CABLE_TYPE);
559 static void magician_set_charge(int flags)
561 if (flags & PDA_POWER_CHARGE_AC) {
562 pr_debug("Charging from AC\n");
563 gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 1);
564 } else if (flags & PDA_POWER_CHARGE_USB) {
565 pr_debug("Charging from USB\n");
566 gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 1);
568 pr_debug("Charging disabled\n");
569 gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 0);
573 static int magician_is_ac_online(void)
575 return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) &&
576 gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE); /* AC=1 */
579 static int magician_is_usb_online(void)
581 return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) &&
582 (!gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE)); /* USB=0 */
585 static void magician_supply_exit(struct device *dev)
587 gpio_free(EGPIO_MAGICIAN_CABLE_INSERTED);
588 gpio_free(EGPIO_MAGICIAN_CABLE_TYPE);
591 static char *magician_supplicants[] = {
592 "ds2760-battery.0", "backup-battery"
595 static struct pda_power_pdata power_supply_info = {
596 .init = magician_supply_init,
597 .exit = magician_supply_exit,
598 .is_ac_online = magician_is_ac_online,
599 .is_usb_online = magician_is_usb_online,
600 .set_charge = magician_set_charge,
601 .supplied_to = magician_supplicants,
602 .num_supplicants = ARRAY_SIZE(magician_supplicants),
605 static struct resource power_supply_resources[] = {
608 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
609 IORESOURCE_IRQ_LOWEDGE,
610 .start = IRQ_MAGICIAN_VBUS,
611 .end = IRQ_MAGICIAN_VBUS,
615 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
616 IORESOURCE_IRQ_LOWEDGE,
617 .start = IRQ_MAGICIAN_VBUS,
618 .end = IRQ_MAGICIAN_VBUS,
622 static struct platform_device power_supply = {
626 .platform_data = &power_supply_info,
628 .resource = power_supply_resources,
629 .num_resources = ARRAY_SIZE(power_supply_resources),
636 static struct regulator_consumer_supply bq24022_consumers[] = {
637 REGULATOR_SUPPLY("vbus_draw", NULL),
638 REGULATOR_SUPPLY("ac_draw", NULL),
641 static struct regulator_init_data bq24022_init_data = {
644 .valid_ops_mask = REGULATOR_CHANGE_CURRENT |
645 REGULATOR_CHANGE_STATUS,
647 .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers),
648 .consumer_supplies = bq24022_consumers,
652 static enum gpiod_flags bq24022_gpiod_gflags[] = { GPIOD_OUT_LOW };
654 static struct gpio_regulator_state bq24022_states[] = {
655 { .value = 100000, .gpios = (0 << 0) },
656 { .value = 500000, .gpios = (1 << 0) },
659 static struct gpio_regulator_config bq24022_info = {
660 .supply_name = "bq24022",
662 .enabled_at_boot = 1,
664 .gflags = bq24022_gpiod_gflags,
665 .ngpios = ARRAY_SIZE(bq24022_gpiod_gflags),
667 .states = bq24022_states,
668 .nr_states = ARRAY_SIZE(bq24022_states),
670 .type = REGULATOR_CURRENT,
671 .init_data = &bq24022_init_data,
674 static struct platform_device bq24022 = {
675 .name = "gpio-regulator",
678 .platform_data = &bq24022_info,
682 static struct gpiod_lookup_table bq24022_gpiod_table = {
683 .dev_id = "gpio-regulator",
685 GPIO_LOOKUP("gpio-pxa", EGPIO_MAGICIAN_BQ24022_ISET2,
686 NULL, GPIO_ACTIVE_HIGH),
687 GPIO_LOOKUP("gpio-pxa", GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
688 "enable", GPIO_ACTIVE_LOW),
694 * fixed regulator for ads7846
697 static struct regulator_consumer_supply ads7846_supply =
698 REGULATOR_SUPPLY("vcc", "spi2.0");
700 static struct regulator_init_data vads7846_regulator = {
702 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
704 .num_consumer_supplies = 1,
705 .consumer_supplies = &ads7846_supply,
708 static struct fixed_voltage_config vads7846 = {
709 .supply_name = "vads7846",
710 .microvolts = 3300000, /* probably */
712 .init_data = &vads7846_regulator,
715 static struct platform_device vads7846_device = {
716 .name = "reg-fixed-voltage",
719 .platform_data = &vads7846,
724 * Vcore regulator MAX1587A
727 static struct regulator_consumer_supply magician_max1587a_consumers[] = {
728 REGULATOR_SUPPLY("vcc_core", NULL),
731 static struct regulator_init_data magician_max1587a_v3_info = {
733 .name = "vcc_core range",
737 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
739 .consumer_supplies = magician_max1587a_consumers,
740 .num_consumer_supplies = ARRAY_SIZE(magician_max1587a_consumers),
743 static struct max1586_subdev_data magician_max1587a_subdevs[] = {
747 .platform_data = &magician_max1587a_v3_info,
751 static struct max1586_platform_data magician_max1587a_info = {
752 .subdevs = magician_max1587a_subdevs,
753 .num_subdevs = ARRAY_SIZE(magician_max1587a_subdevs),
755 * NOTICE measured directly on the PCB (board_id == 0x3a), but
756 * if R24 is present, it will boost the voltage
757 * (write 1.475V, get 1.645V and smoke)
759 .v3_gain = MAX1586_GAIN_NO_R24,
762 static struct i2c_board_info magician_pwr_i2c_board_info[] __initdata = {
764 I2C_BOARD_INFO("max1586", 0x14),
765 .platform_data = &magician_max1587a_info,
773 static int magician_mci_init(struct device *dev,
774 irq_handler_t detect_irq, void *data)
776 return request_irq(IRQ_MAGICIAN_SD, detect_irq, 0,
777 "mmc card detect", data);
780 static void magician_mci_exit(struct device *dev, void *data)
782 free_irq(IRQ_MAGICIAN_SD, data);
785 static struct pxamci_platform_data magician_mci_info = {
786 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
787 .init = magician_mci_init,
788 .exit = magician_mci_exit,
789 .gpio_card_ro_invert = 1,
793 * Write protect on EGPIO register 5 index 4, this is on the second HTC
794 * EGPIO chip which starts at register 4, so we need offset 8+4=12 on that
797 #define EGPIO_MAGICIAN_nSD_READONLY_OFFSET 12
799 * Power on EGPIO register 2 index 0, so this is on the first HTC EGPIO chip
800 * starting at register 0 so we need offset 2*8+0 = 16 on that chip.
802 #define EGPIO_MAGICIAN_nSD_POWER_OFFSET 16
804 static struct gpiod_lookup_table magician_mci_gpio_table = {
805 .dev_id = "pxa2xx-mci.0",
807 GPIO_LOOKUP("htc-egpio-1", EGPIO_MAGICIAN_nSD_READONLY_OFFSET,
808 "wp", GPIO_ACTIVE_HIGH),
809 GPIO_LOOKUP("htc-egpio-0", EGPIO_MAGICIAN_nSD_POWER_OFFSET,
810 "power", GPIO_ACTIVE_HIGH),
819 static struct pxaohci_platform_data magician_ohci_info = {
820 .port_mode = PMM_PERPORT_MODE,
821 /* port1: CSR Bluetooth, port2: OTG with UDC */
822 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
824 .power_on_delay = 100,
831 static int magician_flash_init(struct platform_device *pdev)
833 int ret = gpio_request(EGPIO_MAGICIAN_FLASH_VPP, "flash Vpp enable");
836 pr_err("Cannot request flash enable GPIO (%i)\n", ret);
840 ret = gpio_direction_output(EGPIO_MAGICIAN_FLASH_VPP, 1);
842 pr_err("Cannot set direction for flash enable (%i)\n", ret);
843 gpio_free(EGPIO_MAGICIAN_FLASH_VPP);
849 static void magician_set_vpp(struct platform_device *pdev, int vpp)
851 gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp);
854 static void magician_flash_exit(struct platform_device *pdev)
856 gpio_free(EGPIO_MAGICIAN_FLASH_VPP);
859 static struct resource strataflash_resource = {
860 .start = PXA_CS0_PHYS,
861 .end = PXA_CS0_PHYS + SZ_64M - 1,
862 .flags = IORESOURCE_MEM,
865 static struct mtd_partition magician_flash_parts[] = {
867 .name = "Bootloader",
870 .mask_flags = MTD_WRITEABLE, /* EXPERIMENTAL */
873 .name = "Linux Kernel",
875 .size = MTDPART_SIZ_FULL,
880 * physmap-flash driver
883 static struct physmap_flash_data strataflash_data = {
885 .init = magician_flash_init,
886 .set_vpp = magician_set_vpp,
887 .exit = magician_flash_exit,
888 .parts = magician_flash_parts,
889 .nr_parts = ARRAY_SIZE(magician_flash_parts),
892 static struct platform_device strataflash = {
893 .name = "physmap-flash",
895 .resource = &strataflash_resource,
898 .platform_data = &strataflash_data,
903 * PXA I2C main controller
906 static struct i2c_pxa_platform_data i2c_info = {
907 /* OV9640 I2C device doesn't support fast mode */
912 * PXA I2C power controller
915 static struct i2c_pxa_platform_data magician_i2c_power_info = {
923 static struct ads7846_platform_data ads7846_pdata = {
927 .pressure_max = 1023, /* with x plate ohms it will overflow 255 */
928 .debounce_max = 3, /* first readout is always bad */
931 .gpio_pendown = GPIO115_MAGICIAN_nPEN_IRQ,
934 .vref_delay_usecs = 100,
935 .penirq_recheck_delay_usecs = 100,
938 struct pxa2xx_spi_chip tsc2046_chip_info = {
942 /* NOTICE must be GPIO, incompatibility with hw PXA SPI framing */
943 .gpio_cs = GPIO14_MAGICIAN_TSC2046_CS,
946 static struct pxa2xx_spi_controller magician_spi_info = {
951 static struct spi_board_info ads7846_spi_board_info[] __initdata = {
953 .modalias = "ads7846",
955 .max_speed_hz = 2500000,
956 .platform_data = &ads7846_pdata,
957 .controller_data = &tsc2046_chip_info,
958 .irq = PXA_GPIO_TO_IRQ(GPIO115_MAGICIAN_nPEN_IRQ),
966 static struct platform_device *devices[] __initdata = {
979 static struct gpio magician_global_gpios[] = {
980 { GPIO13_MAGICIAN_CPLD_IRQ, GPIOF_IN, "CPLD_IRQ" },
981 { GPIO107_MAGICIAN_DS1WM_IRQ, GPIOF_IN, "DS1WM_IRQ" },
983 /* NOTICE valid LCD init sequence */
984 { GPIO106_MAGICIAN_LCD_DCDC_NRESET, GPIOF_OUT_INIT_LOW, "LCD DCDC nreset" },
985 { GPIO104_MAGICIAN_LCD_VOFF_EN, GPIOF_OUT_INIT_LOW, "LCD VOFF enable" },
986 { GPIO105_MAGICIAN_LCD_VON_EN, GPIOF_OUT_INIT_LOW, "LCD VON enable" },
989 static void __init magician_init(void)
995 pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config));
996 err = gpio_request_array(ARRAY_AND_SIZE(magician_global_gpios));
998 pr_err("magician: Failed to request global GPIOs: %d\n", err);
1000 pxa_set_ffuart_info(NULL);
1001 pxa_set_btuart_info(NULL);
1003 pwm_add_table(magician_pwm_lookup, ARRAY_SIZE(magician_pwm_lookup));
1005 pxa_set_ficp_info(&magician_ficp_info);
1006 pxa27x_set_i2c_power_info(&magician_i2c_power_info);
1007 pxa_set_i2c_info(&i2c_info);
1009 i2c_register_board_info(1,
1010 ARRAY_AND_SIZE(magician_pwr_i2c_board_info));
1012 gpiod_add_lookup_table(&magician_mci_gpio_table);
1013 pxa_set_mci_info(&magician_mci_info);
1014 pxa_set_ohci_info(&magician_ohci_info);
1015 pxa_set_udc_info(&magician_udc_info);
1017 /* Check LCD type we have */
1018 cpld = ioremap(PXA_CS3_PHYS, 0x1000);
1020 u8 board_id = __raw_readb(cpld + 0x14);
1023 system_rev = board_id & 0x7;
1024 lcd_select = board_id & 0x8;
1025 pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly");
1026 if (lcd_select && (system_rev < 3))
1027 /* NOTICE valid LCD init sequence */
1028 gpio_request_one(GPIO75_MAGICIAN_SAMSUNG_POWER,
1029 GPIOF_OUT_INIT_LOW, "Samsung LCD Power");
1030 pxa_set_fb_info(NULL,
1031 lcd_select ? &samsung_info : &toppoly_info);
1033 pr_err("LCD detection: CPLD mapping failed\n");
1035 pxa2xx_set_spi_info(2, &magician_spi_info);
1036 spi_register_board_info(ARRAY_AND_SIZE(ads7846_spi_board_info));
1038 regulator_register_always_on(0, "power", pwm_backlight_supply,
1039 ARRAY_SIZE(pwm_backlight_supply), 5000000);
1041 gpiod_add_lookup_table(&bq24022_gpiod_table);
1042 gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
1043 platform_add_devices(ARRAY_AND_SIZE(devices));
1046 MACHINE_START(MAGICIAN, "HTC Magician")
1047 .atag_offset = 0x100,
1048 .map_io = pxa27x_map_io,
1049 .nr_irqs = MAGICIAN_NR_IRQS,
1050 .init_irq = pxa27x_init_irq,
1051 .handle_irq = pxa27x_handle_irq,
1052 .init_machine = magician_init,
1053 .init_time = pxa_timer_init,
1054 .restart = pxa_restart,