pinctrl-imx.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 <dong.aisheng@linaro.org>
  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. /**
  17. * struct imx_pin - describes a single i.MX pin
  18. * @pin: the pin_id of this pin
  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 {
  26. unsigned int pin;
  27. unsigned int mux_mode;
  28. u16 input_reg;
  29. unsigned int input_val;
  30. unsigned long config;
  31. };
  32. /**
  33. * struct imx_pin_reg - describe a pin reg map
  34. * @mux_reg: mux register offset
  35. * @conf_reg: config register offset
  36. */
  37. struct imx_pin_reg {
  38. s16 mux_reg;
  39. s16 conf_reg;
  40. };
  41. /* decode a generic config into raw register value */
  42. struct imx_cfg_params_decode {
  43. enum pin_config_param param;
  44. u32 mask;
  45. u8 shift;
  46. bool invert;
  47. };
  48. struct imx_pinctrl_soc_info {
  49. const struct pinctrl_pin_desc *pins;
  50. unsigned int npins;
  51. unsigned int flags;
  52. const char *gpr_compatible;
  53. /* MUX_MODE shift and mask in case SHARE_MUX_CONF_REG */
  54. unsigned int mux_mask;
  55. u8 mux_shift;
  56. /* generic pinconf */
  57. bool generic_pinconf;
  58. const struct pinconf_generic_params *custom_params;
  59. unsigned int num_custom_params;
  60. const struct imx_cfg_params_decode *decodes;
  61. unsigned int num_decodes;
  62. void (*fixup)(unsigned long *configs, unsigned int num_configs,
  63. u32 *raw_config);
  64. int (*gpio_set_direction)(struct pinctrl_dev *pctldev,
  65. struct pinctrl_gpio_range *range,
  66. unsigned offset,
  67. bool input);
  68. };
  69. /**
  70. * @dev: a pointer back to containing device
  71. * @base: the offset to the controller in virtual memory
  72. */
  73. struct imx_pinctrl {
  74. struct device *dev;
  75. struct pinctrl_dev *pctl;
  76. void __iomem *base;
  77. void __iomem *input_sel_base;
  78. const struct imx_pinctrl_soc_info *info;
  79. struct imx_pin_reg *pin_regs;
  80. unsigned int group_index;
  81. struct mutex mutex;
  82. };
  83. #define IMX_CFG_PARAMS_DECODE(p, m, o) \
  84. { .param = p, .mask = m, .shift = o, .invert = false, }
  85. #define IMX_CFG_PARAMS_DECODE_INVERT(p, m, o) \
  86. { .param = p, .mask = m, .shift = o, .invert = true, }
  87. #define SHARE_MUX_CONF_REG 0x1
  88. #define ZERO_OFFSET_VALID 0x2
  89. #define NO_MUX 0x0
  90. #define NO_PAD 0x0
  91. #define IMX_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
  92. #define PAD_CTL_MASK(len) ((1 << len) - 1)
  93. #define IMX_MUX_MASK 0x7
  94. #define IOMUXC_CONFIG_SION (0x1 << 4)
  95. int imx_pinctrl_probe(struct platform_device *pdev,
  96. const struct imx_pinctrl_soc_info *info);
  97. #endif /* __DRIVERS_PINCTRL_IMX_H */