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