pinctrl-lpass-lpi.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2020 Linaro Ltd.
  5. */
  6. #ifndef __PINCTRL_LPASS_LPI_H__
  7. #define __PINCTRL_LPASS_LPI_H__
  8. #include <linux/array_size.h>
  9. #include <linux/bits.h>
  10. #include "../core.h"
  11. struct platform_device;
  12. struct pinctrl_pin_desc;
  13. #define LPI_SLEW_RATE_CTL_REG 0xa000
  14. #define LPI_TLMM_REG_OFFSET 0x1000
  15. #define LPI_SLEW_RATE_MAX 0x03
  16. #define LPI_SLEW_BITS_SIZE 0x02
  17. #define LPI_SLEW_RATE_MASK GENMASK(1, 0)
  18. #define LPI_GPIO_CFG_REG 0x00
  19. #define LPI_GPIO_PULL_MASK GENMASK(1, 0)
  20. #define LPI_GPIO_FUNCTION_MASK GENMASK(5, 2)
  21. #define LPI_GPIO_OUT_STRENGTH_MASK GENMASK(8, 6)
  22. #define LPI_GPIO_OE_MASK BIT(9)
  23. #define LPI_GPIO_VALUE_REG 0x04
  24. #define LPI_GPIO_VALUE_IN_MASK BIT(0)
  25. #define LPI_GPIO_VALUE_OUT_MASK BIT(1)
  26. #define LPI_GPIO_BIAS_DISABLE 0x0
  27. #define LPI_GPIO_PULL_DOWN 0x1
  28. #define LPI_GPIO_KEEPER 0x2
  29. #define LPI_GPIO_PULL_UP 0x3
  30. #define LPI_GPIO_DS_TO_VAL(v) (v / 2 - 1)
  31. #define LPI_NO_SLEW -1
  32. #define LPI_FUNCTION(fname) \
  33. [LPI_MUX_##fname] = { \
  34. .name = #fname, \
  35. .groups = fname##_groups, \
  36. .ngroups = ARRAY_SIZE(fname##_groups), \
  37. }
  38. #define LPI_PINGROUP(id, soff, f1, f2, f3, f4) \
  39. { \
  40. .pin = id, \
  41. .slew_offset = soff, \
  42. .funcs = (int[]){ \
  43. LPI_MUX_gpio, \
  44. LPI_MUX_##f1, \
  45. LPI_MUX_##f2, \
  46. LPI_MUX_##f3, \
  47. LPI_MUX_##f4, \
  48. }, \
  49. .nfuncs = 5, \
  50. }
  51. /*
  52. * Slew rate control is done in the same register as rest of the
  53. * pin configuration.
  54. */
  55. #define LPI_FLAG_SLEW_RATE_SAME_REG BIT(0)
  56. struct lpi_pingroup {
  57. unsigned int pin;
  58. /* Bit offset in slew register for SoundWire pins only */
  59. int slew_offset;
  60. unsigned int *funcs;
  61. unsigned int nfuncs;
  62. };
  63. struct lpi_function {
  64. const char *name;
  65. const char * const *groups;
  66. unsigned int ngroups;
  67. };
  68. struct lpi_pinctrl_variant_data {
  69. const struct pinctrl_pin_desc *pins;
  70. int npins;
  71. const struct lpi_pingroup *groups;
  72. int ngroups;
  73. const struct lpi_function *functions;
  74. int nfunctions;
  75. unsigned int flags;
  76. };
  77. int lpi_pinctrl_probe(struct platform_device *pdev);
  78. void lpi_pinctrl_remove(struct platform_device *pdev);
  79. #endif /*__PINCTRL_LPASS_LPI_H__*/