cablePowerDataOperation.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /*
  2. * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved.
  3. * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. #ifndef __MACH_IOMUX_MX3_H__
  20. #define __MACH_IOMUX_MX3_H__
  21. #include <linux/types.h>
  22. /*
  23. * various IOMUX output functions
  24. */
  25. #define IOMUX_OCONFIG_GPIO (0 << 4) /* used as GPIO */
  26. #define IOMUX_OCONFIG_FUNC (1 << 4) /* used as function */
  27. #define IOMUX_OCONFIG_ALT1 (2 << 4) /* used as alternate function 1 */
  28. #define IOMUX_OCONFIG_ALT2 (3 << 4) /* used as alternate function 2 */
  29. #define IOMUX_OCONFIG_ALT3 (4 << 4) /* used as alternate function 3 */
  30. #define IOMUX_OCONFIG_ALT4 (5 << 4) /* used as alternate function 4 */
  31. #define IOMUX_OCONFIG_ALT5 (6 << 4) /* used as alternate function 5 */
  32. #define IOMUX_OCONFIG_ALT6 (7 << 4) /* used as alternate function 6 */
  33. #define IOMUX_ICONFIG_NONE 0 /* not configured for input */
  34. #define IOMUX_ICONFIG_GPIO 1 /* used as GPIO */
  35. #define IOMUX_ICONFIG_FUNC 2 /* used as function */
  36. #define IOMUX_ICONFIG_ALT1 4 /* used as alternate function 1 */
  37. #define IOMUX_ICONFIG_ALT2 8 /* used as alternate function 2 */
  38. #define IOMUX_CONFIG_GPIO (IOMUX_OCONFIG_GPIO | IOMUX_ICONFIG_GPIO)
  39. #define IOMUX_CONFIG_FUNC (IOMUX_OCONFIG_FUNC | IOMUX_ICONFIG_FUNC)
  40. #define IOMUX_CONFIG_ALT1 (IOMUX_OCONFIG_ALT1 | IOMUX_ICONFIG_ALT1)
  41. #define IOMUX_CONFIG_ALT2 (IOMUX_OCONFIG_ALT2 | IOMUX_ICONFIG_ALT2)
  42. /*
  43. * various IOMUX pad functions
  44. */
  45. enum iomux_pad_config {
  46. PAD_CTL_NOLOOPBACK = 0x0 << 9,
  47. PAD_CTL_LOOPBACK = 0x1 << 9,
  48. PAD_CTL_PKE_NONE = 0x0 << 8,
  49. PAD_CTL_PKE_ENABLE = 0x1 << 8,
  50. PAD_CTL_PUE_KEEPER = 0x0 << 7,
  51. PAD_CTL_PUE_PUD = 0x1 << 7,
  52. PAD_CTL_100K_PD = 0x0 << 5,
  53. PAD_CTL_100K_PU = 0x1 << 5,
  54. PAD_CTL_47K_PU = 0x2 << 5,
  55. PAD_CTL_22K_PU = 0x3 << 5,
  56. PAD_CTL_HYS_CMOS = 0x0 << 4,
  57. PAD_CTL_HYS_SCHMITZ = 0x1 << 4,
  58. PAD_CTL_ODE_CMOS = 0x0 << 3,
  59. PAD_CTL_ODE_OpenDrain = 0x1 << 3,
  60. PAD_CTL_DRV_NORMAL = 0x0 << 1,
  61. PAD_CTL_DRV_HIGH = 0x1 << 1,
  62. PAD_CTL_DRV_MAX = 0x2 << 1,
  63. PAD_CTL_SRE_SLOW = 0x0 << 0,
  64. PAD_CTL_SRE_FAST = 0x1 << 0
  65. };
  66. /*
  67. * various IOMUX general purpose functions
  68. */
  69. enum iomux_gp_func {
  70. MUX_PGP_FIRI = 1 << 0,
  71. MUX_DDR_MODE = 1 << 1,
  72. MUX_PGP_CSPI_BB = 1 << 2,
  73. MUX_PGP_ATA_1 = 1 << 3,
  74. MUX_PGP_ATA_2 = 1 << 4,
  75. MUX_PGP_ATA_3 = 1 << 5,
  76. MUX_PGP_ATA_4 = 1 << 6,
  77. MUX_PGP_ATA_5 = 1 << 7,
  78. MUX_PGP_ATA_6 = 1 << 8,
  79. MUX_PGP_ATA_7 = 1 << 9,
  80. MUX_PGP_ATA_8 = 1 << 10,
  81. MUX_PGP_UH2 = 1 << 11,
  82. MUX_SDCTL_CSD0_SEL = 1 << 12,
  83. MUX_SDCTL_CSD1_SEL = 1 << 13,
  84. MUX_CSPI1_UART3 = 1 << 14,
  85. MUX_EXTDMAREQ2_MBX_SEL = 1 << 15,
  86. MUX_TAMPER_DETECT_EN = 1 << 16,
  87. MUX_PGP_USB_4WIRE = 1 << 17,
  88. MUX_PGP_USB_COMMON = 1 << 18,
  89. MUX_SDHC_MEMSTICK1 = 1 << 19,
  90. MUX_SDHC_MEMSTICK2 = 1 << 20,
  91. MUX_PGP_SPLL_BYP = 1 << 21,
  92. MUX_PGP_UPLL_BYP = 1 << 22,
  93. MUX_PGP_MSHC1_CLK_SEL = 1 << 23,
  94. MUX_PGP_MSHC2_CLK_SEL = 1 << 24,
  95. MUX_CSPI3_UART5_SEL = 1 << 25,
  96. MUX_PGP_ATA_9 = 1 << 26,
  97. MUX_PGP_USB_SUSPEND = 1 << 27,
  98. MUX_PGP_USB_OTG_LOOPBACK = 1 << 28,
  99. MUX_PGP_USB_HS1_LOOPBACK = 1 << 29,
  100. MUX_PGP_USB_HS2_LOOPBACK = 1 << 30,
  101. MUX_CLKO_DDR_MODE = 1 << 31,
  102. };
  103. /*
  104. * setups a single pin:
  105. * - reserves the pin so that it is not claimed by another driver
  106. * - setups the iomux according to the configuration
  107. * - if the pin is configured as a GPIO, we claim it through kernel gpiolib
  108. */
  109. int mxc_iomux_alloc_pin(unsigned int pin, const char *label);
  110. /*
  111. * setups mutliple pins
  112. * convenient way to call the above function with tables
  113. */
  114. int mxc_iomux_setup_multiple_pins(const unsigned int *pin_list, unsigned count,
  115. const char *label);
  116. /*
  117. * releases a single pin:
  118. * - make it available for a future use by another driver
  119. * - frees the GPIO if the pin was configured as GPIO
  120. * - DOES NOT reconfigure the IOMUX in its reset state
  121. */
  122. void mxc_iomux_release_pin(unsigned int pin);
  123. /*
  124. * releases multiple pins
  125. * convenvient way to call the above function with tables
  126. */
  127. void mxc_iomux_release_multiple_pins(const unsigned int *pin_list, int count);
  128. /*
  129. * This function enables/disables the general purpose function for a particular
  130. * signal.
  131. */
  132. void mxc_iomux_set_gpr(enum iomux_gp_func, bool en);
  133. /*
  134. * This function only configures the iomux hardware.
  135. * It is called by the setup functions and should not be called directly anymore.
  136. * It is here visible for backward compatibility
  137. */
  138. int mxc_iomux_mode(unsigned int pin_mode);
  139. #define IOMUX_PADNUM_MASK 0x1ff
  140. #define IOMUX_GPIONUM_SHIFT 9
  141. #define IOMUX_GPIONUM_MASK (0xff << IOMUX_GPIONUM_SHIFT)
  142. #define IOMUX_MODE_SHIFT 17
  143. #define IOMUX_MODE_MASK (0xff << IOMUX_MODE_SHIFT)
  144. #define IOMUX_PIN(gpionum, padnum) \
  145. (((gpionum << IOMUX_GPIONUM_SHIFT) & IOMUX_GPIONUM_MASK) | \
  146. (padnum & IOMUX_PADNUM_MASK))
  147. #define IOMUX_MODE(pin, mode) (pin | mode << IOMUX_MODE_SHIFT)
  148. #define IOMUX_TO_GPIO(iomux_pin) \
  149. ((iomux_pin & IOMUX_GPIONUM_MASK) >> IOMUX_GPIONUM_SHIFT)
  150. /*
  151. * This enumeration is constructed based on the Section
  152. * "sw_pad_ctl & sw_mux_ctl details" of the MX31 IC Spec. Each enumerated
  153. * value is constructed based on the rules described above.
  154. */
  155. enum iomux_pins {
  156. MX31_PIN_TTM_PAD = IOMUX_PIN(0xff, 0),
  157. MX31_PIN_CSPI3_SPI_RDY = IOMUX_PIN(0xff, 1),
  158. MX31_PIN_CSPI3_SCLK = IOMUX_PIN(0xff, 2),
  159. MX31_PIN_CSPI3_MISO = IOMUX_PIN(0xff, 3),
  160. MX31_PIN_CSPI3_MOSI = IOMUX_PIN(0xff, 4),
  161. MX31_PIN_CLKSS = IOMUX_PIN(0xff, 5),
  162. MX31_PIN_CE_CONTROL = IOMUX_PIN(0xff, 6),
  163. MX31_PIN_ATA_RESET_B = IOMUX_PIN(95, 7),
  164. MX31_PIN_ATA_DMACK = IOMUX_PIN(94, 8),
  165. MX31_PIN_ATA_DIOW = IOMUX_PIN(93, 9),
  166. MX31_PIN_ATA_DIOR = IOMUX_PIN(92, 10),
  167. MX31_PIN_ATA_CS1 = IOMUX_PIN(91, 11),
  168. MX31_PIN_ATA_CS0 = IOMUX_PIN(90, 12),
  169. MX31_PIN_SD1_DATA3 = IOMUX_PIN(63, 13),
  170. MX31_PIN_SD1_DATA2 = IOMUX_PIN(62, 14),
  171. MX31_PIN_SD1_DATA1 = IOMUX_PIN(61, 15),
  172. MX31_PIN_SD1_DATA0 = IOMUX_PIN(60, 16),
  173. MX31_PIN_SD1_CLK = IOMUX_PIN(59, 17),
  174. MX31_PIN_SD1_CMD = IOMUX_PIN(58, 18),
  175. MX31_PIN_D3_SPL = IOMUX_PIN(0xff, 19),
  176. MX31_PIN_D3_CLS = IOMUX_PIN(0xff, 20),
  177. MX31_PIN_D3_REV = IOMUX_PIN(0xff, 21),
  178. MX31_PIN_CONTRAST = IOMUX_PIN(0xff, 22),
  179. MX31_PIN_VSYNC3 = IOMUX_PIN(0xff, 23),
  180. MX31_PIN_READ = IOMUX_PIN(0xff, 24),
  181. MX31_PIN_WRITE = IOMUX_PIN(0xff, 25),
  182. MX31_PIN_PAR_RS = IOMUX_PIN(0xff, 26),
  183. MX31_PIN_SER_RS = IOMUX_PIN(89, 27),
  184. MX31_PIN_LCS1 = IOMUX_PIN(88, 28),
  185. MX31_PIN_LCS0 = IOMUX_PIN(87, 29),
  186. MX31_PIN_SD_D_CLK = IOMUX_PIN(86, 30),
  187. MX31_PIN_SD_D_IO = IOMUX_PIN(85, 31),
  188. MX31_PIN_SD_D_I = IOMUX_PIN(84, 32),
  189. MX31_PIN_DRDY0 = IOMUX_PIN(0xff, 33),
  190. MX31_PIN_FPSHIFT = IOMUX_PIN(0xff, 34),
  191. MX31_PIN_HSYNC = IOMUX_PIN(0xff, 35),
  192. MX31_PIN_VSYNC0 = IOMUX_PIN(0xff, 36),
  193. MX31_PIN_LD17 = IOMUX_PIN(0xff, 37),
  194. MX31_PIN_LD16 = IOMUX_PIN(0xff, 38),
  195. MX31_PIN_LD15 = IOMUX_PIN(0xff, 39),
  196. MX31_PIN_LD14 = IOMUX_PIN(0xff, 40),
  197. MX31_PIN_LD13 = IOMUX_PIN(0xff, 41),
  198. MX31_PIN_LD12 = IOMUX_PIN(0xff, 42),
  199. MX31_PIN_LD11 = IOMUX_PIN(0xff, 43),
  200. MX31_PIN_LD10 = IOMUX_PIN(0xff, 44),
  201. MX31_PIN_LD9 = IOMUX_PIN(0xff, 45),
  202. MX31_PIN_LD8 = IOMUX_PIN(0xff, 46),
  203. MX31_PIN_LD7 = IOMUX_PIN(0xff, 47),
  204. MX31_PIN_LD6 = IOMUX_PIN(0xff, 48),
  205. MX31_PIN_LD5 = IOMUX_PIN(0xff, 49),
  206. MX31_PIN_LD4 = IOMUX_PIN(0xff, 50),
  207. MX31_PIN_LD3 = IOMUX_PIN(0xff, 51),
  208. MX31_PIN_LD2 = IOMUX_PIN(0xff, 52),
  209. MX31_PIN_LD1 = IOMUX_PIN(0xff, 53),
  210. MX31_PIN_LD0 = IOMUX_PIN(0xff, 54),
  211. MX31_PIN_USBH2_DATA1 = IOMUX_PIN(0xff, 55),
  212. MX31_PIN_USBH2_DATA0 = IOMUX_PIN(0xff, 56),
  213. MX31_PIN_USBH2_NXT = IOMUX_PIN(0xff, 57),
  214. MX31_PIN_USBH2_STP = IOMUX_PIN(0xff, 58),
  215. MX31_PIN_USBH2_DIR = IOMUX_PIN(0xff, 59),
  216. MX31_PIN_USBH2_CLK = IOMUX_PIN(0xff, 60),
  217. MX31_PIN_USBOTG_DATA7 = IOMUX_PIN(0xff, 61),
  218. MX31_PIN_USBOTG_DATA6 = IOMUX_PIN(0xff, 62),
  219. MX31_PIN_USBOTG_DATA5 = IOMUX_PIN(0xff, 63),
  220. MX31_PIN_USBOTG_DATA4 = IOMUX_PIN(0xff, 64),
  221. MX31_PIN_USBOTG_DATA3 = IOMUX_PIN(0xff, 65),
  222. MX31_PIN_USBOTG_DATA2 = IOMUX_PIN(0xff, 66),
  223. MX31_PIN_USBOTG_DATA1 = IOMUX_PIN(0xff, 67),
  224. MX31_PIN_USBOTG_DATA0 = IOMUX_PIN(0xff, 68),
  225. MX31_PIN_USBOTG_NXT = IOMUX_PIN(0xff, 69),
  226. MX31_PIN_USBOTG_STP = IOMUX_PIN(0xff, 70),
  227. MX31_PIN_USBOTG_DIR = IOMUX_PIN(0xff, 71),
  228. MX31_PIN_USBOTG_CLK = IOMUX_PIN(0xff, 72),
  229. MX31_PIN_USB_BYP = IOMUX_PIN(31, 73),
  230. MX31_PIN_USB_OC = IOMUX_PIN(30, 74),
  231. MX31_PIN_USB_PWR = IOMUX_PIN(29, 75),
  232. MX31_PIN_SJC_MOD = IOMUX_PIN(0xff, 76),
  233. MX31_PIN_DE_B = IOMUX_PIN(0xff, 77),
  234. MX31_PIN_TRSTB = IOMUX_PIN(0xff, 78),
  235. MX31_PIN_TDO = IOMUX_PIN(0xff, 79),
  236. MX31_PIN_TDI = IOMUX_PIN(0xff, 80),
  237. MX31_PIN_TMS = IOMUX_PIN(0xff, 81),
  238. MX31_PIN_TCK = IOMUX_PIN(0xff, 82),
  239. MX31_PIN_RTCK = IOMUX_PIN(0xff, 83),
  240. MX31_PIN_KEY_COL7 = IOMUX_PIN(57, 84),
  241. MX31_PIN_KEY_COL6 = IOMUX_PIN(56, 85),
  242. MX31_PIN_KEY_COL5 = IOMUX_PIN(55, 86),
  243. MX31_PIN_KEY_COL4 = IOMUX_PIN(54, 87),
  244. MX31_PIN_KEY_COL3 = IOMUX_PIN(0xff, 88),
  245. MX31_PIN_KEY_COL2 = IOMUX_PIN(0xff, 89),
  246. MX31_PIN_KEY_COL1 = IOMUX_PIN(0xff, 90),
  247. MX31_PIN_KEY_COL0 = IOMUX_PIN(0xff, 91),
  248. MX31_PIN_KEY_ROW7 = IOMUX_PIN(53, 92),
  249. MX31_PIN_KEY_ROW6 = IOMUX_PIN(52, 93),
  250. MX31_PIN_KEY_ROW5 = IOMUX_PIN(51, 94),
  251. MX31_PIN_KEY_ROW4 = IOMUX_PIN(50, 95),
  252. MX31_PIN_KEY_ROW3 = IOMUX_PIN(0xff, 96),
  253. MX31_PIN_KEY_ROW2 = IOMUX_PIN(0xff, 97),
  254. MX31_PIN_KEY_ROW1 = IOMUX_PIN(0xff, 98),
  255. MX31_PIN_KEY_ROW0 = IOMUX_PIN(0xff, 99),
  256. MX31_PIN_BATT_LINE = IOMUX_PIN(49, 100),
  257. MX31_PIN_CTS2 = IOMUX_PIN(0xff, 101),
  258. MX31_PIN_RTS2 = IOMUX_PIN(0xff, 102),
  259. MX31_PIN_TXD2 = IOMUX_PIN(28, 103),
  260. MX31_PIN_RXD2 = IOMUX_PIN(27, 104),
  261. MX31_PIN_DTR_DCE2 = IOMUX_PIN(48, 105),
  262. MX31_PIN_DCD_DTE1 = IOMUX_PIN(47, 106),
  263. MX31_PIN_RI_DTE1 = IOMUX_PIN(46, 107),
  264. MX31_PIN_DSR_DTE1 = IOMUX_PIN(45, 108),
  265. MX31_PIN_DTR_DTE1 = IOMUX_PIN(44, 109),
  266. MX31_PIN_DCD_DCE1 = IOMUX_PIN(43, 110),
  267. MX31_PIN_RI_DCE1 = IOMUX_PIN(42, 111),
  268. MX31_PIN_DSR_DCE1 = IOMUX_PIN(41, 112),
  269. MX31_PIN_DTR_DCE1 = IOMUX_PIN(40, 113),
  270. MX31_PIN_CTS1 = IOMUX_PIN(39, 114),
  271. MX31_PIN_RTS1 = IOMUX_PIN(38, 115),
  272. MX31_PIN_TXD1 = IOMUX_PIN(37, 116),
  273. MX31_PIN_RXD1 = IOMUX_PIN(36, 117),
  274. MX31_PIN_CSPI2_SPI_RDY = IOMUX_PIN(0xff, 118),
  275. MX31_PIN_CSPI2_SCLK = IOMUX_PIN(0xff, 119),
  276. MX31_PIN_CSPI2_SS2 = IOMUX_PIN(0xff, 120),
  277. MX31_PIN_CSPI2_SS1 = IOMUX_PIN(0xff, 121),
  278. MX31_PIN_CSPI2_SS0 = IOMUX_PIN(0xff, 122),
  279. MX31_PIN_CSPI2_MISO = IOMUX_PIN(0xff, 123),
  280. MX31_PIN_CSPI2_MOSI = IOMUX_PIN(0xff, 124),
  281. MX31_PIN_CSPI1_SPI_RDY = IOMUX_PIN(0xff, 125),
  282. MX31_PIN_CSPI1_SCLK = IOMUX_PIN(0xff, 126),
  283. MX31_PIN_CSPI1_SS2 = IOMUX_PIN(0xff, 127),
  284. MX31_PIN_CSPI1_SS1 = IOMUX_PIN(0xff, 128),