0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __PINCTRL_MVEBU_H__
0010 #define __PINCTRL_MVEBU_H__
0011
0012
0013
0014
0015
0016
0017
0018 struct mvebu_mpp_ctrl_data {
0019 union {
0020 void __iomem *base;
0021 struct {
0022 struct regmap *map;
0023 u32 offset;
0024 } regmap;
0025 };
0026 };
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 struct mvebu_mpp_ctrl {
0048 const char *name;
0049 u8 pid;
0050 u8 npins;
0051 unsigned *pins;
0052 int (*mpp_get)(struct mvebu_mpp_ctrl_data *data, unsigned pid,
0053 unsigned long *config);
0054 int (*mpp_set)(struct mvebu_mpp_ctrl_data *data, unsigned pid,
0055 unsigned long config);
0056 int (*mpp_gpio_req)(struct mvebu_mpp_ctrl_data *data, unsigned pid);
0057 int (*mpp_gpio_dir)(struct mvebu_mpp_ctrl_data *data, unsigned pid,
0058 bool input);
0059 };
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 struct mvebu_mpp_ctrl_setting {
0085 u8 val;
0086 const char *name;
0087 const char *subname;
0088 u8 variant;
0089 u8 flags;
0090 #define MVEBU_SETTING_GPO (1 << 0)
0091 #define MVEBU_SETTING_GPI (1 << 1)
0092 };
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 struct mvebu_mpp_mode {
0103 u8 pid;
0104 struct mvebu_mpp_ctrl_setting *settings;
0105 };
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122 struct mvebu_pinctrl_soc_info {
0123 u8 variant;
0124 const struct mvebu_mpp_ctrl *controls;
0125 struct mvebu_mpp_ctrl_data *control_data;
0126 int ncontrols;
0127 struct mvebu_mpp_mode *modes;
0128 int nmodes;
0129 struct pinctrl_gpio_range *gpioranges;
0130 int ngpioranges;
0131 };
0132
0133 #define MPP_FUNC_CTRL(_idl, _idh, _name, _func) \
0134 { \
0135 .name = _name, \
0136 .pid = _idl, \
0137 .npins = _idh - _idl + 1, \
0138 .pins = (unsigned[_idh - _idl + 1]) { }, \
0139 .mpp_get = _func ## _get, \
0140 .mpp_set = _func ## _set, \
0141 .mpp_gpio_req = NULL, \
0142 .mpp_gpio_dir = NULL, \
0143 }
0144
0145 #define MPP_FUNC_GPIO_CTRL(_idl, _idh, _name, _func) \
0146 { \
0147 .name = _name, \
0148 .pid = _idl, \
0149 .npins = _idh - _idl + 1, \
0150 .pins = (unsigned[_idh - _idl + 1]) { }, \
0151 .mpp_get = _func ## _get, \
0152 .mpp_set = _func ## _set, \
0153 .mpp_gpio_req = _func ## _gpio_req, \
0154 .mpp_gpio_dir = _func ## _gpio_dir, \
0155 }
0156
0157 #define _MPP_VAR_FUNCTION(_val, _name, _subname, _mask) \
0158 { \
0159 .val = _val, \
0160 .name = _name, \
0161 .subname = _subname, \
0162 .variant = _mask, \
0163 .flags = 0, \
0164 }
0165
0166 #if defined(CONFIG_DEBUG_FS)
0167 #define MPP_VAR_FUNCTION(_val, _name, _subname, _mask) \
0168 _MPP_VAR_FUNCTION(_val, _name, _subname, _mask)
0169 #else
0170 #define MPP_VAR_FUNCTION(_val, _name, _subname, _mask) \
0171 _MPP_VAR_FUNCTION(_val, _name, NULL, _mask)
0172 #endif
0173
0174 #define MPP_FUNCTION(_val, _name, _subname) \
0175 MPP_VAR_FUNCTION(_val, _name, _subname, (u8)-1)
0176
0177 #define MPP_MODE(_id, ...) \
0178 { \
0179 .pid = _id, \
0180 .settings = (struct mvebu_mpp_ctrl_setting[]){ \
0181 __VA_ARGS__, { } }, \
0182 }
0183
0184 #define MPP_GPIO_RANGE(_id, _pinbase, _gpiobase, _npins) \
0185 { \
0186 .name = "mvebu-gpio", \
0187 .id = _id, \
0188 .pin_base = _pinbase, \
0189 .base = _gpiobase, \
0190 .npins = _npins, \
0191 }
0192
0193 #define MVEBU_MPPS_PER_REG 8
0194 #define MVEBU_MPP_BITS 4
0195 #define MVEBU_MPP_MASK 0xf
0196
0197 int mvebu_mmio_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
0198 unsigned long *config);
0199 int mvebu_mmio_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
0200 unsigned long config);
0201 int mvebu_regmap_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
0202 unsigned long *config);
0203 int mvebu_regmap_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
0204 unsigned long config);
0205
0206 int mvebu_pinctrl_probe(struct platform_device *pdev);
0207 int mvebu_pinctrl_simple_mmio_probe(struct platform_device *pdev);
0208 int mvebu_pinctrl_simple_regmap_probe(struct platform_device *pdev,
0209 struct device *syscon_dev, u32 offset);
0210
0211 #endif