soc_pinmux.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2019 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file pinmux interface for Actions SoC
  8. */
  9. #ifndef _ACTIONS_SOC_PINMUX_H_
  10. #define _ACTIONS_SOC_PINMUX_H_
  11. #ifndef _ASMLANGUAGE
  12. #include <devicetree.h>
  13. #define GPIO_PIN_DEFAULT_VAL 0x1000
  14. struct acts_pin_config {
  15. unsigned int pin_num;
  16. unsigned int mode;
  17. };
  18. int acts_pinmux_set(unsigned int pin, unsigned int mode);
  19. int acts_pinmux_get(unsigned int pin, unsigned int *mode);
  20. void acts_pinmux_setup_pins(const struct acts_pin_config *pinconf, int pins);
  21. void rom_pinmux_setup_pins(const struct acts_pin_config *pinconf, int pins);
  22. void acts_pinctl_reg_setup_pins(const struct acts_pin_config *pinconf, int pins);
  23. #define NODE_ID_PINCTRL_0(inst, i) \
  24. DT_INST_PHANDLE_BY_IDX(inst, pinctrl_0, i)
  25. #if 0
  26. #define ACTS_PIN_PROP_PINNUM(inst, i) \
  27. DT_PROP(NODE_ID_PINCTRL_0(inst,i), pinnum)
  28. #define ACTS_PIN_PROP_MODES(inst, i) \
  29. DT_PROP(NODE_ID_PINCTRL_0(inst,i), modes)
  30. #define ACTS_DT_PIN(inst, i) \
  31. { \
  32. ACTS_PIN_PROP_PINNUM(inst, i), \
  33. DT_PROP(NODE_ID_PINCTRL_0(inst,i), modes), \
  34. }
  35. #endif
  36. #define PIN_MFP_CONFIG(node) \
  37. {.pin_num = DT_PROP(node, pinnum), \
  38. .mode = DT_PROP(node, modes) },
  39. #define FOREACH_PIN_MFP(n) IF_ENABLED(DT_INST_NODE_HAS_PROP(n, pinctrl_0), (DT_FOREACH_CHILD(NODE_ID_PINCTRL_0(n, 0), PIN_MFP_CONFIG)))
  40. #endif /* !_ASMLANGUAGE */
  41. #endif /* _ACTIONS_SOC_PINMUX_H_ */