pinctrl-stm32.h 1.2 KB

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