pinctrl-wmt.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Pinctrl driver for the Wondermedia SoC's
  3. *
  4. * Copyright (c) 2013 Tony Prisk <linux@prisktech.co.nz>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. */
  15. #include <linux/gpio.h>
  16. /* VT8500 has no enable register in the extgpio bank. */
  17. #define NO_REG 0xFFFF
  18. #define WMT_PINCTRL_BANK(__en, __dir, __dout, __din, __pen, __pcfg) \
  19. { \
  20. .reg_en = __en, \
  21. .reg_dir = __dir, \
  22. .reg_data_out = __dout, \
  23. .reg_data_in = __din, \
  24. .reg_pull_en = __pen, \
  25. .reg_pull_cfg = __pcfg, \
  26. }
  27. /* Encode/decode the bank/bit pairs into a pin value */
  28. #define WMT_PIN(__bank, __offset) ((__bank << 5) | __offset)
  29. #define WMT_BANK_FROM_PIN(__pin) (__pin >> 5)
  30. #define WMT_BIT_FROM_PIN(__pin) (__pin & 0x1f)
  31. #define WMT_GROUP(__name, __data) \
  32. { \
  33. .name = __name, \
  34. .pins = __data, \
  35. .npins = ARRAY_SIZE(__data), \
  36. }
  37. struct wmt_pinctrl_bank_registers {
  38. u32 reg_en;
  39. u32 reg_dir;
  40. u32 reg_data_out;
  41. u32 reg_data_in;
  42. u32 reg_pull_en;
  43. u32 reg_pull_cfg;
  44. };
  45. struct wmt_pinctrl_group {
  46. const char *name;
  47. const unsigned int *pins;
  48. const unsigned npins;
  49. };
  50. struct wmt_pinctrl_data {
  51. struct device *dev;
  52. struct pinctrl_dev *pctl_dev;
  53. /* must be initialized before calling wmt_pinctrl_probe */
  54. void __iomem *base;
  55. const struct wmt_pinctrl_bank_registers *banks;
  56. const struct pinctrl_pin_desc *pins;
  57. const char * const *groups;
  58. u32 nbanks;
  59. u32 npins;
  60. u32 ngroups;
  61. struct gpio_chip gpio_chip;
  62. struct pinctrl_gpio_range gpio_range;
  63. };
  64. int wmt_pinctrl_probe(struct platform_device *pdev,
  65. struct wmt_pinctrl_data *data);
  66. int wmt_pinctrl_remove(struct platform_device *pdev);