board-htcherald.c 17 KB

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