pinctrl-stm32.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) Maxime Coquelin 2015
  3. * Author: Maxime Coquelin <mcoquelin.stm32@gmail.com>
  4. * License terms: GNU General Public License (GPL), version 2
  5. */
  6. #ifndef __PINCTRL_STM32_H
  7. #define __PINCTRL_STM32_H
  8. #include <linux/pinctrl/pinctrl.h>
  9. #include <linux/pinctrl/pinconf-generic.h>
  10. #define STM32_PIN_NO(x) ((x) << 8)
  11. #define STM32_GET_PIN_NO(x) ((x) >> 8)
  12. #define STM32_GET_PIN_FUNC(x) ((x) & 0xff)
  13. #define STM32_PIN_GPIO 0
  14. #define STM32_PIN_AF(x) ((x) + 1)
  15. #define STM32_PIN_ANALOG (STM32_PIN_AF(15) + 1)
  16. struct stm32_desc_function {
  17. const char *name;
  18. const unsigned char num;
  19. };
  20. struct stm32_desc_pin {
  21. struct pinctrl_pin_desc pin;
  22. const struct stm32_desc_function *functions;
  23. };
  24. #define STM32_PIN(_pin, ...) \
  25. { \
  26. .pin = _pin, \
  27. .functions = (struct stm32_desc_function[]){ \
  28. __VA_ARGS__, { } }, \
  29. }
  30. #define STM32_FUNCTION(_num, _name) \
  31. { \
  32. .num = _num, \
  33. .name = _name, \
  34. }
  35. struct stm32_pinctrl_match_data {
  36. const struct stm32_desc_pin *pins;
  37. const unsigned int npins;
  38. };
  39. int stm32_pctl_probe(struct platform_device *pdev);
  40. #endif /* __PINCTRL_STM32_H */