mux-k2g.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * K2G: Pinmux configuration
  3. *
  4. * (C) Copyright 2015
  5. * Texas Instruments Incorporated, <www.ti.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __ASM_ARCH_MUX_K2G_H
  10. #define __ASM_ARCH_MUX_K2G_H
  11. #include <common.h>
  12. #include <asm/io.h>
  13. #define K2G_PADCFG_REG (KS2_DEVICE_STATE_CTRL_BASE + 0x1000)
  14. /*
  15. * 20:19 - buffer class RW fixed
  16. * 18 - rxactive (Input enabled for the pad ) 0 - Di; 1 - En;
  17. * 17 - pulltypesel (0 - PULLDOWN; 1 - PULLUP);
  18. * 16 - pulluden (0 - PULLUP/DOWN EN; 1 - DI);
  19. * 3:0 - muxmode (available modes 0:5)
  20. */
  21. #define PIN_IEN (1 << 18) /* pin input enabled */
  22. #define PIN_PDIS (1 << 16) /* pull up/down disabled */
  23. #define PIN_PTU (1 << 17) /* pull up */
  24. #define PIN_PTD (0 << 17) /* pull down */
  25. #define MODE(m) ((m) & 0x7)
  26. #define MAX_PIN_N 260
  27. #define MUX_CFG(value, index) \
  28. __raw_writel(\
  29. (value) | \
  30. (__raw_readl(K2G_PADCFG_REG + (index << 2)) & \
  31. (0x3 << 19)),\
  32. (K2G_PADCFG_REG + (index << 2))\
  33. );
  34. struct pin_cfg {
  35. int reg_inx;
  36. u32 val;
  37. };
  38. static inline void configure_pin_mux(struct pin_cfg *pin_mux)
  39. {
  40. if (!pin_mux)
  41. return;
  42. while ((pin_mux->reg_inx >= 0) && (pin_mux->reg_inx < MAX_PIN_N)) {
  43. MUX_CFG(pin_mux->val, pin_mux->reg_inx);
  44. pin_mux++;
  45. }
  46. }
  47. #endif /* __ASM_ARCH_MUX_K2G_H */