Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 1 | /* |
| 2 | * HTC Herald board configuration |
| 3 | * Copyright (C) 2009 Cory Maccarrone <darkstar6262@gmail.com> |
| 4 | * Copyright (C) 2009 Wing Linux |
| 5 | * |
| 6 | * Based on the board-htcwizard.c file from the linwizard project: |
| 7 | * Copyright (C) 2006 Unai Uribarri |
| 8 | * Copyright (C) 2008 linwizard.sourceforge.net |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of the |
| 13 | * License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, but |
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 23 | * 02110-1301, USA. |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #include <linux/kernel.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/platform_device.h> |
| 30 | #include <linux/input.h> |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 31 | #include <linux/io.h> |
| 32 | #include <linux/gpio.h> |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 33 | #include <linux/gpio_keys.h> |
| 34 | #include <linux/i2c.h> |
| 35 | #include <linux/i2c-gpio.h> |
| 36 | #include <linux/htcpld.h> |
| 37 | #include <linux/leds.h> |
| 38 | #include <linux/spi/spi.h> |
| 39 | #include <linux/spi/ads7846.h> |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 40 | |
| 41 | #include <asm/mach-types.h> |
| 42 | #include <asm/mach/arch.h> |
| 43 | |
| 44 | #include <plat/omap7xx.h> |
| 45 | #include <plat/common.h> |
| 46 | #include <plat/board.h> |
| 47 | #include <plat/keypad.h> |
Cory Maccarrone | 106997c | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 48 | #include <plat/usb.h> |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 49 | #include <plat/mmc.h> |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 50 | |
| 51 | #include <mach/irqs.h> |
| 52 | |
| 53 | #include <linux/delay.h> |
| 54 | |
| 55 | /* LCD register definition */ |
| 56 | #define OMAP_LCDC_CONTROL (0xfffec000 + 0x00) |
| 57 | #define OMAP_LCDC_STATUS (0xfffec000 + 0x10) |
| 58 | #define OMAP_DMA_LCD_CCR (0xfffee300 + 0xc2) |
| 59 | #define OMAP_DMA_LCD_CTRL (0xfffee300 + 0xc4) |
| 60 | #define OMAP_LCDC_CTRL_LCD_EN (1 << 0) |
| 61 | #define OMAP_LCDC_STAT_DONE (1 << 0) |
| 62 | |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 63 | /* GPIO definitions for the power button and keyboard slide switch */ |
| 64 | #define HTCHERALD_GPIO_POWER 139 |
| 65 | #define HTCHERALD_GPIO_SLIDE 174 |
| 66 | #define HTCHERALD_GIRQ_BTNS 141 |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 67 | |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 68 | /* GPIO definitions for the touchscreen */ |
| 69 | #define HTCHERALD_GPIO_TS 76 |
| 70 | |
| 71 | /* HTCPLD definitions */ |
| 72 | |
| 73 | /* |
| 74 | * CPLD Logic |
| 75 | * |
| 76 | * Chip 3 - 0x03 |
| 77 | * |
| 78 | * Function 7 6 5 4 3 2 1 0 |
| 79 | * ------------------------------------ |
| 80 | * DPAD light x x x x x x x 1 |
| 81 | * SoundDev x x x x 1 x x x |
| 82 | * Screen white 1 x x x x x x x |
| 83 | * MMC power on x x x x x 1 x x |
| 84 | * Happy times (n) 0 x x x x 1 x x |
| 85 | * |
| 86 | * Chip 4 - 0x04 |
| 87 | * |
| 88 | * Function 7 6 5 4 3 2 1 0 |
| 89 | * ------------------------------------ |
| 90 | * Keyboard light x x x x x x x 1 |
| 91 | * LCD Bright (4) x x x x x 1 1 x |
| 92 | * LCD Bright (3) x x x x x 0 1 x |
| 93 | * LCD Bright (2) x x x x x 1 0 x |
| 94 | * LCD Bright (1) x x x x x 0 0 x |
| 95 | * LCD Off x x x x 0 x x x |
| 96 | * LCD image (fb) 1 x x x x x x x |
| 97 | * LCD image (white) 0 x x x x x x x |
| 98 | * Caps lock LED x x 1 x x x x x |
| 99 | * |
| 100 | * Chip 5 - 0x05 |
| 101 | * |
| 102 | * Function 7 6 5 4 3 2 1 0 |
| 103 | * ------------------------------------ |
| 104 | * Red (solid) x x x x x 1 x x |
| 105 | * Red (flash) x x x x x x 1 x |
| 106 | * Green (GSM flash) x x x x 1 x x x |
| 107 | * Green (GSM solid) x x x 1 x x x x |
| 108 | * Green (wifi flash) x x 1 x x x x x |
| 109 | * Blue (bt flash) x 1 x x x x x x |
| 110 | * DPAD Int Enable 1 x x x x x x 0 |
| 111 | * |
| 112 | * (Combinations of the above can be made for different colors.) |
| 113 | * The direction pad interrupt enable must be set each time the |
| 114 | * interrupt is handled. |
| 115 | * |
| 116 | * Chip 6 - 0x06 |
| 117 | * |
| 118 | * Function 7 6 5 4 3 2 1 0 |
| 119 | * ------------------------------------ |
| 120 | * Vibrator x x x x 1 x x x |
| 121 | * Alt LED x x x 1 x x x x |
| 122 | * Screen white 1 x x x x x x x |
| 123 | * Screen white x x 1 x x x x x |
| 124 | * Screen white x 0 x x x x x x |
| 125 | * Enable kbd dpad x x x x x x 0 x |
| 126 | * Happy Times 0 1 0 x x x 0 x |
| 127 | */ |
| 128 | |
| 129 | /* |
| 130 | * HTCPLD GPIO lines start 16 after OMAP_MAX_GPIO_LINES to account |
| 131 | * for the 16 MPUIO lines. |
| 132 | */ |
| 133 | #define HTCPLD_GPIO_START_OFFSET (OMAP_MAX_GPIO_LINES + 16) |
| 134 | #define HTCPLD_IRQ(chip, offset) (OMAP_IRQ_END + 8 * (chip) + (offset)) |
| 135 | #define HTCPLD_BASE(chip, offset) \ |
| 136 | (HTCPLD_GPIO_START_OFFSET + 8 * (chip) + (offset)) |
| 137 | |
| 138 | #define HTCPLD_GPIO_LED_DPAD HTCPLD_BASE(0, 0) |
| 139 | #define HTCPLD_GPIO_LED_KBD HTCPLD_BASE(1, 0) |
| 140 | #define HTCPLD_GPIO_LED_CAPS HTCPLD_BASE(1, 5) |
| 141 | #define HTCPLD_GPIO_LED_RED_FLASH HTCPLD_BASE(2, 1) |
| 142 | #define HTCPLD_GPIO_LED_RED_SOLID HTCPLD_BASE(2, 2) |
| 143 | #define HTCPLD_GPIO_LED_GREEN_FLASH HTCPLD_BASE(2, 3) |
| 144 | #define HTCPLD_GPIO_LED_GREEN_SOLID HTCPLD_BASE(2, 4) |
| 145 | #define HTCPLD_GPIO_LED_WIFI HTCPLD_BASE(2, 5) |
| 146 | #define HTCPLD_GPIO_LED_BT HTCPLD_BASE(2, 6) |
| 147 | #define HTCPLD_GPIO_LED_VIBRATE HTCPLD_BASE(3, 3) |
| 148 | #define HTCPLD_GPIO_LED_ALT HTCPLD_BASE(3, 4) |
| 149 | |
| 150 | #define HTCPLD_GPIO_RIGHT_KBD HTCPLD_BASE(6, 7) |
| 151 | #define HTCPLD_GPIO_UP_KBD HTCPLD_BASE(6, 6) |
| 152 | #define HTCPLD_GPIO_LEFT_KBD HTCPLD_BASE(6, 5) |
| 153 | #define HTCPLD_GPIO_DOWN_KBD HTCPLD_BASE(6, 4) |
| 154 | |
| 155 | #define HTCPLD_GPIO_RIGHT_DPAD HTCPLD_BASE(7, 7) |
| 156 | #define HTCPLD_GPIO_UP_DPAD HTCPLD_BASE(7, 6) |
| 157 | #define HTCPLD_GPIO_LEFT_DPAD HTCPLD_BASE(7, 5) |
| 158 | #define HTCPLD_GPIO_DOWN_DPAD HTCPLD_BASE(7, 4) |
| 159 | #define HTCPLD_GPIO_ENTER_DPAD HTCPLD_BASE(7, 3) |
| 160 | |
| 161 | /* |
| 162 | * The htcpld chip requires a gpio write to a specific line |
| 163 | * to re-enable interrupts after one has occurred. |
| 164 | */ |
| 165 | #define HTCPLD_GPIO_INT_RESET_HI HTCPLD_BASE(2, 7) |
| 166 | #define HTCPLD_GPIO_INT_RESET_LO HTCPLD_BASE(2, 0) |
| 167 | |
| 168 | /* Chip 5 */ |
| 169 | #define HTCPLD_IRQ_RIGHT_KBD HTCPLD_IRQ(0, 7) |
| 170 | #define HTCPLD_IRQ_UP_KBD HTCPLD_IRQ(0, 6) |
| 171 | #define HTCPLD_IRQ_LEFT_KBD HTCPLD_IRQ(0, 5) |
| 172 | #define HTCPLD_IRQ_DOWN_KBD HTCPLD_IRQ(0, 4) |
| 173 | |
| 174 | /* Chip 6 */ |
| 175 | #define HTCPLD_IRQ_RIGHT_DPAD HTCPLD_IRQ(1, 7) |
| 176 | #define HTCPLD_IRQ_UP_DPAD HTCPLD_IRQ(1, 6) |
| 177 | #define HTCPLD_IRQ_LEFT_DPAD HTCPLD_IRQ(1, 5) |
| 178 | #define HTCPLD_IRQ_DOWN_DPAD HTCPLD_IRQ(1, 4) |
| 179 | #define HTCPLD_IRQ_ENTER_DPAD HTCPLD_IRQ(1, 3) |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 180 | |
| 181 | /* Keyboard definition */ |
| 182 | |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 183 | static const unsigned int htc_herald_keymap[] = { |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 184 | KEY(0, 0, KEY_RECORD), /* Mail button */ |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 185 | KEY(1, 0, KEY_CAMERA), /* Camera */ |
| 186 | KEY(2, 0, KEY_PHONE), /* Send key */ |
| 187 | KEY(3, 0, KEY_VOLUMEUP), /* Volume up */ |
| 188 | KEY(4, 0, KEY_F2), /* Right bar (landscape) */ |
| 189 | KEY(5, 0, KEY_MAIL), /* Win key (portrait) */ |
| 190 | KEY(6, 0, KEY_DIRECTORY), /* Right bar (protrait) */ |
| 191 | KEY(0, 1, KEY_LEFTCTRL), /* Windows key */ |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 192 | KEY(1, 1, KEY_COMMA), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 193 | KEY(2, 1, KEY_M), |
| 194 | KEY(3, 1, KEY_K), |
| 195 | KEY(4, 1, KEY_SLASH), /* OK key */ |
| 196 | KEY(5, 1, KEY_I), |
| 197 | KEY(6, 1, KEY_U), |
| 198 | KEY(0, 2, KEY_LEFTALT), |
| 199 | KEY(1, 2, KEY_TAB), |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 200 | KEY(2, 2, KEY_N), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 201 | KEY(3, 2, KEY_J), |
| 202 | KEY(4, 2, KEY_ENTER), |
| 203 | KEY(5, 2, KEY_H), |
| 204 | KEY(6, 2, KEY_Y), |
| 205 | KEY(0, 3, KEY_SPACE), |
| 206 | KEY(1, 3, KEY_L), |
| 207 | KEY(2, 3, KEY_B), |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 208 | KEY(3, 3, KEY_V), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 209 | KEY(4, 3, KEY_BACKSPACE), |
| 210 | KEY(5, 3, KEY_G), |
| 211 | KEY(6, 3, KEY_T), |
| 212 | KEY(0, 4, KEY_CAPSLOCK), /* Shift */ |
| 213 | KEY(1, 4, KEY_C), |
| 214 | KEY(2, 4, KEY_F), |
| 215 | KEY(3, 4, KEY_R), |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 216 | KEY(4, 4, KEY_O), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 217 | KEY(5, 4, KEY_E), |
| 218 | KEY(6, 4, KEY_D), |
| 219 | KEY(0, 5, KEY_X), |
| 220 | KEY(1, 5, KEY_Z), |
| 221 | KEY(2, 5, KEY_S), |
| 222 | KEY(3, 5, KEY_W), |
| 223 | KEY(4, 5, KEY_P), |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 224 | KEY(5, 5, KEY_Q), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 225 | KEY(6, 5, KEY_A), |
| 226 | KEY(0, 6, KEY_CONNECT), /* Voice button */ |
| 227 | KEY(2, 6, KEY_CANCEL), /* End key */ |
| 228 | KEY(3, 6, KEY_VOLUMEDOWN), /* Volume down */ |
| 229 | KEY(4, 6, KEY_F1), /* Left bar (landscape) */ |
| 230 | KEY(5, 6, KEY_WWW), /* OK button (portrait) */ |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 231 | KEY(6, 6, KEY_CALENDAR), /* Left bar (portrait) */ |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 232 | }; |
| 233 | |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 234 | static const struct matrix_keymap_data htc_herald_keymap_data = { |
| 235 | .keymap = htc_herald_keymap, |
| 236 | .keymap_size = ARRAY_SIZE(htc_herald_keymap), |
| 237 | }; |
| 238 | |
| 239 | static struct omap_kp_platform_data htcherald_kp_data = { |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 240 | .rows = 7, |
| 241 | .cols = 7, |
| 242 | .delay = 20, |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 243 | .rep = true, |
| 244 | .keymap_data = &htc_herald_keymap_data, |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | static struct resource kp_resources[] = { |
| 248 | [0] = { |
| 249 | .start = INT_7XX_MPUIO_KEYPAD, |
| 250 | .end = INT_7XX_MPUIO_KEYPAD, |
| 251 | .flags = IORESOURCE_IRQ, |
| 252 | }, |
| 253 | }; |
| 254 | |
| 255 | static struct platform_device kp_device = { |
| 256 | .name = "omap-keypad", |
| 257 | .id = -1, |
| 258 | .dev = { |
| 259 | .platform_data = &htcherald_kp_data, |
| 260 | }, |
| 261 | .num_resources = ARRAY_SIZE(kp_resources), |
| 262 | .resource = kp_resources, |
| 263 | }; |
| 264 | |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 265 | /* GPIO buttons for keyboard slide and power button */ |
| 266 | static struct gpio_keys_button herald_gpio_keys_table[] = { |
| 267 | {BTN_0, HTCHERALD_GPIO_POWER, 1, "POWER", EV_KEY, 1, 20}, |
| 268 | {SW_LID, HTCHERALD_GPIO_SLIDE, 0, "SLIDE", EV_SW, 1, 20}, |
| 269 | |
| 270 | {KEY_LEFT, HTCPLD_GPIO_LEFT_KBD, 1, "LEFT", EV_KEY, 1, 20}, |
| 271 | {KEY_RIGHT, HTCPLD_GPIO_RIGHT_KBD, 1, "RIGHT", EV_KEY, 1, 20}, |
| 272 | {KEY_UP, HTCPLD_GPIO_UP_KBD, 1, "UP", EV_KEY, 1, 20}, |
| 273 | {KEY_DOWN, HTCPLD_GPIO_DOWN_KBD, 1, "DOWN", EV_KEY, 1, 20}, |
| 274 | |
| 275 | {KEY_LEFT, HTCPLD_GPIO_LEFT_DPAD, 1, "DLEFT", EV_KEY, 1, 20}, |
| 276 | {KEY_RIGHT, HTCPLD_GPIO_RIGHT_DPAD, 1, "DRIGHT", EV_KEY, 1, 20}, |
| 277 | {KEY_UP, HTCPLD_GPIO_UP_DPAD, 1, "DUP", EV_KEY, 1, 20}, |
| 278 | {KEY_DOWN, HTCPLD_GPIO_DOWN_DPAD, 1, "DDOWN", EV_KEY, 1, 20}, |
| 279 | {KEY_ENTER, HTCPLD_GPIO_ENTER_DPAD, 1, "DENTER", EV_KEY, 1, 20}, |
| 280 | }; |
| 281 | |
| 282 | static struct gpio_keys_platform_data herald_gpio_keys_data = { |
| 283 | .buttons = herald_gpio_keys_table, |
| 284 | .nbuttons = ARRAY_SIZE(herald_gpio_keys_table), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 285 | .rep = true, |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 286 | }; |
| 287 | |
| 288 | static struct platform_device herald_gpiokeys_device = { |
| 289 | .name = "gpio-keys", |
| 290 | .id = -1, |
| 291 | .dev = { |
| 292 | .platform_data = &herald_gpio_keys_data, |
| 293 | }, |
| 294 | }; |
| 295 | |
| 296 | /* LEDs for the Herald. These connect to the HTCPLD GPIO device. */ |
| 297 | static struct gpio_led gpio_leds[] = { |
| 298 | {"dpad", NULL, HTCPLD_GPIO_LED_DPAD, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 299 | {"kbd", NULL, HTCPLD_GPIO_LED_KBD, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 300 | {"vibrate", NULL, HTCPLD_GPIO_LED_VIBRATE, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 301 | {"green_solid", NULL, HTCPLD_GPIO_LED_GREEN_SOLID, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 302 | {"green_flash", NULL, HTCPLD_GPIO_LED_GREEN_FLASH, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 303 | {"red_solid", "mmc0", HTCPLD_GPIO_LED_RED_SOLID, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 304 | {"red_flash", NULL, HTCPLD_GPIO_LED_RED_FLASH, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 305 | {"wifi", NULL, HTCPLD_GPIO_LED_WIFI, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 306 | {"bt", NULL, HTCPLD_GPIO_LED_BT, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 307 | {"caps", NULL, HTCPLD_GPIO_LED_CAPS, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 308 | {"alt", NULL, HTCPLD_GPIO_LED_ALT, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, |
| 309 | }; |
| 310 | |
| 311 | static struct gpio_led_platform_data gpio_leds_data = { |
| 312 | .leds = gpio_leds, |
| 313 | .num_leds = ARRAY_SIZE(gpio_leds), |
| 314 | }; |
| 315 | |
| 316 | static struct platform_device gpio_leds_device = { |
| 317 | .name = "leds-gpio", |
| 318 | .id = 0, |
| 319 | .dev = { |
| 320 | .platform_data = &gpio_leds_data, |
| 321 | }, |
| 322 | }; |
| 323 | |
| 324 | /* HTC PLD chips */ |
| 325 | |
| 326 | static struct resource htcpld_resources[] = { |
| 327 | [0] = { |
| 328 | .start = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS), |
| 329 | .end = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS), |
| 330 | .flags = IORESOURCE_IRQ, |
| 331 | }, |
| 332 | }; |
| 333 | |
Aaro Koskinen | 140089d | 2011-01-27 16:39:44 -0800 | [diff] [blame] | 334 | static struct htcpld_chip_platform_data htcpld_chips[] = { |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 335 | [0] = { |
| 336 | .addr = 0x03, |
| 337 | .reset = 0x04, |
| 338 | .num_gpios = 8, |
| 339 | .gpio_out_base = HTCPLD_BASE(0, 0), |
| 340 | .gpio_in_base = HTCPLD_BASE(4, 0), |
| 341 | }, |
| 342 | [1] = { |
| 343 | .addr = 0x04, |
| 344 | .reset = 0x8e, |
| 345 | .num_gpios = 8, |
| 346 | .gpio_out_base = HTCPLD_BASE(1, 0), |
| 347 | .gpio_in_base = HTCPLD_BASE(5, 0), |
| 348 | }, |
| 349 | [2] = { |
| 350 | .addr = 0x05, |
| 351 | .reset = 0x80, |
| 352 | .num_gpios = 8, |
| 353 | .gpio_out_base = HTCPLD_BASE(2, 0), |
| 354 | .gpio_in_base = HTCPLD_BASE(6, 0), |
| 355 | .irq_base = HTCPLD_IRQ(0, 0), |
| 356 | .num_irqs = 8, |
| 357 | }, |
| 358 | [3] = { |
| 359 | .addr = 0x06, |
| 360 | .reset = 0x40, |
| 361 | .num_gpios = 8, |
| 362 | .gpio_out_base = HTCPLD_BASE(3, 0), |
| 363 | .gpio_in_base = HTCPLD_BASE(7, 0), |
| 364 | .irq_base = HTCPLD_IRQ(1, 0), |
| 365 | .num_irqs = 8, |
| 366 | }, |
| 367 | }; |
| 368 | |
Aaro Koskinen | 140089d | 2011-01-27 16:39:44 -0800 | [diff] [blame] | 369 | static struct htcpld_core_platform_data htcpld_pfdata = { |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 370 | .int_reset_gpio_hi = HTCPLD_GPIO_INT_RESET_HI, |
| 371 | .int_reset_gpio_lo = HTCPLD_GPIO_INT_RESET_LO, |
| 372 | .i2c_adapter_id = 1, |
| 373 | |
| 374 | .chip = htcpld_chips, |
| 375 | .num_chip = ARRAY_SIZE(htcpld_chips), |
| 376 | }; |
| 377 | |
| 378 | static struct platform_device htcpld_device = { |
| 379 | .name = "i2c-htcpld", |
| 380 | .id = -1, |
| 381 | .resource = htcpld_resources, |
| 382 | .num_resources = ARRAY_SIZE(htcpld_resources), |
| 383 | .dev = { |
| 384 | .platform_data = &htcpld_pfdata, |
| 385 | }, |
| 386 | }; |
| 387 | |
Cory Maccarrone | 106997c | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 388 | /* USB Device */ |
| 389 | static struct omap_usb_config htcherald_usb_config __initdata = { |
| 390 | .otg = 0, |
| 391 | .register_host = 0, |
| 392 | .register_dev = 1, |
| 393 | .hmc_mode = 4, |
| 394 | .pins[0] = 2, |
| 395 | }; |
| 396 | |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 397 | /* LCD Device resources */ |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 398 | static struct omap_lcd_config htcherald_lcd_config __initdata = { |
| 399 | .ctrl_name = "internal", |
| 400 | }; |
| 401 | |
| 402 | static struct omap_board_config_kernel htcherald_config[] __initdata = { |
| 403 | { OMAP_TAG_LCD, &htcherald_lcd_config }, |
| 404 | }; |
| 405 | |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 406 | static struct platform_device lcd_device = { |
| 407 | .name = "lcd_htcherald", |
| 408 | .id = -1, |
| 409 | }; |
| 410 | |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 411 | /* MMC Card */ |
| 412 | #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) |
| 413 | static struct omap_mmc_platform_data htc_mmc1_data = { |
| 414 | .nr_slots = 1, |
| 415 | .switch_slot = NULL, |
| 416 | .slots[0] = { |
Tony Lindgren | 2a12400 | 2010-10-12 16:07:51 -0700 | [diff] [blame] | 417 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 418 | .name = "mmcblk", |
| 419 | .nomux = 1, |
| 420 | .wires = 4, |
| 421 | .switch_pin = -1, |
| 422 | }, |
| 423 | }; |
| 424 | |
| 425 | static struct omap_mmc_platform_data *htc_mmc_data[1]; |
| 426 | #endif |
| 427 | |
| 428 | |
| 429 | /* Platform devices for the Herald */ |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 430 | static struct platform_device *devices[] __initdata = { |
| 431 | &kp_device, |
| 432 | &lcd_device, |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 433 | &htcpld_device, |
| 434 | &gpio_leds_device, |
| 435 | &herald_gpiokeys_device, |
| 436 | }; |
| 437 | |
| 438 | /* |
| 439 | * Touchscreen |
| 440 | */ |
| 441 | static const struct ads7846_platform_data htcherald_ts_platform_data = { |
| 442 | .model = 7846, |
| 443 | .keep_vref_on = 1, |
| 444 | .x_plate_ohms = 496, |
| 445 | .gpio_pendown = HTCHERALD_GPIO_TS, |
Marek Belisko | 16c8a3b | 2010-12-06 12:49:05 +0000 | [diff] [blame] | 446 | .pressure_max = 10000, |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 447 | .pressure_min = 5000, |
| 448 | .x_min = 528, |
| 449 | .x_max = 3760, |
| 450 | .y_min = 624, |
| 451 | .y_max = 3760, |
| 452 | }; |
| 453 | |
| 454 | static struct spi_board_info __initdata htcherald_spi_board_info[] = { |
| 455 | { |
| 456 | .modalias = "ads7846", |
| 457 | .platform_data = &htcherald_ts_platform_data, |
| 458 | .irq = OMAP_GPIO_IRQ(HTCHERALD_GPIO_TS), |
| 459 | .max_speed_hz = 2500000, |
| 460 | .bus_num = 2, |
| 461 | .chip_select = 1, |
| 462 | } |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 463 | }; |
| 464 | |
| 465 | /* |
| 466 | * Init functions from here on |
| 467 | */ |
| 468 | |
| 469 | static void __init htcherald_lcd_init(void) |
| 470 | { |
| 471 | u32 reg; |
| 472 | unsigned int tries = 200; |
| 473 | |
| 474 | /* disable controller if active */ |
| 475 | reg = omap_readl(OMAP_LCDC_CONTROL); |
| 476 | if (reg & OMAP_LCDC_CTRL_LCD_EN) { |
| 477 | reg &= ~OMAP_LCDC_CTRL_LCD_EN; |
| 478 | omap_writel(reg, OMAP_LCDC_CONTROL); |
| 479 | |
| 480 | /* wait for end of frame */ |
| 481 | while (!(omap_readl(OMAP_LCDC_STATUS) & OMAP_LCDC_STAT_DONE)) { |
| 482 | tries--; |
| 483 | if (!tries) |
| 484 | break; |
| 485 | } |
| 486 | if (!tries) |
| 487 | printk(KERN_WARNING "Timeout waiting for end of frame " |
| 488 | "-- LCD may not be available\n"); |
| 489 | |
| 490 | /* turn off DMA */ |
| 491 | reg = omap_readw(OMAP_DMA_LCD_CCR); |
| 492 | reg &= ~(1 << 7); |
| 493 | omap_writew(reg, OMAP_DMA_LCD_CCR); |
| 494 | |
| 495 | reg = omap_readw(OMAP_DMA_LCD_CTRL); |
| 496 | reg &= ~(1 << 8); |
| 497 | omap_writew(reg, OMAP_DMA_LCD_CTRL); |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | static void __init htcherald_map_io(void) |
| 502 | { |
| 503 | omap1_map_common_io(); |
| 504 | |
| 505 | /* |
| 506 | * The LCD panel must be disabled and DMA turned off here, as doing |
| 507 | * it later causes the LCD never to reinitialize. |
| 508 | */ |
| 509 | htcherald_lcd_init(); |
| 510 | |
| 511 | printk(KERN_INFO "htcherald_map_io done.\n"); |
| 512 | } |
| 513 | |
| 514 | static void __init htcherald_disable_watchdog(void) |
| 515 | { |
| 516 | /* Disable watchdog if running */ |
| 517 | if (omap_readl(OMAP_WDT_TIMER_MODE) & 0x8000) { |
| 518 | /* |
| 519 | * disable a potentially running watchdog timer before |
| 520 | * it kills us. |
| 521 | */ |
| 522 | printk(KERN_WARNING "OMAP850 Watchdog seems to be activated, disabling it for now.\n"); |
| 523 | omap_writel(0xF5, OMAP_WDT_TIMER_MODE); |
| 524 | omap_writel(0xA0, OMAP_WDT_TIMER_MODE); |
| 525 | } |
| 526 | } |
| 527 | |
Cory Maccarrone | 106997c | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 528 | #define HTCHERALD_GPIO_USB_EN1 33 |
| 529 | #define HTCHERALD_GPIO_USB_EN2 73 |
| 530 | #define HTCHERALD_GPIO_USB_DM 35 |
| 531 | #define HTCHERALD_GPIO_USB_DP 36 |
| 532 | |
| 533 | static void __init htcherald_usb_enable(void) |
| 534 | { |
| 535 | unsigned int tries = 20; |
| 536 | unsigned int value = 0; |
| 537 | |
| 538 | /* Request the GPIOs we need to control here */ |
| 539 | if (gpio_request(HTCHERALD_GPIO_USB_EN1, "herald_usb") < 0) |
| 540 | goto err1; |
| 541 | |
| 542 | if (gpio_request(HTCHERALD_GPIO_USB_EN2, "herald_usb") < 0) |
| 543 | goto err2; |
| 544 | |
| 545 | if (gpio_request(HTCHERALD_GPIO_USB_DM, "herald_usb") < 0) |
| 546 | goto err3; |
| 547 | |
| 548 | if (gpio_request(HTCHERALD_GPIO_USB_DP, "herald_usb") < 0) |
| 549 | goto err4; |
| 550 | |
| 551 | /* force USB_EN GPIO to 0 */ |
| 552 | do { |
| 553 | /* output low */ |
| 554 | gpio_direction_output(HTCHERALD_GPIO_USB_EN1, 0); |
| 555 | } while ((value = gpio_get_value(HTCHERALD_GPIO_USB_EN1)) == 1 && |
| 556 | --tries); |
| 557 | |
| 558 | if (value == 1) |
| 559 | printk(KERN_WARNING "Unable to reset USB, trying to continue\n"); |
| 560 | |
| 561 | gpio_direction_output(HTCHERALD_GPIO_USB_EN2, 0); /* output low */ |
| 562 | gpio_direction_input(HTCHERALD_GPIO_USB_DM); /* input */ |
| 563 | gpio_direction_input(HTCHERALD_GPIO_USB_DP); /* input */ |
| 564 | |
| 565 | goto done; |
| 566 | |
| 567 | err4: |
| 568 | gpio_free(HTCHERALD_GPIO_USB_DM); |
| 569 | err3: |
| 570 | gpio_free(HTCHERALD_GPIO_USB_EN2); |
| 571 | err2: |
| 572 | gpio_free(HTCHERALD_GPIO_USB_EN1); |
| 573 | err1: |
| 574 | printk(KERN_ERR "Unabled to request GPIO for USB\n"); |
| 575 | done: |
| 576 | printk(KERN_INFO "USB setup complete.\n"); |
| 577 | } |
| 578 | |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 579 | static void __init htcherald_init(void) |
| 580 | { |
| 581 | printk(KERN_INFO "HTC Herald init.\n"); |
| 582 | |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 583 | /* Do board initialization before we register all the devices */ |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 584 | omap_board_config = htcherald_config; |
| 585 | omap_board_config_size = ARRAY_SIZE(htcherald_config); |
| 586 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 587 | |
| 588 | htcherald_disable_watchdog(); |
Cory Maccarrone | 106997c | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 589 | |
| 590 | htcherald_usb_enable(); |
Tony Lindgren | dd0cdd8 | 2010-07-05 16:31:30 +0300 | [diff] [blame] | 591 | omap1_usb_init(&htcherald_usb_config); |
Cory Maccarrone | 493c32a | 2010-08-18 04:35:46 +0000 | [diff] [blame] | 592 | |
| 593 | spi_register_board_info(htcherald_spi_board_info, |
| 594 | ARRAY_SIZE(htcherald_spi_board_info)); |
| 595 | |
| 596 | omap_register_i2c_bus(1, 100, NULL, 0); |
| 597 | |
| 598 | #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) |
| 599 | htc_mmc_data[0] = &htc_mmc1_data; |
| 600 | omap1_init_mmc(htc_mmc_data, 1); |
| 601 | #endif |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | static void __init htcherald_init_irq(void) |
| 605 | { |
| 606 | printk(KERN_INFO "htcherald_init_irq.\n"); |
| 607 | omap1_init_common_hw(); |
| 608 | omap_init_irq(); |
| 609 | } |
| 610 | |
| 611 | MACHINE_START(HERALD, "HTC Herald") |
| 612 | /* Maintainer: Cory Maccarrone <darkstar6262@gmail.com> */ |
| 613 | /* Maintainer: wing-linux.sourceforge.net */ |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 614 | .boot_params = 0x10000100, |
| 615 | .map_io = htcherald_map_io, |
Russell King | 71ee7da | 2010-05-23 10:18:16 +0100 | [diff] [blame] | 616 | .reserve = omap_reserve, |
Cory Maccarrone | 9c2816f | 2009-11-22 10:11:34 -0800 | [diff] [blame] | 617 | .init_irq = htcherald_init_irq, |
| 618 | .init_machine = htcherald_init, |
| 619 | .timer = &omap_timer, |
| 620 | MACHINE_END |