diff options
author | Dong Aisheng <aisheng.dong@nxp.com> | 2017-07-25 09:41:55 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-08-14 09:01:01 -0400 |
commit | 3be6f65102a859d0a4b1b6448df8f4214f3d45ae (patch) | |
tree | b57f2697a8168ab245e6febce4f8b8b1e7f167b5 /drivers/pinctrl/freescale | |
parent | a5c771e6cbdbe026d933c28a7705f6246bac7e64 (diff) |
pinctrl: imx: make imx_pmx_ops.gpio_set_direction platform specific callbacks
Various IMX platforms may have different imx_pmx_ops.gpio_set_direction
implementations, so let's make it platform specific callbacks instead of
the fixed common one.
Currently only VF610 platform implements it. No function level changes.
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Acked-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/freescale')
-rw-r--r-- | drivers/pinctrl/freescale/pinctrl-imx.c | 48 | ||||
-rw-r--r-- | drivers/pinctrl/freescale/pinctrl-imx.h | 20 | ||||
-rw-r--r-- | drivers/pinctrl/freescale/pinctrl-vf610.c | 25 |
3 files changed, 49 insertions, 44 deletions
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index 505fe7912b43..ad23e396da81 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c | |||
@@ -35,18 +35,6 @@ | |||
35 | #define IMX_NO_PAD_CTL 0x80000000 /* no pin config need */ | 35 | #define IMX_NO_PAD_CTL 0x80000000 /* no pin config need */ |
36 | #define IMX_PAD_SION 0x40000000 /* set SION */ | 36 | #define IMX_PAD_SION 0x40000000 /* set SION */ |
37 | 37 | ||
38 | /** | ||
39 | * @dev: a pointer back to containing device | ||
40 | * @base: the offset to the controller in virtual memory | ||
41 | */ | ||
42 | struct imx_pinctrl { | ||
43 | struct device *dev; | ||
44 | struct pinctrl_dev *pctl; | ||
45 | void __iomem *base; | ||
46 | void __iomem *input_sel_base; | ||
47 | struct imx_pinctrl_soc_info *info; | ||
48 | }; | ||
49 | |||
50 | static inline const struct group_desc *imx_pinctrl_find_group_by_name( | 38 | static inline const struct group_desc *imx_pinctrl_find_group_by_name( |
51 | struct pinctrl_dev *pctldev, | 39 | struct pinctrl_dev *pctldev, |
52 | const char *name) | 40 | const char *name) |
@@ -255,42 +243,11 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, | |||
255 | return 0; | 243 | return 0; |
256 | } | 244 | } |
257 | 245 | ||
258 | static int imx_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, | 246 | struct pinmux_ops imx_pmx_ops = { |
259 | struct pinctrl_gpio_range *range, unsigned offset, bool input) | ||
260 | { | ||
261 | struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); | ||
262 | struct imx_pinctrl_soc_info *info = ipctl->info; | ||
263 | const struct imx_pin_reg *pin_reg; | ||
264 | u32 reg; | ||
265 | |||
266 | /* | ||
267 | * Only Vybrid has the input/output buffer enable flags (IBE/OBE) | ||
268 | * They are part of the shared mux/conf register. | ||
269 | */ | ||
270 | if (!(info->flags & SHARE_MUX_CONF_REG)) | ||
271 | return 0; | ||
272 | |||
273 | pin_reg = &info->pin_regs[offset]; | ||
274 | if (pin_reg->mux_reg == -1) | ||
275 | return -EINVAL; | ||
276 | |||
277 | /* IBE always enabled allows us to read the value "on the wire" */ | ||
278 | reg = readl(ipctl->base + pin_reg->mux_reg); | ||
279 | if (input) | ||
280 | reg &= ~0x2; | ||
281 | else | ||
282 | reg |= 0x2; | ||
283 | writel(reg, ipctl->base + pin_reg->mux_reg); | ||
284 | |||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static const struct pinmux_ops imx_pmx_ops = { | ||
289 | .get_functions_count = pinmux_generic_get_function_count, | 247 | .get_functions_count = pinmux_generic_get_function_count, |
290 | .get_function_name = pinmux_generic_get_function_name, | 248 | .get_function_name = pinmux_generic_get_function_name, |
291 | .get_function_groups = pinmux_generic_get_function_groups, | 249 | .get_function_groups = pinmux_generic_get_function_groups, |
292 | .set_mux = imx_pmx_set, | 250 | .set_mux = imx_pmx_set, |
293 | .gpio_set_direction = imx_pmx_gpio_set_direction, | ||
294 | }; | 251 | }; |
295 | 252 | ||
296 | /* decode generic config into raw register values */ | 253 | /* decode generic config into raw register values */ |
@@ -793,6 +750,9 @@ int imx_pinctrl_probe(struct platform_device *pdev, | |||
793 | imx_pinctrl_desc->custom_params = info->custom_params; | 750 | imx_pinctrl_desc->custom_params = info->custom_params; |
794 | imx_pinctrl_desc->num_custom_params = info->num_custom_params; | 751 | imx_pinctrl_desc->num_custom_params = info->num_custom_params; |
795 | 752 | ||
753 | /* platform specific callback */ | ||
754 | imx_pmx_ops.gpio_set_direction = info->gpio_set_direction; | ||
755 | |||
796 | mutex_init(&info->mutex); | 756 | mutex_init(&info->mutex); |
797 | 757 | ||
798 | ipctl->info = info; | 758 | ipctl->info = info; |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.h b/drivers/pinctrl/freescale/pinctrl-imx.h index 880bba7fd1ab..5aa22b52c1d4 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.h +++ b/drivers/pinctrl/freescale/pinctrl-imx.h | |||
@@ -16,9 +16,12 @@ | |||
16 | #define __DRIVERS_PINCTRL_IMX_H | 16 | #define __DRIVERS_PINCTRL_IMX_H |
17 | 17 | ||
18 | #include <linux/pinctrl/pinconf-generic.h> | 18 | #include <linux/pinctrl/pinconf-generic.h> |
19 | #include <linux/pinctrl/pinmux.h> | ||
19 | 20 | ||
20 | struct platform_device; | 21 | struct platform_device; |
21 | 22 | ||
23 | extern struct pinmux_ops imx_pmx_ops; | ||
24 | |||
22 | /** | 25 | /** |
23 | * struct imx_pin - describes a single i.MX pin | 26 | * struct imx_pin - describes a single i.MX pin |
24 | * @pin: the pin_id of this pin | 27 | * @pin: the pin_id of this pin |
@@ -76,6 +79,23 @@ struct imx_pinctrl_soc_info { | |||
76 | unsigned int num_decodes; | 79 | unsigned int num_decodes; |
77 | void (*fixup)(unsigned long *configs, unsigned int num_configs, | 80 | void (*fixup)(unsigned long *configs, unsigned int num_configs, |
78 | u32 *raw_config); | 81 | u32 *raw_config); |
82 | |||
83 | int (*gpio_set_direction)(struct pinctrl_dev *pctldev, | ||
84 | struct pinctrl_gpio_range *range, | ||
85 | unsigned offset, | ||
86 | bool input); | ||
87 | }; | ||
88 | |||
89 | /** | ||
90 | * @dev: a pointer back to containing device | ||
91 | * @base: the offset to the controller in virtual memory | ||
92 | */ | ||
93 | struct imx_pinctrl { | ||
94 | struct device *dev; | ||
95 | struct pinctrl_dev *pctl; | ||
96 | void __iomem *base; | ||
97 | void __iomem *input_sel_base; | ||
98 | struct imx_pinctrl_soc_info *info; | ||
79 | }; | 99 | }; |
80 | 100 | ||
81 | #define IMX_CFG_PARAMS_DECODE(p, m, o) \ | 101 | #define IMX_CFG_PARAMS_DECODE(p, m, o) \ |
diff --git a/drivers/pinctrl/freescale/pinctrl-vf610.c b/drivers/pinctrl/freescale/pinctrl-vf610.c index 3bd85564d1e4..ac18bb6d6d5e 100644 --- a/drivers/pinctrl/freescale/pinctrl-vf610.c +++ b/drivers/pinctrl/freescale/pinctrl-vf610.c | |||
@@ -295,10 +295,35 @@ static const struct pinctrl_pin_desc vf610_pinctrl_pads[] = { | |||
295 | IMX_PINCTRL_PIN(VF610_PAD_PTA7), | 295 | IMX_PINCTRL_PIN(VF610_PAD_PTA7), |
296 | }; | 296 | }; |
297 | 297 | ||
298 | static int vf610_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, | ||
299 | struct pinctrl_gpio_range *range, | ||
300 | unsigned offset, bool input) | ||
301 | { | ||
302 | struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); | ||
303 | struct imx_pinctrl_soc_info *info = ipctl->info; | ||
304 | const struct imx_pin_reg *pin_reg; | ||
305 | u32 reg; | ||
306 | |||
307 | pin_reg = &info->pin_regs[offset]; | ||
308 | if (pin_reg->mux_reg == -1) | ||
309 | return -EINVAL; | ||
310 | |||
311 | /* IBE always enabled allows us to read the value "on the wire" */ | ||
312 | reg = readl(ipctl->base + pin_reg->mux_reg); | ||
313 | if (input) | ||
314 | reg &= ~0x2; | ||
315 | else | ||
316 | reg |= 0x2; | ||
317 | writel(reg, ipctl->base + pin_reg->mux_reg); | ||
318 | |||
319 | return 0; | ||
320 | } | ||
321 | |||
298 | static struct imx_pinctrl_soc_info vf610_pinctrl_info = { | 322 | static struct imx_pinctrl_soc_info vf610_pinctrl_info = { |
299 | .pins = vf610_pinctrl_pads, | 323 | .pins = vf610_pinctrl_pads, |
300 | .npins = ARRAY_SIZE(vf610_pinctrl_pads), | 324 | .npins = ARRAY_SIZE(vf610_pinctrl_pads), |
301 | .flags = SHARE_MUX_CONF_REG | ZERO_OFFSET_VALID, | 325 | .flags = SHARE_MUX_CONF_REG | ZERO_OFFSET_VALID, |
326 | .gpio_set_direction = vf610_pmx_gpio_set_direction, | ||
302 | .mux_mask = 0x700000, | 327 | .mux_mask = 0x700000, |
303 | .mux_shift = 20, | 328 | .mux_shift = 20, |
304 | }; | 329 | }; |