mvebu cleanups and preparation for Armada 7k/8k
Subsystems (3)
cover mvebu cleanups and preparation for Armada 7k/8k
(Resend including linux-arm-kernel)
This patch series cleans up the mvebu pin controller implementation such that we can support multiple pin controllers as found in Armada 7k and 8k SoCs.
Currently, in order to do that, we would have to have static variables and multiple implementations of functions whose only purpose is to read from the correct static variable. This is caused by a lack of driver private data passed into the mvebu pin controller's methods.
Most mvebu pin controllers methods are performing exactly the same action, so it makes sense to generalise the methods, which in turn lets us come up with a fairly standardised set of methods.
Another important side effect of these changes is that the structures with function pointers are now marked const - as they should be in today's security concious kernel programming environment.
I've included everything except the 7k and 8k drivers, which, before Thomas went away, he suggested changes to these, so they aren't ready for submission yet. However, the rest of the ground work is, and I'd like users of this code to test it - I don't have all these platforms!
I'm aware of other mvebu SoC support, so I think it's probably a good idea to get these patches out there and known about, so folk can consider how they'd like to order merging the changes - obviously new SoCs with new pinctrl files will need updates somewhere...
The cleanup side of these patches (without the last adding the regmap support) shows a reduction in code size:
drivers/pinctrl/mvebu/pinctrl-armada-370.c | 24 +------- drivers/pinctrl/mvebu/pinctrl-armada-375.c | 24 +------- drivers/pinctrl/mvebu/pinctrl-armada-38x.c | 24 +------- drivers/pinctrl/mvebu/pinctrl-armada-39x.c | 24 +------- drivers/pinctrl/mvebu/pinctrl-armada-xp.c | 35 +++-------- drivers/pinctrl/mvebu/pinctrl-dove.c | 96 +++++++++++++++++------------- drivers/pinctrl/mvebu/pinctrl-kirkwood.c | 32 +++------- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 77 +++++++++++++++++++++--- drivers/pinctrl/mvebu/pinctrl-mvebu.h | 51 +++++++--------- drivers/pinctrl/mvebu/pinctrl-orion.c | 8 ++- 10 files changed, 183 insertions(+), 212 deletions(-)
Adding regmap support increases the code size again:
drivers/pinctrl/mvebu/pinctrl-armada-370.c | 24 +---- drivers/pinctrl/mvebu/pinctrl-armada-375.c | 24 +---- drivers/pinctrl/mvebu/pinctrl-armada-38x.c | 24 +---- drivers/pinctrl/mvebu/pinctrl-armada-39x.c | 24 +---- drivers/pinctrl/mvebu/pinctrl-armada-xp.c | 35 ++------ drivers/pinctrl/mvebu/pinctrl-dove.c | 96 +++++++++++--------- drivers/pinctrl/mvebu/pinctrl-kirkwood.c | 32 ++----- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 137 +++++++++++++++++++++++++++-- drivers/pinctrl/mvebu/pinctrl-mvebu.h | 65 ++++++++------ drivers/pinctrl/mvebu/pinctrl-orion.c | 8 +- 10 files changed, 257 insertions(+), 212 deletions(-)
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
RFC PATCH 1/5 pinctrl: mvebu: constify mvebu_mpp_ctrl structures
As the mvebu_mpp_ctrl structures contain function pointers, it is preferable for these to be made read-only to prevent the function pointers being modified. So make these const.
--- drivers/pinctrl/mvebu/pinctrl-armada-370.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-375.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-38x.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-39x.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-xp.c | 6 +++--- drivers/pinctrl/mvebu/pinctrl-dove.c | 2 +- drivers/pinctrl/mvebu/pinctrl-kirkwood.c | 6 +++--- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 6 +++--- drivers/pinctrl/mvebu/pinctrl-mvebu.h | 2 +- drivers/pinctrl/mvebu/pinctrl-orion.c | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-370.c +1 -1
@@ -384,7 +384,7 @@ static const struct of_device_id armada_370_pinctrl_of_match[] = { { }, }; -static struct mvebu_mpp_ctrl mv88f6710_mpp_controls[] = { +static const struct mvebu_mpp_ctrl mv88f6710_mpp_controls[] = {MPP_FUNC_CTRL (0 ,65 ,NULL , armada_370_mpp_ctrl), };
drivers/pinctrl/mvebu/pinctrl-armada-375.c +1 -1
@@ -402,7 +402,7 @@ static const struct of_device_id armada_375_pinctrl_of_match[] = { { }, }; -static struct mvebu_mpp_ctrl mv88f6720_mpp_controls[] = { +static const struct mvebu_mpp_ctrl mv88f6720_mpp_controls[] = {MPP_FUNC_CTRL (0 ,69 ,NULL , armada_375_mpp_ctrl), };
drivers/pinctrl/mvebu/pinctrl-armada-38x.c +1 -1
@@ -409,7 +409,7 @@ static const struct of_device_id armada_38x_pinctrl_of_match[] = { { }, }; -static struct mvebu_mpp_ctrl armada_38x_mpp_controls[] = { +static const struct mvebu_mpp_ctrl armada_38x_mpp_controls[] = {MPP_FUNC_CTRL (0 ,59 ,NULL , armada_38x_mpp_ctrl), };
drivers/pinctrl/mvebu/pinctrl-armada-39x.c +1 -1
@@ -391,7 +391,7 @@ static const struct of_device_id armada_39x_pinctrl_of_match[] = { { }, }; -static struct mvebu_mpp_ctrl armada_39x_mpp_controls[] = { +static const struct mvebu_mpp_ctrl armada_39x_mpp_controls[] = {MPP_FUNC_CTRL (0 ,59 ,NULL , armada_39x_mpp_ctrl), };
drivers/pinctrl/mvebu/pinctrl-armada-xp.c +3 -3
@@ -378,7 +378,7 @@ static const struct of_device_id armada_xp_pinctrl_of_match[] = { { }, }; -static struct mvebu_mpp_ctrl mv78230_mpp_controls[] = { +static const struct mvebu_mpp_ctrl mv78230_mpp_controls[] = {MPP_FUNC_CTRL (0 ,48 ,NULL , armada_xp_mpp_ctrl), };
@@ -387,7 +387,7 @@ static struct pinctrl_gpio_range mv78230_mpp_gpio_ranges[] = { MPP_GPIO_RANGE(1, 32, 32, 17), }; -static struct mvebu_mpp_ctrl mv78260_mpp_controls[] = { +static const struct mvebu_mpp_ctrl mv78260_mpp_controls[] = {MPP_FUNC_CTRL (0 ,66 ,NULL , armada_xp_mpp_ctrl), };
@@ -397,7 +397,7 @@ static struct pinctrl_gpio_range mv78260_mpp_gpio_ranges[] = { MPP_GPIO_RANGE(2, 64, 64, 3), }; -static struct mvebu_mpp_ctrl mv78460_mpp_controls[] = { +static const struct mvebu_mpp_ctrl mv78460_mpp_controls[] = {MPP_FUNC_CTRL (0 ,66 ,NULL , armada_xp_mpp_ctrl), };
drivers/pinctrl/mvebu/pinctrl-dove.c +1 -1
@@ -354,7 +354,7 @@ static int dove_twsi_ctrl_set(unsigned pid, unsigned long config)return 0 ; } -static struct mvebu_mpp_ctrl dove_mpp_controls[] = { +static const struct mvebu_mpp_ctrl dove_mpp_controls[] = {MPP_FUNC_CTRL (0 ,15 ,NULL , dove_pmu_mpp_ctrl),MPP_FUNC_CTRL (16 ,23 ,NULL , dove_mpp_ctrl),MPP_FUNC_CTRL (24 ,39 ,"mpp_camera" , dove_mpp4_ctrl),
drivers/pinctrl/mvebu/pinctrl-kirkwood.c +3 -3
@@ -370,7 +370,7 @@ static struct mvebu_mpp_mode mv88f6xxx_mpp_modes[] = { MPP_VAR_FUNCTION(0xb, "lcd", "d17", V(0, 0, 0, 0, 1, 0))), }; -static struct mvebu_mpp_ctrl mv88f6180_mpp_controls[] = { +static const struct mvebu_mpp_ctrl mv88f6180_mpp_controls[] = {MPP_FUNC_CTRL (0 ,44 ,NULL , kirkwood_mpp_ctrl), };
@@ -379,7 +379,7 @@ static struct pinctrl_gpio_range mv88f6180_gpio_ranges[] = { MPP_GPIO_RANGE(1, 35, 35, 10), }; -static struct mvebu_mpp_ctrl mv88f619x_mpp_controls[] = { +static const struct mvebu_mpp_ctrl mv88f619x_mpp_controls[] = {MPP_FUNC_CTRL (0 ,35 ,NULL , kirkwood_mpp_ctrl), };
@@ -388,7 +388,7 @@ static struct pinctrl_gpio_range mv88f619x_gpio_ranges[] = { MPP_GPIO_RANGE(1, 32, 32, 4), }; -static struct mvebu_mpp_ctrl mv88f628x_mpp_controls[] = { +static const struct mvebu_mpp_ctrl mv88f628x_mpp_controls[] = {MPP_FUNC_CTRL (0 ,49 ,NULL , kirkwood_mpp_ctrl), };
drivers/pinctrl/mvebu/pinctrl-mvebu.c +3 -3
@@ -38,7 +38,7 @@ struct mvebu_pinctrl_function {struct mvebu_pinctrl_group {const char *name; -struct mvebu_mpp_ctrl *ctrl; +const struct mvebu_mpp_ctrl *ctrl;struct mvebu_mpp_ctrl_setting *settings;unsigned num_settings;unsigned gid;
@@ -582,7 +582,7 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) pctl->num_groups =0 ; pctl->desc.npins =0 ;for (n =0 ; n < soc->ncontrols; n++) { -struct mvebu_mpp_ctrl *ctrl = &soc->controls[n]; +const struct mvebu_mpp_ctrl *ctrl = &soc->controls[n]; pctl->desc.npins += ctrl->npins;/* initialize control's pins[] array */
@@ -628,7 +628,7 @@ int mvebu_pinctrl_probe(struct platform_device *pdev)/* assign mpp controls to groups */ gid =0 ;for (n =0 ; n < soc->ncontrols; n++) { -struct mvebu_mpp_ctrl *ctrl = &soc->controls[n]; +const struct mvebu_mpp_ctrl *ctrl = &soc->controls[n]; pctl->groups[gid].gid = gid; pctl->groups[gid].ctrl = ctrl; pctl->groups[gid].name = ctrl->name;
drivers/pinctrl/mvebu/pinctrl-mvebu.h +1 -1
@@ -105,7 +105,7 @@ struct mvebu_mpp_mode {*/ struct mvebu_pinctrl_soc_info {u8 variant; -struct mvebu_mpp_ctrl *controls; +const struct mvebu_mpp_ctrl *controls;int ncontrols;struct mvebu_mpp_mode *modes;int nmodes;
drivers/pinctrl/mvebu/pinctrl-orion.c +1 -1
@@ -161,7 +161,7 @@ static struct mvebu_mpp_mode orion_mpp_modes[] = { MPP_VAR_FUNCTION(0x5, "gpio", NULL, V_5182)), }; -static struct mvebu_mpp_ctrl orion_mpp_controls[] = { +static const struct mvebu_mpp_ctrl orion_mpp_controls[] = {MPP_FUNC_CTRL (0 ,19 ,NULL , orion_mpp_ctrl), };
Signature · 1 line
2.7.4
RFC PATCH 1/5 pinctrl: mvebu: constify mvebu_mpp_ctrl structures
Quoted 5 lines · Russell King
As the
mvebu_mpp_ctrlstructures contain function pointers, it is preferable for these to be made read-only to prevent the function pointers being modified. So make these const.Signed-off-by Russell King <[email protected]>
Patch applied.
Yours,
Linus Walleij
RFC PATCH 2/5 pinctrl: mvebu: provide per-control private data
In reply to Russell King - ARM LinuxProvide per-control private data into each mvebu pinctrl method, which will allow us to provide some completely generic helpers without the global variable and per-instance function definitions that would be required when we have multiple pin controllers on a SoC.
--- drivers/pinctrl/mvebu/pinctrl-armada-370.c | 6 ++-- drivers/pinctrl/mvebu/pinctrl-armada-375.c | 6 ++-- drivers/pinctrl/mvebu/pinctrl-armada-38x.c | 6 ++-- drivers/pinctrl/mvebu/pinctrl-armada-39x.c | 6 ++-- drivers/pinctrl/mvebu/pinctrl-armada-xp.c | 6 ++-- drivers/pinctrl/mvebu/pinctrl-dove.c | 50 ++++++++++++++++++++---------- drivers/pinctrl/mvebu/pinctrl-kirkwood.c | 6 ++-- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 14 ++++++--- drivers/pinctrl/mvebu/pinctrl-mvebu.h | 21 ++++++++++--- drivers/pinctrl/mvebu/pinctrl-orion.c | 6 ++-- 10 files changed, 88 insertions(+), 39 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-370.c +4 -2
@@ -25,12 +25,14 @@static void __iomem *mpp_base; -static int armada_370_mpp_ctrl_get (unsigned pid,unsigned long *config) +static int armada_370_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long *config) {return default_mpp_ctrl_get (mpp_base, pid, config); } -static int armada_370_mpp_ctrl_set (unsigned pid,unsigned long config) +static int armada_370_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long config) {return default_mpp_ctrl_set (mpp_base, pid, config); }
drivers/pinctrl/mvebu/pinctrl-armada-375.c +4 -2
@@ -25,12 +25,14 @@static void __iomem *mpp_base; -static int armada_375_mpp_ctrl_get (unsigned pid,unsigned long *config) +static int armada_375_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long *config) {return default_mpp_ctrl_get (mpp_base, pid, config); } -static int armada_375_mpp_ctrl_set (unsigned pid,unsigned long config) +static int armada_375_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long config) {return default_mpp_ctrl_set (mpp_base, pid, config); }
drivers/pinctrl/mvebu/pinctrl-armada-38x.c +4 -2
@@ -24,12 +24,14 @@static void __iomem *mpp_base; -static int armada_38x_mpp_ctrl_get (unsigned pid,unsigned long *config) +static int armada_38x_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long *config) {return default_mpp_ctrl_get (mpp_base, pid, config); } -static int armada_38x_mpp_ctrl_set (unsigned pid,unsigned long config) +static int armada_38x_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long config) {return default_mpp_ctrl_set (mpp_base, pid, config); }
drivers/pinctrl/mvebu/pinctrl-armada-39x.c +4 -2
@@ -24,12 +24,14 @@static void __iomem *mpp_base; -static int armada_39x_mpp_ctrl_get (unsigned pid,unsigned long *config) +static int armada_39x_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long *config) {return default_mpp_ctrl_get (mpp_base, pid, config); } -static int armada_39x_mpp_ctrl_set (unsigned pid,unsigned long config) +static int armada_39x_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long config) {return default_mpp_ctrl_set (mpp_base, pid, config); }
drivers/pinctrl/mvebu/pinctrl-armada-xp.c +4 -2
@@ -33,12 +33,14 @@static void __iomem *mpp_base;static u32 *mpp_saved_regs; -static int armada_xp_mpp_ctrl_get (unsigned pid,unsigned long *config) +static int armada_xp_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long *config) {return default_mpp_ctrl_get (mpp_base, pid, config); } -static int armada_xp_mpp_ctrl_set (unsigned pid,unsigned long config) +static int armada_xp_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long config) {return default_mpp_ctrl_set (mpp_base, pid, config); }
drivers/pinctrl/mvebu/pinctrl-dove.c +33 -17
145 lines not on this page · raw message
drivers/pinctrl/mvebu/pinctrl-kirkwood.c +4 -2
@@ -23,12 +23,14 @@static void __iomem *mpp_base; -static int kirkwood_mpp_ctrl_get (unsigned pid,unsigned long *config) +static int kirkwood_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long *config) {return default_mpp_ctrl_get (mpp_base, pid, config); } -static int kirkwood_mpp_ctrl_set (unsigned pid,unsigned long config) +static int kirkwood_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long config) {return default_mpp_ctrl_set (mpp_base, pid, config); }
drivers/pinctrl/mvebu/pinctrl-mvebu.c +10 -4
@@ -39,6 +39,7 @@ struct mvebu_pinctrl_function {struct mvebu_pinctrl_group {const char *name;const struct mvebu_mpp_ctrl *ctrl; +struct mvebu_mpp_ctrl_data *data;struct mvebu_mpp_ctrl_setting *settings;unsigned num_settings;unsigned gid;
@@ -146,7 +147,7 @@ static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev,if (!grp->ctrl)return -EINVAL ; -return grp->ctrl->mpp_get (grp->pins[0 ], config); +return grp->ctrl->mpp_get (grp->data, grp->pins[0 ], config); } static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev,
@@ -161,7 +162,7 @@ static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev,return -EINVAL ;for (i =0 ; i < num_configs; i++) { - ret = grp->ctrl->mpp_set (grp->pins[0 ], configs[i]); + ret = grp->ctrl->mpp_set (grp->data, grp->pins[0 ], configs[i]);if (ret)return ret; }/* for each config */
@@ -302,7 +303,7 @@ static int mvebu_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,return -EINVAL ;if (grp->ctrl->mpp_gpio_req) -return grp->ctrl->mpp_gpio_req (offset); +return grp->ctrl->mpp_gpio_req (grp->data, offset); setting =mvebu_pinctrl_find_gpio_setting (pctl, grp);if (!setting)
@@ -325,7 +326,7 @@ static int mvebu_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,return -EINVAL ;if (grp->ctrl->mpp_gpio_dir) -return grp->ctrl->mpp_gpio_dir (offset, input); +return grp->ctrl->mpp_gpio_dir (grp->data, offset, input); setting =mvebu_pinctrl_find_gpio_setting (pctl, grp);if (!setting)
@@ -629,8 +630,12 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) gid =0 ;for (n =0 ; n < soc->ncontrols; n++) {const struct mvebu_mpp_ctrl *ctrl = &soc->controls[n]; +struct mvebu_mpp_ctrl_data *data = soc->control_data ? + &soc->control_data[n] :NULL ; + pctl->groups[gid].gid = gid; pctl->groups[gid].ctrl = ctrl; + pctl->groups[gid].data = data; pctl->groups[gid].name = ctrl->name; pctl->groups[gid].pins = ctrl->pins; pctl->groups[gid].npins = ctrl->npins;
@@ -650,6 +655,7 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) gid++; pctl->groups[gid].gid = gid; pctl->groups[gid].ctrl = ctrl; + pctl->groups[gid].data = data; pctl->groups[gid].name = noname_buf; pctl->groups[gid].pins = &ctrl->pins[k]; pctl->groups[gid].npins =1 ;
drivers/pinctrl/mvebu/pinctrl-mvebu.h +17 -4
@@ -14,6 +14,14 @@#define __PINCTRL_MVEBU_H__/** +* struct mvebu_mpp_ctrl_data - private data for the mpp ctrl operations +* @base: base address of pinctrl hardware +*/ +struct mvebu_mpp_ctrl_data { +void __iomem *base; +}; + +/** * struct mvebu_mpp_ctrl - describe a mpp control * @name: name of the control group * @pid: first pin id handled by this control
@@ -37,10 +45,13 @@ struct mvebu_mpp_ctrl {u8 pid;u8 npins;unsigned *pins; -int (*mpp_get)(unsigned pid,unsigned long *config); -int (*mpp_set)(unsigned pid,unsigned long config); -int (*mpp_gpio_req)(unsigned pid); -int (*mpp_gpio_dir)(unsigned pid,bool input); +int (*mpp_get)(struct mvebu_mpp_ctrl_data *data,unsigned pid, +unsigned long *config); +int (*mpp_set)(struct mvebu_mpp_ctrl_data *data,unsigned pid, +unsigned long config); +int (*mpp_gpio_req)(struct mvebu_mpp_ctrl_data *data,unsigned pid); +int (*mpp_gpio_dir)(struct mvebu_mpp_ctrl_data *data,unsigned pid, +bool input); };/**
@@ -93,6 +104,7 @@ struct mvebu_mpp_mode {* struct mvebu_pinctrl_soc_info - SoC specific info passed to pinctrl-mvebu * @variant: variant mask of soc_info * @controls: list of available mvebu_mpp_ctrls +* @control_data: optional array, one entry for each control * @ncontrols: number of available mvebu_mpp_ctrls * @modes: list of available mvebu_mpp_modes * @nmodes: number of available mvebu_mpp_modes
@@ -106,6 +118,7 @@ struct mvebu_mpp_mode {struct mvebu_pinctrl_soc_info {u8 variant;const struct mvebu_mpp_ctrl *controls; +struct mvebu_mpp_ctrl_data *control_data;int ncontrols;struct mvebu_mpp_mode *modes;int nmodes;
drivers/pinctrl/mvebu/pinctrl-orion.c +4 -2
@@ -32,7 +32,8 @@static void __iomem *mpp_base;static void __iomem *high_mpp_base; -static int orion_mpp_ctrl_get (unsigned pid,unsigned long *config) +static int orion_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long *config) {unsigned shift = (pid %MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ;
@@ -47,7 +48,8 @@ static int orion_mpp_ctrl_get(unsigned pid, unsigned long *config)return 0 ; } -static int orion_mpp_ctrl_set (unsigned pid,unsigned long config) +static int orion_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, +unsigned pid,unsigned long config) {unsigned shift = (pid %MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ;
Signature · 1 line
2.7.4
RFC PATCH 2/5 pinctrl: mvebu: provide per-control private data
Quoted 6 lines · Russell King
Provide per-control private data into each mvebu pinctrl method, which will allow us to provide some completely generic helpers without the global variable and per-instance function definitions that would be required when we have multiple pin controllers on a SoC.
Signed-off-by Russell King <[email protected]>
Patch applied.
Yours,
Linus Walleij
RFC PATCH 3/5 pinctrl: mvebu: provide generic simple mmio-based implementation
In reply to Russell King - ARM LinuxProvide a generic simple mmio-based probe function and methods, which pinctrl drivers can use to initialise the mvebu pinctrl subsystem. Most mvebu pinctrl drivers can use this.
--- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 57 +++++++++++++++++++++++++++++++++++ drivers/pinctrl/mvebu/pinctrl-mvebu.h | 6 ++++ 2 files changed, 63 insertions(+)
drivers/pinctrl/mvebu/pinctrl-mvebu.c +57 -0
@@ -58,6 +58,30 @@ struct mvebu_pinctrl {u8 variant; }; +int mvebu_mmio_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, +unsigned int pid,unsigned long *config) +{ +unsigned off = (pid /MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; +unsigned shift = (pid %MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; + + *config = (readl (data->base + off) >> shift) &MVEBU_MPP_MASK ; + +return 0 ; +} + +int mvebu_mmio_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, +unsigned int pid,unsigned long config) +{ +unsigned off = (pid /MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; +unsigned shift = (pid %MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; +unsigned long reg; + + reg =readl (data->base + off) & ~(MVEBU_MPP_MASK << shift); +writel (reg | (config << shift), data->base + off); + +return 0 ; +} +static struct mvebu_pinctrl_group *mvebu_pinctrl_find_group_by_pid (struct mvebu_pinctrl *pctl,unsigned pid) {
@@ -731,3 +755,36 @@ int mvebu_pinctrl_probe(struct platform_device *pdev)return 0 ; } + +/* +* mvebu_pinctrl_simple_mmio_probe - probe a simple mmio pinctrl +* @pdev: platform device (with platform data already attached) +* +* Initialise a simple (single base address) mmio pinctrl driver, +* assigning the MMIO base address to all mvebu mpp ctrl instances. +*/ +int mvebu_pinctrl_simple_mmio_probe (struct platform_device *pdev) +{ +struct mvebu_pinctrl_soc_info *soc =dev_get_platdata (&pdev->dev); +struct mvebu_mpp_ctrl_data *mpp_data; +struct resource *res; +void __iomem *base; +int i; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (base)) +return PTR_ERR (base); + + mpp_data =devm_kcalloc (&pdev->dev, soc->ncontrols,sizeof (*mpp_data), +GFP_KERNEL ); +if (!mpp_data) +return -ENOMEM ; + +for (i =0 ; i < soc->ncontrols; i++) + mpp_data[i].base = base; + + soc->control_data = mpp_data; + +return mvebu_pinctrl_probe (pdev); +}
drivers/pinctrl/mvebu/pinctrl-mvebu.h +6 -0
@@ -214,6 +214,12 @@ static inline int default_mpp_ctrl_set(void __iomem *base, unsigned int pid, return 0; } +int mvebu_mmio_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data,unsigned pid, +unsigned long *config); +int mvebu_mmio_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data,unsigned pid, +unsigned long config); +int mvebu_pinctrl_probe (struct platform_device *pdev); +int mvebu_pinctrl_simple_mmio_probe (struct platform_device *pdev);#endif
Signature · 1 line
2.7.4
RFC PATCH 4/5 pinctrl: mvebu: switch drivers to generic simple mmio
In reply to Russell King - ARM LinuxMove the mvebu pinctrl drivers over to the generic simple mmio implementation, saving a substantial number of lines of code in the process.
--- drivers/pinctrl/mvebu/pinctrl-armada-370.c | 24 ++------------ drivers/pinctrl/mvebu/pinctrl-armada-375.c | 24 ++------------ drivers/pinctrl/mvebu/pinctrl-armada-38x.c | 24 ++------------ drivers/pinctrl/mvebu/pinctrl-armada-39x.c | 24 ++------------ drivers/pinctrl/mvebu/pinctrl-armada-xp.c | 31 ++++-------------- drivers/pinctrl/mvebu/pinctrl-dove.c | 52 +++++++++++++++--------------- drivers/pinctrl/mvebu/pinctrl-kirkwood.c | 28 +++------------- drivers/pinctrl/mvebu/pinctrl-mvebu.h | 24 -------------- 8 files changed, 45 insertions(+), 186 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-370.c +2 -22
@@ -23,20 +23,6 @@#include "pinctrl-mvebu.h" -static void __iomem *mpp_base; - -static int armada_370_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long *config) -{ -return default_mpp_ctrl_get (mpp_base, pid, config); -} - -static int armada_370_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long config) -{ -return default_mpp_ctrl_set (mpp_base, pid, config); -} -static struct mvebu_mpp_mode mv88f6710_mpp_modes[] = { MPP_MODE(0, MPP_FUNCTION(0x0, "gpio", NULL),
@@ -387,7 +373,7 @@ static const struct of_device_id armada_370_pinctrl_of_match[] = { };static const struct mvebu_mpp_ctrl mv88f6710_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,65 ,NULL , armada_370_mpp_ctrl), +MPP_FUNC_CTRL (0 ,65 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range mv88f6710_mpp_gpio_ranges[] = {
@@ -399,12 +385,6 @@ static struct pinctrl_gpio_range mv88f6710_mpp_gpio_ranges[] = {static int armada_370_pinctrl_probe (struct platform_device *pdev) {struct mvebu_pinctrl_soc_info *soc = &armada_370_pinctrl_info; -struct resource *res; - - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mpp_base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (mpp_base)) -return PTR_ERR (mpp_base); soc->variant =0 ;/* no variants for Armada 370 */ soc->controls = mv88f6710_mpp_controls;
@@ -416,7 +396,7 @@ static int armada_370_pinctrl_probe(struct platform_device *pdev) pdev->dev.platform_data = soc; -return mvebu_pinctrl_probe (pdev); +return mvebu_pinctrl_simple_mmio_probe (pdev); }static struct platform_driver armada_370_pinctrl_driver = {
drivers/pinctrl/mvebu/pinctrl-armada-375.c +2 -22
@@ -23,20 +23,6 @@#include "pinctrl-mvebu.h" -static void __iomem *mpp_base; - -static int armada_375_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long *config) -{ -return default_mpp_ctrl_get (mpp_base, pid, config); -} - -static int armada_375_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long config) -{ -return default_mpp_ctrl_set (mpp_base, pid, config); -} -static struct mvebu_mpp_mode mv88f6720_mpp_modes[] = { MPP_MODE(0, MPP_FUNCTION(0x0, "gpio", NULL),
@@ -405,7 +391,7 @@ static const struct of_device_id armada_375_pinctrl_of_match[] = { };static const struct mvebu_mpp_ctrl mv88f6720_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,69 ,NULL , armada_375_mpp_ctrl), +MPP_FUNC_CTRL (0 ,69 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range mv88f6720_mpp_gpio_ranges[] = {
@@ -417,12 +403,6 @@ static struct pinctrl_gpio_range mv88f6720_mpp_gpio_ranges[] = {static int armada_375_pinctrl_probe (struct platform_device *pdev) {struct mvebu_pinctrl_soc_info *soc = &armada_375_pinctrl_info; -struct resource *res; - - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mpp_base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (mpp_base)) -return PTR_ERR (mpp_base); soc->variant =0 ;/* no variants for Armada 375 */ soc->controls = mv88f6720_mpp_controls;
@@ -434,7 +414,7 @@ static int armada_375_pinctrl_probe(struct platform_device *pdev) pdev->dev.platform_data = soc; -return mvebu_pinctrl_probe (pdev); +return mvebu_pinctrl_simple_mmio_probe (pdev); }static struct platform_driver armada_375_pinctrl_driver = {
drivers/pinctrl/mvebu/pinctrl-armada-38x.c +2 -22
@@ -22,20 +22,6 @@#include "pinctrl-mvebu.h" -static void __iomem *mpp_base; - -static int armada_38x_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long *config) -{ -return default_mpp_ctrl_get (mpp_base, pid, config); -} - -static int armada_38x_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long config) -{ -return default_mpp_ctrl_set (mpp_base, pid, config); -} -enum {V_88F6810 =BIT (0 ),V_88F6820 =BIT (1 ),
@@ -412,7 +398,7 @@ static const struct of_device_id armada_38x_pinctrl_of_match[] = { };static const struct mvebu_mpp_ctrl armada_38x_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,59 ,NULL , armada_38x_mpp_ctrl), +MPP_FUNC_CTRL (0 ,59 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range armada_38x_mpp_gpio_ranges[] = {
@@ -425,16 +411,10 @@ static int armada_38x_pinctrl_probe(struct platform_device *pdev)struct mvebu_pinctrl_soc_info *soc = &armada_38x_pinctrl_info;const struct of_device_id *match =of_match_device (armada_38x_pinctrl_of_match, &pdev->dev); -struct resource *res;if (!match)return -ENODEV ; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mpp_base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (mpp_base)) -return PTR_ERR (mpp_base); - soc->variant = (unsigned ) match->data &0xff ; soc->controls = armada_38x_mpp_controls; soc->ncontrols =ARRAY_SIZE (armada_38x_mpp_controls);
@@ -445,7 +425,7 @@ static int armada_38x_pinctrl_probe(struct platform_device *pdev) pdev->dev.platform_data = soc; -return mvebu_pinctrl_probe (pdev); +return mvebu_pinctrl_simple_mmio_probe (pdev); }static struct platform_driver armada_38x_pinctrl_driver = {
drivers/pinctrl/mvebu/pinctrl-armada-39x.c +2 -22
@@ -22,20 +22,6 @@#include "pinctrl-mvebu.h" -static void __iomem *mpp_base; - -static int armada_39x_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long *config) -{ -return default_mpp_ctrl_get (mpp_base, pid, config); -} - -static int armada_39x_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long config) -{ -return default_mpp_ctrl_set (mpp_base, pid, config); -} -enum {V_88F6920 =BIT (0 ),V_88F6925 =BIT (1 ),
@@ -394,7 +380,7 @@ static const struct of_device_id armada_39x_pinctrl_of_match[] = { };static const struct mvebu_mpp_ctrl armada_39x_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,59 ,NULL , armada_39x_mpp_ctrl), +MPP_FUNC_CTRL (0 ,59 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range armada_39x_mpp_gpio_ranges[] = {
@@ -407,16 +393,10 @@ static int armada_39x_pinctrl_probe(struct platform_device *pdev)struct mvebu_pinctrl_soc_info *soc = &armada_39x_pinctrl_info;const struct of_device_id *match =of_match_device (armada_39x_pinctrl_of_match, &pdev->dev); -struct resource *res;if (!match)return -ENODEV ; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mpp_base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (mpp_base)) -return PTR_ERR (mpp_base); - soc->variant = (unsigned ) match->data &0xff ; soc->controls = armada_39x_mpp_controls; soc->ncontrols =ARRAY_SIZE (armada_39x_mpp_controls);
@@ -427,7 +407,7 @@ static int armada_39x_pinctrl_probe(struct platform_device *pdev) pdev->dev.platform_data = soc; -return mvebu_pinctrl_probe (pdev); +return mvebu_pinctrl_simple_mmio_probe (pdev); }static struct platform_driver armada_39x_pinctrl_driver = {
drivers/pinctrl/mvebu/pinctrl-armada-xp.c +6 -25
@@ -30,21 +30,8 @@#include "pinctrl-mvebu.h" -static void __iomem *mpp_base;static u32 *mpp_saved_regs; -static int armada_xp_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long *config) -{ -return default_mpp_ctrl_get (mpp_base, pid, config); -} - -static int armada_xp_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long config) -{ -return default_mpp_ctrl_set (mpp_base, pid, config); -} -enum armada_xp_variant {V_MV78230 =BIT (0 ),V_MV78260 =BIT (1 ),
@@ -381,7 +368,7 @@ static const struct of_device_id armada_xp_pinctrl_of_match[] = { };static const struct mvebu_mpp_ctrl mv78230_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,48 ,NULL , armada_xp_mpp_ctrl), +MPP_FUNC_CTRL (0 ,48 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range mv78230_mpp_gpio_ranges[] = {
@@ -390,7 +377,7 @@ static struct pinctrl_gpio_range mv78230_mpp_gpio_ranges[] = { };static const struct mvebu_mpp_ctrl mv78260_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,66 ,NULL , armada_xp_mpp_ctrl), +MPP_FUNC_CTRL (0 ,66 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range mv78260_mpp_gpio_ranges[] = {
@@ -400,7 +387,7 @@ static struct pinctrl_gpio_range mv78260_mpp_gpio_ranges[] = { };static const struct mvebu_mpp_ctrl mv78460_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,66 ,NULL , armada_xp_mpp_ctrl), +MPP_FUNC_CTRL (0 ,66 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range mv78460_mpp_gpio_ranges[] = {
@@ -419,7 +406,7 @@ static int armada_xp_pinctrl_suspend(struct platform_device *pdev, nregs =DIV_ROUND_UP (soc->nmodes,MVEBU_MPPS_PER_REG );for (i =0 ; i < nregs; i++) - mpp_saved_regs[i] =readl (mpp_base + i *4 ); + mpp_saved_regs[i] =readl (soc->control_data[0 ].base + i *4 );return 0 ; }
@@ -433,7 +420,7 @@ static int armada_xp_pinctrl_resume(struct platform_device *pdev) nregs =DIV_ROUND_UP (soc->nmodes,MVEBU_MPPS_PER_REG );for (i =0 ; i < nregs; i++) -writel (mpp_saved_regs[i], mpp_base + i *4 ); +writel (mpp_saved_regs[i], soc->control_data[0 ].base + i *4 );return 0 ; }
@@ -443,17 +430,11 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev)struct mvebu_pinctrl_soc_info *soc = &armada_xp_pinctrl_info;const struct of_device_id *match =of_match_device (armada_xp_pinctrl_of_match, &pdev->dev); -struct resource *res;int nregs;if (!match)return -ENODEV ; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mpp_base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (mpp_base)) -return PTR_ERR (mpp_base); - soc->variant = (unsigned ) match->data &0xff ;switch (soc->variant) {
@@ -501,7 +482,7 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev) pdev->dev.platform_data = soc; -return mvebu_pinctrl_probe (pdev); +return mvebu_pinctrl_simple_mmio_probe (pdev); }static struct platform_driver armada_xp_pinctrl_driver = {
drivers/pinctrl/mvebu/pinctrl-dove.c +26 -26
115 lines not on this page · raw message
drivers/pinctrl/mvebu/pinctrl-kirkwood.c +5 -23
@@ -21,20 +21,6 @@#include "pinctrl-mvebu.h" -static void __iomem *mpp_base; - -static int kirkwood_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long *config) -{ -return default_mpp_ctrl_get (mpp_base, pid, config); -} - -static int kirkwood_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, -unsigned pid,unsigned long config) -{ -return default_mpp_ctrl_set (mpp_base, pid, config); -} -#define V (f6180, f6190, f6192, f6281, f6282, dx4122) \ ((f6180 << 0) | (f6190 << 1) | (f6192 << 2) | \ (f6281 << 3) | (f6282 << 4) | (dx4122 << 5))
@@ -373,7 +359,7 @@ static struct mvebu_mpp_mode mv88f6xxx_mpp_modes[] = { };static const struct mvebu_mpp_ctrl mv88f6180_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,44 ,NULL , kirkwood_mpp_ctrl), +MPP_FUNC_CTRL (0 ,44 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range mv88f6180_gpio_ranges[] = {
@@ -382,7 +368,7 @@ static struct pinctrl_gpio_range mv88f6180_gpio_ranges[] = { };static const struct mvebu_mpp_ctrl mv88f619x_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,35 ,NULL , kirkwood_mpp_ctrl), +MPP_FUNC_CTRL (0 ,35 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range mv88f619x_gpio_ranges[] = {
@@ -391,7 +377,7 @@ static struct pinctrl_gpio_range mv88f619x_gpio_ranges[] = { };static const struct mvebu_mpp_ctrl mv88f628x_mpp_controls[] = { -MPP_FUNC_CTRL (0 ,49 ,NULL , kirkwood_mpp_ctrl), +MPP_FUNC_CTRL (0 ,49 ,NULL , mvebu_mmio_mpp_ctrl), };static struct pinctrl_gpio_range mv88f628x_gpio_ranges[] = {
@@ -474,14 +460,10 @@ static int kirkwood_pinctrl_probe(struct platform_device *pdev)struct resource *res;const struct of_device_id *match =of_match_device (kirkwood_pinctrl_of_match, &pdev->dev); - pdev->dev.platform_data = (void *)match->data; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mpp_base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (mpp_base)) -return PTR_ERR (mpp_base); + pdev->dev.platform_data = (void *)match->data; -return mvebu_pinctrl_probe (pdev); +return mvebu_pinctrl_simple_mmio_probe (pdev); }static struct platform_driver kirkwood_pinctrl_driver = {
drivers/pinctrl/mvebu/pinctrl-mvebu.h +0 -24
@@ -190,30 +190,6 @@ struct mvebu_pinctrl_soc_info {#define MVEBU_MPP_BITS 4#define MVEBU_MPP_MASK 0xf -static inline int default_mpp_ctrl_get (void __iomem *base,unsigned int pid, -unsigned long *config) -{ -unsigned off = (pid /MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; -unsigned shift = (pid %MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; - - *config = (readl (base + off) >> shift) &MVEBU_MPP_MASK ; - -return 0 ; -} - -static inline int default_mpp_ctrl_set (void __iomem *base,unsigned int pid, -unsigned long config) -{ -unsigned off = (pid /MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; -unsigned shift = (pid %MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; -unsigned long reg; - - reg =readl (base + off) & ~(MVEBU_MPP_MASK << shift); -writel (reg | (config << shift), base + off); - -return 0 ; -} -int mvebu_mmio_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data,unsigned pid,unsigned long *config); int mvebu_mmio_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
Signature · 1 line
2.7.4
RFC PATCH 4/5 pinctrl: mvebu: switch drivers to generic simple mmio
Quoted 5 lines · Russell King
Move the mvebu pinctrl drivers over to the generic simple mmio implementation, saving a substantial number of lines of code in the process.
Signed-off-by Russell King <[email protected]>
Very nice patch applied.
Yours,
Linus Walleij
RFC PATCH 5/5 pinctrl: mvebu: add simple regmap based pinctrl implementation
In reply to Russell King - ARM LinuxAdd a simple regmap based pinctrl implementation for mvebu, for syscon based regmap drivers.
--- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 60 +++++++++++++++++++++++++++++++++++ drivers/pinctrl/mvebu/pinctrl-mvebu.h | 16 +++++++++- 2 files changed, 75 insertions(+), 1 deletion(-)
drivers/pinctrl/mvebu/pinctrl-mvebu.c +60 -0
@@ -23,6 +23,8 @@#include <linux/pinctrl/pinconf.h> #include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinmux.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> #include "pinctrl-mvebu.h"
@@ -788,3 +790,61 @@ int mvebu_pinctrl_simple_mmio_probe(struct platform_device *pdev)return mvebu_pinctrl_probe (pdev); } + +int mvebu_regmap_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data, +unsigned int pid,unsigned long *config) +{ +unsigned off = (pid /MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; +unsigned shift = (pid %MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; +unsigned int val; +int err; + + err =regmap_read (data->regmap.map, data->regmap.offset + off, &val); +if (err) +return err; + + *config = (val >> shift) &MVEBU_MPP_MASK ; + +return 0 ; +} + +int mvebu_regmap_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data, +unsigned int pid,unsigned long config) +{ +unsigned off = (pid /MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; +unsigned shift = (pid %MVEBU_MPPS_PER_REG ) *MVEBU_MPP_BITS ; + +return regmap_update_bits (data->regmap.map, data->regmap.offset + off, +MVEBU_MPP_MASK << shift, config << shift); +} + +int mvebu_pinctrl_simple_regmap_probe (struct platform_device *pdev, +struct device *syscon_dev) +{ +struct mvebu_pinctrl_soc_info *soc =dev_get_platdata (&pdev->dev); +struct mvebu_mpp_ctrl_data *mpp_data; +struct regmap *regmap; +u32 offset; +int i; + + regmap =syscon_node_to_regmap (syscon_dev->of_node); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +if (of_property_read_u32 (pdev->dev.of_node,"offset" , &offset)) +return -EINVAL ; + + mpp_data =devm_kcalloc (&pdev->dev, soc->ncontrols,sizeof (*mpp_data), +GFP_KERNEL ); +if (!mpp_data) +return -ENOMEM ; + +for (i =0 ; i < soc->ncontrols; i++) { + mpp_data[i].regmap.map = regmap; + mpp_data[i].regmap.offset = offset; + } + + soc->control_data = mpp_data; + +return mvebu_pinctrl_probe (pdev); +}
drivers/pinctrl/mvebu/pinctrl-mvebu.h +15 -1
@@ -16,9 +16,17 @@/** * struct mvebu_mpp_ctrl_data - private data for the mpp ctrl operations * @base: base address of pinctrl hardware +* @regmap.map: regmap structure +* @regmap.offset: regmap offset */ struct mvebu_mpp_ctrl_data { -void __iomem *base; +union { +void __iomem *base; +struct { +struct regmap *map; +u32 offset; + } regmap; + }; };/**
@@ -194,8 +202,14 @@ int mvebu_mmio_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, unsigned long *config);int mvebu_mmio_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data,unsigned pid,unsigned long config); +int mvebu_regmap_mpp_ctrl_get (struct mvebu_mpp_ctrl_data *data,unsigned pid, +unsigned long *config); +int mvebu_regmap_mpp_ctrl_set (struct mvebu_mpp_ctrl_data *data,unsigned pid, +unsigned long config);int mvebu_pinctrl_probe (struct platform_device *pdev);int mvebu_pinctrl_simple_mmio_probe (struct platform_device *pdev); +int mvebu_pinctrl_simple_regmap_probe (struct platform_device *pdev, +struct device *syscon_dev);#endif
Signature · 1 line
2.7.4
RFC PATCH 5/5 pinctrl: mvebu: add simple regmap based pinctrl implementation
Quoted 4 lines · Russell King
Add a simple regmap based pinctrl implementation for mvebu, for syscon based regmap drivers.
Signed-off-by Russell King <[email protected]>
Patch applied.
Yours,
Linus Walleij
cover mvebu cleanups and preparation for Armada 7k/8k
In reply to Russell King - ARM LinuxQuoted 1 line · Russell King - ARM Linux
(Resend including linux-arm-kernel)
BTW, would be useful if MAINTAINERS could list maintainers for both this code and the mvebu gpio code too. At the moment, it seems Linus is the person responsible for both of those - but I suspect the mvebu people want to be copied on patches...
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
cover mvebu cleanups and preparation for Armada 7k/8k
Quoted 7 lines · Russell King - ARM Linux
Quoted 1 line · Russell King - ARM Linux
(Resend including linux-arm-kernel)
BTW, would be useful if
MAINTAINERScould list maintainers for both this code and the mvebu gpio code too. At the moment, it seems Linus is the person responsible for both of those - but I suspect the mvebu people want to be copied on patches...
Agreed. Since they are silent I will likely simply apply the patches, they certainly look good to me.
Yours,
Linus Walleij
cover mvebu cleanups and preparation for Armada 7k/8k
Hello,
Quoted 7 lines · Linus Walleij
Quoted 4 lines
BTW, would be useful if
MAINTAINERScould list maintainers for both this code and the mvebu gpio code too. At the moment, it seems Linus is the person responsible for both of those - but I suspect the mvebu people want to be copied on patches...Agreed. Since they are silent I will likely simply apply the patches, they certainly look good to me.
Sorry, I'm away on travel. The patches looked generally good to me, though I haven't had the time to do a thorough review. I'll post a patch for the MAINTAINERS file, as suggested by Russell.
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com