mscc-common.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2. /*
  3. * Microsemi SoCs pinctrl driver
  4. *
  5. * Author: <alexandre.belloni@free-electrons.com>
  6. * License: Dual MIT/GPL
  7. * Copyright (c) 2017 Microsemi Corporation
  8. */
  9. #define MSCC_FUNC_PER_PIN 4
  10. enum mscc_regs_gpio {
  11. MSCC_GPIO_OUT_SET,
  12. MSCC_GPIO_OUT_CLR,
  13. MSCC_GPIO_OUT,
  14. MSCC_GPIO_IN,
  15. MSCC_GPIO_OE,
  16. MSCC_GPIO_INTR,
  17. MSCC_GPIO_INTR_ENA,
  18. MSCC_GPIO_INTR_IDENT,
  19. MSCC_GPIO_ALT0,
  20. MSCC_GPIO_ALT1,
  21. };
  22. struct mscc_pin_caps {
  23. unsigned int pin;
  24. unsigned char functions[MSCC_FUNC_PER_PIN];
  25. };
  26. struct mscc_pin_data {
  27. const char *name;
  28. struct mscc_pin_caps *drv_data;
  29. };
  30. #define MSCC_P(p, f0, f1, f2) \
  31. static struct mscc_pin_caps mscc_pin_##p = { \
  32. .pin = p, \
  33. .functions = { \
  34. FUNC_GPIO, FUNC_##f0, FUNC_##f1, FUNC_##f2, \
  35. }, \
  36. }
  37. struct mscc_pmx_func {
  38. const char **groups;
  39. unsigned int ngroups;
  40. };
  41. struct mscc_pinctrl {
  42. struct udevice *dev;
  43. struct pinctrl_dev *pctl;
  44. void __iomem *regs;
  45. struct mscc_pmx_func *func;
  46. int num_func;
  47. const struct mscc_pin_data *mscc_pins;
  48. int num_pins;
  49. char * const *function_names;
  50. const unsigned long *mscc_gpios;
  51. };
  52. int mscc_pinctrl_probe(struct udevice *dev, int num_func,
  53. const struct mscc_pin_data *mscc_pins, int num_pins,
  54. char * const *function_names,
  55. const unsigned long *mscc_gpios);
  56. const struct pinctrl_ops mscc_pinctrl_ops;
  57. const struct dm_gpio_ops mscc_gpio_ops;