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