pinctrl-mxs.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 <dm/pinctrl.h>
  8. #define SET 0x4
  9. #define CLR 0x8
  10. #define TOG 0xc
  11. #define MXS_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
  12. #define PINID(bank, pin) ((bank) * 32 + (pin))
  13. /*
  14. * pinmux-id bit field definitions
  15. *
  16. * bank: 15..12 (4)
  17. * pin: 11..4 (8)
  18. * muxsel: 3..0 (4)
  19. */
  20. #define MUXID_TO_PINID(m) PINID((m) >> 12 & 0xf, (m) >> 4 & 0xff)
  21. #define MUXID_TO_MUXSEL(m) ((m) & 0xf)
  22. #define PINID_TO_BANK(p) ((p) >> 5)
  23. #define PINID_TO_PIN(p) ((p) % 32)
  24. /*
  25. * pin config bit field definitions
  26. *
  27. * pull-up: 6..5 (2)
  28. * voltage: 4..3 (2)
  29. * mA: 2..0 (3)
  30. *
  31. * MSB of each field is presence bit for the config.
  32. */
  33. #define PULL_PRESENT (1 << 6)
  34. #define PULL_SHIFT 5
  35. #define VOL_PRESENT (1 << 4)
  36. #define VOL_SHIFT 3
  37. #define MA_PRESENT (1 << 2)
  38. #define MA_SHIFT 0
  39. #define CFG_TO_PULL(c) ((c) >> PULL_SHIFT & 0x1)
  40. #define CFG_TO_VOL(c) ((c) >> VOL_SHIFT & 0x1)
  41. #define CFG_TO_MA(c) ((c) >> MA_SHIFT & 0x3)
  42. struct mxs_regs {
  43. u16 muxsel;
  44. u16 drive;
  45. u16 pull;
  46. };
  47. static inline void mxs_pinctrl_rmwl(u32 value, u32 mask, u8 shift,
  48. void __iomem *reg)
  49. {
  50. clrsetbits_le32(reg, mask << shift, value << shift);
  51. }
  52. #endif /* __PINCTRL_MXS_H */