Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 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> |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 19 | #include <linux/delay.h> |
Philipp Zabel | e181191 | 2008-06-22 13:00:55 +0100 | [diff] [blame] | 20 | #include <linux/gpio.h> |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 21 | #include <linux/gpio_keys.h> |
| 22 | #include <linux/input.h> |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 23 | #include <linux/mfd/htc-pasic3.h> |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 24 | #include <linux/mtd/physmap.h> |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 25 | #include <linux/pda_power.h> |
Linus Walleij | 3c6e8d0 | 2016-09-16 13:48:12 +0200 | [diff] [blame] | 26 | #include <linux/platform_data/gpio-htc-egpio.h> |
Thierry Reding | bd3208b | 2015-10-05 10:49:46 +0200 | [diff] [blame] | 27 | #include <linux/pwm.h> |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 28 | #include <linux/pwm_backlight.h> |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 29 | #include <linux/regulator/driver.h> |
Petr Cvek | e2f1b8b | 2015-09-28 23:40:57 +0200 | [diff] [blame] | 30 | #include <linux/regulator/fixed.h> |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 31 | #include <linux/regulator/gpio-regulator.h> |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 32 | #include <linux/regulator/machine.h> |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 33 | #include <linux/usb/gpio_vbus.h> |
Sebastian Andrzej Siewior | b459396 | 2011-02-23 12:38:16 +0100 | [diff] [blame] | 34 | #include <linux/i2c/pxa-i2c.h> |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 35 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 36 | #include <mach/hardware.h> |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 37 | #include <asm/mach-types.h> |
| 38 | #include <asm/mach/arch.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 39 | #include <asm/system_info.h> |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 40 | |
Arnd Bergmann | 4c25c5d | 2015-01-30 10:45:33 +0100 | [diff] [blame] | 41 | #include "pxa27x.h" |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 42 | #include <mach/magician.h> |
Arnd Bergmann | 293b2da | 2012-08-24 15:16:48 +0200 | [diff] [blame] | 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> |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 47 | |
Petr Cvek | ff5eff3 | 2015-09-28 23:39:03 +0200 | [diff] [blame] | 48 | #include <linux/regulator/max1586.h> |
| 49 | |
Petr Cvek | 31134b5 | 2015-09-28 23:39:33 +0200 | [diff] [blame] | 50 | #include <linux/platform_data/pxa2xx_udc.h> |
Petr Cvek | 31134b5 | 2015-09-28 23:39:33 +0200 | [diff] [blame] | 51 | |
Arnd Bergmann | 4c25c5d | 2015-01-30 10:45:33 +0100 | [diff] [blame] | 52 | #include "udc.h" |
| 53 | #include "pxa27x-udc.h" |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 54 | #include "devices.h" |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 55 | #include "generic.h" |
| 56 | |
Petr Cvek | 7ade445 | 2017-03-13 09:05:49 +0100 | [diff] [blame] | 57 | #include <linux/spi/spi.h> |
| 58 | #include <linux/spi/pxa2xx_spi.h> |
| 59 | #include <linux/spi/ads7846.h> |
| 60 | |
Philipp Zabel | 7a97010 | 2008-06-26 21:03:54 +0100 | [diff] [blame] | 61 | static unsigned long magician_pin_config[] __initdata = { |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 62 | |
| 63 | /* SDRAM and Static Memory I/O Signals */ |
| 64 | GPIO20_nSDCS_2, |
| 65 | GPIO21_nSDCS_3, |
| 66 | GPIO15_nCS_1, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 67 | GPIO78_nCS_2, /* PASIC3 */ |
| 68 | GPIO79_nCS_3, /* EGPIO CPLD */ |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 69 | GPIO80_nCS_4, |
| 70 | GPIO33_nCS_5, |
| 71 | |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 72 | /* I2C UDA1380 + OV9640 */ |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 73 | GPIO117_I2C_SCL, |
| 74 | GPIO118_I2C_SDA, |
| 75 | |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 76 | /* PWM 0 - LCD backlight */ |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 77 | GPIO16_PWM0_OUT, |
| 78 | |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 79 | /* I2S UDA1380 capture */ |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 80 | GPIO28_I2S_BITCLK_OUT, |
| 81 | GPIO29_I2S_SDATA_IN, |
| 82 | GPIO31_I2S_SYNC, |
| 83 | GPIO113_I2S_SYSCLK, |
| 84 | |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 85 | /* SSP 1 UDA1380 playback */ |
Philipp Zabel | 16c3ea4 | 2009-01-17 18:45:41 +0100 | [diff] [blame] | 86 | GPIO23_SSP1_SCLK, |
| 87 | GPIO24_SSP1_SFRM, |
| 88 | GPIO25_SSP1_TXD, |
| 89 | |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 90 | /* SSP 2 TSC2046 touchscreen */ |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 91 | GPIO19_SSP2_SCLK, |
Petr Cvek | 7ade445 | 2017-03-13 09:05:49 +0100 | [diff] [blame] | 92 | MFP_CFG_OUT(GPIO14, AF0, DRIVE_HIGH), /* frame as GPIO */ |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 93 | GPIO89_SSP2_TXD, |
| 94 | GPIO88_SSP2_RXD, |
| 95 | |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 96 | /* MMC/SD/SDHC slot */ |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 97 | GPIO32_MMC_CLK, |
| 98 | GPIO92_MMC_DAT_0, |
| 99 | GPIO109_MMC_DAT_1, |
| 100 | GPIO110_MMC_DAT_2, |
| 101 | GPIO111_MMC_DAT_3, |
| 102 | GPIO112_MMC_CMD, |
| 103 | |
| 104 | /* LCD */ |
Eric Miao | bedbda9 | 2010-01-04 11:37:14 +0800 | [diff] [blame] | 105 | GPIOxx_LCD_TFT_16BPP, |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 106 | |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 107 | /* QCI camera interface */ |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 108 | GPIO12_CIF_DD_7, |
| 109 | GPIO17_CIF_DD_6, |
| 110 | GPIO50_CIF_DD_3, |
| 111 | GPIO51_CIF_DD_2, |
| 112 | GPIO52_CIF_DD_4, |
| 113 | GPIO53_CIF_MCLK, |
| 114 | GPIO54_CIF_PCLK, |
| 115 | GPIO55_CIF_DD_1, |
| 116 | GPIO81_CIF_DD_0, |
| 117 | GPIO82_CIF_DD_5, |
| 118 | GPIO84_CIF_FV, |
| 119 | GPIO85_CIF_LV, |
Philipp Zabel | 2f13195 | 2008-04-20 17:40:11 +0100 | [diff] [blame] | 120 | |
| 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 */ |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 128 | }; |
| 129 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 130 | /* |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 131 | * IrDA |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 132 | */ |
| 133 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 134 | static struct pxaficp_platform_data magician_ficp_info = { |
Marek Vasut | c4bd017 | 2009-07-17 12:50:43 +0200 | [diff] [blame] | 135 | .gpio_pwdown = GPIO83_MAGICIAN_nIR_EN, |
| 136 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
Petr Cvek | 0f073e3 | 2015-09-28 23:34:18 +0200 | [diff] [blame] | 137 | .gpio_pwdown_inverted = 0, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | /* |
| 141 | * GPIO Keys |
| 142 | */ |
| 143 | |
Philipp Zabel | 51c10bb | 2009-01-17 18:45:44 +0100 | [diff] [blame] | 144 | #define INIT_KEY(_code, _gpio, _desc) \ |
| 145 | { \ |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 146 | .code = KEY_##_code, \ |
| 147 | .gpio = _gpio, \ |
| 148 | .desc = _desc, \ |
| 149 | .type = EV_KEY, \ |
| 150 | .wakeup = 1, \ |
Philipp Zabel | 51c10bb | 2009-01-17 18:45:44 +0100 | [diff] [blame] | 151 | } |
| 152 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 153 | static struct gpio_keys_button magician_button_table[] = { |
Philipp Zabel | 51c10bb | 2009-01-17 18:45:44 +0100 | [diff] [blame] | 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"), |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | static struct gpio_keys_platform_data gpio_keys_data = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 172 | .buttons = magician_button_table, |
| 173 | .nbuttons = ARRAY_SIZE(magician_button_table), |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | static struct platform_device gpio_keys = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 177 | .name = "gpio-keys", |
| 178 | .dev = { |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 179 | .platform_data = &gpio_keys_data, |
| 180 | }, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 181 | .id = -1, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 182 | }; |
| 183 | |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 184 | /* |
| 185 | * EGPIO (Xilinx CPLD) |
| 186 | * |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 187 | * 32-bit aligned 8-bit registers |
| 188 | * 16 possible registers (reg windows size), only 7 used: |
| 189 | * 3x output, 1x irq, 3x input |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 190 | */ |
| 191 | |
| 192 | static struct resource egpio_resources[] = { |
| 193 | [0] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 194 | .start = PXA_CS3_PHYS, |
| 195 | .end = PXA_CS3_PHYS + 0x20 - 1, |
| 196 | .flags = IORESOURCE_MEM, |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 197 | }, |
| 198 | [1] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 199 | .start = PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ), |
| 200 | .end = PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ), |
| 201 | .flags = IORESOURCE_IRQ, |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 202 | }, |
| 203 | }; |
| 204 | |
| 205 | static struct htc_egpio_chip egpio_chips[] = { |
| 206 | [0] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 207 | .reg_start = 0, |
| 208 | .gpio_base = MAGICIAN_EGPIO(0, 0), |
| 209 | .num_gpios = 24, |
| 210 | .direction = HTC_EGPIO_OUTPUT, |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 211 | /* |
| 212 | * Depends on modules configuration |
| 213 | */ |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 214 | .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */ |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 215 | }, |
| 216 | [1] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 217 | .reg_start = 4, |
| 218 | .gpio_base = MAGICIAN_EGPIO(4, 0), |
| 219 | .num_gpios = 24, |
| 220 | .direction = HTC_EGPIO_INPUT, |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 221 | }, |
| 222 | }; |
| 223 | |
| 224 | static struct htc_egpio_platform_data egpio_info = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 225 | .reg_width = 8, |
| 226 | .bus_width = 32, |
| 227 | .irq_base = IRQ_BOARD_START, |
| 228 | .num_irqs = 4, |
| 229 | .ack_register = 3, |
| 230 | .chip = egpio_chips, |
| 231 | .num_chips = ARRAY_SIZE(egpio_chips), |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 232 | }; |
| 233 | |
| 234 | static struct platform_device egpio = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 235 | .name = "htc-egpio", |
| 236 | .id = -1, |
| 237 | .resource = egpio_resources, |
| 238 | .num_resources = ARRAY_SIZE(egpio_resources), |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 239 | .dev = { |
| 240 | .platform_data = &egpio_info, |
| 241 | }, |
| 242 | }; |
| 243 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 244 | /* |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 245 | * PXAFB LCD - Toppoly TD028STEB1 or Samsung LTP280QV |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 246 | */ |
| 247 | |
| 248 | static struct pxafb_mode_info toppoly_modes[] = { |
| 249 | { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 250 | .pixclock = 96153, |
| 251 | .bpp = 16, |
| 252 | .xres = 240, |
| 253 | .yres = 320, |
| 254 | .hsync_len = 11, |
| 255 | .vsync_len = 3, |
| 256 | .left_margin = 19, |
| 257 | .upper_margin = 2, |
| 258 | .right_margin = 10, |
| 259 | .lower_margin = 2, |
| 260 | .sync = 0, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 261 | }, |
| 262 | }; |
| 263 | |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 264 | static struct pxafb_mode_info samsung_modes[] = { |
| 265 | { |
Petr Cvek | e7b97a4 | 2015-09-28 23:32:12 +0200 | [diff] [blame] | 266 | .pixclock = 226469, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 267 | .bpp = 16, |
| 268 | .xres = 240, |
| 269 | .yres = 320, |
| 270 | .hsync_len = 8, |
| 271 | .vsync_len = 4, |
| 272 | .left_margin = 9, |
| 273 | .upper_margin = 4, |
| 274 | .right_margin = 9, |
| 275 | .lower_margin = 4, |
| 276 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 277 | }, |
| 278 | }; |
| 279 | |
| 280 | static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si) |
| 281 | { |
Petr Cvek | dedad4d | 2015-09-28 23:11:11 +0200 | [diff] [blame] | 282 | pr_debug("Toppoly LCD power: %s\n", on ? "on" : "off"); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 283 | |
| 284 | if (on) { |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 285 | gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1); |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 286 | gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 287 | udelay(2000); |
| 288 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); |
| 289 | udelay(2000); |
| 290 | /* FIXME: enable LCDC here */ |
| 291 | udelay(2000); |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 292 | gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 293 | udelay(2000); |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 294 | gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 295 | } else { |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 296 | msleep(15); |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 297 | gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 298 | udelay(500); |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 299 | gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 300 | udelay(1000); |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 301 | gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 302 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | static void samsung_lcd_power(int on, struct fb_var_screeninfo *si) |
| 307 | { |
Petr Cvek | dedad4d | 2015-09-28 23:11:11 +0200 | [diff] [blame] | 308 | pr_debug("Samsung LCD power: %s\n", on ? "on" : "off"); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 309 | |
| 310 | if (on) { |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 311 | if (system_rev < 3) |
| 312 | gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1); |
| 313 | else |
| 314 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); |
Petr Cvek | fa5407a | 2015-09-28 23:16:14 +0200 | [diff] [blame] | 315 | mdelay(6); |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 316 | gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1); |
Petr Cvek | fa5407a | 2015-09-28 23:16:14 +0200 | [diff] [blame] | 317 | mdelay(6); /* Avdd -> Voff >5ms */ |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 318 | gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1); |
Petr Cvek | fa5407a | 2015-09-28 23:16:14 +0200 | [diff] [blame] | 319 | mdelay(16); /* Voff -> Von >(5+10)ms */ |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 320 | gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 321 | } else { |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 322 | gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0); |
Petr Cvek | fa5407a | 2015-09-28 23:16:14 +0200 | [diff] [blame] | 323 | mdelay(16); |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 324 | gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0); |
Petr Cvek | fa5407a | 2015-09-28 23:16:14 +0200 | [diff] [blame] | 325 | mdelay(6); |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 326 | gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0); |
Petr Cvek | fa5407a | 2015-09-28 23:16:14 +0200 | [diff] [blame] | 327 | mdelay(6); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 328 | if (system_rev < 3) |
| 329 | gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0); |
| 330 | else |
| 331 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); |
| 332 | } |
| 333 | } |
| 334 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 335 | static struct pxafb_mach_info toppoly_info = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 336 | .modes = toppoly_modes, |
| 337 | .num_modes = 1, |
| 338 | .fixed_modes = 1, |
| 339 | .lcd_conn = LCD_COLOR_TFT_16BPP, |
| 340 | .pxafb_lcd_power = toppoly_lcd_power, |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 341 | }; |
| 342 | |
| 343 | static struct pxafb_mach_info samsung_info = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 344 | .modes = samsung_modes, |
| 345 | .num_modes = 1, |
| 346 | .fixed_modes = 1, |
| 347 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL | |
| 348 | LCD_ALTERNATE_MAPPING, |
| 349 | .pxafb_lcd_power = samsung_lcd_power, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 350 | }; |
| 351 | |
| 352 | /* |
| 353 | * Backlight |
| 354 | */ |
| 355 | |
Thierry Reding | bd3208b | 2015-10-05 10:49:46 +0200 | [diff] [blame] | 356 | static struct pwm_lookup magician_pwm_lookup[] = { |
| 357 | PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 30923, |
| 358 | PWM_POLARITY_NORMAL), |
| 359 | }; |
| 360 | |
Petr Cvek | e2f1b8b | 2015-09-28 23:40:57 +0200 | [diff] [blame] | 361 | /* |
| 362 | * fixed regulator for pwm_backlight |
| 363 | */ |
| 364 | |
| 365 | static struct regulator_consumer_supply pwm_backlight_supply[] = { |
| 366 | REGULATOR_SUPPLY("power", "pwm_backlight"), |
| 367 | }; |
| 368 | |
| 369 | |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 370 | static struct gpio magician_bl_gpios[] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 371 | { EGPIO_MAGICIAN_BL_POWER, GPIOF_DIR_OUT, "Backlight power" }, |
| 372 | { EGPIO_MAGICIAN_BL_POWER2, GPIOF_DIR_OUT, "Backlight power 2" }, |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 373 | }; |
| 374 | |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 375 | static int magician_backlight_init(struct device *dev) |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 376 | { |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 377 | return gpio_request_array(ARRAY_AND_SIZE(magician_bl_gpios)); |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 378 | } |
| 379 | |
Eric Miao | 2d51a52 | 2010-01-04 11:42:01 +0800 | [diff] [blame] | 380 | static int magician_backlight_notify(struct device *dev, int brightness) |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 381 | { |
Petr Cvek | 539122a | 2015-09-28 23:40:44 +0200 | [diff] [blame] | 382 | pr_debug("Brightness = %i\n", brightness); |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 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; |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 387 | } else { |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 388 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0); |
| 389 | return brightness; |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 393 | static void magician_backlight_exit(struct device *dev) |
| 394 | { |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 395 | gpio_free_array(ARRAY_AND_SIZE(magician_bl_gpios)); |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 396 | } |
| 397 | |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 398 | /* |
| 399 | * LCD PWM backlight (main) |
| 400 | * |
| 401 | * MP1521 frequency should be: |
| 402 | * 100-400 Hz = 2 .5*10^6 - 10 *10^6 ns |
| 403 | */ |
| 404 | |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 405 | static struct platform_pwm_backlight_data backlight_data = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 406 | .max_brightness = 272, |
| 407 | .dft_brightness = 100, |
| 408 | .enable_gpio = -1, |
| 409 | .init = magician_backlight_init, |
| 410 | .notify = magician_backlight_notify, |
| 411 | .exit = magician_backlight_exit, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 412 | }; |
| 413 | |
| 414 | static struct platform_device backlight = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 415 | .name = "pwm-backlight", |
| 416 | .id = -1, |
| 417 | .dev = { |
| 418 | .parent = &pxa27x_device_pwm0.dev, |
| 419 | .platform_data = &backlight_data, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 420 | }, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 421 | }; |
| 422 | |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 423 | /* |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 424 | * GPIO LEDs, Phone keys backlight, vibra |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 425 | */ |
| 426 | |
Russell King | a55faca | 2008-09-25 14:35:48 +0100 | [diff] [blame] | 427 | static struct gpio_led gpio_leds[] = { |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 428 | { |
| 429 | .name = "magician::vibra", |
| 430 | .default_trigger = "none", |
| 431 | .gpio = GPIO22_MAGICIAN_VIBRA_EN, |
| 432 | }, |
| 433 | { |
| 434 | .name = "magician::phone_bl", |
Philipp Zabel | 05199ec | 2009-02-09 17:34:08 +0100 | [diff] [blame] | 435 | .default_trigger = "backlight", |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 436 | .gpio = GPIO103_MAGICIAN_LED_KP, |
| 437 | }, |
| 438 | }; |
| 439 | |
| 440 | static struct gpio_led_platform_data gpio_led_info = { |
| 441 | .leds = gpio_leds, |
| 442 | .num_leds = ARRAY_SIZE(gpio_leds), |
| 443 | }; |
| 444 | |
| 445 | static struct platform_device leds_gpio = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 446 | .name = "leds-gpio", |
| 447 | .id = -1, |
| 448 | .dev = { |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 449 | .platform_data = &gpio_led_info, |
| 450 | }, |
| 451 | }; |
| 452 | |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 453 | /* |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 454 | * PASIC3 with DS1WM |
| 455 | */ |
| 456 | |
| 457 | static struct resource pasic3_resources[] = { |
| 458 | [0] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 459 | .start = PXA_CS2_PHYS, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 460 | .end = PXA_CS2_PHYS + 0x1b, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 461 | .flags = IORESOURCE_MEM, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 462 | }, |
| 463 | /* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */ |
| 464 | [1] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 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, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 468 | } |
| 469 | }; |
| 470 | |
| 471 | static struct pasic3_platform_data pasic3_platform_data = { |
Petr Cvek | 28496be | 2015-09-28 23:39:51 +0200 | [diff] [blame] | 472 | .clock_rate = 4000000, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 473 | }; |
| 474 | |
| 475 | static struct platform_device pasic3 = { |
| 476 | .name = "pasic3", |
| 477 | .id = -1, |
| 478 | .num_resources = ARRAY_SIZE(pasic3_resources), |
| 479 | .resource = pasic3_resources, |
| 480 | .dev = { |
| 481 | .platform_data = &pasic3_platform_data, |
| 482 | }, |
| 483 | }; |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 484 | |
| 485 | /* |
Petr Cvek | 31134b5 | 2015-09-28 23:39:33 +0200 | [diff] [blame] | 486 | * PXA UDC |
| 487 | */ |
| 488 | |
| 489 | static void magician_udc_command(int cmd) |
| 490 | { |
| 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); |
| 495 | } |
| 496 | |
| 497 | static struct pxa2xx_udc_mach_info magician_udc_info __initdata = { |
| 498 | .udc_command = magician_udc_command, |
| 499 | .gpio_pullup = GPIO27_MAGICIAN_USBC_PUEN, |
| 500 | }; |
| 501 | |
| 502 | /* |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 503 | * USB device VBus detection |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 504 | */ |
| 505 | |
| 506 | static struct resource gpio_vbus_resource = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 507 | .flags = IORESOURCE_IRQ, |
| 508 | .start = IRQ_MAGICIAN_VBUS, |
| 509 | .end = IRQ_MAGICIAN_VBUS, |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 510 | }; |
| 511 | |
| 512 | static struct gpio_vbus_mach_info gpio_vbus_info = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 513 | .gpio_pullup = GPIO27_MAGICIAN_USBC_PUEN, |
Petr Cvek | f78b3a1 | 2015-09-28 23:32:40 +0200 | [diff] [blame] | 514 | .gpio_vbus = EGPIO_MAGICIAN_CABLE_VBUS, |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 515 | }; |
| 516 | |
| 517 | static struct platform_device gpio_vbus = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 518 | .name = "gpio-vbus", |
| 519 | .id = -1, |
| 520 | .num_resources = 1, |
| 521 | .resource = &gpio_vbus_resource, |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 522 | .dev = { |
| 523 | .platform_data = &gpio_vbus_info, |
| 524 | }, |
| 525 | }; |
| 526 | |
| 527 | /* |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 528 | * External power |
| 529 | */ |
| 530 | |
Petr Cvek | eac2eac | 2015-09-28 23:33:02 +0200 | [diff] [blame] | 531 | static int magician_supply_init(struct device *dev) |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 532 | { |
Petr Cvek | eac2eac | 2015-09-28 23:33:02 +0200 | [diff] [blame] | 533 | int ret = -1; |
| 534 | |
| 535 | ret = gpio_request(EGPIO_MAGICIAN_CABLE_TYPE, "Cable is AC charger"); |
| 536 | if (ret) { |
| 537 | pr_err("Cannot request AC/USB charger GPIO (%i)\n", ret); |
| 538 | goto err_ac; |
| 539 | } |
| 540 | |
| 541 | ret = gpio_request(EGPIO_MAGICIAN_CABLE_INSERTED, "Cable inserted"); |
| 542 | if (ret) { |
| 543 | pr_err("Cannot request cable detection GPIO (%i)\n", ret); |
| 544 | goto err_usb; |
| 545 | } |
| 546 | |
| 547 | return 0; |
| 548 | |
| 549 | err_usb: |
| 550 | gpio_free(EGPIO_MAGICIAN_CABLE_TYPE); |
| 551 | err_ac: |
| 552 | return ret; |
| 553 | } |
| 554 | |
| 555 | static void magician_set_charge(int flags) |
| 556 | { |
| 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); |
| 563 | } else { |
| 564 | pr_debug("Charging disabled\n"); |
| 565 | gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 0); |
| 566 | } |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 567 | } |
| 568 | |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 569 | static int magician_is_ac_online(void) |
| 570 | { |
Petr Cvek | eac2eac | 2015-09-28 23:33:02 +0200 | [diff] [blame] | 571 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) && |
| 572 | gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE); /* AC=1 */ |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 573 | } |
| 574 | |
Petr Cvek | eac2eac | 2015-09-28 23:33:02 +0200 | [diff] [blame] | 575 | static int magician_is_usb_online(void) |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 576 | { |
Petr Cvek | eac2eac | 2015-09-28 23:33:02 +0200 | [diff] [blame] | 577 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) && |
| 578 | (!gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE)); /* USB=0 */ |
| 579 | } |
| 580 | |
| 581 | static void magician_supply_exit(struct device *dev) |
| 582 | { |
| 583 | gpio_free(EGPIO_MAGICIAN_CABLE_INSERTED); |
Petr Cvek | f78b3a1 | 2015-09-28 23:32:40 +0200 | [diff] [blame] | 584 | gpio_free(EGPIO_MAGICIAN_CABLE_TYPE); |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 585 | } |
| 586 | |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 587 | static char *magician_supplicants[] = { |
| 588 | "ds2760-battery.0", "backup-battery" |
| 589 | }; |
| 590 | |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 591 | static struct pda_power_pdata power_supply_info = { |
Petr Cvek | eac2eac | 2015-09-28 23:33:02 +0200 | [diff] [blame] | 592 | .init = magician_supply_init, |
| 593 | .exit = magician_supply_exit, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 594 | .is_ac_online = magician_is_ac_online, |
Petr Cvek | eac2eac | 2015-09-28 23:33:02 +0200 | [diff] [blame] | 595 | .is_usb_online = magician_is_usb_online, |
| 596 | .set_charge = magician_set_charge, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 597 | .supplied_to = magician_supplicants, |
| 598 | .num_supplicants = ARRAY_SIZE(magician_supplicants), |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 599 | }; |
| 600 | |
| 601 | static struct resource power_supply_resources[] = { |
| 602 | [0] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 603 | .name = "ac", |
| 604 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | |
| 605 | IORESOURCE_IRQ_LOWEDGE, |
| 606 | .start = IRQ_MAGICIAN_VBUS, |
| 607 | .end = IRQ_MAGICIAN_VBUS, |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 608 | }, |
| 609 | [1] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 610 | .name = "usb", |
| 611 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | |
| 612 | IORESOURCE_IRQ_LOWEDGE, |
| 613 | .start = IRQ_MAGICIAN_VBUS, |
| 614 | .end = IRQ_MAGICIAN_VBUS, |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 615 | }, |
| 616 | }; |
| 617 | |
| 618 | static struct platform_device power_supply = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 619 | .name = "pda-power", |
| 620 | .id = -1, |
| 621 | .dev = { |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 622 | .platform_data = &power_supply_info, |
| 623 | }, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 624 | .resource = power_supply_resources, |
| 625 | .num_resources = ARRAY_SIZE(power_supply_resources), |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 626 | }; |
| 627 | |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 628 | /* |
| 629 | * Battery charger |
| 630 | */ |
| 631 | |
| 632 | static struct regulator_consumer_supply bq24022_consumers[] = { |
Axel Lin | 0bf189a | 2012-05-08 16:25:10 +0800 | [diff] [blame] | 633 | REGULATOR_SUPPLY("vbus_draw", NULL), |
| 634 | REGULATOR_SUPPLY("ac_draw", NULL), |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 635 | }; |
| 636 | |
| 637 | static struct regulator_init_data bq24022_init_data = { |
| 638 | .constraints = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 639 | .max_uA = 500000, |
| 640 | .valid_ops_mask = REGULATOR_CHANGE_CURRENT | |
| 641 | REGULATOR_CHANGE_STATUS, |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 642 | }, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 643 | .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers), |
| 644 | .consumer_supplies = bq24022_consumers, |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 645 | }; |
| 646 | |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 647 | static struct gpio bq24022_gpios[] = { |
| 648 | { EGPIO_MAGICIAN_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" }, |
| 649 | }; |
| 650 | |
| 651 | static struct gpio_regulator_state bq24022_states[] = { |
| 652 | { .value = 100000, .gpios = (0 << 0) }, |
| 653 | { .value = 500000, .gpios = (1 << 0) }, |
| 654 | }; |
| 655 | |
| 656 | static struct gpio_regulator_config bq24022_info = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 657 | .supply_name = "bq24022", |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 658 | |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 659 | .enable_gpio = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, |
| 660 | .enable_high = 0, |
Petr Cvek | eac2eac | 2015-09-28 23:33:02 +0200 | [diff] [blame] | 661 | .enabled_at_boot = 1, |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 662 | |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 663 | .gpios = bq24022_gpios, |
| 664 | .nr_gpios = ARRAY_SIZE(bq24022_gpios), |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 665 | |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 666 | .states = bq24022_states, |
| 667 | .nr_states = ARRAY_SIZE(bq24022_states), |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 668 | |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 669 | .type = REGULATOR_CURRENT, |
| 670 | .init_data = &bq24022_init_data, |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 671 | }; |
| 672 | |
| 673 | static struct platform_device bq24022 = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 674 | .name = "gpio-regulator", |
| 675 | .id = -1, |
| 676 | .dev = { |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 677 | .platform_data = &bq24022_info, |
| 678 | }, |
| 679 | }; |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 680 | |
| 681 | /* |
Petr Cvek | 7ade445 | 2017-03-13 09:05:49 +0100 | [diff] [blame] | 682 | * fixed regulator for ads7846 |
| 683 | */ |
| 684 | |
| 685 | static struct regulator_consumer_supply ads7846_supply = |
| 686 | REGULATOR_SUPPLY("vcc", "spi2.0"); |
| 687 | |
| 688 | static struct regulator_init_data vads7846_regulator = { |
| 689 | .constraints = { |
| 690 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, |
| 691 | }, |
| 692 | .num_consumer_supplies = 1, |
| 693 | .consumer_supplies = &ads7846_supply, |
| 694 | }; |
| 695 | |
| 696 | static struct fixed_voltage_config vads7846 = { |
| 697 | .supply_name = "vads7846", |
| 698 | .microvolts = 3300000, /* probably */ |
| 699 | .gpio = -EINVAL, |
| 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 | |
| 712 | /* |
Petr Cvek | ff5eff3 | 2015-09-28 23:39:03 +0200 | [diff] [blame] | 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 | |
| 758 | /* |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 759 | * MMC/SD |
| 760 | */ |
| 761 | |
| 762 | static int magician_mci_init(struct device *dev, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 763 | irq_handler_t detect_irq, void *data) |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 764 | { |
Michael Opdenacker | ed7936f | 2013-12-09 11:22:22 +0100 | [diff] [blame] | 765 | return request_irq(IRQ_MAGICIAN_SD, detect_irq, 0, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 766 | "mmc card detect", data); |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 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 = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 775 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 776 | .init = magician_mci_init, |
| 777 | .exit = magician_mci_exit, |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 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, |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 782 | }; |
| 783 | |
| 784 | |
| 785 | /* |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 786 | * USB OHCI |
| 787 | */ |
| 788 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 789 | static struct pxaohci_platform_data magician_ohci_info = { |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 790 | .port_mode = PMM_PERPORT_MODE, |
Petr Cvek | 2eb7414 | 2015-09-28 23:38:03 +0200 | [diff] [blame] | 791 | /* port1: CSR Bluetooth, port2: OTG with UDC */ |
| 792 | .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW, |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 793 | .power_budget = 0, |
Petr Cvek | 2eb7414 | 2015-09-28 23:38:03 +0200 | [diff] [blame] | 794 | .power_on_delay = 100, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 795 | }; |
| 796 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 797 | /* |
| 798 | * StrataFlash |
| 799 | */ |
| 800 | |
Petr Cvek | fdb902b6 | 2015-09-28 23:34:39 +0200 | [diff] [blame] | 801 | static int magician_flash_init(struct platform_device *pdev) |
| 802 | { |
| 803 | int ret = gpio_request(EGPIO_MAGICIAN_FLASH_VPP, "flash Vpp enable"); |
| 804 | |
| 805 | if (ret) { |
| 806 | pr_err("Cannot request flash enable GPIO (%i)\n", ret); |
| 807 | return ret; |
| 808 | } |
| 809 | |
| 810 | ret = gpio_direction_output(EGPIO_MAGICIAN_FLASH_VPP, 1); |
| 811 | if (ret) { |
| 812 | pr_err("Cannot set direction for flash enable (%i)\n", ret); |
| 813 | gpio_free(EGPIO_MAGICIAN_FLASH_VPP); |
| 814 | } |
| 815 | |
| 816 | return ret; |
| 817 | } |
| 818 | |
Marc Zyngier | 667f390 | 2011-05-18 10:51:55 +0100 | [diff] [blame] | 819 | static void magician_set_vpp(struct platform_device *pdev, int vpp) |
Philipp Zabel | aa79759 | 2008-04-09 19:24:05 +0100 | [diff] [blame] | 820 | { |
| 821 | gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp); |
| 822 | } |
| 823 | |
Petr Cvek | fdb902b6 | 2015-09-28 23:34:39 +0200 | [diff] [blame] | 824 | static void magician_flash_exit(struct platform_device *pdev) |
| 825 | { |
| 826 | gpio_free(EGPIO_MAGICIAN_FLASH_VPP); |
| 827 | } |
| 828 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 829 | static struct resource strataflash_resource = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 830 | .start = PXA_CS0_PHYS, |
| 831 | .end = PXA_CS0_PHYS + SZ_64M - 1, |
| 832 | .flags = IORESOURCE_MEM, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 833 | }; |
| 834 | |
Petr Cvek | fdb902b6 | 2015-09-28 23:34:39 +0200 | [diff] [blame] | 835 | static struct mtd_partition magician_flash_parts[] = { |
| 836 | { |
| 837 | .name = "Bootloader", |
| 838 | .offset = 0x0, |
| 839 | .size = 0x40000, |
| 840 | .mask_flags = MTD_WRITEABLE, /* EXPERIMENTAL */ |
| 841 | }, |
| 842 | { |
| 843 | .name = "Linux Kernel", |
| 844 | .offset = 0x40000, |
| 845 | .size = MTDPART_SIZ_FULL, |
| 846 | }, |
| 847 | }; |
| 848 | |
| 849 | /* |
| 850 | * physmap-flash driver |
| 851 | */ |
| 852 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 853 | static struct physmap_flash_data strataflash_data = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 854 | .width = 4, |
Petr Cvek | fdb902b6 | 2015-09-28 23:34:39 +0200 | [diff] [blame] | 855 | .init = magician_flash_init, |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 856 | .set_vpp = magician_set_vpp, |
Petr Cvek | fdb902b6 | 2015-09-28 23:34:39 +0200 | [diff] [blame] | 857 | .exit = magician_flash_exit, |
| 858 | .parts = magician_flash_parts, |
| 859 | .nr_parts = ARRAY_SIZE(magician_flash_parts), |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 860 | }; |
| 861 | |
| 862 | static struct platform_device strataflash = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 863 | .name = "physmap-flash", |
| 864 | .id = -1, |
| 865 | .resource = &strataflash_resource, |
| 866 | .num_resources = 1, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 867 | .dev = { |
| 868 | .platform_data = &strataflash_data, |
| 869 | }, |
| 870 | }; |
| 871 | |
| 872 | /* |
Petr Cvek | f36150b | 2015-09-28 23:10:18 +0200 | [diff] [blame] | 873 | * PXA I2C main controller |
Philipp Zabel | f8f9d5e | 2009-04-17 11:38:23 +0200 | [diff] [blame] | 874 | */ |
| 875 | |
| 876 | static struct i2c_pxa_platform_data i2c_info = { |
Petr Cvek | 0fb58ab | 2015-09-28 23:33:55 +0200 | [diff] [blame] | 877 | /* OV9640 I2C device doesn't support fast mode */ |
| 878 | .fast_mode = 0, |
| 879 | }; |
| 880 | |
| 881 | /* |
| 882 | * PXA I2C power controller |
| 883 | */ |
| 884 | |
| 885 | static struct i2c_pxa_platform_data magician_i2c_power_info = { |
| 886 | .fast_mode = 1, |
Philipp Zabel | f8f9d5e | 2009-04-17 11:38:23 +0200 | [diff] [blame] | 887 | }; |
| 888 | |
| 889 | /* |
Petr Cvek | 7ade445 | 2017-03-13 09:05:49 +0100 | [diff] [blame] | 890 | * Touchscreen |
| 891 | */ |
| 892 | |
| 893 | static struct ads7846_platform_data ads7846_pdata = { |
| 894 | .model = 7846, |
| 895 | .x_plate_ohms = 317, |
| 896 | .y_plate_ohms = 500, |
| 897 | .pressure_max = 1023, /* with x plate ohms it will overflow 255 */ |
| 898 | .debounce_max = 3, /* first readout is always bad */ |
| 899 | .debounce_tol = 30, |
| 900 | .debounce_rep = 0, |
| 901 | .gpio_pendown = GPIO115_MAGICIAN_nPEN_IRQ, |
| 902 | .keep_vref_on = 1, |
| 903 | .wakeup = true, |
| 904 | .vref_delay_usecs = 100, |
| 905 | .penirq_recheck_delay_usecs = 100, |
| 906 | }; |
| 907 | |
| 908 | struct pxa2xx_spi_chip tsc2046_chip_info = { |
| 909 | .tx_threshold = 1, |
| 910 | .rx_threshold = 2, |
| 911 | .timeout = 64, |
| 912 | /* NOTICE must be GPIO, incompatibility with hw PXA SPI framing */ |
| 913 | .gpio_cs = GPIO14_MAGICIAN_TSC2046_CS, |
| 914 | }; |
| 915 | |
| 916 | static struct pxa2xx_spi_master magician_spi_info = { |
| 917 | .num_chipselect = 1, |
| 918 | .enable_dma = 1, |
| 919 | }; |
| 920 | |
| 921 | static struct spi_board_info ads7846_spi_board_info[] __initdata = { |
| 922 | { |
| 923 | .modalias = "ads7846", |
| 924 | .bus_num = 2, |
| 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), |
| 929 | }, |
| 930 | }; |
| 931 | |
| 932 | /* |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 933 | * Platform devices |
| 934 | */ |
| 935 | |
| 936 | static struct platform_device *devices[] __initdata = { |
| 937 | &gpio_keys, |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 938 | &egpio, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 939 | &backlight, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 940 | &pasic3, |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 941 | &bq24022, |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 942 | &gpio_vbus, |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 943 | &power_supply, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 944 | &strataflash, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 945 | &leds_gpio, |
Petr Cvek | 7ade445 | 2017-03-13 09:05:49 +0100 | [diff] [blame] | 946 | &vads7846_device, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 947 | }; |
| 948 | |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 949 | static struct gpio magician_global_gpios[] = { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 950 | { GPIO13_MAGICIAN_CPLD_IRQ, GPIOF_IN, "CPLD_IRQ" }, |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 951 | { GPIO107_MAGICIAN_DS1WM_IRQ, GPIOF_IN, "DS1WM_IRQ" }, |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 952 | |
| 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" }, |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 957 | }; |
| 958 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 959 | static void __init magician_init(void) |
| 960 | { |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 961 | void __iomem *cpld; |
| 962 | int lcd_select; |
Philipp Zabel | a1999cd | 2008-04-20 17:39:12 +0100 | [diff] [blame] | 963 | int err; |
| 964 | |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 965 | pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config)); |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 966 | err = gpio_request_array(ARRAY_AND_SIZE(magician_global_gpios)); |
| 967 | if (err) |
Petr Cvek | 7f63a75 | 2015-09-28 23:10:43 +0200 | [diff] [blame] | 968 | pr_err("magician: Failed to request global GPIOs: %d\n", err); |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 969 | |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 970 | pxa_set_ffuart_info(NULL); |
| 971 | pxa_set_btuart_info(NULL); |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 972 | |
Thierry Reding | bd3208b | 2015-10-05 10:49:46 +0200 | [diff] [blame] | 973 | pwm_add_table(magician_pwm_lookup, ARRAY_SIZE(magician_pwm_lookup)); |
Philipp Zabel | a1999cd | 2008-04-20 17:39:12 +0100 | [diff] [blame] | 974 | |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 975 | pxa_set_ficp_info(&magician_ficp_info); |
Petr Cvek | 0fb58ab | 2015-09-28 23:33:55 +0200 | [diff] [blame] | 976 | pxa27x_set_i2c_power_info(&magician_i2c_power_info); |
Philipp Zabel | f8f9d5e | 2009-04-17 11:38:23 +0200 | [diff] [blame] | 977 | pxa_set_i2c_info(&i2c_info); |
Petr Cvek | ff5eff3 | 2015-09-28 23:39:03 +0200 | [diff] [blame] | 978 | |
| 979 | i2c_register_board_info(1, |
| 980 | ARRAY_AND_SIZE(magician_pwr_i2c_board_info)); |
| 981 | |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 982 | pxa_set_mci_info(&magician_mci_info); |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 983 | pxa_set_ohci_info(&magician_ohci_info); |
Petr Cvek | 31134b5 | 2015-09-28 23:39:33 +0200 | [diff] [blame] | 984 | pxa_set_udc_info(&magician_udc_info); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 985 | |
| 986 | /* Check LCD type we have */ |
| 987 | cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000); |
| 988 | if (cpld) { |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 989 | u8 board_id = __raw_readb(cpld + 0x14); |
| 990 | |
Philipp Zabel | a1999cd | 2008-04-20 17:39:12 +0100 | [diff] [blame] | 991 | iounmap(cpld); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 992 | system_rev = board_id & 0x7; |
| 993 | lcd_select = board_id & 0x8; |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 994 | pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly"); |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 995 | if (lcd_select && (system_rev < 3)) |
Petr Cvek | 6001ae7 | 2015-09-28 23:15:57 +0200 | [diff] [blame] | 996 | /* NOTICE valid LCD init sequence */ |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 997 | gpio_request_one(GPIO75_MAGICIAN_SAMSUNG_POWER, |
Petr Cvek | 6382a59 | 2015-09-28 23:11:34 +0200 | [diff] [blame] | 998 | GPIOF_OUT_INIT_LOW, "Samsung LCD Power"); |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 999 | pxa_set_fb_info(NULL, |
| 1000 | lcd_select ? &samsung_info : &toppoly_info); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 1001 | } else |
| 1002 | pr_err("LCD detection: CPLD mapping failed\n"); |
Petr Cvek | e2f1b8b | 2015-09-28 23:40:57 +0200 | [diff] [blame] | 1003 | |
Petr Cvek | 7ade445 | 2017-03-13 09:05:49 +0100 | [diff] [blame] | 1004 | pxa2xx_set_spi_info(2, &magician_spi_info); |
| 1005 | spi_register_board_info(ARRAY_AND_SIZE(ads7846_spi_board_info)); |
| 1006 | |
Petr Cvek | e2f1b8b | 2015-09-28 23:40:57 +0200 | [diff] [blame] | 1007 | regulator_register_always_on(0, "power", pwm_backlight_supply, |
| 1008 | ARRAY_SIZE(pwm_backlight_supply), 5000000); |
Petr Cvek | 78afa4f | 2015-09-28 23:42:23 +0200 | [diff] [blame] | 1009 | |
| 1010 | platform_add_devices(ARRAY_AND_SIZE(devices)); |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 1011 | } |
| 1012 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 1013 | MACHINE_START(MAGICIAN, "HTC Magician") |
Petr Cvek | ccb6f9a | 2015-09-28 23:09:52 +0200 | [diff] [blame] | 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, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 1020 | .init_time = pxa_timer_init, |
Russell King | 271a74f | 2011-11-04 14:15:53 +0000 | [diff] [blame] | 1021 | .restart = pxa_restart, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 1022 | MACHINE_END |