pinctrl-mxs.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright 2012 Freescale Semiconductor, Inc.
  3. *
  4. * The code contained herein is licensed under the GNU General Public
  5. * License. You may obtain a copy of the GNU General Public License
  6. * Version 2 or later at the following locations:
  7. *
  8. * http://www.opensource.org/licenses/gpl-license.html
  9. * http://www.gnu.org/copyleft/gpl.html
  10. */
  11. #ifndef __PINCTRL_MXS_H
  12. #define __PINCTRL_MXS_H
  13. #include <linux/platform_device.h>
  14. #include <linux/pinctrl/pinctrl.h>
  15. #define SET 0x4
  16. #define CLR 0x8
  17. #define TOG 0xc
  18. #define MXS_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
  19. #define PINID(bank, pin) ((bank) * 32 + (pin))
  20. /*
  21. * pinmux-id bit field definitions
  22. *
  23. * bank: 15..12 (4)
  24. * pin: 11..4 (8)
  25. * muxsel: 3..0 (4)
  26. */
  27. #define MUXID_TO_PINID(m) PINID((m) >> 12 & 0xf, (m) >> 4 & 0xff)
  28. #define MUXID_TO_MUXSEL(m) ((m) & 0xf)
  29. #define PINID_TO_BANK(p) ((p) >> 5)
  30. #define PINID_TO_PIN(p) ((p) % 32)
  31. /*
  32. * pin config bit field definitions
  33. *
  34. * pull-up: 6..5 (2)
  35. * voltage: 4..3 (2)
  36. * mA: 2..0 (3)
  37. *
  38. * MSB of each field is presence bit for the config.
  39. */
  40. #define PULL_PRESENT (1 << 6)
  41. #define PULL_SHIFT 5
  42. #define VOL_PRESENT (1 << 4)
  43. #define VOL_SHIFT 3
  44. #define MA_PRESENT (1 << 2)
  45. #define MA_SHIFT 0
  46. #define CONFIG_TO_PULL(c) ((c) >> PULL_SHIFT & 0x1)
  47. #define CONFIG_TO_VOL(c) ((c) >> VOL_SHIFT & 0x1)
  48. #define CONFIG_TO_MA(c) ((c) >> MA_SHIFT & 0x3)
  49. struct mxs_function {
  50. const char *name;
  51. const char **groups;
  52. unsigned ngroups;
  53. };
  54. struct mxs_group {
  55. const char *name;
  56. unsigned int *pins;
  57. unsigned npins;
  58. u8 *muxsel;
  59. u8 config;
  60. };
  61. struct mxs_regs {
  62. u16 muxsel;
  63. u16 drive;
  64. u16 pull;
  65. };
  66. struct mxs_pinctrl_soc_data {
  67. const struct mxs_regs *regs;
  68. const struct pinctrl_pin_desc *pins;
  69. unsigned npins;
  70. struct mxs_function *functions;
  71. unsigned nfunctions;
  72. struct mxs_group *groups;
  73. unsigned ngroups;
  74. };
  75. int mxs_pinctrl_probe(struct platform_device *pdev,
  76. struct mxs_pinctrl_soc_data *soc);
  77. #endif /* __PINCTRL_MXS_H */