pinmux.c 923 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <common.h>
  2. #include <asm/arch/pinmux.h>
  3. void pinmux_set(int bank, int pin, int func)
  4. {
  5. u32 reg;
  6. u32 base;
  7. /* TODO: check parameters */
  8. if (bank == PINMUX_BANK_MFA)
  9. base = SYS_CONTROL_BASE;
  10. else
  11. base = SEC_CONTROL_BASE;
  12. clrbits_le32(base + PINMUX_SECONDARY_SEL, BIT(pin));
  13. clrbits_le32(base + PINMUX_TERTIARY_SEL, BIT(pin));
  14. clrbits_le32(base + PINMUX_QUATERNARY_SEL, BIT(pin));
  15. clrbits_le32(base + PINMUX_DEBUG_SEL, BIT(pin));
  16. clrbits_le32(base + PINMUX_ALTERNATIVE_SEL, BIT(pin));
  17. switch (func) {
  18. case PINMUX_GPIO:
  19. default:
  20. return;
  21. break;
  22. case PINMUX_2:
  23. reg = base + PINMUX_SECONDARY_SEL;
  24. break;
  25. case PINMUX_3:
  26. reg = base + PINMUX_TERTIARY_SEL;
  27. break;
  28. case PINMUX_4:
  29. reg = base + PINMUX_QUATERNARY_SEL;
  30. break;
  31. case PINMUX_DEBUG:
  32. reg = base + PINMUX_DEBUG_SEL;
  33. break;
  34. case PINMUX_ALT:
  35. reg = base + PINMUX_ALTERNATIVE_SEL;
  36. break;
  37. }
  38. setbits_le32(reg, BIT(pin));
  39. }