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 | |
| 130 | /* MISC. */ |
| 131 | GPIO10_GPIO, /* hotsync button */ |
| 132 | GPIO12_GPIO, /* power detect */ |
| 133 | GPIO107_GPIO, /* earphone detect */ |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | /****************************************************************************** |
| 137 | * SD/MMC card controller |
| 138 | ******************************************************************************/ |
| 139 | static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int, |
| 140 | void *data) |
| 141 | { |
| 142 | int err = 0; |
| 143 | |
| 144 | /* Setup an interrupt for detecting card insert/remove events */ |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 145 | err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ"); |
| 146 | if (err) |
| 147 | goto err; |
| 148 | err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N); |
| 149 | if (err) |
| 150 | goto err2; |
| 151 | err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), |
| 152 | palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM | |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 153 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, |
| 154 | "SD/MMC card detect", data); |
| 155 | if (err) { |
| 156 | printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n", |
| 157 | __func__); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 158 | goto err2; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER"); |
| 162 | if (err) |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 163 | goto err3; |
| 164 | err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0); |
| 165 | if (err) |
| 166 | goto err4; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 167 | |
| 168 | err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY"); |
| 169 | if (err) |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 170 | goto err4; |
| 171 | err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY); |
| 172 | if (err) |
| 173 | goto err5; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 174 | |
| 175 | printk(KERN_DEBUG "%s: irq registered\n", __func__); |
| 176 | |
| 177 | return 0; |
| 178 | |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 179 | err5: |
| 180 | gpio_free(GPIO_NR_PALMTX_SD_READONLY); |
| 181 | err4: |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 182 | gpio_free(GPIO_NR_PALMTX_SD_POWER); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 183 | err3: |
| 184 | free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data); |
| 185 | err2: |
| 186 | gpio_free(GPIO_NR_PALMTX_SD_DETECT_N); |
| 187 | err: |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 188 | return err; |
| 189 | } |
| 190 | |
| 191 | static void palmtx_mci_exit(struct device *dev, void *data) |
| 192 | { |
| 193 | gpio_free(GPIO_NR_PALMTX_SD_READONLY); |
| 194 | gpio_free(GPIO_NR_PALMTX_SD_POWER); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 195 | free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data); |
| 196 | gpio_free(GPIO_NR_PALMTX_SD_DETECT_N); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | static void palmtx_mci_power(struct device *dev, unsigned int vdd) |
| 200 | { |
| 201 | struct pxamci_platform_data *p_d = dev->platform_data; |
| 202 | gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd)); |
| 203 | } |
| 204 | |
| 205 | static int palmtx_mci_get_ro(struct device *dev) |
| 206 | { |
| 207 | return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY); |
| 208 | } |
| 209 | |
| 210 | static struct pxamci_platform_data palmtx_mci_platform_data = { |
| 211 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 212 | .setpower = palmtx_mci_power, |
| 213 | .get_ro = palmtx_mci_get_ro, |
| 214 | .init = palmtx_mci_init, |
| 215 | .exit = palmtx_mci_exit, |
| 216 | }; |
| 217 | |
| 218 | /****************************************************************************** |
| 219 | * GPIO keyboard |
| 220 | ******************************************************************************/ |
| 221 | static unsigned int palmtx_matrix_keys[] = { |
| 222 | KEY(0, 0, KEY_POWER), |
| 223 | KEY(0, 1, KEY_F1), |
| 224 | KEY(0, 2, KEY_ENTER), |
| 225 | |
| 226 | KEY(1, 0, KEY_F2), |
| 227 | KEY(1, 1, KEY_F3), |
| 228 | KEY(1, 2, KEY_F4), |
| 229 | |
| 230 | KEY(2, 0, KEY_UP), |
| 231 | KEY(2, 2, KEY_DOWN), |
| 232 | |
| 233 | KEY(3, 0, KEY_RIGHT), |
| 234 | KEY(3, 2, KEY_LEFT), |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 235 | }; |
| 236 | |
| 237 | static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = { |
| 238 | .matrix_key_rows = 4, |
| 239 | .matrix_key_cols = 3, |
| 240 | .matrix_key_map = palmtx_matrix_keys, |
| 241 | .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys), |
| 242 | |
| 243 | .debounce_interval = 30, |
| 244 | }; |
| 245 | |
| 246 | /****************************************************************************** |
| 247 | * GPIO keys |
| 248 | ******************************************************************************/ |
| 249 | static struct gpio_keys_button palmtx_pxa_buttons[] = { |
| 250 | {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" }, |
| 251 | }; |
| 252 | |
| 253 | static struct gpio_keys_platform_data palmtx_pxa_keys_data = { |
| 254 | .buttons = palmtx_pxa_buttons, |
| 255 | .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons), |
| 256 | }; |
| 257 | |
| 258 | static struct platform_device palmtx_pxa_keys = { |
| 259 | .name = "gpio-keys", |
| 260 | .id = -1, |
| 261 | .dev = { |
| 262 | .platform_data = &palmtx_pxa_keys_data, |
| 263 | }, |
| 264 | }; |
| 265 | |
| 266 | /****************************************************************************** |
| 267 | * Backlight |
| 268 | ******************************************************************************/ |
| 269 | static int palmtx_backlight_init(struct device *dev) |
| 270 | { |
| 271 | int ret; |
| 272 | |
| 273 | ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER"); |
| 274 | if (ret) |
| 275 | goto err; |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 276 | ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0); |
| 277 | if (ret) |
| 278 | goto err2; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 279 | ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER"); |
| 280 | if (ret) |
| 281 | goto err2; |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 282 | ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0); |
| 283 | if (ret) |
| 284 | goto err3; |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 285 | |
| 286 | return 0; |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 287 | err3: |
| 288 | gpio_free(GPIO_NR_PALMTX_LCD_POWER); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 289 | err2: |
| 290 | gpio_free(GPIO_NR_PALMTX_BL_POWER); |
| 291 | err: |
| 292 | return ret; |
| 293 | } |
| 294 | |
| 295 | static int palmtx_backlight_notify(int brightness) |
| 296 | { |
| 297 | gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness); |
| 298 | gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness); |
| 299 | return brightness; |
| 300 | } |
| 301 | |
| 302 | static void palmtx_backlight_exit(struct device *dev) |
| 303 | { |
| 304 | gpio_free(GPIO_NR_PALMTX_BL_POWER); |
| 305 | gpio_free(GPIO_NR_PALMTX_LCD_POWER); |
| 306 | } |
| 307 | |
| 308 | static struct platform_pwm_backlight_data palmtx_backlight_data = { |
| 309 | .pwm_id = 0, |
| 310 | .max_brightness = PALMTX_MAX_INTENSITY, |
| 311 | .dft_brightness = PALMTX_MAX_INTENSITY, |
| 312 | .pwm_period_ns = PALMTX_PERIOD_NS, |
| 313 | .init = palmtx_backlight_init, |
| 314 | .notify = palmtx_backlight_notify, |
| 315 | .exit = palmtx_backlight_exit, |
| 316 | }; |
| 317 | |
| 318 | static struct platform_device palmtx_backlight = { |
| 319 | .name = "pwm-backlight", |
| 320 | .dev = { |
| 321 | .parent = &pxa27x_device_pwm0.dev, |
| 322 | .platform_data = &palmtx_backlight_data, |
| 323 | }, |
| 324 | }; |
| 325 | |
| 326 | /****************************************************************************** |
| 327 | * IrDA |
| 328 | ******************************************************************************/ |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 329 | static int palmtx_irda_startup(struct device *dev) |
| 330 | { |
| 331 | int err; |
| 332 | err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE"); |
| 333 | if (err) |
| 334 | goto err; |
| 335 | err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1); |
| 336 | if (err) |
| 337 | gpio_free(GPIO_NR_PALMTX_IR_DISABLE); |
| 338 | err: |
| 339 | return err; |
| 340 | } |
| 341 | |
| 342 | static void palmtx_irda_shutdown(struct device *dev) |
| 343 | { |
| 344 | gpio_free(GPIO_NR_PALMTX_IR_DISABLE); |
| 345 | } |
| 346 | |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 347 | static void palmtx_irda_transceiver_mode(struct device *dev, int mode) |
| 348 | { |
| 349 | gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF); |
| 350 | pxa2xx_transceiver_mode(dev, mode); |
| 351 | } |
| 352 | |
| 353 | static struct pxaficp_platform_data palmtx_ficp_platform_data = { |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 354 | .startup = palmtx_irda_startup, |
| 355 | .shutdown = palmtx_irda_shutdown, |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 356 | .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF, |
| 357 | .transceiver_mode = palmtx_irda_transceiver_mode, |
| 358 | }; |
| 359 | |
| 360 | /****************************************************************************** |
| 361 | * UDC |
| 362 | ******************************************************************************/ |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 363 | static struct gpio_vbus_mach_info palmtx_udc_info = { |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 364 | .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N, |
| 365 | .gpio_vbus_inverted = 1, |
Marek Vasut | efb12cd | 2009-04-12 16:37:23 +0200 | [diff] [blame] | 366 | .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP, |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 367 | }; |
| 368 | |
| 369 | static struct platform_device palmtx_gpio_vbus = { |
| 370 | .name = "gpio-vbus", |
| 371 | .id = -1, |
| 372 | .dev = { |
| 373 | .platform_data = &palmtx_udc_info, |
| 374 | }, |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 375 | }; |
| 376 | |
| 377 | /****************************************************************************** |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 378 | * Power supply |
| 379 | ******************************************************************************/ |
| 380 | static int power_supply_init(struct device *dev) |
| 381 | { |
| 382 | int ret; |
| 383 | |
| 384 | ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC"); |
| 385 | if (ret) |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 386 | goto err1; |
| 387 | ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT); |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 388 | if (ret) |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 389 | goto err2; |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 390 | |
| 391 | return 0; |
| 392 | |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 393 | err2: |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 394 | gpio_free(GPIO_NR_PALMTX_POWER_DETECT); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 395 | err1: |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 396 | return ret; |
| 397 | } |
| 398 | |
| 399 | static int palmtx_is_ac_online(void) |
| 400 | { |
| 401 | return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT); |
| 402 | } |
| 403 | |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 404 | static void power_supply_exit(struct device *dev) |
| 405 | { |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 406 | gpio_free(GPIO_NR_PALMTX_POWER_DETECT); |
| 407 | } |
| 408 | |
| 409 | static char *palmtx_supplicants[] = { |
| 410 | "main-battery", |
| 411 | }; |
| 412 | |
| 413 | static struct pda_power_pdata power_supply_info = { |
| 414 | .init = power_supply_init, |
| 415 | .is_ac_online = palmtx_is_ac_online, |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 416 | .exit = power_supply_exit, |
| 417 | .supplied_to = palmtx_supplicants, |
| 418 | .num_supplicants = ARRAY_SIZE(palmtx_supplicants), |
| 419 | }; |
| 420 | |
| 421 | static struct platform_device power_supply = { |
| 422 | .name = "pda-power", |
| 423 | .id = -1, |
| 424 | .dev = { |
| 425 | .platform_data = &power_supply_info, |
| 426 | }, |
| 427 | }; |
| 428 | |
| 429 | /****************************************************************************** |
Marek Vašut | 4e9687d | 2008-09-11 19:37:32 +0100 | [diff] [blame] | 430 | * WM97xx battery |
| 431 | ******************************************************************************/ |
| 432 | static struct wm97xx_batt_info wm97xx_batt_pdata = { |
| 433 | .batt_aux = WM97XX_AUX_ID3, |
| 434 | .temp_aux = WM97XX_AUX_ID2, |
| 435 | .charge_gpio = -1, |
| 436 | .max_voltage = PALMTX_BAT_MAX_VOLTAGE, |
| 437 | .min_voltage = PALMTX_BAT_MIN_VOLTAGE, |
| 438 | .batt_mult = 1000, |
| 439 | .batt_div = 414, |
| 440 | .temp_mult = 1, |
| 441 | .temp_div = 1, |
| 442 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO, |
| 443 | .batt_name = "main-batt", |
| 444 | }; |
| 445 | |
| 446 | /****************************************************************************** |
Marek Vasut | e91fb91 | 2009-04-17 11:37:35 +0200 | [diff] [blame] | 447 | * aSoC audio |
| 448 | ******************************************************************************/ |
| 449 | static struct palm27x_asoc_info palmtx_asoc_pdata = { |
| 450 | .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT, |
| 451 | }; |
| 452 | |
| 453 | static pxa2xx_audio_ops_t palmtx_ac97_pdata = { |
| 454 | .reset_gpio = 95, |
| 455 | }; |
| 456 | |
| 457 | static struct platform_device palmtx_asoc = { |
| 458 | .name = "palm27x-asoc", |
| 459 | .id = -1, |
| 460 | .dev = { |
| 461 | .platform_data = &palmtx_asoc_pdata, |
| 462 | }, |
| 463 | }; |
| 464 | |
| 465 | /****************************************************************************** |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 466 | * Framebuffer |
| 467 | ******************************************************************************/ |
| 468 | static struct pxafb_mode_info palmtx_lcd_modes[] = { |
| 469 | { |
| 470 | .pixclock = 57692, |
| 471 | .xres = 320, |
| 472 | .yres = 480, |
| 473 | .bpp = 16, |
| 474 | |
| 475 | .left_margin = 32, |
| 476 | .right_margin = 1, |
| 477 | .upper_margin = 7, |
| 478 | .lower_margin = 1, |
| 479 | |
| 480 | .hsync_len = 4, |
| 481 | .vsync_len = 1, |
| 482 | }, |
| 483 | }; |
| 484 | |
| 485 | static struct pxafb_mach_info palmtx_lcd_screen = { |
| 486 | .modes = palmtx_lcd_modes, |
| 487 | .num_modes = ARRAY_SIZE(palmtx_lcd_modes), |
| 488 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
| 489 | }; |
| 490 | |
| 491 | /****************************************************************************** |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 492 | * Power management - standby |
| 493 | ******************************************************************************/ |
Marek Vasut | fc9c1b6 | 2009-05-14 11:27:00 +0200 | [diff] [blame] | 494 | static void __init palmtx_pm_init(void) |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 495 | { |
Marek Vasut | fc9c1b6 | 2009-05-14 11:27:00 +0200 | [diff] [blame] | 496 | static u32 resume[] = { |
| 497 | 0xe3a00101, /* mov r0, #0x40000000 */ |
| 498 | 0xe380060f, /* orr r0, r0, #0x00f00000 */ |
| 499 | 0xe590f008, /* ldr pc, [r0, #0x08] */ |
| 500 | }; |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 501 | |
Marek Vasut | fc9c1b6 | 2009-05-14 11:27:00 +0200 | [diff] [blame] | 502 | /* copy the bootloader */ |
| 503 | memcpy(phys_to_virt(PALMTX_STR_BASE), resume, sizeof(resume)); |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 504 | } |
| 505 | |
Marek Vasut | 81854f8 | 2009-03-28 12:37:42 +0100 | [diff] [blame] | 506 | /****************************************************************************** |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 507 | * Machine init |
| 508 | ******************************************************************************/ |
| 509 | static struct platform_device *devices[] __initdata = { |
| 510 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 511 | &palmtx_pxa_keys, |
| 512 | #endif |
| 513 | &palmtx_backlight, |
Marek Vašut | d4b19c4 | 2008-07-07 17:31:58 +0100 | [diff] [blame] | 514 | &power_supply, |
Marek Vasut | e91fb91 | 2009-04-17 11:37:35 +0200 | [diff] [blame] | 515 | &palmtx_asoc, |
Marek Vasut | 8768dc9 | 2009-04-23 11:12:37 +0200 | [diff] [blame] | 516 | &palmtx_gpio_vbus, |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 517 | }; |
| 518 | |
| 519 | static struct map_desc palmtx_io_desc[] __initdata = { |
| 520 | { |
| 521 | .virtual = PALMTX_PCMCIA_VIRT, |
| 522 | .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS), |
| 523 | .length = PALMTX_PCMCIA_SIZE, |
| 524 | .type = MT_DEVICE |
| 525 | }, |
| 526 | }; |
| 527 | |
| 528 | static void __init palmtx_map_io(void) |
| 529 | { |
| 530 | pxa_map_io(); |
| 531 | iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc)); |
| 532 | } |
| 533 | |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 534 | /* setup udc GPIOs initial state */ |
| 535 | static void __init palmtx_udc_init(void) |
| 536 | { |
Marek Vasut | efb12cd | 2009-04-12 16:37:23 +0200 | [diff] [blame] | 537 | if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) { |
| 538 | gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1); |
| 539 | gpio_free(GPIO_NR_PALMTX_USB_PULLUP); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | |
| 543 | |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 544 | static void __init palmtx_init(void) |
| 545 | { |
| 546 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config)); |
| 547 | |
Marek Vasut | fc9c1b6 | 2009-05-14 11:27:00 +0200 | [diff] [blame] | 548 | palmtx_pm_init(); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 549 | set_pxa_fb_info(&palmtx_lcd_screen); |
| 550 | pxa_set_mci_info(&palmtx_mci_platform_data); |
Marek Vasut | a730b32 | 2008-11-20 17:34:57 +0100 | [diff] [blame] | 551 | palmtx_udc_init(); |
Marek Vasut | e91fb91 | 2009-04-17 11:37:35 +0200 | [diff] [blame] | 552 | pxa_set_ac97_info(&palmtx_ac97_pdata); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 553 | pxa_set_ficp_info(&palmtx_ficp_platform_data); |
| 554 | pxa_set_keypad_info(&palmtx_keypad_platform_data); |
Marek Vašut | 4e9687d | 2008-09-11 19:37:32 +0100 | [diff] [blame] | 555 | wm97xx_bat_set_pdata(&wm97xx_batt_pdata); |
Marek Vašut | b5e4ad5 | 2008-07-07 17:25:46 +0100 | [diff] [blame] | 556 | |
| 557 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 558 | } |
| 559 | |
| 560 | MACHINE_START(PALMTX, "Palm T|X") |
| 561 | .phys_io = PALMTX_PHYS_IO_START, |
| 562 | .io_pg_offst = io_p2v(0x40000000), |
| 563 | .boot_params = 0xa0000100, |
| 564 | .map_io = palmtx_map_io, |
| 565 | .init_irq = pxa27x_init_irq, |
| 566 | .timer = &pxa_timer, |
| 567 | .init_machine = palmtx_init |
| 568 | MACHINE_END |