soc_pinmux.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. struct acts_pin_config {
  14. unsigned int pin_num;
  15. unsigned int mode;
  16. };
  17. int acts_pinmux_set(unsigned int pin, unsigned int mode);
  18. int acts_pinmux_get(unsigned int pin, unsigned int *mode);
  19. void acts_pinmux_setup_pins(const struct acts_pin_config *pinconf, int pins);
  20. void rom_pinmux_setup_pins(const struct acts_pin_config *pinconf, int pins);
  21. #define NODE_ID_PINCTRL_0(inst, i) \
  22. DT_INST_PHANDLE_BY_IDX(inst, pinctrl_0, i)
  23. #if 0
  24. #define ACTS_PIN_PROP_PINNUM(inst, i) \
  25. DT_PROP(NODE_ID_PINCTRL_0(inst,i), pinnum)
  26. #define ACTS_PIN_PROP_MODES(inst, i) \
  27. DT_PROP(NODE_ID_PINCTRL_0(inst,i), modes)
  28. #define ACTS_DT_PIN(inst, i) \
  29. { \
  30. ACTS_PIN_PROP_PINNUM(inst, i), \
  31. DT_PROP(NODE_ID_PINCTRL_0(inst,i), modes), \
  32. }
  33. #endif
  34. #define PIN_MFP_CONFIG(node) \
  35. {.pin_num = DT_PROP(node, pinnum), \
  36. .mode = DT_PROP(node, modes) },
  37. #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)))
  38. #endif /* !_ASMLANGUAGE */
  39. #endif /* _ACTIONS_SOC_PINMUX_H_ */