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> |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 27 | #include <linux/pwm_backlight.h> |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 28 | #include <linux/regulator/driver.h> |
| 29 | #include <linux/regulator/gpio-regulator.h> |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 30 | #include <linux/regulator/machine.h> |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 31 | #include <linux/usb/gpio_vbus.h> |
Sebastian Andrzej Siewior | b459396 | 2011-02-23 12:38:16 +0100 | [diff] [blame] | 32 | #include <linux/i2c/pxa-i2c.h> |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 33 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 34 | #include <mach/hardware.h> |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 35 | #include <asm/mach-types.h> |
| 36 | #include <asm/mach/arch.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 37 | #include <asm/system_info.h> |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 38 | |
| 39 | #include <mach/pxa27x.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 40 | #include <mach/magician.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 41 | #include <mach/pxafb.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 42 | #include <mach/mmc.h> |
| 43 | #include <mach/irda.h> |
| 44 | #include <mach/ohci.h> |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 45 | |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 46 | #include "devices.h" |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 47 | #include "generic.h" |
| 48 | |
Philipp Zabel | 7a97010 | 2008-06-26 21:03:54 +0100 | [diff] [blame] | 49 | static unsigned long magician_pin_config[] __initdata = { |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 50 | |
| 51 | /* SDRAM and Static Memory I/O Signals */ |
| 52 | GPIO20_nSDCS_2, |
| 53 | GPIO21_nSDCS_3, |
| 54 | GPIO15_nCS_1, |
| 55 | GPIO78_nCS_2, /* PASIC3 */ |
| 56 | GPIO79_nCS_3, /* EGPIO CPLD */ |
| 57 | GPIO80_nCS_4, |
| 58 | GPIO33_nCS_5, |
| 59 | |
| 60 | /* I2C */ |
| 61 | GPIO117_I2C_SCL, |
| 62 | GPIO118_I2C_SDA, |
| 63 | |
| 64 | /* PWM 0 */ |
| 65 | GPIO16_PWM0_OUT, |
| 66 | |
| 67 | /* I2S */ |
| 68 | GPIO28_I2S_BITCLK_OUT, |
| 69 | GPIO29_I2S_SDATA_IN, |
| 70 | GPIO31_I2S_SYNC, |
| 71 | GPIO113_I2S_SYSCLK, |
| 72 | |
Philipp Zabel | 16c3ea4 | 2009-01-17 18:45:41 +0100 | [diff] [blame] | 73 | /* SSP 1 */ |
| 74 | GPIO23_SSP1_SCLK, |
| 75 | GPIO24_SSP1_SFRM, |
| 76 | GPIO25_SSP1_TXD, |
| 77 | |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 78 | /* SSP 2 */ |
| 79 | GPIO19_SSP2_SCLK, |
| 80 | GPIO14_SSP2_SFRM, |
| 81 | GPIO89_SSP2_TXD, |
| 82 | GPIO88_SSP2_RXD, |
| 83 | |
| 84 | /* MMC */ |
| 85 | GPIO32_MMC_CLK, |
| 86 | GPIO92_MMC_DAT_0, |
| 87 | GPIO109_MMC_DAT_1, |
| 88 | GPIO110_MMC_DAT_2, |
| 89 | GPIO111_MMC_DAT_3, |
| 90 | GPIO112_MMC_CMD, |
| 91 | |
| 92 | /* LCD */ |
Eric Miao | bedbda9 | 2010-01-04 11:37:14 +0800 | [diff] [blame] | 93 | GPIOxx_LCD_TFT_16BPP, |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 94 | |
| 95 | /* QCI */ |
| 96 | GPIO12_CIF_DD_7, |
| 97 | GPIO17_CIF_DD_6, |
| 98 | GPIO50_CIF_DD_3, |
| 99 | GPIO51_CIF_DD_2, |
| 100 | GPIO52_CIF_DD_4, |
| 101 | GPIO53_CIF_MCLK, |
| 102 | GPIO54_CIF_PCLK, |
| 103 | GPIO55_CIF_DD_1, |
| 104 | GPIO81_CIF_DD_0, |
| 105 | GPIO82_CIF_DD_5, |
| 106 | GPIO84_CIF_FV, |
| 107 | GPIO85_CIF_LV, |
Philipp Zabel | 2f13195 | 2008-04-20 17:40:11 +0100 | [diff] [blame] | 108 | |
| 109 | /* Magician specific input GPIOs */ |
| 110 | GPIO9_GPIO, /* unknown */ |
| 111 | GPIO10_GPIO, /* GSM_IRQ */ |
| 112 | GPIO13_GPIO, /* CPLD_IRQ */ |
| 113 | GPIO107_GPIO, /* DS1WM_IRQ */ |
| 114 | GPIO108_GPIO, /* GSM_READY */ |
| 115 | GPIO115_GPIO, /* nPEN_IRQ */ |
Eric Miao | 6f584cf | 2008-11-28 16:00:24 +0800 | [diff] [blame] | 116 | |
| 117 | /* I2C */ |
| 118 | GPIO117_I2C_SCL, |
| 119 | GPIO118_I2C_SDA, |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 120 | }; |
| 121 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 122 | /* |
| 123 | * IRDA |
| 124 | */ |
| 125 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 126 | static struct pxaficp_platform_data magician_ficp_info = { |
Marek Vasut | c4bd017 | 2009-07-17 12:50:43 +0200 | [diff] [blame] | 127 | .gpio_pwdown = GPIO83_MAGICIAN_nIR_EN, |
| 128 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | /* |
| 132 | * GPIO Keys |
| 133 | */ |
| 134 | |
Philipp Zabel | 51c10bb | 2009-01-17 18:45:44 +0100 | [diff] [blame] | 135 | #define INIT_KEY(_code, _gpio, _desc) \ |
| 136 | { \ |
| 137 | .code = KEY_##_code, \ |
| 138 | .gpio = _gpio, \ |
| 139 | .desc = _desc, \ |
| 140 | .type = EV_KEY, \ |
| 141 | .wakeup = 1, \ |
| 142 | } |
| 143 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 144 | static struct gpio_keys_button magician_button_table[] = { |
Philipp Zabel | 51c10bb | 2009-01-17 18:45:44 +0100 | [diff] [blame] | 145 | INIT_KEY(POWER, GPIO0_MAGICIAN_KEY_POWER, "Power button"), |
| 146 | INIT_KEY(ESC, GPIO37_MAGICIAN_KEY_HANGUP, "Hangup button"), |
| 147 | INIT_KEY(F10, GPIO38_MAGICIAN_KEY_CONTACTS, "Contacts button"), |
| 148 | INIT_KEY(CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, "Calendar button"), |
| 149 | INIT_KEY(CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, "Camera button"), |
| 150 | INIT_KEY(UP, GPIO93_MAGICIAN_KEY_UP, "Up button"), |
| 151 | INIT_KEY(DOWN, GPIO94_MAGICIAN_KEY_DOWN, "Down button"), |
| 152 | INIT_KEY(LEFT, GPIO95_MAGICIAN_KEY_LEFT, "Left button"), |
| 153 | INIT_KEY(RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, "Right button"), |
| 154 | INIT_KEY(KPENTER, GPIO97_MAGICIAN_KEY_ENTER, "Action button"), |
| 155 | INIT_KEY(RECORD, GPIO98_MAGICIAN_KEY_RECORD, "Record button"), |
| 156 | INIT_KEY(VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, "Volume up"), |
| 157 | INIT_KEY(VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, "Volume down"), |
| 158 | INIT_KEY(PHONE, GPIO102_MAGICIAN_KEY_PHONE, "Phone button"), |
| 159 | INIT_KEY(PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, "Headset button"), |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | static struct gpio_keys_platform_data gpio_keys_data = { |
| 163 | .buttons = magician_button_table, |
| 164 | .nbuttons = ARRAY_SIZE(magician_button_table), |
| 165 | }; |
| 166 | |
| 167 | static struct platform_device gpio_keys = { |
| 168 | .name = "gpio-keys", |
| 169 | .dev = { |
| 170 | .platform_data = &gpio_keys_data, |
| 171 | }, |
| 172 | .id = -1, |
| 173 | }; |
| 174 | |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 175 | |
| 176 | /* |
| 177 | * EGPIO (Xilinx CPLD) |
| 178 | * |
| 179 | * 7 32-bit aligned 8-bit registers: 3x output, 1x irq, 3x input |
| 180 | */ |
| 181 | |
| 182 | static struct resource egpio_resources[] = { |
| 183 | [0] = { |
| 184 | .start = PXA_CS3_PHYS, |
Philipp Zabel | 2380461 | 2009-02-09 17:34:05 +0100 | [diff] [blame] | 185 | .end = PXA_CS3_PHYS + 0x20 - 1, |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 186 | .flags = IORESOURCE_MEM, |
| 187 | }, |
| 188 | [1] = { |
Haojian Zhuang | 4929f5a | 2011-10-10 16:03:51 +0800 | [diff] [blame] | 189 | .start = PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ), |
| 190 | .end = PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ), |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 191 | .flags = IORESOURCE_IRQ, |
| 192 | }, |
| 193 | }; |
| 194 | |
| 195 | static struct htc_egpio_chip egpio_chips[] = { |
| 196 | [0] = { |
| 197 | .reg_start = 0, |
| 198 | .gpio_base = MAGICIAN_EGPIO(0, 0), |
| 199 | .num_gpios = 24, |
| 200 | .direction = HTC_EGPIO_OUTPUT, |
| 201 | .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */ |
| 202 | }, |
| 203 | [1] = { |
| 204 | .reg_start = 4, |
| 205 | .gpio_base = MAGICIAN_EGPIO(4, 0), |
| 206 | .num_gpios = 24, |
| 207 | .direction = HTC_EGPIO_INPUT, |
| 208 | }, |
| 209 | }; |
| 210 | |
| 211 | static struct htc_egpio_platform_data egpio_info = { |
| 212 | .reg_width = 8, |
| 213 | .bus_width = 32, |
| 214 | .irq_base = IRQ_BOARD_START, |
| 215 | .num_irqs = 4, |
| 216 | .ack_register = 3, |
| 217 | .chip = egpio_chips, |
| 218 | .num_chips = ARRAY_SIZE(egpio_chips), |
| 219 | }; |
| 220 | |
| 221 | static struct platform_device egpio = { |
| 222 | .name = "htc-egpio", |
| 223 | .id = -1, |
| 224 | .resource = egpio_resources, |
| 225 | .num_resources = ARRAY_SIZE(egpio_resources), |
| 226 | .dev = { |
| 227 | .platform_data = &egpio_info, |
| 228 | }, |
| 229 | }; |
| 230 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 231 | /* |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 232 | * LCD - Toppoly TD028STEB1 or Samsung LTP280QV |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 233 | */ |
| 234 | |
| 235 | static struct pxafb_mode_info toppoly_modes[] = { |
| 236 | { |
| 237 | .pixclock = 96153, |
| 238 | .bpp = 16, |
| 239 | .xres = 240, |
| 240 | .yres = 320, |
| 241 | .hsync_len = 11, |
| 242 | .vsync_len = 3, |
| 243 | .left_margin = 19, |
| 244 | .upper_margin = 2, |
| 245 | .right_margin = 10, |
| 246 | .lower_margin = 2, |
| 247 | .sync = 0, |
| 248 | }, |
| 249 | }; |
| 250 | |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 251 | static struct pxafb_mode_info samsung_modes[] = { |
| 252 | { |
| 253 | .pixclock = 96153, |
| 254 | .bpp = 16, |
| 255 | .xres = 240, |
| 256 | .yres = 320, |
| 257 | .hsync_len = 8, |
| 258 | .vsync_len = 4, |
| 259 | .left_margin = 9, |
| 260 | .upper_margin = 4, |
| 261 | .right_margin = 9, |
| 262 | .lower_margin = 4, |
| 263 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 264 | }, |
| 265 | }; |
| 266 | |
| 267 | static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si) |
| 268 | { |
| 269 | pr_debug("Toppoly LCD power\n"); |
| 270 | |
| 271 | if (on) { |
| 272 | pr_debug("on\n"); |
| 273 | gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1); |
| 274 | gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1); |
| 275 | udelay(2000); |
| 276 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); |
| 277 | udelay(2000); |
| 278 | /* FIXME: enable LCDC here */ |
| 279 | udelay(2000); |
| 280 | gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1); |
| 281 | udelay(2000); |
| 282 | gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1); |
| 283 | } else { |
| 284 | pr_debug("off\n"); |
| 285 | msleep(15); |
| 286 | gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0); |
| 287 | udelay(500); |
| 288 | gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0); |
| 289 | udelay(1000); |
| 290 | gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0); |
| 291 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | static void samsung_lcd_power(int on, struct fb_var_screeninfo *si) |
| 296 | { |
| 297 | pr_debug("Samsung LCD power\n"); |
| 298 | |
| 299 | if (on) { |
| 300 | pr_debug("on\n"); |
| 301 | if (system_rev < 3) |
| 302 | gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1); |
| 303 | else |
| 304 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); |
| 305 | mdelay(10); |
| 306 | gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1); |
| 307 | mdelay(10); |
| 308 | gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1); |
| 309 | mdelay(30); |
| 310 | gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1); |
| 311 | mdelay(10); |
| 312 | } else { |
| 313 | pr_debug("off\n"); |
| 314 | mdelay(10); |
| 315 | gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0); |
| 316 | mdelay(30); |
| 317 | gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0); |
| 318 | mdelay(10); |
| 319 | gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0); |
| 320 | mdelay(10); |
| 321 | if (system_rev < 3) |
| 322 | gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0); |
| 323 | else |
| 324 | gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); |
| 325 | } |
| 326 | } |
| 327 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 328 | static struct pxafb_mach_info toppoly_info = { |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 329 | .modes = toppoly_modes, |
| 330 | .num_modes = 1, |
| 331 | .fixed_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 332 | .lcd_conn = LCD_COLOR_TFT_16BPP, |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 333 | .pxafb_lcd_power = toppoly_lcd_power, |
| 334 | }; |
| 335 | |
| 336 | static struct pxafb_mach_info samsung_info = { |
| 337 | .modes = samsung_modes, |
| 338 | .num_modes = 1, |
| 339 | .fixed_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 340 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |\ |
| 341 | LCD_ALTERNATE_MAPPING, |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 342 | .pxafb_lcd_power = samsung_lcd_power, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 343 | }; |
| 344 | |
| 345 | /* |
| 346 | * Backlight |
| 347 | */ |
| 348 | |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 349 | static struct gpio magician_bl_gpios[] = { |
| 350 | { EGPIO_MAGICIAN_BL_POWER, GPIOF_DIR_OUT, "Backlight power" }, |
| 351 | { EGPIO_MAGICIAN_BL_POWER2, GPIOF_DIR_OUT, "Backlight power 2" }, |
| 352 | }; |
| 353 | |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 354 | static int magician_backlight_init(struct device *dev) |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 355 | { |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 356 | return gpio_request_array(ARRAY_AND_SIZE(magician_bl_gpios)); |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 357 | } |
| 358 | |
Eric Miao | 2d51a52 | 2010-01-04 11:42:01 +0800 | [diff] [blame] | 359 | static int magician_backlight_notify(struct device *dev, int brightness) |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 360 | { |
| 361 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER, brightness); |
| 362 | if (brightness >= 200) { |
| 363 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1); |
| 364 | return brightness - 72; |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 365 | } else { |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 366 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0); |
| 367 | return brightness; |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 368 | } |
| 369 | } |
| 370 | |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 371 | static void magician_backlight_exit(struct device *dev) |
| 372 | { |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 373 | gpio_free_array(ARRAY_AND_SIZE(magician_bl_gpios)); |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | static struct platform_pwm_backlight_data backlight_data = { |
| 377 | .pwm_id = 0, |
| 378 | .max_brightness = 272, |
| 379 | .dft_brightness = 100, |
| 380 | .pwm_period_ns = 30923, |
| 381 | .init = magician_backlight_init, |
| 382 | .notify = magician_backlight_notify, |
| 383 | .exit = magician_backlight_exit, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 384 | }; |
| 385 | |
| 386 | static struct platform_device backlight = { |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 387 | .name = "pwm-backlight", |
Philipp Zabel | 14d1012 | 2008-06-30 18:11:55 +0100 | [diff] [blame] | 388 | .id = -1, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 389 | .dev = { |
Philipp Zabel | 85847a3 | 2008-05-22 14:20:01 +0100 | [diff] [blame] | 390 | .parent = &pxa27x_device_pwm0.dev, |
| 391 | .platform_data = &backlight_data, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 392 | }, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 393 | }; |
| 394 | |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 395 | /* |
| 396 | * LEDs |
| 397 | */ |
| 398 | |
Russell King | a55faca | 2008-09-25 14:35:48 +0100 | [diff] [blame] | 399 | static struct gpio_led gpio_leds[] = { |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 400 | { |
| 401 | .name = "magician::vibra", |
| 402 | .default_trigger = "none", |
| 403 | .gpio = GPIO22_MAGICIAN_VIBRA_EN, |
| 404 | }, |
| 405 | { |
| 406 | .name = "magician::phone_bl", |
Philipp Zabel | 05199ec | 2009-02-09 17:34:08 +0100 | [diff] [blame] | 407 | .default_trigger = "backlight", |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 408 | .gpio = GPIO103_MAGICIAN_LED_KP, |
| 409 | }, |
| 410 | }; |
| 411 | |
| 412 | static struct gpio_led_platform_data gpio_led_info = { |
| 413 | .leds = gpio_leds, |
| 414 | .num_leds = ARRAY_SIZE(gpio_leds), |
| 415 | }; |
| 416 | |
| 417 | static struct platform_device leds_gpio = { |
| 418 | .name = "leds-gpio", |
| 419 | .id = -1, |
| 420 | .dev = { |
| 421 | .platform_data = &gpio_led_info, |
| 422 | }, |
| 423 | }; |
| 424 | |
| 425 | static struct pasic3_led pasic3_leds[] = { |
| 426 | { |
| 427 | .led = { |
| 428 | .name = "magician:red", |
| 429 | .default_trigger = "ds2760-battery.0-charging", |
| 430 | }, |
| 431 | .hw_num = 0, |
| 432 | .bit2 = PASIC3_BIT2_LED0, |
| 433 | .mask = PASIC3_MASK_LED0, |
| 434 | }, |
| 435 | { |
| 436 | .led = { |
| 437 | .name = "magician:green", |
| 438 | .default_trigger = "ds2760-battery.0-charging-or-full", |
| 439 | }, |
| 440 | .hw_num = 1, |
| 441 | .bit2 = PASIC3_BIT2_LED1, |
| 442 | .mask = PASIC3_MASK_LED1, |
| 443 | }, |
| 444 | { |
| 445 | .led = { |
| 446 | .name = "magician:blue", |
| 447 | .default_trigger = "bluetooth", |
| 448 | }, |
| 449 | .hw_num = 2, |
| 450 | .bit2 = PASIC3_BIT2_LED2, |
| 451 | .mask = PASIC3_MASK_LED2, |
| 452 | }, |
| 453 | }; |
| 454 | |
Philipp Zabel | e03e059 | 2008-04-24 18:10:46 +0100 | [diff] [blame] | 455 | static struct pasic3_leds_machinfo pasic3_leds_info = { |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 456 | .num_leds = ARRAY_SIZE(pasic3_leds), |
| 457 | .power_gpio = EGPIO_MAGICIAN_LED_POWER, |
| 458 | .leds = pasic3_leds, |
| 459 | }; |
| 460 | |
| 461 | /* |
| 462 | * PASIC3 with DS1WM |
| 463 | */ |
| 464 | |
| 465 | static struct resource pasic3_resources[] = { |
| 466 | [0] = { |
| 467 | .start = PXA_CS2_PHYS, |
| 468 | .end = PXA_CS2_PHYS + 0x1b, |
| 469 | .flags = IORESOURCE_MEM, |
| 470 | }, |
| 471 | /* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */ |
| 472 | [1] = { |
Haojian Zhuang | 4929f5a | 2011-10-10 16:03:51 +0800 | [diff] [blame] | 473 | .start = PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ), |
| 474 | .end = PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ), |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 475 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
| 476 | } |
| 477 | }; |
| 478 | |
| 479 | static struct pasic3_platform_data pasic3_platform_data = { |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 480 | .led_pdata = &pasic3_leds_info, |
| 481 | .clock_rate = 4000000, |
| 482 | }; |
| 483 | |
| 484 | static struct platform_device pasic3 = { |
| 485 | .name = "pasic3", |
| 486 | .id = -1, |
| 487 | .num_resources = ARRAY_SIZE(pasic3_resources), |
| 488 | .resource = pasic3_resources, |
| 489 | .dev = { |
| 490 | .platform_data = &pasic3_platform_data, |
| 491 | }, |
| 492 | }; |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 493 | |
| 494 | /* |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 495 | * USB "Transceiver" |
| 496 | */ |
| 497 | |
| 498 | static struct resource gpio_vbus_resource = { |
| 499 | .flags = IORESOURCE_IRQ, |
| 500 | .start = IRQ_MAGICIAN_VBUS, |
| 501 | .end = IRQ_MAGICIAN_VBUS, |
| 502 | }; |
| 503 | |
| 504 | static struct gpio_vbus_mach_info gpio_vbus_info = { |
| 505 | .gpio_pullup = GPIO27_MAGICIAN_USBC_PUEN, |
| 506 | .gpio_vbus = EGPIO_MAGICIAN_CABLE_STATE_USB, |
| 507 | }; |
| 508 | |
| 509 | static struct platform_device gpio_vbus = { |
| 510 | .name = "gpio-vbus", |
| 511 | .id = -1, |
| 512 | .num_resources = 1, |
| 513 | .resource = &gpio_vbus_resource, |
| 514 | .dev = { |
| 515 | .platform_data = &gpio_vbus_info, |
| 516 | }, |
| 517 | }; |
| 518 | |
| 519 | /* |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 520 | * External power |
| 521 | */ |
| 522 | |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 523 | static int power_supply_init(struct device *dev) |
| 524 | { |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 525 | return gpio_request(EGPIO_MAGICIAN_CABLE_STATE_AC, "CABLE_STATE_AC"); |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 526 | } |
| 527 | |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 528 | static int magician_is_ac_online(void) |
| 529 | { |
| 530 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC); |
| 531 | } |
| 532 | |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 533 | static void power_supply_exit(struct device *dev) |
| 534 | { |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 535 | gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC); |
| 536 | } |
| 537 | |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 538 | static char *magician_supplicants[] = { |
| 539 | "ds2760-battery.0", "backup-battery" |
| 540 | }; |
| 541 | |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 542 | static struct pda_power_pdata power_supply_info = { |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 543 | .init = power_supply_init, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 544 | .is_ac_online = magician_is_ac_online, |
Philipp Zabel | ff27920 | 2008-05-22 10:14:21 +0100 | [diff] [blame] | 545 | .exit = power_supply_exit, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 546 | .supplied_to = magician_supplicants, |
| 547 | .num_supplicants = ARRAY_SIZE(magician_supplicants), |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 548 | }; |
| 549 | |
| 550 | static struct resource power_supply_resources[] = { |
| 551 | [0] = { |
| 552 | .name = "ac", |
Philipp Zabel | d942d77 | 2009-02-09 17:34:07 +0100 | [diff] [blame] | 553 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | |
| 554 | IORESOURCE_IRQ_LOWEDGE, |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 555 | .start = IRQ_MAGICIAN_VBUS, |
| 556 | .end = IRQ_MAGICIAN_VBUS, |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 557 | }, |
| 558 | [1] = { |
| 559 | .name = "usb", |
Philipp Zabel | d942d77 | 2009-02-09 17:34:07 +0100 | [diff] [blame] | 560 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | |
| 561 | IORESOURCE_IRQ_LOWEDGE, |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 562 | .start = IRQ_MAGICIAN_VBUS, |
| 563 | .end = IRQ_MAGICIAN_VBUS, |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 564 | }, |
| 565 | }; |
| 566 | |
| 567 | static struct platform_device power_supply = { |
| 568 | .name = "pda-power", |
| 569 | .id = -1, |
| 570 | .dev = { |
| 571 | .platform_data = &power_supply_info, |
| 572 | }, |
| 573 | .resource = power_supply_resources, |
| 574 | .num_resources = ARRAY_SIZE(power_supply_resources), |
| 575 | }; |
| 576 | |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 577 | /* |
| 578 | * Battery charger |
| 579 | */ |
| 580 | |
| 581 | static struct regulator_consumer_supply bq24022_consumers[] = { |
Axel Lin | 0bf189a | 2012-05-08 16:25:10 +0800 | [diff] [blame^] | 582 | REGULATOR_SUPPLY("vbus_draw", NULL), |
| 583 | REGULATOR_SUPPLY("ac_draw", NULL), |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 584 | }; |
| 585 | |
| 586 | static struct regulator_init_data bq24022_init_data = { |
| 587 | .constraints = { |
| 588 | .max_uA = 500000, |
Philipp Zabel | e454d16 | 2011-04-20 15:41:29 +0200 | [diff] [blame] | 589 | .valid_ops_mask = REGULATOR_CHANGE_CURRENT | REGULATOR_CHANGE_STATUS, |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 590 | }, |
| 591 | .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers), |
| 592 | .consumer_supplies = bq24022_consumers, |
| 593 | }; |
| 594 | |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 595 | static struct gpio bq24022_gpios[] = { |
| 596 | { EGPIO_MAGICIAN_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" }, |
| 597 | }; |
| 598 | |
| 599 | static struct gpio_regulator_state bq24022_states[] = { |
| 600 | { .value = 100000, .gpios = (0 << 0) }, |
| 601 | { .value = 500000, .gpios = (1 << 0) }, |
| 602 | }; |
| 603 | |
| 604 | static struct gpio_regulator_config bq24022_info = { |
| 605 | .supply_name = "bq24022", |
| 606 | |
| 607 | .enable_gpio = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, |
| 608 | .enable_high = 0, |
| 609 | .enabled_at_boot = 0, |
| 610 | |
| 611 | .gpios = bq24022_gpios, |
| 612 | .nr_gpios = ARRAY_SIZE(bq24022_gpios), |
| 613 | |
| 614 | .states = bq24022_states, |
| 615 | .nr_states = ARRAY_SIZE(bq24022_states), |
| 616 | |
| 617 | .type = REGULATOR_CURRENT, |
| 618 | .init_data = &bq24022_init_data, |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 619 | }; |
| 620 | |
| 621 | static struct platform_device bq24022 = { |
Heiko Stübner | 6967cca | 2012-03-02 13:56:38 +0100 | [diff] [blame] | 622 | .name = "gpio-regulator", |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 623 | .id = -1, |
| 624 | .dev = { |
| 625 | .platform_data = &bq24022_info, |
| 626 | }, |
| 627 | }; |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 628 | |
| 629 | /* |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 630 | * MMC/SD |
| 631 | */ |
| 632 | |
| 633 | static int magician_mci_init(struct device *dev, |
| 634 | irq_handler_t detect_irq, void *data) |
| 635 | { |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 636 | return request_irq(IRQ_MAGICIAN_SD, detect_irq, |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 637 | IRQF_DISABLED | IRQF_SAMPLE_RANDOM, |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 638 | "mmc card detect", data); |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | static void magician_mci_exit(struct device *dev, void *data) |
| 642 | { |
| 643 | free_irq(IRQ_MAGICIAN_SD, data); |
| 644 | } |
| 645 | |
| 646 | static struct pxamci_platform_data magician_mci_info = { |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 647 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 648 | .init = magician_mci_init, |
| 649 | .exit = magician_mci_exit, |
| 650 | .gpio_card_detect = -1, |
| 651 | .gpio_card_ro = EGPIO_MAGICIAN_nSD_READONLY, |
| 652 | .gpio_card_ro_invert = 1, |
| 653 | .gpio_power = EGPIO_MAGICIAN_SD_POWER, |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 654 | }; |
| 655 | |
| 656 | |
| 657 | /* |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 658 | * USB OHCI |
| 659 | */ |
| 660 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 661 | static struct pxaohci_platform_data magician_ohci_info = { |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 662 | .port_mode = PMM_PERPORT_MODE, |
| 663 | .flags = ENABLE_PORT1 | ENABLE_PORT3 | POWER_CONTROL_LOW, |
| 664 | .power_budget = 0, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 665 | }; |
| 666 | |
| 667 | |
| 668 | /* |
| 669 | * StrataFlash |
| 670 | */ |
| 671 | |
Marc Zyngier | 667f390 | 2011-05-18 10:51:55 +0100 | [diff] [blame] | 672 | static void magician_set_vpp(struct platform_device *pdev, int vpp) |
Philipp Zabel | aa79759 | 2008-04-09 19:24:05 +0100 | [diff] [blame] | 673 | { |
| 674 | gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp); |
| 675 | } |
| 676 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 677 | static struct resource strataflash_resource = { |
| 678 | .start = PXA_CS0_PHYS, |
Philipp Zabel | fcb78d1 | 2009-01-17 18:45:43 +0100 | [diff] [blame] | 679 | .end = PXA_CS0_PHYS + SZ_64M - 1, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 680 | .flags = IORESOURCE_MEM, |
| 681 | }; |
| 682 | |
| 683 | static struct physmap_flash_data strataflash_data = { |
| 684 | .width = 4, |
Philipp Zabel | aa79759 | 2008-04-09 19:24:05 +0100 | [diff] [blame] | 685 | .set_vpp = magician_set_vpp, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 686 | }; |
| 687 | |
| 688 | static struct platform_device strataflash = { |
| 689 | .name = "physmap-flash", |
| 690 | .id = -1, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 691 | .resource = &strataflash_resource, |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 692 | .num_resources = 1, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 693 | .dev = { |
| 694 | .platform_data = &strataflash_data, |
| 695 | }, |
| 696 | }; |
| 697 | |
| 698 | /* |
Philipp Zabel | f8f9d5e | 2009-04-17 11:38:23 +0200 | [diff] [blame] | 699 | * I2C |
| 700 | */ |
| 701 | |
| 702 | static struct i2c_pxa_platform_data i2c_info = { |
| 703 | .fast_mode = 1, |
| 704 | }; |
| 705 | |
| 706 | /* |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 707 | * Platform devices |
| 708 | */ |
| 709 | |
| 710 | static struct platform_device *devices[] __initdata = { |
| 711 | &gpio_keys, |
Philipp Zabel | 70e357f | 2008-04-09 19:22:57 +0100 | [diff] [blame] | 712 | &egpio, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 713 | &backlight, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 714 | &pasic3, |
Philipp Zabel | eb650b9 | 2009-01-31 12:13:57 +0100 | [diff] [blame] | 715 | &bq24022, |
Philipp Zabel | 6489c61 | 2009-02-01 11:20:30 +0100 | [diff] [blame] | 716 | &gpio_vbus, |
Philipp Zabel | 350d115 | 2008-04-09 19:25:56 +0100 | [diff] [blame] | 717 | &power_supply, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 718 | &strataflash, |
Philipp Zabel | 81447b2 | 2008-04-12 13:28:02 +0100 | [diff] [blame] | 719 | &leds_gpio, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 720 | }; |
| 721 | |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 722 | static struct gpio magician_global_gpios[] = { |
| 723 | { GPIO13_MAGICIAN_CPLD_IRQ, GPIOF_IN, "CPLD_IRQ" }, |
| 724 | { GPIO107_MAGICIAN_DS1WM_IRQ, GPIOF_IN, "DS1WM_IRQ" }, |
| 725 | { GPIO104_MAGICIAN_LCD_POWER_1, GPIOF_OUT_INIT_LOW, "LCD power 1" }, |
| 726 | { GPIO105_MAGICIAN_LCD_POWER_2, GPIOF_OUT_INIT_LOW, "LCD power 2" }, |
| 727 | { GPIO106_MAGICIAN_LCD_POWER_3, GPIOF_OUT_INIT_LOW, "LCD power 3" }, |
| 728 | { GPIO83_MAGICIAN_nIR_EN, GPIOF_OUT_INIT_HIGH, "nIR_EN" }, |
| 729 | }; |
| 730 | |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 731 | static void __init magician_init(void) |
| 732 | { |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 733 | void __iomem *cpld; |
| 734 | int lcd_select; |
Philipp Zabel | a1999cd | 2008-04-20 17:39:12 +0100 | [diff] [blame] | 735 | int err; |
| 736 | |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 737 | pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config)); |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 738 | err = gpio_request_array(ARRAY_AND_SIZE(magician_global_gpios)); |
| 739 | if (err) |
| 740 | pr_err("magician: Failed to request GPIOs: %d\n", err); |
Philipp Zabel | b168281 | 2008-04-12 13:29:22 +0100 | [diff] [blame] | 741 | |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 742 | pxa_set_ffuart_info(NULL); |
| 743 | pxa_set_btuart_info(NULL); |
| 744 | pxa_set_stuart_info(NULL); |
| 745 | |
Philipp Zabel | 2f1a5bf | 2009-04-28 13:31:08 +0200 | [diff] [blame] | 746 | platform_add_devices(ARRAY_AND_SIZE(devices)); |
Philipp Zabel | a1999cd | 2008-04-20 17:39:12 +0100 | [diff] [blame] | 747 | |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 748 | pxa_set_ficp_info(&magician_ficp_info); |
Philipp Zabel | dee6316 | 2009-01-17 18:45:42 +0100 | [diff] [blame] | 749 | pxa27x_set_i2c_power_info(NULL); |
Philipp Zabel | f8f9d5e | 2009-04-17 11:38:23 +0200 | [diff] [blame] | 750 | pxa_set_i2c_info(&i2c_info); |
Philipp Zabel | bdb0c16 | 2008-04-09 19:24:55 +0100 | [diff] [blame] | 751 | pxa_set_mci_info(&magician_mci_info); |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 752 | pxa_set_ohci_info(&magician_ohci_info); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 753 | |
| 754 | /* Check LCD type we have */ |
| 755 | cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000); |
| 756 | if (cpld) { |
| 757 | u8 board_id = __raw_readb(cpld+0x14); |
Philipp Zabel | a1999cd | 2008-04-20 17:39:12 +0100 | [diff] [blame] | 758 | iounmap(cpld); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 759 | system_rev = board_id & 0x7; |
| 760 | lcd_select = board_id & 0x8; |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 761 | pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly"); |
Philipp Zabel | 5db15f8 | 2011-04-28 22:21:04 +0200 | [diff] [blame] | 762 | if (lcd_select && (system_rev < 3)) |
| 763 | gpio_request_one(GPIO75_MAGICIAN_SAMSUNG_POWER, |
| 764 | GPIOF_OUT_INIT_LOW, "SAMSUNG_POWER"); |
Russell King - ARM Linux | 4321e1a | 2011-02-15 15:37:30 +0800 | [diff] [blame] | 765 | pxa_set_fb_info(NULL, lcd_select ? &samsung_info : &toppoly_info); |
Philipp Zabel | e07ff8d8 | 2008-04-09 19:27:10 +0100 | [diff] [blame] | 766 | } else |
| 767 | pr_err("LCD detection: CPLD mapping failed\n"); |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 768 | } |
| 769 | |
| 770 | |
| 771 | MACHINE_START(MAGICIAN, "HTC Magician") |
Nicolas Pitre | 7375aba | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 772 | .atag_offset = 0x100, |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 773 | .map_io = pxa27x_map_io, |
Haojian Zhuang | 6ac6b81 | 2010-08-20 15:23:59 +0800 | [diff] [blame] | 774 | .nr_irqs = MAGICIAN_NR_IRQS, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 775 | .init_irq = pxa27x_init_irq, |
Eric Miao | 8a97ae2 | 2011-05-18 21:30:04 +0800 | [diff] [blame] | 776 | .handle_irq = pxa27x_handle_irq, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 777 | .init_machine = magician_init, |
| 778 | .timer = &pxa_timer, |
Russell King | 271a74f | 2011-11-04 14:15:53 +0000 | [diff] [blame] | 779 | .restart = pxa_restart, |
Philipp Zabel | e5c271e | 2007-11-22 17:59:11 +0100 | [diff] [blame] | 780 | MACHINE_END |