pinctrl-imx.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * IMX pinmux core definitions
  3. *
  4. * Copyright (C) 2012 Freescale Semiconductor, Inc.
  5. * Copyright (C) 2012 Linaro Ltd.
  6. *
  7. * Author: Dong Aisheng <dong.aisheng@linaro.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. */
  14. #ifndef __DRIVERS_PINCTRL_IMX_H
  15. #define __DRIVERS_PINCTRL_IMX_H
  16. #include <linux/pinctrl/pinconf-generic.h>
  17. #include <linux/pinctrl/pinmux.h>
  18. struct platform_device;
  19. extern struct pinmux_ops imx_pmx_ops;
  20. /**
  21. * struct imx_pin - describes a single i.MX pin
  22. * @pin: the pin_id of this pin
  23. * @mux_mode: the mux mode for this pin.
  24. * @input_reg: the select input register offset for this pin if any
  25. * 0 if no select input setting needed.
  26. * @input_val: the select input value for this pin.
  27. * @configs: the config for this pin.
  28. */
  29. struct imx_pin {
  30. unsigned int pin;
  31. unsigned int mux_mode;
  32. u16 input_reg;
  33. unsigned int input_val;
  34. unsigned long config;
  35. };
  36. /**
  37. * struct imx_pin_reg - describe a pin reg map
  38. * @mux_reg: mux register offset
  39. * @conf_reg: config register offset
  40. */
  41. struct imx_pin_reg {
  42. s16 mux_reg;
  43. s16 conf_reg;
  44. };
  45. /* decode a generic config into raw register value */
  46. struct imx_cfg_params_decode {
  47. enum pin_config_param param;
  48. u32 mask;
  49. u8 shift;
  50. bool invert;
  51. };
  52. struct imx_pinctrl_soc_info {
  53. struct device *dev;
  54. const struct pinctrl_pin_desc *pins;
  55. unsigned int npins;
  56. struct imx_pin_reg *pin_regs;
  57. unsigned int group_index;
  58. unsigned int flags;
  59. const char *gpr_compatible;
  60. struct mutex mutex;
  61. /* MUX_MODE shift and mask in case SHARE_MUX_CONF_REG */
  62. unsigned int mux_mask;
  63. u8 mux_shift;
  64. /* generic pinconf */
  65. bool generic_pinconf;
  66. const struct pinconf_generic_params *custom_params;
  67. unsigned int num_custom_params;
  68. struct imx_cfg_params_decode *decodes;
  69. unsigned int num_decodes;
  70. void (*fixup)(unsigned long *configs, unsigned int num_configs,
  71. u32 *raw_config);
  72. int (*gpio_set_direction)(struct pinctrl_dev *pctldev,
  73. struct pinctrl_gpio_range *range,
  74. unsigned offset,
  75. bool input);
  76. };
  77. /**
  78. * @dev: a pointer back to containing device
  79. * @base: the offset to the controller in virtual memory
  80. */
  81. struct imx_pinctrl {
  82. struct device *dev;
  83. struct pinctrl_dev *pctl;
  84. void __iomem *base;
  85. void __iomem *input_sel_base;
  86. struct imx_pinctrl_soc_info *info;
  87. };
  88. #define IMX_CFG_PARAMS_DECODE(p, m, o) \
  89. { .param = p, .mask = m, .shift = o, .invert = false, }
  90. #define IMX_CFG_PARAMS_DECODE_INVERT(p, m, o) \
  91. { .param = p, .mask = m, .shift = o, .invert = true, }
  92. #define SHARE_MUX_CONF_REG 0x1
  93. #define ZERO_OFFSET_VALID 0x2
  94. #define NO_MUX 0x0
  95. #define NO_PAD 0x0
  96. #define IMX_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
  97. #define PAD_CTL_MASK(len) ((1 << len) - 1)
  98. #define IMX_MUX_MASK 0x7
  99. #define IOMUXC_CONFIG_SION (0x1 << 4)
  100. int imx_pinctrl_probe(struct platform_device *pdev,
  101. struct imx_pinctrl_soc_info *info);
  102. #endif /* __DRIVERS_PINCTRL_IMX_H */