pinctrl-stm32.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #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. #define STM32MP_PKG_AI BIT(8)
  24. #define STM32MP_PKG_AK BIT(10)
  25. #define STM32MP_PKG_AL BIT(11)
  26. struct stm32_desc_function {
  27. const char *name;
  28. const unsigned char num;
  29. };
  30. struct stm32_desc_pin {
  31. struct pinctrl_pin_desc pin;
  32. const struct stm32_desc_function functions[STM32_CONFIG_NUM];
  33. const unsigned int pkg;
  34. };
  35. #define STM32_PIN(_pin, ...) \
  36. { \
  37. .pin = _pin, \
  38. .functions = { \
  39. __VA_ARGS__}, \
  40. }
  41. #define STM32_PIN_PKG(_pin, _pkg, ...) \
  42. { \
  43. .pin = _pin, \
  44. .pkg = _pkg, \
  45. .functions = { \
  46. __VA_ARGS__}, \
  47. }
  48. #define STM32_FUNCTION(_num, _name) \
  49. [_num] = { \
  50. .num = _num, \
  51. .name = _name, \
  52. }
  53. struct stm32_pinctrl_match_data {
  54. const struct stm32_desc_pin *pins;
  55. const unsigned int npins;
  56. bool secure_control;
  57. };
  58. struct stm32_gpio_bank;
  59. int stm32_pctl_probe(struct platform_device *pdev);
  60. void stm32_pmx_get_mode(struct stm32_gpio_bank *bank,
  61. int pin, u32 *mode, u32 *alt);
  62. int stm32_pinctrl_suspend(struct device *dev);
  63. int stm32_pinctrl_resume(struct device *dev);
  64. #endif /* __PINCTRL_STM32_H */