iomux-v3.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * Based on Linux i.MX iomux-v3.h file:
  3. * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
  4. * <armlinux@phytec.de>
  5. *
  6. * Copyright (C) 2011 Freescale Semiconductor, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20. * MA 02110-1301, USA.
  21. */
  22. #ifndef __MACH_IOMUX_V3_H__
  23. #define __MACH_IOMUX_V3_H__
  24. /*
  25. * build IOMUX_PAD structure
  26. *
  27. * This iomux scheme is based around pads, which are the physical balls
  28. * on the processor.
  29. *
  30. * - Each pad has a pad control register (IOMUXC_SW_PAD_CTRL_x) which controls
  31. * things like driving strength and pullup/pulldown.
  32. * - Each pad can have but not necessarily does have an output routing register
  33. * (IOMUXC_SW_MUX_CTL_PAD_x).
  34. * - Each pad can have but not necessarily does have an input routing register
  35. * (IOMUXC_x_SELECT_INPUT)
  36. *
  37. * The three register sets do not have a fixed offset to each other,
  38. * hence we order this table by pad control registers (which all pads
  39. * have) and put the optional i/o routing registers into additional
  40. * fields.
  41. *
  42. * The naming convention for the pad modes is SOC_PAD_<padname>__<padmode>
  43. * If <padname> or <padmode> refers to a GPIO, it is named GPIO_<unit>_<num>
  44. *
  45. * IOMUX/PAD Bit field definitions
  46. *
  47. * MUX_CTRL_OFS: 0..11 (12)
  48. * PAD_CTRL_OFS: 12..23 (12)
  49. * SEL_INPUT_OFS: 24..35 (12)
  50. * MUX_MODE + SION: 36..40 (5)
  51. * PAD_CTRL + NO_PAD_CTRL: 41..58 (18)
  52. * SEL_INP: 59..62 (4)
  53. * reserved: 63 (1)
  54. */
  55. typedef u64 iomux_v3_cfg_t;
  56. #define MUX_CTRL_OFS_SHIFT 0
  57. #define MUX_CTRL_OFS_MASK ((iomux_v3_cfg_t)0xfff << MUX_CTRL_OFS_SHIFT)
  58. #define MUX_PAD_CTRL_OFS_SHIFT 12
  59. #define MUX_PAD_CTRL_OFS_MASK ((iomux_v3_cfg_t)0xfff << \
  60. MUX_PAD_CTRL_OFS_SHIFT)
  61. #define MUX_SEL_INPUT_OFS_SHIFT 24
  62. #define MUX_SEL_INPUT_OFS_MASK ((iomux_v3_cfg_t)0xfff << \
  63. MUX_SEL_INPUT_OFS_SHIFT)
  64. #define MUX_MODE_SHIFT 36
  65. #define MUX_MODE_MASK ((iomux_v3_cfg_t)0x1f << MUX_MODE_SHIFT)
  66. #define MUX_PAD_CTRL_SHIFT 41
  67. #define MUX_PAD_CTRL_MASK ((iomux_v3_cfg_t)0x3ffff << MUX_PAD_CTRL_SHIFT)
  68. #define MUX_SEL_INPUT_SHIFT 59
  69. #define MUX_SEL_INPUT_MASK ((iomux_v3_cfg_t)0xf << MUX_SEL_INPUT_SHIFT)
  70. #define MUX_PAD_CTRL(x) ((iomux_v3_cfg_t)(x) << MUX_PAD_CTRL_SHIFT)
  71. #define IOMUX_PAD(pad_ctrl_ofs, mux_ctrl_ofs, mux_mode, sel_input_ofs, \
  72. sel_input, pad_ctrl) \
  73. (((iomux_v3_cfg_t)(mux_ctrl_ofs) << MUX_CTRL_OFS_SHIFT) | \
  74. ((iomux_v3_cfg_t)(mux_mode) << MUX_MODE_SHIFT) | \
  75. ((iomux_v3_cfg_t)(pad_ctrl_ofs) << MUX_PAD_CTRL_OFS_SHIFT) | \
  76. ((iomux_v3_cfg_t)(pad_ctrl) << MUX_PAD_CTRL_SHIFT) | \
  77. ((iomux_v3_cfg_t)(sel_input_ofs) << MUX_SEL_INPUT_OFS_SHIFT)| \
  78. ((iomux_v3_cfg_t)(sel_input) << MUX_SEL_INPUT_SHIFT))
  79. #define NO_PAD_CTRL (1 << 17)
  80. #define GPIO_PIN_MASK 0x1f
  81. #define GPIO_PORT_SHIFT 5
  82. #define GPIO_PORT_MASK (0x7 << GPIO_PORT_SHIFT)
  83. #define GPIO_PORTA (0 << GPIO_PORT_SHIFT)
  84. #define GPIO_PORTB (1 << GPIO_PORT_SHIFT)
  85. #define GPIO_PORTC (2 << GPIO_PORT_SHIFT)
  86. #define GPIO_PORTD (3 << GPIO_PORT_SHIFT)
  87. #define GPIO_PORTE (4 << GPIO_PORT_SHIFT)
  88. #define GPIO_PORTF (5 << GPIO_PORT_SHIFT)
  89. #define MUX_CONFIG_SION (0x1 << 4)
  90. int imx_iomux_v3_setup_pad(iomux_v3_cfg_t pad);
  91. int imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count);
  92. /*
  93. * IOMUXC_GPR13 bit fields
  94. */
  95. #define IOMUXC_GPR13_SDMA_STOP_REQ (1<<30)
  96. #define IOMUXC_GPR13_CAN2_STOP_REQ (1<<29)
  97. #define IOMUXC_GPR13_CAN1_STOP_REQ (1<<28)
  98. #define IOMUXC_GPR13_ENET_STOP_REQ (1<<27)
  99. #define IOMUXC_GPR13_SATA_PHY_8_MASK (7<<24)
  100. #define IOMUXC_GPR13_SATA_PHY_7_MASK (0x1f<<19)
  101. #define IOMUXC_GPR13_SATA_PHY_6_SHIFT 16
  102. #define IOMUXC_GPR13_SATA_PHY_6_MASK (7<<IOMUXC_GPR13_SATA_PHY_6_SHIFT)
  103. #define IOMUXC_GPR13_SATA_SPEED_MASK (1<<15)
  104. #define IOMUXC_GPR13_SATA_PHY_5_MASK (1<<14)
  105. #define IOMUXC_GPR13_SATA_PHY_4_MASK (7<<11)
  106. #define IOMUXC_GPR13_SATA_PHY_3_MASK (0x1f<<7)
  107. #define IOMUXC_GPR13_SATA_PHY_2_MASK (0x1f<<2)
  108. #define IOMUXC_GPR13_SATA_PHY_1_MASK (3<<0)
  109. #define IOMUXC_GPR13_SATA_PHY_8_RXEQ_0P5DB (0b000<<24)
  110. #define IOMUXC_GPR13_SATA_PHY_8_RXEQ_1P0DB (0b001<<24)
  111. #define IOMUXC_GPR13_SATA_PHY_8_RXEQ_1P5DB (0b010<<24)
  112. #define IOMUXC_GPR13_SATA_PHY_8_RXEQ_2P0DB (0b011<<24)
  113. #define IOMUXC_GPR13_SATA_PHY_8_RXEQ_2P5DB (0b100<<24)
  114. #define IOMUXC_GPR13_SATA_PHY_8_RXEQ_3P0DB (0b101<<24)
  115. #define IOMUXC_GPR13_SATA_PHY_8_RXEQ_3P5DB (0b110<<24)
  116. #define IOMUXC_GPR13_SATA_PHY_8_RXEQ_4P0DB (0b111<<24)
  117. #define IOMUXC_GPR13_SATA_PHY_7_SATA1I (0b10000<<19)
  118. #define IOMUXC_GPR13_SATA_PHY_7_SATA1M (0b10000<<19)
  119. #define IOMUXC_GPR13_SATA_PHY_7_SATA1X (0b11010<<19)
  120. #define IOMUXC_GPR13_SATA_PHY_7_SATA2I (0b10010<<19)
  121. #define IOMUXC_GPR13_SATA_PHY_7_SATA2M (0b10010<<19)
  122. #define IOMUXC_GPR13_SATA_PHY_7_SATA2X (0b11010<<19)
  123. #define IOMUXC_GPR13_SATA_SPEED_1P5G (0<<15)
  124. #define IOMUXC_GPR13_SATA_SPEED_3G (1<<15)
  125. #define IOMUXC_GPR13_SATA_SATA_PHY_5_SS_DISABLED (0<<14)
  126. #define IOMUXC_GPR13_SATA_SATA_PHY_5_SS_ENABLED (1<<14)
  127. #define IOMUXC_GPR13_SATA_SATA_PHY_4_ATTEN_16_16 (0<<11)
  128. #define IOMUXC_GPR13_SATA_SATA_PHY_4_ATTEN_14_16 (1<<11)
  129. #define IOMUXC_GPR13_SATA_SATA_PHY_4_ATTEN_12_16 (2<<11)
  130. #define IOMUXC_GPR13_SATA_SATA_PHY_4_ATTEN_10_16 (3<<11)
  131. #define IOMUXC_GPR13_SATA_SATA_PHY_4_ATTEN_9_16 (4<<11)
  132. #define IOMUXC_GPR13_SATA_SATA_PHY_4_ATTEN_8_16 (5<<11)
  133. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_0P00_DB (0b0000<<7)
  134. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_0P37_DB (0b0001<<7)
  135. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_0P74_DB (0b0010<<7)
  136. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_1P11_DB (0b0011<<7)
  137. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_1P48_DB (0b0100<<7)
  138. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_1P85_DB (0b0101<<7)
  139. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_2P22_DB (0b0110<<7)
  140. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_2P59_DB (0b0111<<7)
  141. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_2P96_DB (0b1000<<7)
  142. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_3P33_DB (0b1001<<7)
  143. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_3P70_DB (0b1010<<7)
  144. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_4P07_DB (0b1011<<7)
  145. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_4P44_DB (0b1100<<7)
  146. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_4P81_DB (0b1101<<7)
  147. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_5P28_DB (0b1110<<7)
  148. #define IOMUXC_GPR13_SATA_PHY_3_TXBOOST_5P75_DB (0b1111<<7)
  149. #define IOMUXC_GPR13_SATA_PHY_2_TX_0P937V (0b00000<<2)
  150. #define IOMUXC_GPR13_SATA_PHY_2_TX_0P947V (0b00001<<2)
  151. #define IOMUXC_GPR13_SATA_PHY_2_TX_0P957V (0b00010<<2)
  152. #define IOMUXC_GPR13_SATA_PHY_2_TX_0P966V (0b00011<<2)
  153. #define IOMUXC_GPR13_SATA_PHY_2_TX_0P976V (0b00100<<2)
  154. #define IOMUXC_GPR13_SATA_PHY_2_TX_0P986V (0b00101<<2)
  155. #define IOMUXC_GPR13_SATA_PHY_2_TX_0P996V (0b00110<<2)
  156. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P005V (0b00111<<2)
  157. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P015V (0b01000<<2)
  158. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P025V (0b01001<<2)
  159. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P035V (0b01010<<2)
  160. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P045V (0b01011<<2)
  161. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P054V (0b01100<<2)
  162. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P064V (0b01101<<2)
  163. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P074V (0b01110<<2)
  164. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P084V (0b01111<<2)
  165. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P094V (0b10000<<2)
  166. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P104V (0b10001<<2)
  167. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P113V (0b10010<<2)
  168. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P123V (0b10011<<2)
  169. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P133V (0b10100<<2)
  170. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P143V (0b10101<<2)
  171. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P152V (0b10110<<2)
  172. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P162V (0b10111<<2)
  173. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P172V (0b11000<<2)
  174. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P182V (0b11001<<2)
  175. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P191V (0b11010<<2)
  176. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P201V (0b11011<<2)
  177. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P211V (0b11100<<2)
  178. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P221V (0b11101<<2)
  179. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P230V (0b11110<<2)
  180. #define IOMUXC_GPR13_SATA_PHY_2_TX_1P240V (0b11111<<2)
  181. #define IOMUXC_GPR13_SATA_PHY_1_FAST 0
  182. #define IOMUXC_GPR13_SATA_PHY_1_MEDIUM 1
  183. #define IOMUXC_GPR13_SATA_PHY_1_SLOW 2
  184. #define IOMUXC_GPR13_SATA_MASK (IOMUXC_GPR13_SATA_PHY_8_MASK \
  185. |IOMUXC_GPR13_SATA_PHY_7_MASK \
  186. |IOMUXC_GPR13_SATA_PHY_6_MASK \
  187. |IOMUXC_GPR13_SATA_SPEED_MASK \
  188. |IOMUXC_GPR13_SATA_PHY_5_MASK \
  189. |IOMUXC_GPR13_SATA_PHY_4_MASK \
  190. |IOMUXC_GPR13_SATA_PHY_3_MASK \
  191. |IOMUXC_GPR13_SATA_PHY_2_MASK \
  192. |IOMUXC_GPR13_SATA_PHY_1_MASK)
  193. #endif /* __MACH_IOMUX_V3_H__*/