mux-k2g.h 1.3 KB

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