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