0001
0002
0003
0004
0005
0006 #ifndef __PINCTRL_LPASS_LPI_H__
0007 #define __PINCTRL_LPASS_LPI_H__
0008
0009 #include <linux/bitops.h>
0010 #include <linux/bitfield.h>
0011 #include "../core.h"
0012
0013 #define LPI_SLEW_RATE_CTL_REG 0xa000
0014 #define LPI_TLMM_REG_OFFSET 0x1000
0015 #define LPI_SLEW_RATE_MAX 0x03
0016 #define LPI_SLEW_BITS_SIZE 0x02
0017 #define LPI_SLEW_RATE_MASK GENMASK(1, 0)
0018 #define LPI_GPIO_CFG_REG 0x00
0019 #define LPI_GPIO_PULL_MASK GENMASK(1, 0)
0020 #define LPI_GPIO_FUNCTION_MASK GENMASK(5, 2)
0021 #define LPI_GPIO_OUT_STRENGTH_MASK GENMASK(8, 6)
0022 #define LPI_GPIO_OE_MASK BIT(9)
0023 #define LPI_GPIO_VALUE_REG 0x04
0024 #define LPI_GPIO_VALUE_IN_MASK BIT(0)
0025 #define LPI_GPIO_VALUE_OUT_MASK BIT(1)
0026
0027 #define LPI_GPIO_BIAS_DISABLE 0x0
0028 #define LPI_GPIO_PULL_DOWN 0x1
0029 #define LPI_GPIO_KEEPER 0x2
0030 #define LPI_GPIO_PULL_UP 0x3
0031 #define LPI_GPIO_DS_TO_VAL(v) (v / 2 - 1)
0032 #define LPI_NO_SLEW -1
0033
0034 #define LPI_FUNCTION(fname) \
0035 [LPI_MUX_##fname] = { \
0036 .name = #fname, \
0037 .groups = fname##_groups, \
0038 .ngroups = ARRAY_SIZE(fname##_groups), \
0039 }
0040
0041 #define LPI_PINGROUP(id, soff, f1, f2, f3, f4) \
0042 { \
0043 .group.name = "gpio" #id, \
0044 .group.pins = gpio##id##_pins, \
0045 .pin = id, \
0046 .slew_offset = soff, \
0047 .group.num_pins = ARRAY_SIZE(gpio##id##_pins), \
0048 .funcs = (int[]){ \
0049 LPI_MUX_gpio, \
0050 LPI_MUX_##f1, \
0051 LPI_MUX_##f2, \
0052 LPI_MUX_##f3, \
0053 LPI_MUX_##f4, \
0054 }, \
0055 .nfuncs = 5, \
0056 }
0057
0058 struct lpi_pingroup {
0059 struct group_desc group;
0060 unsigned int pin;
0061
0062 int slew_offset;
0063 unsigned int *funcs;
0064 unsigned int nfuncs;
0065 };
0066
0067 struct lpi_function {
0068 const char *name;
0069 const char * const *groups;
0070 unsigned int ngroups;
0071 };
0072
0073 struct lpi_pinctrl_variant_data {
0074 const struct pinctrl_pin_desc *pins;
0075 int npins;
0076 const struct lpi_pingroup *groups;
0077 int ngroups;
0078 const struct lpi_function *functions;
0079 int nfunctions;
0080 };
0081
0082 int lpi_pinctrl_probe(struct platform_device *pdev);
0083 int lpi_pinctrl_remove(struct platform_device *pdev);
0084
0085 #endif