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