Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Hardware definitions for Palm Tungsten|E2 |
| 3 | * |
| 4 | * Author: |
| 5 | * Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com> |
| 6 | * |
| 7 | * Rewrite for mainline: |
| 8 | * Marek Vasut <marek.vasut@gmail.com> |
| 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 | * (find more info at www.hackndev.com) |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #include <linux/platform_device.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <linux/irq.h> |
| 21 | #include <linux/gpio_keys.h> |
| 22 | #include <linux/input.h> |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 23 | #include <linux/pda_power.h> |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 24 | #include <linux/pwm_backlight.h> |
| 25 | #include <linux/gpio.h> |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 26 | #include <linux/wm97xx_batt.h> |
| 27 | #include <linux/power_supply.h> |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 28 | #include <linux/usb/gpio_vbus.h> |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 29 | |
| 30 | #include <asm/mach-types.h> |
| 31 | #include <asm/mach/arch.h> |
| 32 | #include <asm/mach/map.h> |
| 33 | |
| 34 | #include <mach/audio.h> |
| 35 | #include <mach/palmte2.h> |
| 36 | #include <mach/mmc.h> |
| 37 | #include <mach/pxafb.h> |
| 38 | #include <mach/mfp-pxa25x.h> |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 39 | #include <mach/irda.h> |
| 40 | #include <mach/udc.h> |
Marek Vasut | 37330ef | 2009-04-23 11:27:11 +0200 | [diff] [blame] | 41 | #include <mach/palmasoc.h> |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 42 | |
| 43 | #include "generic.h" |
| 44 | #include "devices.h" |
| 45 | |
| 46 | /****************************************************************************** |
| 47 | * Pin configuration |
| 48 | ******************************************************************************/ |
| 49 | static unsigned long palmte2_pin_config[] __initdata = { |
| 50 | /* MMC */ |
| 51 | GPIO6_MMC_CLK, |
| 52 | GPIO8_MMC_CS0, |
| 53 | GPIO10_GPIO, /* SD detect */ |
| 54 | GPIO55_GPIO, /* SD power */ |
| 55 | GPIO51_GPIO, /* SD r/o switch */ |
| 56 | |
| 57 | /* AC97 */ |
| 58 | GPIO28_AC97_BITCLK, |
| 59 | GPIO29_AC97_SDATA_IN_0, |
| 60 | GPIO30_AC97_SDATA_OUT, |
| 61 | GPIO31_AC97_SYNC, |
| 62 | |
| 63 | /* PWM */ |
| 64 | GPIO16_PWM0_OUT, |
| 65 | |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 66 | /* USB */ |
| 67 | GPIO15_GPIO, /* usb detect */ |
| 68 | GPIO53_GPIO, /* usb power */ |
| 69 | |
| 70 | /* IrDA */ |
| 71 | GPIO48_GPIO, /* ir disable */ |
| 72 | GPIO46_FICP_RXD, |
| 73 | GPIO47_FICP_TXD, |
| 74 | |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 75 | /* LCD */ |
| 76 | GPIO58_LCD_LDD_0, |
| 77 | GPIO59_LCD_LDD_1, |
| 78 | GPIO60_LCD_LDD_2, |
| 79 | GPIO61_LCD_LDD_3, |
| 80 | GPIO62_LCD_LDD_4, |
| 81 | GPIO63_LCD_LDD_5, |
| 82 | GPIO64_LCD_LDD_6, |
| 83 | GPIO65_LCD_LDD_7, |
| 84 | GPIO66_LCD_LDD_8, |
| 85 | GPIO67_LCD_LDD_9, |
| 86 | GPIO68_LCD_LDD_10, |
| 87 | GPIO69_LCD_LDD_11, |
| 88 | GPIO70_LCD_LDD_12, |
| 89 | GPIO71_LCD_LDD_13, |
| 90 | GPIO72_LCD_LDD_14, |
| 91 | GPIO73_LCD_LDD_15, |
| 92 | GPIO74_LCD_FCLK, |
| 93 | GPIO75_LCD_LCLK, |
| 94 | GPIO76_LCD_PCLK, |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 95 | GPIO77_LCD_BIAS, |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 96 | |
| 97 | /* GPIO KEYS */ |
| 98 | GPIO5_GPIO, /* notes */ |
| 99 | GPIO7_GPIO, /* tasks */ |
| 100 | GPIO11_GPIO, /* calendar */ |
| 101 | GPIO13_GPIO, /* contacts */ |
| 102 | GPIO14_GPIO, /* center */ |
| 103 | GPIO19_GPIO, /* left */ |
| 104 | GPIO20_GPIO, /* right */ |
| 105 | GPIO21_GPIO, /* down */ |
| 106 | GPIO22_GPIO, /* up */ |
| 107 | |
| 108 | /* MISC */ |
| 109 | GPIO1_RST, /* reset */ |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 110 | GPIO4_GPIO, /* Hotsync button */ |
| 111 | GPIO9_GPIO, /* power detect */ |
Marek Vasut | 37330ef | 2009-04-23 11:27:11 +0200 | [diff] [blame] | 112 | GPIO15_GPIO, /* earphone detect */ |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 113 | GPIO37_GPIO, /* LCD power */ |
| 114 | GPIO56_GPIO, /* Backlight power */ |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | /****************************************************************************** |
| 118 | * SD/MMC card controller |
| 119 | ******************************************************************************/ |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 120 | static struct pxamci_platform_data palmte2_mci_platform_data = { |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 121 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 122 | .gpio_card_detect = GPIO_NR_PALMTE2_SD_DETECT_N, |
| 123 | .gpio_card_ro = GPIO_NR_PALMTE2_SD_READONLY, |
| 124 | .gpio_power = GPIO_NR_PALMTE2_SD_POWER, |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | /****************************************************************************** |
| 128 | * GPIO keys |
| 129 | ******************************************************************************/ |
| 130 | static struct gpio_keys_button palmte2_pxa_buttons[] = { |
| 131 | {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" }, |
| 132 | {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" }, |
| 133 | {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" }, |
| 134 | {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" }, |
| 135 | {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" }, |
| 136 | {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" }, |
| 137 | {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" }, |
| 138 | {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" }, |
| 139 | {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" }, |
| 140 | }; |
| 141 | |
| 142 | static struct gpio_keys_platform_data palmte2_pxa_keys_data = { |
| 143 | .buttons = palmte2_pxa_buttons, |
| 144 | .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons), |
| 145 | }; |
| 146 | |
| 147 | static struct platform_device palmte2_pxa_keys = { |
| 148 | .name = "gpio-keys", |
| 149 | .id = -1, |
| 150 | .dev = { |
| 151 | .platform_data = &palmte2_pxa_keys_data, |
| 152 | }, |
| 153 | }; |
| 154 | |
| 155 | /****************************************************************************** |
| 156 | * Backlight |
| 157 | ******************************************************************************/ |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 158 | static int palmte2_backlight_init(struct device *dev) |
| 159 | { |
| 160 | int ret; |
| 161 | |
| 162 | ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER"); |
| 163 | if (ret) |
| 164 | goto err; |
| 165 | ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0); |
| 166 | if (ret) |
| 167 | goto err2; |
| 168 | ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER"); |
| 169 | if (ret) |
| 170 | goto err2; |
| 171 | ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0); |
| 172 | if (ret) |
| 173 | goto err3; |
| 174 | |
| 175 | return 0; |
| 176 | err3: |
| 177 | gpio_free(GPIO_NR_PALMTE2_LCD_POWER); |
| 178 | err2: |
| 179 | gpio_free(GPIO_NR_PALMTE2_BL_POWER); |
| 180 | err: |
| 181 | return ret; |
| 182 | } |
| 183 | |
| 184 | static int palmte2_backlight_notify(int brightness) |
| 185 | { |
| 186 | gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness); |
| 187 | gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness); |
| 188 | return brightness; |
| 189 | } |
| 190 | |
| 191 | static void palmte2_backlight_exit(struct device *dev) |
| 192 | { |
| 193 | gpio_free(GPIO_NR_PALMTE2_BL_POWER); |
| 194 | gpio_free(GPIO_NR_PALMTE2_LCD_POWER); |
| 195 | } |
| 196 | |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 197 | static struct platform_pwm_backlight_data palmte2_backlight_data = { |
| 198 | .pwm_id = 0, |
| 199 | .max_brightness = PALMTE2_MAX_INTENSITY, |
| 200 | .dft_brightness = PALMTE2_MAX_INTENSITY, |
| 201 | .pwm_period_ns = PALMTE2_PERIOD_NS, |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 202 | .init = palmte2_backlight_init, |
| 203 | .notify = palmte2_backlight_notify, |
| 204 | .exit = palmte2_backlight_exit, |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 205 | }; |
| 206 | |
| 207 | static struct platform_device palmte2_backlight = { |
| 208 | .name = "pwm-backlight", |
| 209 | .dev = { |
| 210 | .parent = &pxa25x_device_pwm0.dev, |
| 211 | .platform_data = &palmte2_backlight_data, |
| 212 | }, |
| 213 | }; |
| 214 | |
| 215 | /****************************************************************************** |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 216 | * IrDA |
| 217 | ******************************************************************************/ |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 218 | static struct pxaficp_platform_data palmte2_ficp_platform_data = { |
Marek Vasut | c4bd017 | 2009-07-17 12:50:43 +0200 | [diff] [blame] | 219 | .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE, |
| 220 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 221 | }; |
| 222 | |
| 223 | /****************************************************************************** |
| 224 | * UDC |
| 225 | ******************************************************************************/ |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 226 | static struct gpio_vbus_mach_info palmte2_udc_info = { |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 227 | .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N, |
| 228 | .gpio_vbus_inverted = 1, |
| 229 | .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP, |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 230 | }; |
| 231 | |
| 232 | static struct platform_device palmte2_gpio_vbus = { |
| 233 | .name = "gpio-vbus", |
| 234 | .id = -1, |
| 235 | .dev = { |
| 236 | .platform_data = &palmte2_udc_info, |
| 237 | }, |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | /****************************************************************************** |
| 241 | * Power supply |
| 242 | ******************************************************************************/ |
| 243 | static int power_supply_init(struct device *dev) |
| 244 | { |
| 245 | int ret; |
| 246 | |
| 247 | ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC"); |
| 248 | if (ret) |
| 249 | goto err1; |
| 250 | ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT); |
| 251 | if (ret) |
| 252 | goto err2; |
| 253 | |
| 254 | return 0; |
| 255 | |
| 256 | err2: |
| 257 | gpio_free(GPIO_NR_PALMTE2_POWER_DETECT); |
| 258 | err1: |
| 259 | return ret; |
| 260 | } |
| 261 | |
| 262 | static int palmte2_is_ac_online(void) |
| 263 | { |
| 264 | return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT); |
| 265 | } |
| 266 | |
| 267 | static void power_supply_exit(struct device *dev) |
| 268 | { |
| 269 | gpio_free(GPIO_NR_PALMTE2_POWER_DETECT); |
| 270 | } |
| 271 | |
| 272 | static char *palmte2_supplicants[] = { |
| 273 | "main-battery", |
| 274 | }; |
| 275 | |
| 276 | static struct pda_power_pdata power_supply_info = { |
| 277 | .init = power_supply_init, |
| 278 | .is_ac_online = palmte2_is_ac_online, |
| 279 | .exit = power_supply_exit, |
| 280 | .supplied_to = palmte2_supplicants, |
| 281 | .num_supplicants = ARRAY_SIZE(palmte2_supplicants), |
| 282 | }; |
| 283 | |
| 284 | static struct platform_device power_supply = { |
| 285 | .name = "pda-power", |
| 286 | .id = -1, |
| 287 | .dev = { |
| 288 | .platform_data = &power_supply_info, |
| 289 | }, |
| 290 | }; |
| 291 | |
| 292 | /****************************************************************************** |
| 293 | * WM97xx battery |
| 294 | ******************************************************************************/ |
| 295 | static struct wm97xx_batt_info wm97xx_batt_pdata = { |
| 296 | .batt_aux = WM97XX_AUX_ID3, |
| 297 | .temp_aux = WM97XX_AUX_ID2, |
| 298 | .charge_gpio = -1, |
| 299 | .max_voltage = PALMTE2_BAT_MAX_VOLTAGE, |
| 300 | .min_voltage = PALMTE2_BAT_MIN_VOLTAGE, |
| 301 | .batt_mult = 1000, |
| 302 | .batt_div = 414, |
| 303 | .temp_mult = 1, |
| 304 | .temp_div = 1, |
| 305 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO, |
| 306 | .batt_name = "main-batt", |
| 307 | }; |
| 308 | |
| 309 | /****************************************************************************** |
Marek Vasut | 37330ef | 2009-04-23 11:27:11 +0200 | [diff] [blame] | 310 | * aSoC audio |
| 311 | ******************************************************************************/ |
| 312 | static struct palm27x_asoc_info palmte2_asoc_pdata = { |
| 313 | .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT, |
| 314 | }; |
| 315 | |
| 316 | static struct platform_device palmte2_asoc = { |
| 317 | .name = "palm27x-asoc", |
| 318 | .id = -1, |
| 319 | .dev = { |
| 320 | .platform_data = &palmte2_asoc_pdata, |
| 321 | }, |
| 322 | }; |
| 323 | |
| 324 | /****************************************************************************** |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 325 | * Framebuffer |
| 326 | ******************************************************************************/ |
| 327 | static struct pxafb_mode_info palmte2_lcd_modes[] = { |
| 328 | { |
| 329 | .pixclock = 77757, |
| 330 | .xres = 320, |
| 331 | .yres = 320, |
| 332 | .bpp = 16, |
| 333 | |
| 334 | .left_margin = 28, |
| 335 | .right_margin = 7, |
| 336 | .upper_margin = 7, |
| 337 | .lower_margin = 5, |
| 338 | |
| 339 | .hsync_len = 4, |
| 340 | .vsync_len = 1, |
| 341 | }, |
| 342 | }; |
| 343 | |
| 344 | static struct pxafb_mach_info palmte2_lcd_screen = { |
| 345 | .modes = palmte2_lcd_modes, |
| 346 | .num_modes = ARRAY_SIZE(palmte2_lcd_modes), |
| 347 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
| 348 | }; |
| 349 | |
| 350 | /****************************************************************************** |
| 351 | * Machine init |
| 352 | ******************************************************************************/ |
| 353 | static struct platform_device *devices[] __initdata = { |
| 354 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 355 | &palmte2_pxa_keys, |
| 356 | #endif |
| 357 | &palmte2_backlight, |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 358 | &power_supply, |
Marek Vasut | 37330ef | 2009-04-23 11:27:11 +0200 | [diff] [blame] | 359 | &palmte2_asoc, |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 360 | &palmte2_gpio_vbus, |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 361 | }; |
| 362 | |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 363 | /* setup udc GPIOs initial state */ |
| 364 | static void __init palmte2_udc_init(void) |
| 365 | { |
| 366 | if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) { |
| 367 | gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1); |
| 368 | gpio_free(GPIO_NR_PALMTE2_USB_PULLUP); |
| 369 | } |
| 370 | } |
| 371 | |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 372 | static void __init palmte2_init(void) |
| 373 | { |
| 374 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config)); |
| 375 | |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 376 | pxa_set_ffuart_info(NULL); |
| 377 | pxa_set_btuart_info(NULL); |
| 378 | pxa_set_stuart_info(NULL); |
| 379 | |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 380 | set_pxa_fb_info(&palmte2_lcd_screen); |
| 381 | pxa_set_mci_info(&palmte2_mci_platform_data); |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 382 | palmte2_udc_init(); |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 383 | pxa_set_ac97_info(NULL); |
Marek Vasut | 8c8aa5f | 2009-03-24 21:23:39 +0100 | [diff] [blame] | 384 | pxa_set_ficp_info(&palmte2_ficp_platform_data); |
| 385 | wm97xx_bat_set_pdata(&wm97xx_batt_pdata); |
Marek Vasut | 54088bf | 2009-03-24 00:29:29 +0100 | [diff] [blame] | 386 | |
| 387 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 388 | } |
| 389 | |
| 390 | MACHINE_START(PALMTE2, "Palm Tungsten|E2") |
| 391 | .phys_io = 0x40000000, |
| 392 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 393 | .boot_params = 0xa0000100, |
| 394 | .map_io = pxa_map_io, |
| 395 | .init_irq = pxa25x_init_irq, |
| 396 | .timer = &pxa_timer, |
| 397 | .init_machine = palmte2_init |
| 398 | MACHINE_END |