pinctrl-imx.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * IMX pinmux core definitions
  4. *
  5. * Copyright (C) 2012 Freescale Semiconductor, Inc.
  6. * Copyright (C) 2012 Linaro Ltd.
  7. *
  8. * Author: Dong Aisheng <[email protected]>
  9. */
  10. #ifndef __DRIVERS_PINCTRL_IMX_H
  11. #define __DRIVERS_PINCTRL_IMX_H
  12. #include <linux/pinctrl/pinconf-generic.h>
  13. #include <linux/pinctrl/pinmux.h>
  14. struct platform_device;
  15. extern struct pinmux_ops imx_pmx_ops;
  16. extern const struct dev_pm_ops imx_pinctrl_pm_ops;
  17. /**
  18. * struct imx_pin_mmio - MMIO pin configurations
  19. * @mux_mode: the mux mode for this pin.
  20. * @input_reg: the select input register offset for this pin if any
  21. * 0 if no select input setting needed.
  22. * @input_val: the select input value for this pin.
  23. * @configs: the config for this pin.
  24. */
  25. struct imx_pin_mmio {
  26. unsigned int mux_mode;
  27. u16 input_reg;
  28. unsigned int input_val;
  29. unsigned long config;
  30. };
  31. /**
  32. * struct imx_pin_scu - SCU pin configurations
  33. * @mux: the mux mode for this pin.
  34. * @configs: the config for this pin.
  35. */
  36. struct imx_pin_scu {
  37. unsigned int mux_mode;
  38. unsigned long config;
  39. };
  40. /**
  41. * struct imx_pin - describes a single i.MX pin
  42. * @pin: the pin_id of this pin
  43. * @conf: config type of this pin, either mmio or scu
  44. */
  45. struct imx_pin {
  46. unsigned int pin;
  47. union {
  48. struct imx_pin_mmio mmio;
  49. struct imx_pin_scu scu;
  50. } conf;
  51. };
  52. /**
  53. * struct imx_pin_reg - describe a pin reg map
  54. * @mux_reg: mux register offset
  55. * @conf_reg: config register offset
  56. */
  57. struct imx_pin_reg {
  58. s16 mux_reg;
  59. s16 conf_reg;
  60. };
  61. /* decode a generic config into raw register value */
  62. struct imx_cfg_params_decode {
  63. enum pin_config_param param;
  64. u32 mask;
  65. u8 shift;
  66. bool invert;
  67. };
  68. /**
  69. * @dev: a pointer back to containing device
  70. * @base: the offset to the controller in virtual memory
  71. */
  72. struct imx_pinctrl {
  73. struct device *dev;
  74. struct pinctrl_dev *pctl;
  75. void __iomem *base;
  76. void __iomem *input_sel_base;
  77. const struct imx_pinctrl_soc_info *info;
  78. struct imx_pin_reg *pin_regs;
  79. unsigned int group_index;
  80. struct mutex mutex;
  81. };
  82. struct imx_pinctrl_soc_info {
  83. const struct pinctrl_pin_desc *pins;
  84. unsigned int npins;
  85. unsigned int flags;
  86. const char *gpr_compatible;
  87. /* MUX_MODE shift and mask in case SHARE_MUX_CONF_REG */
  88. unsigned int mux_mask;
  89. u8 mux_shift;
  90. /* generic pinconf */
  91. bool generic_pinconf;
  92. const struct pinconf_generic_params *custom_params;
  93. unsigned int num_custom_params;
  94. const struct imx_cfg_params_decode *decodes;
  95. unsigned int num_decodes;
  96. void (*fixup)(unsigned long *configs, unsigned int num_configs,
  97. u32 *raw_config);
  98. int (*gpio_set_direction)(struct pinctrl_dev *pctldev,
  99. struct pinctrl_gpio_range *range,
  100. unsigned offset,
  101. bool input);
  102. int (*imx_pinconf_get)(struct pinctrl_dev *pctldev, unsigned int pin_id,
  103. unsigned long *config);
  104. int (*imx_pinconf_set)(struct pinctrl_dev *pctldev, unsigned int pin_id,
  105. unsigned long *configs, unsigned int num_configs);
  106. void (*imx_pinctrl_parse_pin)(struct imx_pinctrl *ipctl,
  107. unsigned int *pin_id, struct imx_pin *pin,
  108. const __be32 **list_p);
  109. };
  110. #define IMX_CFG_PARAMS_DECODE(p, m, o) \
  111. { .param = p, .mask = m, .shift = o, .invert = false, }
  112. #define IMX_CFG_PARAMS_DECODE_INVERT(p, m, o) \
  113. { .param = p, .mask = m, .shift = o, .invert = true, }
  114. #define SHARE_MUX_CONF_REG BIT(0)
  115. #define ZERO_OFFSET_VALID BIT(1)
  116. #define IMX_USE_SCU BIT(2)
  117. #define NO_MUX 0x0
  118. #define NO_PAD 0x0
  119. #define IMX_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
  120. #define PAD_CTL_MASK(len) ((1 << len) - 1)
  121. #define IMX_MUX_MASK 0x7
  122. #define IOMUXC_CONFIG_SION (0x1 << 4)
  123. int imx_pinctrl_probe(struct platform_device *pdev,
  124. const struct imx_pinctrl_soc_info *info);
  125. #define BM_PAD_CTL_GP_ENABLE BIT(30)
  126. #define BM_PAD_CTL_IFMUX_ENABLE BIT(31)
  127. #define BP_PAD_CTL_IFMUX 27
  128. int imx_pinctrl_sc_ipc_init(struct platform_device *pdev);
  129. int imx_pinconf_get_scu(struct pinctrl_dev *pctldev, unsigned pin_id,
  130. unsigned long *config);
  131. int imx_pinconf_set_scu(struct pinctrl_dev *pctldev, unsigned pin_id,
  132. unsigned long *configs, unsigned num_configs);
  133. void imx_pinctrl_parse_pin_scu(struct imx_pinctrl *ipctl,
  134. unsigned int *pin_id, struct imx_pin *pin,
  135. const __be32 **list_p);
  136. #endif /* __DRIVERS_PINCTRL_IMX_H */