pinctrl-mxs.h 1.7 KB

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