iomux-v3.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
  3. * <armlinux@phytec.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_V3_H__
  20. #define __MACH_IOMUX_V3_H__
  21. /*
  22. * build IOMUX_PAD structure
  23. *
  24. * This iomux scheme is based around pads, which are the physical balls
  25. * on the processor.
  26. *
  27. * - Each pad has a pad control register (IOMUXC_SW_PAD_CTRL_x) which controls
  28. * things like driving strength and pullup/pulldown.
  29. * - Each pad can have but not necessarily does have an output routing register
  30. * (IOMUXC_SW_MUX_CTL_PAD_x).
  31. * - Each pad can have but not necessarily does have an input routing register
  32. * (IOMUXC_x_SELECT_INPUT)
  33. *
  34. * The three register sets do not have a fixed offset to each other,
  35. * hence we order this table by pad control registers (which all pads
  36. * have) and put the optional i/o routing registers into additional
  37. * fields.
  38. *
  39. * The naming convention for the pad modes is MX35_PAD_<padname>__<padmode>
  40. * If <padname> or <padmode> refers to a GPIO, it is named
  41. * GPIO_<unit>_<num>
  42. *
  43. */
  44. struct pad_desc {
  45. unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */
  46. unsigned mux_mode:8;
  47. unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */
  48. #define NO_PAD_CTRL (1 << 16)
  49. unsigned pad_ctrl:17;
  50. unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */
  51. unsigned select_input:3;
  52. };
  53. #define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \
  54. _select_input, _pad_ctrl) \
  55. { \
  56. .mux_ctrl_ofs = _mux_ctrl_ofs, \
  57. .mux_mode = _mux_mode, \
  58. .pad_ctrl_ofs = _pad_ctrl_ofs, \
  59. .pad_ctrl = _pad_ctrl, \
  60. .select_input_ofs = _select_input_ofs, \
  61. .select_input = _select_input, \
  62. }
  63. /*
  64. * Use to set PAD control
  65. */
  66. #define PAD_CTL_DVS (1 << 13)
  67. #define PAD_CTL_HYS (1 << 8)
  68. #define PAD_CTL_PKE (1 << 7)
  69. #define PAD_CTL_PUE (1 << 6)
  70. #define PAD_CTL_PUS_100K_DOWN (0 << 4)
  71. #define PAD_CTL_PUS_47K_UP (1 << 4)
  72. #define PAD_CTL_PUS_100K_UP (2 << 4)
  73. #define PAD_CTL_PUS_22K_UP (3 << 4)
  74. #define PAD_CTL_ODE (1 << 3)
  75. #define PAD_CTL_DSE_STANDARD (0 << 1)
  76. #define PAD_CTL_DSE_HIGH (1 << 1)
  77. #define PAD_CTL_DSE_MAX (2 << 1)
  78. #define PAD_CTL_SRE_FAST (1 << 0)
  79. /*
  80. * setups a single pad:
  81. * - reserves the pad so that it is not claimed by another driver
  82. * - setups the iomux according to the configuration
  83. */
  84. int mxc_iomux_v3_setup_pad(struct pad_desc *pad);
  85. /*
  86. * setups mutliple pads
  87. * convenient way to call the above function with tables
  88. */
  89. int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count);
  90. /*
  91. * releases a single pad:
  92. * - make it available for a future use by another driver
  93. * - DOES NOT reconfigure the IOMUX in its reset state
  94. */
  95. void mxc_iomux_v3_release_pad(struct pad_desc *pad);
  96. /*
  97. * releases multiple pads
  98. * convenvient way to call the above function with tables
  99. */
  100. void mxc_iomux_v3_release_multiple_pads(struct pad_desc *pad_list, int count);
  101. /*
  102. * Initialise the iomux controller
  103. */
  104. void mxc_iomux_v3_init(void __iomem *iomux_v3_base);
  105. #endif /* __MACH_IOMUX_V3_H__*/