board-htcherald.c 17 KB

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