board-htcherald.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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 const unsigned int htc_herald_keymap[] = {
  165. KEY(0, 0, KEY_RECORD), /* Mail button */
  166. KEY(1, 0, KEY_CAMERA), /* Camera */
  167. KEY(2, 0, KEY_PHONE), /* Send key */
  168. KEY(3, 0, KEY_VOLUMEUP), /* Volume up */
  169. KEY(4, 0, KEY_F2), /* Right bar (landscape) */
  170. KEY(5, 0, KEY_MAIL), /* Win key (portrait) */
  171. KEY(6, 0, KEY_DIRECTORY), /* Right bar (protrait) */
  172. KEY(0, 1, KEY_LEFTCTRL), /* Windows key */
  173. KEY(1, 1, KEY_COMMA),
  174. KEY(2, 1, KEY_M),
  175. KEY(3, 1, KEY_K),
  176. KEY(4, 1, KEY_SLASH), /* OK key */
  177. KEY(5, 1, KEY_I),
  178. KEY(6, 1, KEY_U),
  179. KEY(0, 2, KEY_LEFTALT),
  180. KEY(1, 2, KEY_TAB),
  181. KEY(2, 2, KEY_N),
  182. KEY(3, 2, KEY_J),
  183. KEY(4, 2, KEY_ENTER),
  184. KEY(5, 2, KEY_H),
  185. KEY(6, 2, KEY_Y),
  186. KEY(0, 3, KEY_SPACE),
  187. KEY(1, 3, KEY_L),
  188. KEY(2, 3, KEY_B),
  189. KEY(3, 3, KEY_V),
  190. KEY(4, 3, KEY_BACKSPACE),
  191. KEY(5, 3, KEY_G),
  192. KEY(6, 3, KEY_T),
  193. KEY(0, 4, KEY_CAPSLOCK), /* Shift */
  194. KEY(1, 4, KEY_C),
  195. KEY(2, 4, KEY_F),
  196. KEY(3, 4, KEY_R),
  197. KEY(4, 4, KEY_O),
  198. KEY(5, 4, KEY_E),
  199. KEY(6, 4, KEY_D),
  200. KEY(0, 5, KEY_X),
  201. KEY(1, 5, KEY_Z),
  202. KEY(2, 5, KEY_S),
  203. KEY(3, 5, KEY_W),
  204. KEY(4, 5, KEY_P),
  205. KEY(5, 5, KEY_Q),
  206. KEY(6, 5, KEY_A),
  207. KEY(0, 6, KEY_CONNECT), /* Voice button */
  208. KEY(2, 6, KEY_CANCEL), /* End key */
  209. KEY(3, 6, KEY_VOLUMEDOWN), /* Volume down */
  210. KEY(4, 6, KEY_F1), /* Left bar (landscape) */
  211. KEY(5, 6, KEY_WWW), /* OK button (portrait) */
  212. KEY(6, 6, KEY_CALENDAR), /* Left bar (portrait) */
  213. };
  214. static const struct matrix_keymap_data htc_herald_keymap_data = {
  215. .keymap = htc_herald_keymap,
  216. .keymap_size = ARRAY_SIZE(htc_herald_keymap),
  217. };
  218. static struct omap_kp_platform_data htcherald_kp_data = {
  219. .rows = 7,
  220. .cols = 7,
  221. .delay = 20,
  222. .rep = true,
  223. .keymap_data = &htc_herald_keymap_data,
  224. };
  225. static struct resource kp_resources[] = {
  226. [0] = {
  227. .start = INT_7XX_MPUIO_KEYPAD,
  228. .end = INT_7XX_MPUIO_KEYPAD,
  229. .flags = IORESOURCE_IRQ,
  230. },
  231. };
  232. static struct platform_device kp_device = {
  233. .name = "omap-keypad",
  234. .id = -1,
  235. .dev = {
  236. .platform_data = &htcherald_kp_data,
  237. },
  238. .num_resources = ARRAY_SIZE(kp_resources),
  239. .resource = kp_resources,
  240. };
  241. /* GPIO buttons for keyboard slide and power button */
  242. static struct gpio_keys_button herald_gpio_keys_table[] = {
  243. {BTN_0, HTCHERALD_GPIO_POWER, 1, "POWER", EV_KEY, 1, 20},
  244. {SW_LID, HTCHERALD_GPIO_SLIDE, 0, "SLIDE", EV_SW, 1, 20},
  245. {KEY_LEFT, HTCPLD_GPIO_LEFT_KBD, 1, "LEFT", EV_KEY, 1, 20},
  246. {KEY_RIGHT, HTCPLD_GPIO_RIGHT_KBD, 1, "RIGHT", EV_KEY, 1, 20},
  247. {KEY_UP, HTCPLD_GPIO_UP_KBD, 1, "UP", EV_KEY, 1, 20},
  248. {KEY_DOWN, HTCPLD_GPIO_DOWN_KBD, 1, "DOWN", EV_KEY, 1, 20},
  249. {KEY_LEFT, HTCPLD_GPIO_LEFT_DPAD, 1, "DLEFT", EV_KEY, 1, 20},
  250. {KEY_RIGHT, HTCPLD_GPIO_RIGHT_DPAD, 1, "DRIGHT", EV_KEY, 1, 20},
  251. {KEY_UP, HTCPLD_GPIO_UP_DPAD, 1, "DUP", EV_KEY, 1, 20},
  252. {KEY_DOWN, HTCPLD_GPIO_DOWN_DPAD, 1, "DDOWN", EV_KEY, 1, 20},
  253. {KEY_ENTER, HTCPLD_GPIO_ENTER_DPAD, 1, "DENTER", EV_KEY, 1, 20},
  254. };
  255. static struct gpio_keys_platform_data herald_gpio_keys_data = {
  256. .buttons = herald_gpio_keys_table,
  257. .nbuttons = ARRAY_SIZE(herald_gpio_keys_table),
  258. .rep = true,
  259. };
  260. static struct platform_device herald_gpiokeys_device = {
  261. .name = "gpio-keys",
  262. .id = -1,
  263. .dev = {
  264. .platform_data = &herald_gpio_keys_data,
  265. },
  266. };
  267. /* LEDs for the Herald. These connect to the HTCPLD GPIO device. */
  268. static struct gpio_led gpio_leds[] = {
  269. {"dpad", NULL, HTCPLD_GPIO_LED_DPAD, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  270. {"kbd", NULL, HTCPLD_GPIO_LED_KBD, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  271. {"vibrate", NULL, HTCPLD_GPIO_LED_VIBRATE, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  272. {"green_solid", NULL, HTCPLD_GPIO_LED_GREEN_SOLID, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  273. {"green_flash", NULL, HTCPLD_GPIO_LED_GREEN_FLASH, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  274. {"red_solid", "mmc0", HTCPLD_GPIO_LED_RED_SOLID, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  275. {"red_flash", NULL, HTCPLD_GPIO_LED_RED_FLASH, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  276. {"wifi", NULL, HTCPLD_GPIO_LED_WIFI, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  277. {"bt", NULL, HTCPLD_GPIO_LED_BT, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  278. {"caps", NULL, HTCPLD_GPIO_LED_CAPS, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  279. {"alt", NULL, HTCPLD_GPIO_LED_ALT, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
  280. };
  281. static struct gpio_led_platform_data gpio_leds_data = {
  282. .leds = gpio_leds,
  283. .num_leds = ARRAY_SIZE(gpio_leds),
  284. };
  285. static struct platform_device gpio_leds_device = {
  286. .name = "leds-gpio",
  287. .id = 0,
  288. .dev = {
  289. .platform_data = &gpio_leds_data,
  290. },
  291. };
  292. /* HTC PLD chips */
  293. static struct resource htcpld_resources[] = {
  294. [0] = {
  295. .start = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
  296. .end = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
  297. .flags = IORESOURCE_IRQ,
  298. },
  299. };
  300. static struct htcpld_chip_platform_data htcpld_chips[] = {
  301. [0] = {
  302. .addr = 0x03,
  303. .reset = 0x04,
  304. .num_gpios = 8,
  305. .gpio_out_base = HTCPLD_BASE(0, 0),
  306. .gpio_in_base = HTCPLD_BASE(4, 0),
  307. },
  308. [1] = {
  309. .addr = 0x04,
  310. .reset = 0x8e,
  311. .num_gpios = 8,
  312. .gpio_out_base = HTCPLD_BASE(1, 0),
  313. .gpio_in_base = HTCPLD_BASE(5, 0),
  314. },
  315. [2] = {
  316. .addr = 0x05,
  317. .reset = 0x80,
  318. .num_gpios = 8,
  319. .gpio_out_base = HTCPLD_BASE(2, 0),
  320. .gpio_in_base = HTCPLD_BASE(6, 0),
  321. .irq_base = HTCPLD_IRQ(0, 0),
  322. .num_irqs = 8,
  323. },
  324. [3] = {
  325. .addr = 0x06,
  326. .reset = 0x40,
  327. .num_gpios = 8,
  328. .gpio_out_base = HTCPLD_BASE(3, 0),
  329. .gpio_in_base = HTCPLD_BASE(7, 0),
  330. .irq_base = HTCPLD_IRQ(1, 0),
  331. .num_irqs = 8,
  332. },
  333. };
  334. static struct htcpld_core_platform_data htcpld_pfdata = {
  335. .int_reset_gpio_hi = HTCPLD_GPIO_INT_RESET_HI,
  336. .int_reset_gpio_lo = HTCPLD_GPIO_INT_RESET_LO,
  337. .i2c_adapter_id = 1,
  338. .chip = htcpld_chips,
  339. .num_chip = ARRAY_SIZE(htcpld_chips),
  340. };
  341. static struct platform_device htcpld_device = {
  342. .name = "i2c-htcpld",
  343. .id = -1,
  344. .resource = htcpld_resources,
  345. .num_resources = ARRAY_SIZE(htcpld_resources),
  346. .dev = {
  347. .platform_data = &htcpld_pfdata,
  348. },
  349. };
  350. /* USB Device */
  351. static struct omap_usb_config htcherald_usb_config __initdata = {
  352. .otg = 0,
  353. .register_host = 0,
  354. .register_dev = 1,
  355. .hmc_mode = 4,
  356. .pins[0] = 2,
  357. };
  358. /* LCD Device resources */
  359. static struct omap_lcd_config htcherald_lcd_config __initdata = {
  360. .ctrl_name = "internal",
  361. };
  362. static struct omap_board_config_kernel htcherald_config[] __initdata = {
  363. { OMAP_TAG_LCD, &htcherald_lcd_config },
  364. };
  365. static struct platform_device lcd_device = {
  366. .name = "lcd_htcherald",
  367. .id = -1,
  368. };
  369. /* MMC Card */
  370. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
  371. static struct omap_mmc_platform_data htc_mmc1_data = {
  372. .nr_slots = 1,
  373. .switch_slot = NULL,
  374. .slots[0] = {
  375. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  376. .name = "mmcblk",
  377. .nomux = 1,
  378. .wires = 4,
  379. .switch_pin = -1,
  380. },
  381. };
  382. static struct omap_mmc_platform_data *htc_mmc_data[1];
  383. #endif
  384. /* Platform devices for the Herald */
  385. static struct platform_device *devices[] __initdata = {
  386. &kp_device,
  387. &lcd_device,
  388. &htcpld_device,
  389. &gpio_leds_device,
  390. &herald_gpiokeys_device,
  391. };
  392. /*
  393. * Touchscreen
  394. */
  395. static const struct ads7846_platform_data htcherald_ts_platform_data = {
  396. .model = 7846,
  397. .keep_vref_on = 1,
  398. .x_plate_ohms = 496,
  399. .gpio_pendown = HTCHERALD_GPIO_TS,
  400. .pressure_max = 10000,
  401. .pressure_min = 5000,
  402. .x_min = 528,
  403. .x_max = 3760,
  404. .y_min = 624,
  405. .y_max = 3760,
  406. };
  407. static struct spi_board_info __initdata htcherald_spi_board_info[] = {
  408. {
  409. .modalias = "ads7846",
  410. .platform_data = &htcherald_ts_platform_data,
  411. .irq = OMAP_GPIO_IRQ(HTCHERALD_GPIO_TS),
  412. .max_speed_hz = 2500000,
  413. .bus_num = 2,
  414. .chip_select = 1,
  415. }
  416. };
  417. /*
  418. * Init functions from here on
  419. */
  420. static void __init htcherald_lcd_init(void)
  421. {
  422. u32 reg;
  423. unsigned int tries = 200;
  424. /* disable controller if active */
  425. reg = omap_readl(OMAP_LCDC_CONTROL);
  426. if (reg & OMAP_LCDC_CTRL_LCD_EN) {
  427. reg &= ~OMAP_LCDC_CTRL_LCD_EN;
  428. omap_writel(reg, OMAP_LCDC_CONTROL);
  429. /* wait for end of frame */
  430. while (!(omap_readl(OMAP_LCDC_STATUS) & OMAP_LCDC_STAT_DONE)) {
  431. tries--;
  432. if (!tries)
  433. break;
  434. }
  435. if (!tries)
  436. printk(KERN_WARNING "Timeout waiting for end of frame "
  437. "-- LCD may not be available\n");
  438. /* turn off DMA */
  439. reg = omap_readw(OMAP_DMA_LCD_CCR);
  440. reg &= ~(1 << 7);
  441. omap_writew(reg, OMAP_DMA_LCD_CCR);
  442. reg = omap_readw(OMAP_DMA_LCD_CTRL);
  443. reg &= ~(1 << 8);
  444. omap_writew(reg, OMAP_DMA_LCD_CTRL);
  445. }
  446. }
  447. static void __init htcherald_map_io(void)
  448. {
  449. omap1_map_common_io();
  450. /*
  451. * The LCD panel must be disabled and DMA turned off here, as doing
  452. * it later causes the LCD never to reinitialize.
  453. */
  454. htcherald_lcd_init();
  455. printk(KERN_INFO "htcherald_map_io done.\n");
  456. }
  457. static void __init htcherald_disable_watchdog(void)
  458. {
  459. /* Disable watchdog if running */
  460. if (omap_readl(OMAP_WDT_TIMER_MODE) & 0x8000) {
  461. /*
  462. * disable a potentially running watchdog timer before
  463. * it kills us.
  464. */
  465. printk(KERN_WARNING "OMAP850 Watchdog seems to be activated, disabling it for now.\n");
  466. omap_writel(0xF5, OMAP_WDT_TIMER_MODE);
  467. omap_writel(0xA0, OMAP_WDT_TIMER_MODE);
  468. }
  469. }
  470. #define HTCHERALD_GPIO_USB_EN1 33
  471. #define HTCHERALD_GPIO_USB_EN2 73
  472. #define HTCHERALD_GPIO_USB_DM 35
  473. #define HTCHERALD_GPIO_USB_DP 36
  474. static void __init htcherald_usb_enable(void)
  475. {
  476. unsigned int tries = 20;
  477. unsigned int value = 0;
  478. /* Request the GPIOs we need to control here */
  479. if (gpio_request(HTCHERALD_GPIO_USB_EN1, "herald_usb") < 0)
  480. goto err1;
  481. if (gpio_request(HTCHERALD_GPIO_USB_EN2, "herald_usb") < 0)
  482. goto err2;
  483. if (gpio_request(HTCHERALD_GPIO_USB_DM, "herald_usb") < 0)
  484. goto err3;
  485. if (gpio_request(HTCHERALD_GPIO_USB_DP, "herald_usb") < 0)
  486. goto err4;
  487. /* force USB_EN GPIO to 0 */
  488. do {
  489. /* output low */
  490. gpio_direction_output(HTCHERALD_GPIO_USB_EN1, 0);
  491. } while ((value = gpio_get_value(HTCHERALD_GPIO_USB_EN1)) == 1 &&
  492. --tries);
  493. if (value == 1)
  494. printk(KERN_WARNING "Unable to reset USB, trying to continue\n");
  495. gpio_direction_output(HTCHERALD_GPIO_USB_EN2, 0); /* output low */
  496. gpio_direction_input(HTCHERALD_GPIO_USB_DM); /* input */
  497. gpio_direction_input(HTCHERALD_GPIO_USB_DP); /* input */
  498. goto done;
  499. err4:
  500. gpio_free(HTCHERALD_GPIO_USB_DM);
  501. err3:
  502. gpio_free(HTCHERALD_GPIO_USB_EN2);
  503. err2:
  504. gpio_free(HTCHERALD_GPIO_USB_EN1);
  505. err1:
  506. printk(KERN_ERR "Unabled to request GPIO for USB\n");
  507. done:
  508. printk(KERN_INFO "USB setup complete.\n");
  509. }
  510. static void __init htcherald_init(void)
  511. {
  512. printk(KERN_INFO "HTC Herald init.\n");
  513. /* Do board initialization before we register all the devices */
  514. omap_board_config = htcherald_config;
  515. omap_board_config_size = ARRAY_SIZE(htcherald_config);
  516. platform_add_devices(devices, ARRAY_SIZE(devices));
  517. htcherald_disable_watchdog();
  518. htcherald_usb_enable();
  519. omap1_usb_init(&htcherald_usb_config);
  520. spi_register_board_info(htcherald_spi_board_info,
  521. ARRAY_SIZE(htcherald_spi_board_info));
  522. omap_register_i2c_bus(1, 100, NULL, 0);
  523. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
  524. htc_mmc_data[0] = &htc_mmc1_data;
  525. omap1_init_mmc(htc_mmc_data, 1);
  526. #endif
  527. }
  528. static void __init htcherald_init_irq(void)
  529. {
  530. printk(KERN_INFO "htcherald_init_irq.\n");
  531. omap1_init_common_hw();
  532. omap_init_irq();
  533. }
  534. MACHINE_START(HERALD, "HTC Herald")
  535. /* Maintainer: Cory Maccarrone <darkstar6262@gmail.com> */
  536. /* Maintainer: wing-linux.sourceforge.net */
  537. .boot_params = 0x10000100,
  538. .map_io = htcherald_map_io,
  539. .reserve = omap_reserve,
  540. .init_irq = htcherald_init_irq,
  541. .init_machine = htcherald_init,
  542. .timer = &omap_timer,
  543. MACHINE_END