functionDefinition.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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/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 */