Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Hardware definitions for PalmTX |
| 3 | * |
| 4 | * Author: Marek Vasut <marek.vasut@gmail.com> |
| 5 | * |
| 6 | * Based on work of: |
| 7 | * Alex Osborne <ato@meshy.org> |
| 8 | * Cristiano P. <cristianop@users.sourceforge.net> |
| 9 | * Jan Herman <2hp@seznam.cz> |
| 10 | * Michal Hrusecky |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License version 2 as |
| 14 | * published by the Free Software Foundation. |
| 15 | * |
| 16 | * (find more info at www.hackndev.com) |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/irq.h> |
| 23 | #include <linux/gpio_keys.h> |
| 24 | #include <linux/input.h> |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 25 | #include <linux/pda_power.h> |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 26 | #include <linux/pwm_backlight.h> |
| 27 | #include <linux/gpio.h> |
Marek Vašut | 4e9687d | 2008-09-11 19:37:32 +0100 | [diff] [blame] | 28 | #include <linux/wm97xx_batt.h> |
| 29 | #include <linux/power_supply.h> |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 30 | #include <linux/usb/gpio_vbus.h> |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 31 | |
| 32 | #include <asm/mach-types.h> |
| 33 | #include <asm/mach/arch.h> |
| 34 | #include <asm/mach/map.h> |
| 35 | |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 36 | #include <mach/pxa27x.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 37 | #include <mach/audio.h> |
| 38 | #include <mach/palmtx.h> |
| 39 | #include <mach/mmc.h> |
| 40 | #include <mach/pxafb.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 41 | #include <mach/irda.h> |
| 42 | #include <mach/pxa27x_keypad.h> |
| 43 | #include <mach/udc.h> |
Marek Vasut | e91fb91 | 2009-04-17 11:37:35 +0200 | [diff] [blame] | 44 | #include <mach/palmasoc.h> |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 45 | |
| 46 | #include "generic.h" |
| 47 | #include "devices.h" |
| 48 | |
| 49 | /****************************************************************************** |
| 50 | * Pin configuration |
| 51 | ******************************************************************************/ |
| 52 | static unsigned long palmtx_pin_config[] __initdata = { |
| 53 | /* MMC */ |
| 54 | GPIO32_MMC_CLK, |
| 55 | GPIO92_MMC_DAT_0, |
| 56 | GPIO109_MMC_DAT_1, |
| 57 | GPIO110_MMC_DAT_2, |
| 58 | GPIO111_MMC_DAT_3, |
| 59 | GPIO112_MMC_CMD, |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 60 | GPIO14_GPIO, /* SD detect */ |
| 61 | GPIO114_GPIO, /* SD power */ |
| 62 | GPIO115_GPIO, /* SD r/o switch */ |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 63 | |
| 64 | /* AC97 */ |
| 65 | GPIO28_AC97_BITCLK, |
| 66 | GPIO29_AC97_SDATA_IN_0, |
| 67 | GPIO30_AC97_SDATA_OUT, |
| 68 | GPIO31_AC97_SYNC, |
Marek Vasut | 6ec04f4 | 2009-05-22 01:39:10 +0200 | [diff] [blame] | 69 | GPIO89_AC97_SYSCLK, |
Marek Vasut | efb12cd | 2009-04-12 16:37:23 +0200 | [diff] [blame] | 70 | GPIO95_AC97_nRESET, |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 71 | |
| 72 | /* IrDA */ |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 73 | GPIO40_GPIO, /* ir disable */ |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 74 | GPIO46_FICP_RXD, |
| 75 | GPIO47_FICP_TXD, |
| 76 | |
| 77 | /* PWM */ |
| 78 | GPIO16_PWM0_OUT, |
| 79 | |
| 80 | /* USB */ |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 81 | GPIO13_GPIO, /* usb detect */ |
Marek Vasut | efb12cd | 2009-04-12 16:37:23 +0200 | [diff] [blame] | 82 | GPIO93_GPIO, /* usb power */ |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 83 | |
| 84 | /* PCMCIA */ |
| 85 | GPIO48_nPOE, |
| 86 | GPIO49_nPWE, |
| 87 | GPIO50_nPIOR, |
| 88 | GPIO51_nPIOW, |
| 89 | GPIO85_nPCE_1, |
| 90 | GPIO54_nPCE_2, |
| 91 | GPIO79_PSKTSEL, |
| 92 | GPIO55_nPREG, |
| 93 | GPIO56_nPWAIT, |
| 94 | GPIO57_nIOIS16, |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 95 | GPIO94_GPIO, /* wifi power 1 */ |
| 96 | GPIO108_GPIO, /* wifi power 2 */ |
| 97 | GPIO116_GPIO, /* wifi ready */ |
| 98 | |
| 99 | /* MATRIX KEYPAD */ |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 100 | GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH, |
| 101 | GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH, |
| 102 | GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH, |
| 103 | GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH, |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 104 | GPIO103_KP_MKOUT_0, |
| 105 | GPIO104_KP_MKOUT_1, |
| 106 | GPIO105_KP_MKOUT_2, |
| 107 | |
| 108 | /* LCD */ |
| 109 | GPIO58_LCD_LDD_0, |
| 110 | GPIO59_LCD_LDD_1, |
| 111 | GPIO60_LCD_LDD_2, |
| 112 | GPIO61_LCD_LDD_3, |
| 113 | GPIO62_LCD_LDD_4, |
| 114 | GPIO63_LCD_LDD_5, |
| 115 | GPIO64_LCD_LDD_6, |
| 116 | GPIO65_LCD_LDD_7, |
| 117 | GPIO66_LCD_LDD_8, |
| 118 | GPIO67_LCD_LDD_9, |
| 119 | GPIO68_LCD_LDD_10, |
| 120 | GPIO69_LCD_LDD_11, |
| 121 | GPIO70_LCD_LDD_12, |
| 122 | GPIO71_LCD_LDD_13, |
| 123 | GPIO72_LCD_LDD_14, |
| 124 | GPIO73_LCD_LDD_15, |
| 125 | GPIO74_LCD_FCLK, |
| 126 | GPIO75_LCD_LCLK, |
| 127 | GPIO76_LCD_PCLK, |
| 128 | GPIO77_LCD_BIAS, |
| 129 | |
Marek Vasut | ecf763c | 2009-07-16 19:37:29 +0200 | [diff] [blame^] | 130 | /* FFUART */ |
| 131 | GPIO34_FFUART_RXD, |
| 132 | GPIO39_FFUART_TXD, |
| 133 | |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 134 | /* MISC. */ |
| 135 | GPIO10_GPIO, /* hotsync button */ |
| 136 | GPIO12_GPIO, /* power detect */ |
| 137 | GPIO107_GPIO, /* earphone detect */ |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | /****************************************************************************** |
| 141 | * SD/MMC card controller |
| 142 | ******************************************************************************/ |
| 143 | static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int, |
| 144 | void *data) |
| 145 | { |
| 146 | int err = 0; |
| 147 | |
| 148 | /* Setup an interrupt for detecting card insert/remove events */ |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 149 | err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ"); |
| 150 | if (err) |
| 151 | goto err; |
| 152 | err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N); |
| 153 | if (err) |
| 154 | goto err2; |
| 155 | err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), |
| 156 | palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM | |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 157 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, |
| 158 | "SD/MMC card detect", data); |
| 159 | if (err) { |
| 160 | printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n", |
| 161 | __func__); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 162 | goto err2; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER"); |
| 166 | if (err) |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 167 | goto err3; |
| 168 | err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0); |
| 169 | if (err) |
| 170 | goto err4; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 171 | |
| 172 | err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY"); |
| 173 | if (err) |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 174 | goto err4; |
| 175 | err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY); |
| 176 | if (err) |
| 177 | goto err5; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 178 | |
| 179 | printk(KERN_DEBUG "%s: irq registered\n", __func__); |
| 180 | |
| 181 | return 0; |
| 182 | |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 183 | err5: |
| 184 | gpio_free(GPIO_NR_PALMTX_SD_READONLY); |
| 185 | err4: |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 186 | gpio_free(GPIO_NR_PALMTX_SD_POWER); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 187 | err3: |
| 188 | free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data); |
| 189 | err2: |
| 190 | gpio_free(GPIO_NR_PALMTX_SD_DETECT_N); |
| 191 | err: |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 192 | return err; |
| 193 | } |
| 194 | |
| 195 | static void palmtx_mci_exit(struct device *dev, void *data) |
| 196 | { |
| 197 | gpio_free(GPIO_NR_PALMTX_SD_READONLY); |
| 198 | gpio_free(GPIO_NR_PALMTX_SD_POWER); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 199 | free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data); |
| 200 | gpio_free(GPIO_NR_PALMTX_SD_DETECT_N); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | static void palmtx_mci_power(struct device *dev, unsigned int vdd) |
| 204 | { |
| 205 | struct pxamci_platform_data *p_d = dev->platform_data; |
| 206 | gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd)); |
| 207 | } |
| 208 | |
| 209 | static int palmtx_mci_get_ro(struct device *dev) |
| 210 | { |
| 211 | return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY); |
| 212 | } |
| 213 | |
| 214 | static struct pxamci_platform_data palmtx_mci_platform_data = { |
| 215 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 216 | .setpower = palmtx_mci_power, |
| 217 | .get_ro = palmtx_mci_get_ro, |
| 218 | .init = palmtx_mci_init, |
| 219 | .exit = palmtx_mci_exit, |
| 220 | }; |
| 221 | |
| 222 | /****************************************************************************** |
| 223 | * GPIO keyboard |
| 224 | ******************************************************************************/ |
| 225 | static unsigned int palmtx_matrix_keys[] = { |
| 226 | KEY(0, 0, KEY_POWER), |
| 227 | KEY(0, 1, KEY_F1), |
| 228 | KEY(0, 2, KEY_ENTER), |
| 229 | |
| 230 | KEY(1, 0, KEY_F2), |
| 231 | KEY(1, 1, KEY_F3), |
| 232 | KEY(1, 2, KEY_F4), |
| 233 | |
| 234 | KEY(2, 0, KEY_UP), |
| 235 | KEY(2, 2, KEY_DOWN), |
| 236 | |
| 237 | KEY(3, 0, KEY_RIGHT), |
| 238 | KEY(3, 2, KEY_LEFT), |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = { |
| 242 | .matrix_key_rows = 4, |
| 243 | .matrix_key_cols = 3, |
| 244 | .matrix_key_map = palmtx_matrix_keys, |
| 245 | .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys), |
| 246 | |
| 247 | .debounce_interval = 30, |
| 248 | }; |
| 249 | |
| 250 | /****************************************************************************** |
| 251 | * GPIO keys |
| 252 | ******************************************************************************/ |
| 253 | static struct gpio_keys_button palmtx_pxa_buttons[] = { |
| 254 | {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" }, |
| 255 | }; |
| 256 | |
| 257 | static struct gpio_keys_platform_data palmtx_pxa_keys_data = { |
| 258 | .buttons = palmtx_pxa_buttons, |
| 259 | .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons), |
| 260 | }; |
| 261 | |
| 262 | static struct platform_device palmtx_pxa_keys = { |
| 263 | .name = "gpio-keys", |
| 264 | .id = -1, |
| 265 | .dev = { |
| 266 | .platform_data = &palmtx_pxa_keys_data, |
| 267 | }, |
| 268 | }; |
| 269 | |
| 270 | /****************************************************************************** |
| 271 | * Backlight |
| 272 | ******************************************************************************/ |
| 273 | static int palmtx_backlight_init(struct device *dev) |
| 274 | { |
| 275 | int ret; |
| 276 | |
| 277 | ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER"); |
| 278 | if (ret) |
| 279 | goto err; |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 280 | ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0); |
| 281 | if (ret) |
| 282 | goto err2; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 283 | ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER"); |
| 284 | if (ret) |
| 285 | goto err2; |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 286 | ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0); |
| 287 | if (ret) |
| 288 | goto err3; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 289 | |
| 290 | return 0; |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 291 | err3: |
| 292 | gpio_free(GPIO_NR_PALMTX_LCD_POWER); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 293 | err2: |
| 294 | gpio_free(GPIO_NR_PALMTX_BL_POWER); |
| 295 | err: |
| 296 | return ret; |
| 297 | } |
| 298 | |
| 299 | static int palmtx_backlight_notify(int brightness) |
| 300 | { |
| 301 | gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness); |
| 302 | gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness); |
| 303 | return brightness; |
| 304 | } |
| 305 | |
| 306 | static void palmtx_backlight_exit(struct device *dev) |
| 307 | { |
| 308 | gpio_free(GPIO_NR_PALMTX_BL_POWER); |
| 309 | gpio_free(GPIO_NR_PALMTX_LCD_POWER); |
| 310 | } |
| 311 | |
| 312 | static struct platform_pwm_backlight_data palmtx_backlight_data = { |
| 313 | .pwm_id = 0, |
| 314 | .max_brightness = PALMTX_MAX_INTENSITY, |
| 315 | .dft_brightness = PALMTX_MAX_INTENSITY, |
| 316 | .pwm_period_ns = PALMTX_PERIOD_NS, |
| 317 | .init = palmtx_backlight_init, |
| 318 | .notify = palmtx_backlight_notify, |
| 319 | .exit = palmtx_backlight_exit, |
| 320 | }; |
| 321 | |
| 322 | static struct platform_device palmtx_backlight = { |
| 323 | .name = "pwm-backlight", |
| 324 | .dev = { |
| 325 | .parent = &pxa27x_device_pwm0.dev, |
| 326 | .platform_data = &palmtx_backlight_data, |
| 327 | }, |
| 328 | }; |
| 329 | |
| 330 | /****************************************************************************** |
| 331 | * IrDA |
| 332 | ******************************************************************************/ |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 333 | static int palmtx_irda_startup(struct device *dev) |
| 334 | { |
| 335 | int err; |
| 336 | err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE"); |
| 337 | if (err) |
| 338 | goto err; |
| 339 | err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1); |
| 340 | if (err) |
| 341 | gpio_free(GPIO_NR_PALMTX_IR_DISABLE); |
| 342 | err: |
| 343 | return err; |
| 344 | } |
| 345 | |
| 346 | static void palmtx_irda_shutdown(struct device *dev) |
| 347 | { |
| 348 | gpio_free(GPIO_NR_PALMTX_IR_DISABLE); |
| 349 | } |
| 350 | |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 351 | static void palmtx_irda_transceiver_mode(struct device *dev, int mode) |
| 352 | { |
| 353 | gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF); |
| 354 | pxa2xx_transceiver_mode(dev, mode); |
| 355 | } |
| 356 | |
| 357 | static struct pxaficp_platform_data palmtx_ficp_platform_data = { |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 358 | .startup = palmtx_irda_startup, |
| 359 | .shutdown = palmtx_irda_shutdown, |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 360 | .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF, |
| 361 | .transceiver_mode = palmtx_irda_transceiver_mode, |
| 362 | }; |
| 363 | |
| 364 | /****************************************************************************** |
| 365 | * UDC |
| 366 | ******************************************************************************/ |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 367 | static struct gpio_vbus_mach_info palmtx_udc_info = { |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 368 | .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N, |
| 369 | .gpio_vbus_inverted = 1, |
Marek Vasut | efb12cd | 2009-04-12 16:37:23 +0200 | [diff] [blame] | 370 | .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP, |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 371 | }; |
| 372 | |
| 373 | static struct platform_device palmtx_gpio_vbus = { |
| 374 | .name = "gpio-vbus", |
| 375 | .id = -1, |
| 376 | .dev = { |
| 377 | .platform_data = &palmtx_udc_info, |
| 378 | }, |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 379 | }; |
| 380 | |
| 381 | /****************************************************************************** |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 382 | * Power supply |
| 383 | ******************************************************************************/ |
| 384 | static int power_supply_init(struct device *dev) |
| 385 | { |
| 386 | int ret; |
| 387 | |
| 388 | ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC"); |
| 389 | if (ret) |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 390 | goto err1; |
| 391 | ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT); |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 392 | if (ret) |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 393 | goto err2; |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 394 | |
| 395 | return 0; |
| 396 | |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 397 | err2: |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 398 | gpio_free(GPIO_NR_PALMTX_POWER_DETECT); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 399 | err1: |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 400 | return ret; |
| 401 | } |
| 402 | |
| 403 | static int palmtx_is_ac_online(void) |
| 404 | { |
| 405 | return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT); |
| 406 | } |
| 407 | |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 408 | static void power_supply_exit(struct device *dev) |
| 409 | { |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 410 | gpio_free(GPIO_NR_PALMTX_POWER_DETECT); |
| 411 | } |
| 412 | |
| 413 | static char *palmtx_supplicants[] = { |
| 414 | "main-battery", |
| 415 | }; |
| 416 | |
| 417 | static struct pda_power_pdata power_supply_info = { |
| 418 | .init = power_supply_init, |
| 419 | .is_ac_online = palmtx_is_ac_online, |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 420 | .exit = power_supply_exit, |
| 421 | .supplied_to = palmtx_supplicants, |
| 422 | .num_supplicants = ARRAY_SIZE(palmtx_supplicants), |
| 423 | }; |
| 424 | |
| 425 | static struct platform_device power_supply = { |
| 426 | .name = "pda-power", |
| 427 | .id = -1, |
| 428 | .dev = { |
| 429 | .platform_data = &power_supply_info, |
| 430 | }, |
| 431 | }; |
| 432 | |
| 433 | /****************************************************************************** |
Marek Vašut | 4e9687d | 2008-09-11 19:37:32 +0100 | [diff] [blame] | 434 | * WM97xx battery |
| 435 | ******************************************************************************/ |
| 436 | static struct wm97xx_batt_info wm97xx_batt_pdata = { |
| 437 | .batt_aux = WM97XX_AUX_ID3, |
| 438 | .temp_aux = WM97XX_AUX_ID2, |
| 439 | .charge_gpio = -1, |
| 440 | .max_voltage = PALMTX_BAT_MAX_VOLTAGE, |
| 441 | .min_voltage = PALMTX_BAT_MIN_VOLTAGE, |
| 442 | .batt_mult = 1000, |
| 443 | .batt_div = 414, |
| 444 | .temp_mult = 1, |
| 445 | .temp_div = 1, |
| 446 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO, |
| 447 | .batt_name = "main-batt", |
| 448 | }; |
| 449 | |
| 450 | /****************************************************************************** |
Marek Vasut | e91fb91 | 2009-04-17 11:37:35 +0200 | [diff] [blame] | 451 | * aSoC audio |
| 452 | ******************************************************************************/ |
| 453 | static struct palm27x_asoc_info palmtx_asoc_pdata = { |
| 454 | .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT, |
| 455 | }; |
| 456 | |
| 457 | static pxa2xx_audio_ops_t palmtx_ac97_pdata = { |
| 458 | .reset_gpio = 95, |
| 459 | }; |
| 460 | |
| 461 | static struct platform_device palmtx_asoc = { |
| 462 | .name = "palm27x-asoc", |
| 463 | .id = -1, |
| 464 | .dev = { |
| 465 | .platform_data = &palmtx_asoc_pdata, |
| 466 | }, |
| 467 | }; |
| 468 | |
| 469 | /****************************************************************************** |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 470 | * Framebuffer |
| 471 | ******************************************************************************/ |
| 472 | static struct pxafb_mode_info palmtx_lcd_modes[] = { |
| 473 | { |
| 474 | .pixclock = 57692, |
| 475 | .xres = 320, |
| 476 | .yres = 480, |
| 477 | .bpp = 16, |
| 478 | |
| 479 | .left_margin = 32, |
| 480 | .right_margin = 1, |
| 481 | .upper_margin = 7, |
| 482 | .lower_margin = 1, |
| 483 | |
| 484 | .hsync_len = 4, |
| 485 | .vsync_len = 1, |
| 486 | }, |
| 487 | }; |
| 488 | |
| 489 | static struct pxafb_mach_info palmtx_lcd_screen = { |
| 490 | .modes = palmtx_lcd_modes, |
| 491 | .num_modes = ARRAY_SIZE(palmtx_lcd_modes), |
| 492 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
| 493 | }; |
| 494 | |
| 495 | /****************************************************************************** |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 496 | * Power management - standby |
| 497 | ******************************************************************************/ |
Marek Vasut | fc9c1b6 | 2009-05-14 11:27:00 +0200 | [diff] [blame] | 498 | static void __init palmtx_pm_init(void) |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 499 | { |
Marek Vasut | fc9c1b6 | 2009-05-14 11:27:00 +0200 | [diff] [blame] | 500 | static u32 resume[] = { |
| 501 | 0xe3a00101, /* mov r0, #0x40000000 */ |
| 502 | 0xe380060f, /* orr r0, r0, #0x00f00000 */ |
| 503 | 0xe590f008, /* ldr pc, [r0, #0x08] */ |
| 504 | }; |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 505 | |
Marek Vasut | fc9c1b6 | 2009-05-14 11:27:00 +0200 | [diff] [blame] | 506 | /* copy the bootloader */ |
| 507 | memcpy(phys_to_virt(PALMTX_STR_BASE), resume, sizeof(resume)); |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 508 | } |
| 509 | |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 510 | /****************************************************************************** |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 511 | * Machine init |
| 512 | ******************************************************************************/ |
| 513 | static struct platform_device *devices[] __initdata = { |
| 514 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 515 | &palmtx_pxa_keys, |
| 516 | #endif |
| 517 | &palmtx_backlight, |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 518 | &power_supply, |
Marek Vasut | e91fb91 | 2009-04-17 11:37:35 +0200 | [diff] [blame] | 519 | &palmtx_asoc, |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 520 | &palmtx_gpio_vbus, |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 521 | }; |
| 522 | |
| 523 | static struct map_desc palmtx_io_desc[] __initdata = { |
| 524 | { |
| 525 | .virtual = PALMTX_PCMCIA_VIRT, |
| 526 | .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS), |
| 527 | .length = PALMTX_PCMCIA_SIZE, |
| 528 | .type = MT_DEVICE |
| 529 | }, |
| 530 | }; |
| 531 | |
| 532 | static void __init palmtx_map_io(void) |
| 533 | { |
| 534 | pxa_map_io(); |
| 535 | iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc)); |
| 536 | } |
| 537 | |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 538 | /* setup udc GPIOs initial state */ |
| 539 | static void __init palmtx_udc_init(void) |
| 540 | { |
Marek Vasut | efb12cd | 2009-04-12 16:37:23 +0200 | [diff] [blame] | 541 | if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) { |
| 542 | gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1); |
| 543 | gpio_free(GPIO_NR_PALMTX_USB_PULLUP); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 544 | } |
| 545 | } |
| 546 | |
| 547 | |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 548 | static void __init palmtx_init(void) |
| 549 | { |
| 550 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config)); |
| 551 | |
Marek Vasut | fc9c1b6 | 2009-05-14 11:27:00 +0200 | [diff] [blame] | 552 | palmtx_pm_init(); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 553 | set_pxa_fb_info(&palmtx_lcd_screen); |
| 554 | pxa_set_mci_info(&palmtx_mci_platform_data); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 555 | palmtx_udc_init(); |
Marek Vasut | e91fb91 | 2009-04-17 11:37:35 +0200 | [diff] [blame] | 556 | pxa_set_ac97_info(&palmtx_ac97_pdata); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 557 | pxa_set_ficp_info(&palmtx_ficp_platform_data); |
| 558 | pxa_set_keypad_info(&palmtx_keypad_platform_data); |
Marek Vašut | 4e9687d | 2008-09-11 19:37:32 +0100 | [diff] [blame] | 559 | wm97xx_bat_set_pdata(&wm97xx_batt_pdata); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 560 | |
| 561 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 562 | } |
| 563 | |
| 564 | MACHINE_START(PALMTX, "Palm T|X") |
| 565 | .phys_io = PALMTX_PHYS_IO_START, |
| 566 | .io_pg_offst = io_p2v(0x40000000), |
| 567 | .boot_params = 0xa0000100, |
| 568 | .map_io = palmtx_map_io, |
| 569 | .init_irq = pxa27x_init_irq, |
| 570 | .timer = &pxa_timer, |
| 571 | .init_machine = palmtx_init |
| 572 | MACHINE_END |