pinctrl-stm32.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) Maxime Coquelin 2015
  4. * Copyright (C) STMicroelectronics 2017
  5. * Author: Maxime Coquelin <[email protected]>
  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. #define STM32_CONFIG_NUM (STM32_PIN_ANALOG + 1)
  18. /* package information */
  19. #define STM32MP_PKG_AA BIT(0)
  20. #define STM32MP_PKG_AB BIT(1)
  21. #define STM32MP_PKG_AC BIT(2)
  22. #define STM32MP_PKG_AD BIT(3)
  23. struct stm32_desc_function {
  24. const char *name;
  25. const unsigned char num;
  26. };
  27. struct stm32_desc_pin {
  28. struct pinctrl_pin_desc pin;
  29. const struct stm32_desc_function functions[STM32_CONFIG_NUM];
  30. const unsigned int pkg;
  31. };
  32. #define STM32_PIN(_pin, ...) \
  33. { \
  34. .pin = _pin, \
  35. .functions = { \
  36. __VA_ARGS__}, \
  37. }
  38. #define STM32_PIN_PKG(_pin, _pkg, ...) \
  39. { \
  40. .pin = _pin, \
  41. .pkg = _pkg, \
  42. .functions = { \
  43. __VA_ARGS__}, \
  44. }
  45. #define STM32_FUNCTION(_num, _name) \
  46. [_num] = { \
  47. .num = _num, \
  48. .name = _name, \
  49. }
  50. struct stm32_pinctrl_match_data {
  51. const struct stm32_desc_pin *pins;
  52. const unsigned int npins;
  53. bool secure_control;
  54. };
  55. struct stm32_gpio_bank;
  56. int stm32_pctl_probe(struct platform_device *pdev);
  57. void stm32_pmx_get_mode(struct stm32_gpio_bank *bank,
  58. int pin, u32 *mode, u32 *alt);
  59. int stm32_pinctrl_suspend(struct device *dev);
  60. int stm32_pinctrl_resume(struct device *dev);
  61. #endif /* __PINCTRL_STM32_H */