Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 1 | /* |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 2 | * Hardware definitions for Palm Treo smartphones |
| 3 | * |
| 4 | * currently supported: |
| 5 | * Palm Treo 680 (GSM) |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 6 | * |
| 7 | * Author: Tomas Cech <sleep_walker@suse.cz> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | * (find more info at www.hackndev.com) |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/delay.h> |
| 19 | #include <linux/irq.h> |
| 20 | #include <linux/gpio_keys.h> |
| 21 | #include <linux/input.h> |
| 22 | #include <linux/pda_power.h> |
| 23 | #include <linux/pwm_backlight.h> |
| 24 | #include <linux/gpio.h> |
| 25 | #include <linux/wm97xx_batt.h> |
| 26 | #include <linux/power_supply.h> |
| 27 | #include <linux/sysdev.h> |
| 28 | #include <linux/w1-gpio.h> |
| 29 | |
| 30 | #include <asm/mach-types.h> |
| 31 | #include <asm/mach/arch.h> |
| 32 | #include <asm/mach/map.h> |
| 33 | |
| 34 | #include <mach/pxa27x.h> |
| 35 | #include <mach/pxa27x-udc.h> |
| 36 | #include <mach/audio.h> |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 37 | #include <mach/palmtreo.h> |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 38 | #include <mach/mmc.h> |
| 39 | #include <mach/pxafb.h> |
| 40 | #include <mach/irda.h> |
| 41 | #include <mach/pxa27x_keypad.h> |
| 42 | #include <mach/udc.h> |
| 43 | #include <mach/ohci.h> |
| 44 | #include <mach/pxa2xx-regs.h> |
| 45 | #include <mach/palmasoc.h> |
| 46 | #include <mach/camera.h> |
| 47 | |
| 48 | #include <sound/pxa2xx-lib.h> |
| 49 | |
| 50 | #include "generic.h" |
| 51 | #include "devices.h" |
| 52 | |
| 53 | /****************************************************************************** |
| 54 | * Pin configuration |
| 55 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 56 | static unsigned long treo_pin_config[] __initdata = { |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 57 | /* MMC */ |
| 58 | GPIO32_MMC_CLK, |
| 59 | GPIO92_MMC_DAT_0, |
| 60 | GPIO109_MMC_DAT_1, |
| 61 | GPIO110_MMC_DAT_2, |
| 62 | GPIO111_MMC_DAT_3, |
| 63 | GPIO112_MMC_CMD, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 64 | GPIO113_GPIO, /* SD detect */ |
| 65 | |
| 66 | /* AC97 */ |
| 67 | GPIO28_AC97_BITCLK, |
| 68 | GPIO29_AC97_SDATA_IN_0, |
| 69 | GPIO30_AC97_SDATA_OUT, |
| 70 | GPIO31_AC97_SYNC, |
| 71 | GPIO89_AC97_SYSCLK, |
| 72 | GPIO95_AC97_nRESET, |
| 73 | |
| 74 | /* IrDA */ |
| 75 | GPIO46_FICP_RXD, |
| 76 | GPIO47_FICP_TXD, |
| 77 | |
| 78 | /* PWM */ |
| 79 | GPIO16_PWM0_OUT, |
| 80 | |
| 81 | /* USB */ |
| 82 | GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* usb detect */ |
| 83 | |
| 84 | /* MATRIX KEYPAD */ |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 85 | GPIO101_KP_MKIN_1, |
| 86 | GPIO102_KP_MKIN_2, |
| 87 | GPIO97_KP_MKIN_3, |
| 88 | GPIO98_KP_MKIN_4, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 89 | GPIO91_KP_MKIN_6, |
| 90 | GPIO13_KP_MKIN_7, |
| 91 | GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH, |
| 92 | GPIO104_KP_MKOUT_1, |
| 93 | GPIO105_KP_MKOUT_2, |
| 94 | GPIO106_KP_MKOUT_3, |
| 95 | GPIO107_KP_MKOUT_4, |
| 96 | GPIO108_KP_MKOUT_5, |
| 97 | GPIO96_KP_MKOUT_6, |
| 98 | GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH, /* Hotsync button */ |
| 99 | |
| 100 | /* LCD */ |
| 101 | GPIO58_LCD_LDD_0, |
| 102 | GPIO59_LCD_LDD_1, |
| 103 | GPIO60_LCD_LDD_2, |
| 104 | GPIO61_LCD_LDD_3, |
| 105 | GPIO62_LCD_LDD_4, |
| 106 | GPIO63_LCD_LDD_5, |
| 107 | GPIO64_LCD_LDD_6, |
| 108 | GPIO65_LCD_LDD_7, |
| 109 | GPIO66_LCD_LDD_8, |
| 110 | GPIO67_LCD_LDD_9, |
| 111 | GPIO68_LCD_LDD_10, |
| 112 | GPIO69_LCD_LDD_11, |
| 113 | GPIO70_LCD_LDD_12, |
| 114 | GPIO71_LCD_LDD_13, |
| 115 | GPIO72_LCD_LDD_14, |
| 116 | GPIO73_LCD_LDD_15, |
| 117 | GPIO74_LCD_FCLK, |
| 118 | GPIO75_LCD_LCLK, |
| 119 | GPIO76_LCD_PCLK, |
| 120 | |
| 121 | /* Quick Capture Interface */ |
| 122 | GPIO84_CIF_FV, |
| 123 | GPIO85_CIF_LV, |
| 124 | GPIO53_CIF_MCLK, |
| 125 | GPIO54_CIF_PCLK, |
| 126 | GPIO81_CIF_DD_0, |
| 127 | GPIO55_CIF_DD_1, |
| 128 | GPIO51_CIF_DD_2, |
| 129 | GPIO50_CIF_DD_3, |
| 130 | GPIO52_CIF_DD_4, |
| 131 | GPIO48_CIF_DD_5, |
| 132 | GPIO17_CIF_DD_6, |
| 133 | GPIO12_CIF_DD_7, |
| 134 | |
| 135 | /* I2C */ |
| 136 | GPIO117_I2C_SCL, |
| 137 | GPIO118_I2C_SDA, |
| 138 | |
| 139 | /* GSM */ |
| 140 | GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */ |
| 141 | GPIO34_FFUART_RXD, |
| 142 | GPIO35_FFUART_CTS, |
| 143 | GPIO39_FFUART_TXD, |
| 144 | GPIO41_FFUART_RTS, |
| 145 | |
| 146 | /* MISC. */ |
| 147 | GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */ |
| 148 | GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */ |
| 149 | GPIO116_GPIO, /* headphone detect */ |
| 150 | GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */ |
| 151 | }; |
| 152 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 153 | #ifdef CONFIG_MACH_TREO680 |
| 154 | static unsigned long treo680_pin_config[] __initdata = { |
| 155 | GPIO33_GPIO, /* SD read only */ |
| 156 | |
| 157 | /* MATRIX KEYPAD - different wake up source */ |
| 158 | GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH, |
| 159 | GPIO99_KP_MKIN_5, |
| 160 | }; |
| 161 | #endif /* CONFIG_MACH_TREO680 */ |
| 162 | |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 163 | /****************************************************************************** |
| 164 | * SD/MMC card controller |
| 165 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 166 | #ifdef CONFIG_MACH_TREO680 |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 167 | static struct pxamci_platform_data treo680_mci_platform_data = { |
walker@suse.cz | 7dafdf3 | 2009-08-31 19:25:57 +0200 | [diff] [blame] | 168 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 169 | .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N, |
walker@suse.cz | 7dafdf3 | 2009-08-31 19:25:57 +0200 | [diff] [blame] | 170 | .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY, |
| 171 | .gpio_power = GPIO_NR_TREO680_SD_POWER, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 172 | }; |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 173 | #endif /* CONFIG_MACH_TREO680 */ |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 174 | |
| 175 | /****************************************************************************** |
| 176 | * GPIO keyboard |
| 177 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 178 | #ifdef CONFIG_MACH_TREO680 |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 179 | static unsigned int treo680_matrix_keys[] = { |
| 180 | KEY(0, 0, KEY_F8), /* Red/Off/Power */ |
| 181 | KEY(0, 1, KEY_LEFT), |
| 182 | KEY(0, 2, KEY_LEFTCTRL), /* Alternate */ |
| 183 | KEY(0, 3, KEY_L), |
| 184 | KEY(0, 4, KEY_A), |
| 185 | KEY(0, 5, KEY_Q), |
| 186 | KEY(0, 6, KEY_P), |
| 187 | |
| 188 | KEY(1, 0, KEY_RIGHTCTRL), /* Menu */ |
| 189 | KEY(1, 1, KEY_RIGHT), |
| 190 | KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */ |
| 191 | KEY(1, 3, KEY_Z), |
| 192 | KEY(1, 4, KEY_S), |
| 193 | KEY(1, 5, KEY_W), |
| 194 | |
| 195 | KEY(2, 0, KEY_F1), /* Phone */ |
| 196 | KEY(2, 1, KEY_UP), |
| 197 | KEY(2, 2, KEY_0), |
| 198 | KEY(2, 3, KEY_X), |
| 199 | KEY(2, 4, KEY_D), |
| 200 | KEY(2, 5, KEY_E), |
| 201 | |
| 202 | KEY(3, 0, KEY_F10), /* Calendar */ |
| 203 | KEY(3, 1, KEY_DOWN), |
| 204 | KEY(3, 2, KEY_SPACE), |
| 205 | KEY(3, 3, KEY_C), |
| 206 | KEY(3, 4, KEY_F), |
| 207 | KEY(3, 5, KEY_R), |
| 208 | |
| 209 | KEY(4, 0, KEY_F12), /* Mail */ |
| 210 | KEY(4, 1, KEY_KPENTER), |
| 211 | KEY(4, 2, KEY_RIGHTALT), /* Alt */ |
| 212 | KEY(4, 3, KEY_V), |
| 213 | KEY(4, 4, KEY_G), |
| 214 | KEY(4, 5, KEY_T), |
| 215 | |
| 216 | KEY(5, 0, KEY_F9), /* Home */ |
| 217 | KEY(5, 1, KEY_PAGEUP), /* Side up */ |
| 218 | KEY(5, 2, KEY_DOT), |
| 219 | KEY(5, 3, KEY_B), |
| 220 | KEY(5, 4, KEY_H), |
| 221 | KEY(5, 5, KEY_Y), |
| 222 | |
| 223 | KEY(6, 0, KEY_TAB), /* Side Activate */ |
| 224 | KEY(6, 1, KEY_PAGEDOWN), /* Side down */ |
| 225 | KEY(6, 2, KEY_ENTER), |
| 226 | KEY(6, 3, KEY_N), |
| 227 | KEY(6, 4, KEY_J), |
| 228 | KEY(6, 5, KEY_U), |
| 229 | |
| 230 | KEY(7, 0, KEY_F6), /* Green/Call */ |
| 231 | KEY(7, 1, KEY_O), |
| 232 | KEY(7, 2, KEY_BACKSPACE), |
| 233 | KEY(7, 3, KEY_M), |
| 234 | KEY(7, 4, KEY_K), |
| 235 | KEY(7, 5, KEY_I), |
| 236 | }; |
| 237 | |
| 238 | static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = { |
| 239 | .matrix_key_rows = 8, |
| 240 | .matrix_key_cols = 7, |
| 241 | .matrix_key_map = treo680_matrix_keys, |
| 242 | .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys), |
| 243 | .direct_key_map = { KEY_CONNECT }, |
| 244 | .direct_key_num = 1, |
| 245 | |
| 246 | .debounce_interval = 30, |
| 247 | }; |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 248 | #endif /* CONFIG_MACH_TREO680 */ |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 249 | |
| 250 | /****************************************************************************** |
| 251 | * aSoC audio |
| 252 | ******************************************************************************/ |
| 253 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 254 | static pxa2xx_audio_ops_t treo_ac97_pdata = { |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 255 | .reset_gpio = 95, |
| 256 | }; |
| 257 | |
| 258 | /****************************************************************************** |
| 259 | * Backlight |
| 260 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 261 | static int treo_backlight_init(struct device *dev) |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 262 | { |
| 263 | int ret; |
| 264 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 265 | ret = gpio_request(GPIO_NR_TREO_BL_POWER, "BL POWER"); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 266 | if (ret) |
| 267 | goto err; |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 268 | ret = gpio_direction_output(GPIO_NR_TREO_BL_POWER, 0); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 269 | if (ret) |
| 270 | goto err2; |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 271 | |
| 272 | return 0; |
Tomáš Čech | 28d7a94 | 2009-09-03 16:55:47 +0200 | [diff] [blame] | 273 | |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 274 | err2: |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 275 | gpio_free(GPIO_NR_TREO_BL_POWER); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 276 | err: |
| 277 | return ret; |
| 278 | } |
| 279 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 280 | static int treo_backlight_notify(int brightness) |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 281 | { |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 282 | gpio_set_value(GPIO_NR_TREO_BL_POWER, brightness); |
| 283 | return TREO_MAX_INTENSITY - brightness; |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 284 | }; |
| 285 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 286 | static void treo_backlight_exit(struct device *dev) |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 287 | { |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 288 | gpio_free(GPIO_NR_TREO_BL_POWER); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 291 | static struct platform_pwm_backlight_data treo_backlight_data = { |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 292 | .pwm_id = 0, |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 293 | .max_brightness = TREO_MAX_INTENSITY, |
| 294 | .dft_brightness = TREO_DEFAULT_INTENSITY, |
| 295 | .pwm_period_ns = TREO_PERIOD_NS, |
| 296 | .init = treo_backlight_init, |
| 297 | .notify = treo_backlight_notify, |
| 298 | .exit = treo_backlight_exit, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 299 | }; |
| 300 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 301 | static struct platform_device treo_backlight = { |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 302 | .name = "pwm-backlight", |
| 303 | .dev = { |
| 304 | .parent = &pxa27x_device_pwm0.dev, |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 305 | .platform_data = &treo_backlight_data, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 306 | }, |
| 307 | }; |
| 308 | |
| 309 | /****************************************************************************** |
| 310 | * IrDA |
| 311 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 312 | static struct pxaficp_platform_data treo_ficp_info = { |
| 313 | .gpio_pwdown = GPIO_NR_TREO_IR_EN, |
Marek Vasut | c4bd017 | 2009-07-17 12:50:43 +0200 | [diff] [blame] | 314 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 315 | }; |
| 316 | |
| 317 | /****************************************************************************** |
| 318 | * UDC |
| 319 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 320 | static struct pxa2xx_udc_mach_info treo_udc_info __initdata = { |
| 321 | .gpio_vbus = GPIO_NR_TREO_USB_DETECT, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 322 | .gpio_vbus_inverted = 1, |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 323 | .gpio_pullup = GPIO_NR_TREO_USB_PULLUP, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 324 | }; |
| 325 | |
| 326 | |
| 327 | /****************************************************************************** |
| 328 | * USB host |
| 329 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 330 | #ifdef CONFIG_MACH_TREO680 |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 331 | static struct pxaohci_platform_data treo680_ohci_info = { |
| 332 | .port_mode = PMM_PERPORT_MODE, |
| 333 | .flags = ENABLE_PORT1 | ENABLE_PORT3, |
| 334 | .power_budget = 0, |
| 335 | }; |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 336 | #endif /* CONFIG_MACH_TREO680 */ |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 337 | |
| 338 | /****************************************************************************** |
| 339 | * Power supply |
| 340 | ******************************************************************************/ |
| 341 | static int power_supply_init(struct device *dev) |
| 342 | { |
| 343 | int ret; |
| 344 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 345 | ret = gpio_request(GPIO_NR_TREO_POWER_DETECT, "CABLE_STATE_AC"); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 346 | if (ret) |
| 347 | goto err1; |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 348 | ret = gpio_direction_input(GPIO_NR_TREO_POWER_DETECT); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 349 | if (ret) |
| 350 | goto err2; |
| 351 | |
| 352 | return 0; |
| 353 | |
| 354 | err2: |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 355 | gpio_free(GPIO_NR_TREO_POWER_DETECT); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 356 | err1: |
| 357 | return ret; |
| 358 | } |
| 359 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 360 | static int treo_is_ac_online(void) |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 361 | { |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 362 | return gpio_get_value(GPIO_NR_TREO_POWER_DETECT); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | static void power_supply_exit(struct device *dev) |
| 366 | { |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 367 | gpio_free(GPIO_NR_TREO_POWER_DETECT); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 368 | } |
| 369 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 370 | static char *treo_supplicants[] = { |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 371 | "main-battery", |
| 372 | }; |
| 373 | |
| 374 | static struct pda_power_pdata power_supply_info = { |
| 375 | .init = power_supply_init, |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 376 | .is_ac_online = treo_is_ac_online, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 377 | .exit = power_supply_exit, |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 378 | .supplied_to = treo_supplicants, |
| 379 | .num_supplicants = ARRAY_SIZE(treo_supplicants), |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 380 | }; |
| 381 | |
| 382 | static struct platform_device power_supply = { |
| 383 | .name = "pda-power", |
| 384 | .id = -1, |
| 385 | .dev = { |
| 386 | .platform_data = &power_supply_info, |
| 387 | }, |
| 388 | }; |
| 389 | |
| 390 | /****************************************************************************** |
| 391 | * Vibra and LEDs |
| 392 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 393 | #ifdef CONFIG_MACH_TREO680 |
| 394 | static struct gpio_led treo680_gpio_leds[] = { |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 395 | { |
| 396 | .name = "treo680:vibra:vibra", |
| 397 | .default_trigger = "none", |
| 398 | .gpio = GPIO_NR_TREO680_VIBRATE_EN, |
| 399 | }, |
| 400 | { |
| 401 | .name = "treo680:green:led", |
| 402 | .default_trigger = "mmc0", |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 403 | .gpio = GPIO_NR_TREO_GREEN_LED, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 404 | }, |
| 405 | { |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 406 | .name = "treo680:white:keybbl", |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 407 | .default_trigger = "none", |
| 408 | .gpio = GPIO_NR_TREO680_KEYB_BL, |
| 409 | }, |
| 410 | }; |
| 411 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 412 | static struct gpio_led_platform_data treo680_gpio_led_info = { |
| 413 | .leds = treo680_gpio_leds, |
| 414 | .num_leds = ARRAY_SIZE(treo680_gpio_leds), |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 415 | }; |
| 416 | |
| 417 | static struct platform_device treo680_leds = { |
| 418 | .name = "leds-gpio", |
| 419 | .id = -1, |
| 420 | .dev = { |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 421 | .platform_data = &treo680_gpio_led_info, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 422 | } |
| 423 | }; |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 424 | #endif /* CONFIG_MACH_TREO680 */ |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 425 | |
| 426 | /****************************************************************************** |
| 427 | * Framebuffer |
| 428 | ******************************************************************************/ |
| 429 | /* TODO: add support for 324x324 */ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 430 | static struct pxafb_mode_info treo_lcd_modes[] = { |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 431 | { |
| 432 | .pixclock = 86538, |
| 433 | .xres = 320, |
| 434 | .yres = 320, |
| 435 | .bpp = 16, |
| 436 | |
| 437 | .left_margin = 20, |
| 438 | .right_margin = 8, |
| 439 | .upper_margin = 8, |
| 440 | .lower_margin = 5, |
| 441 | |
| 442 | .hsync_len = 4, |
| 443 | .vsync_len = 1, |
| 444 | }, |
| 445 | }; |
| 446 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 447 | static void treo_lcd_power(int on, struct fb_var_screeninfo *info) |
Tomáš Čech | 28d7a94 | 2009-09-03 16:55:47 +0200 | [diff] [blame] | 448 | { |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 449 | gpio_set_value(GPIO_NR_TREO_BL_POWER, on); |
Tomáš Čech | 28d7a94 | 2009-09-03 16:55:47 +0200 | [diff] [blame] | 450 | } |
| 451 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 452 | static struct pxafb_mach_info treo_lcd_screen = { |
| 453 | .modes = treo_lcd_modes, |
| 454 | .num_modes = ARRAY_SIZE(treo_lcd_modes), |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 455 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
| 456 | }; |
| 457 | |
| 458 | /****************************************************************************** |
| 459 | * Power management - standby |
| 460 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 461 | static void __init treo_pm_init(void) |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 462 | { |
| 463 | static u32 resume[] = { |
| 464 | 0xe3a00101, /* mov r0, #0x40000000 */ |
| 465 | 0xe380060f, /* orr r0, r0, #0x00f00000 */ |
| 466 | 0xe590f008, /* ldr pc, [r0, #0x08] */ |
| 467 | }; |
| 468 | |
| 469 | /* this is where the bootloader jumps */ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 470 | memcpy(phys_to_virt(TREO_STR_BASE), resume, sizeof(resume)); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | /****************************************************************************** |
| 474 | * Machine init |
| 475 | ******************************************************************************/ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 476 | static struct platform_device *treo_devices[] __initdata = { |
| 477 | &treo_backlight, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 478 | &power_supply, |
| 479 | }; |
| 480 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 481 | #ifdef CONFIG_MACH_TREO680 |
| 482 | static struct platform_device *treo680_devices[] __initdata = { |
| 483 | &treo680_leds, |
| 484 | }; |
| 485 | #endif /* CONFIG_MACH_TREO680 */ |
| 486 | |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 487 | /* setup udc GPIOs initial state */ |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 488 | static void __init treo_udc_init(void) |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 489 | { |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 490 | if (!gpio_request(GPIO_NR_TREO_USB_PULLUP, "UDC Vbus")) { |
| 491 | gpio_direction_output(GPIO_NR_TREO_USB_PULLUP, 1); |
| 492 | gpio_free(GPIO_NR_TREO_USB_PULLUP); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 493 | } |
| 494 | } |
| 495 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 496 | static void __init treo_lcd_power_init(void) |
Tomáš Čech | 28d7a94 | 2009-09-03 16:55:47 +0200 | [diff] [blame] | 497 | { |
| 498 | int ret; |
| 499 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 500 | ret = gpio_request(GPIO_NR_TREO_LCD_POWER, "LCD POWER"); |
Tomáš Čech | 28d7a94 | 2009-09-03 16:55:47 +0200 | [diff] [blame] | 501 | if (ret) { |
| 502 | pr_err("Treo680: LCD power GPIO request failed!\n"); |
| 503 | return; |
| 504 | } |
| 505 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 506 | ret = gpio_direction_output(GPIO_NR_TREO_LCD_POWER, 0); |
Tomáš Čech | 28d7a94 | 2009-09-03 16:55:47 +0200 | [diff] [blame] | 507 | if (ret) { |
| 508 | pr_err("Treo680: setting LCD power GPIO direction failed!\n"); |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 509 | gpio_free(GPIO_NR_TREO_LCD_POWER); |
Tomáš Čech | 28d7a94 | 2009-09-03 16:55:47 +0200 | [diff] [blame] | 510 | return; |
| 511 | } |
| 512 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 513 | treo_lcd_screen.pxafb_lcd_power = treo_lcd_power; |
Tomáš Čech | 28d7a94 | 2009-09-03 16:55:47 +0200 | [diff] [blame] | 514 | } |
| 515 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 516 | static void __init treo_init(void) |
| 517 | { |
| 518 | treo_pm_init(); |
| 519 | pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config)); |
| 520 | treo_lcd_power_init(); |
| 521 | set_pxa_fb_info(&treo_lcd_screen); |
| 522 | treo_udc_init(); |
| 523 | pxa_set_udc_info(&treo_udc_info); |
| 524 | pxa_set_ac97_info(&treo_ac97_pdata); |
| 525 | pxa_set_ficp_info(&treo_ficp_info); |
| 526 | |
| 527 | platform_add_devices(ARRAY_AND_SIZE(treo_devices)); |
| 528 | } |
| 529 | |
| 530 | #ifdef CONFIG_MACH_TREO680 |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 531 | static void __init treo680_init(void) |
| 532 | { |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 533 | treo_init(); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 534 | pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config)); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 535 | pxa_set_mci_info(&treo680_mci_platform_data); |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 536 | pxa_set_keypad_info(&treo680_keypad_platform_data); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 537 | pxa_set_ohci_info(&treo680_ohci_info); |
| 538 | |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 539 | platform_add_devices(ARRAY_AND_SIZE(treo680_devices)); |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | MACHINE_START(TREO680, "Palm Treo 680") |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 543 | .phys_io = TREO_PHYS_IO_START, |
| 544 | .io_pg_offst = io_p2v(0x40000000), |
| 545 | .boot_params = 0xa0000100, |
| 546 | .map_io = pxa_map_io, |
| 547 | .init_irq = pxa27x_init_irq, |
| 548 | .timer = &pxa_timer, |
| 549 | .init_machine = treo680_init, |
Tomas 'Sleep_Walker' Cech | e6c3f4b | 2009-05-18 15:24:14 +0200 | [diff] [blame] | 550 | MACHINE_END |
Tomáš Čech | bb2ae8f | 2009-09-11 13:57:01 +0200 | [diff] [blame^] | 551 | #endif /* CONFIG_MACH_TREO680 */ |