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