pinctrl-stm32.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /* package information */
  18. #define STM32MP_PKG_AA BIT(0)
  19. #define STM32MP_PKG_AB BIT(1)
  20. #define STM32MP_PKG_AC BIT(2)
  21. #define STM32MP_PKG_AD BIT(3)
  22. struct stm32_desc_function {
  23. const char *name;
  24. const unsigned char num;
  25. };
  26. struct stm32_desc_pin {
  27. struct pinctrl_pin_desc pin;
  28. const struct stm32_desc_function *functions;
  29. const unsigned int pkg;
  30. };
  31. #define STM32_PIN(_pin, ...) \
  32. { \
  33. .pin = _pin, \
  34. .functions = (struct stm32_desc_function[]){ \
  35. __VA_ARGS__, { } }, \
  36. }
  37. #define STM32_PIN_PKG(_pin, _pkg, ...) \
  38. { \
  39. .pin = _pin, \
  40. .pkg = _pkg, \
  41. .functions = (struct stm32_desc_function[]){ \
  42. __VA_ARGS__, { } }, \
  43. }
  44. #define STM32_FUNCTION(_num, _name) \
  45. { \
  46. .num = _num, \
  47. .name = _name, \
  48. }
  49. struct stm32_pinctrl_match_data {
  50. const struct stm32_desc_pin *pins;
  51. const unsigned int npins;
  52. };
  53. struct stm32_gpio_bank;
  54. int stm32_pctl_probe(struct platform_device *pdev);
  55. void stm32_pmx_get_mode(struct stm32_gpio_bank *bank,
  56. int pin, u32 *mode, u32 *alt);
  57. int stm32_pinctrl_resume(struct device *dev);
  58. #endif /* __PINCTRL_STM32_H */