pinctrl: imx: add VF610 support to imx pinctrl framework
PATCH RESEND v3 1/2 pinctrl: imx: add VF610 support to imx pinctrl framework
On some platforms such as VF610, offset of mux and pad ctrl register may be zero, and the mux_mode and config_val are in one 32-bit register. This patch adds support to imx core pinctrl framework to handle these cases.
---
v3:
Add ZERO_OFFSET_VALID flag to handle register offset from zero on Vybrid vf610. Add SHARE_MUX_CONF_REG flag to handle mux mode and config value in one 32-bit
register on Vybrid vf610.
drivers/pinctrl/pinctrl-imx.c | 53 ++++++++++++++++++++++++++++++++++--------- drivers/pinctrl/pinctrl-imx.h | 4 ++++ 2 files changed, 46 insertions(+), 11 deletions(-)
drivers/pinctrl/pinctrl-imx.c +42 -11
@@ -221,13 +221,21 @@ static int imx_pmx_enable(struct pinctrl_dev *pctldev, unsigned selector, pin_id = pins[i]; pin_reg = &info->pin_regs[pin_id]; -if (!pin_reg->mux_reg) { +if (!(info->flags &ZERO_OFFSET_VALID ) && !pin_reg->mux_reg) {dev_err (ipctl->dev,"Pin(%s) does not support mux function\n" , info->pins[pin_id].name);return -EINVAL ; } -writel (mux[i], ipctl->base + pin_reg->mux_reg); +if (info->flags &SHARE_MUX_CONF_REG ) { +u32 reg; + reg =readl (ipctl->base + pin_reg->mux_reg); + reg &= ~(0x7 <<20 ); + reg |= (mux[i] <<20 ); +writel (reg, ipctl->base + pin_reg->mux_reg); + }else { +writel (mux[i], ipctl->base + pin_reg->mux_reg); + }dev_dbg (ipctl->dev,"write: offset 0x%x val 0x%x\n" , pin_reg->mux_reg, mux[i]);
@@ -287,7 +295,7 @@ static int imx_pinconf_get(struct pinctrl_dev *pctldev,const struct imx_pinctrl_soc_info *info = ipctl->info;const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id]; -if (!pin_reg->conf_reg) { +if (!(info->flags &ZERO_OFFSET_VALID ) && !pin_reg->conf_reg) {dev_err (info->dev,"Pin(%s) does not support config function\n" , info->pins[pin_id].name);return -EINVAL ;
@@ -295,6 +303,9 @@ static int imx_pinconf_get(struct pinctrl_dev *pctldev, *config =readl (ipctl->base + pin_reg->conf_reg); +if (info->flags &SHARE_MUX_CONF_REG ) + *config &=0xffff ; +return 0 ; }
@@ -305,7 +316,7 @@ static int imx_pinconf_set(struct pinctrl_dev *pctldev,const struct imx_pinctrl_soc_info *info = ipctl->info;const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id]; -if (!pin_reg->conf_reg) { +if (!(info->flags &ZERO_OFFSET_VALID ) && !pin_reg->conf_reg) {dev_err (info->dev,"Pin(%s) does not support config function\n" , info->pins[pin_id].name);return -EINVAL ;
@@ -314,7 +325,15 @@ static int imx_pinconf_set(struct pinctrl_dev *pctldev,dev_dbg (ipctl->dev,"pinconf set pin %s\n" , info->pins[pin_id].name); -writel (config, ipctl->base + pin_reg->conf_reg); +if (info->flags &SHARE_MUX_CONF_REG ) { +u32 reg; + reg =readl (ipctl->base + pin_reg->conf_reg); + reg &= ~0xffff ; + reg |= config; +writel (reg, ipctl->base + pin_reg->conf_reg); + }else { +writel (config, ipctl->base + pin_reg->conf_reg); + }dev_dbg (ipctl->dev,"write: offset 0x%x val 0x%lx\n" , pin_reg->conf_reg, config);
@@ -381,19 +400,24 @@ static struct pinctrl_desc imx_pinctrl_desc = {* 1 u32 CONFIG, so 24 types in total for each pin. */ #define FSL_PIN_SIZE 24 +#define SHARE_FSL_PIN_SIZE 20static int imx_pinctrl_parse_groups (struct device_node *np,struct imx_pin_group *grp,struct imx_pinctrl_soc_info *info,u32 index) { -int size; +int size, pin_size;const __be32 *list;int i;u32 config;dev_dbg (info->dev,"group(%d): %s\n" , index, np->name); +if (info->flags &SHARE_MUX_CONF_REG ) + pin_size =SHARE_FSL_PIN_SIZE ; +else + pin_size =FSL_PIN_SIZE ;/* Initialise group */ grp->name = np->name;
@@ -403,12 +427,12 @@ static int imx_pinctrl_parse_groups(struct device_node *np,*/ list =of_get_property (np,"fsl,pins" , &size);/* we do not check return since it's safe node passed down */ -if (!size || size %FSL_PIN_SIZE ) { +if (!size || size % pin_size) {dev_err (info->dev,"Invalid fsl,pins property\n" );return -EINVAL ; } - grp->npins = size /FSL_PIN_SIZE ; + grp->npins = size / pin_size; grp->pins =devm_kzalloc (info->dev, grp->npins *sizeof (unsigned int ),GFP_KERNEL ); grp->mux_mode = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int),
@@ -421,10 +445,17 @@ static int imx_pinctrl_parse_groups(struct device_node *np, GFP_KERNEL);for (i =0 ; i < grp->npins; i++) {u32 mux_reg =be32_to_cpu (*list++); -u32 conf_reg =be32_to_cpu (*list++); -unsigned int pin_id = mux_reg ? mux_reg /4 : conf_reg /4 ; -struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id]; +u32 conf_reg; +unsigned int pin_id; +struct imx_pin_reg *pin_reg; +if (info->flags &SHARE_MUX_CONF_REG ) + conf_reg = mux_reg; +else + conf_reg =be32_to_cpu (*list++); + + pin_id = mux_reg ? mux_reg /4 : conf_reg /4 ; + pin_reg = &info->pin_regs[pin_id]; grp->pins[i] = pin_id; pin_reg->mux_reg = mux_reg; pin_reg->conf_reg = conf_reg;
drivers/pinctrl/pinctrl-imx.h +4 -0
@@ -74,8 +74,12 @@ struct imx_pinctrl_soc_info {unsigned int ngroups;struct imx_pmx_func *functions;unsigned int nfunctions; +unsigned int flags; }; +#define ZERO_OFFSET_VALID 0x1 +#define SHARE_MUX_CONF_REG 0x2 +#define NO_MUX 0x0#define NO_PAD 0x0
Signature · 1 line
1.8.0
PATCH v4 2/2 pinctrl: add VF610 pinctrl driver
Adds Freescale Vybrid VF610 pin controller
driver to IMX common pinctrl driver framework.
---
v4:
Fix document error.
Fix code style error.
Follow internal suggestions to name the soc name as VF610.
v3:
Clean up code.
Update binding document according recommendation.
v2:
Update the driver according to the IMX new pinctrl framework.
.../bindings/pinctrl/fsl,vf610-pinctrl.txt | 41 +++ drivers/pinctrl/Kconfig | 8 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-vf610.c | 338 +++++++++++++++++++++ 4 files changed, 388 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/fsl,vf610-pinctrl.txt create mode 100644 drivers/pinctrl/pinctrl-vf610.c
Documentation/devicetree/bindings/pinctrl/fsl,vf610-pinctrl.txt new file +41 -0
@@ -0,0 +1,41 @@ +Freescale Vybrid VF610 IOMUX Controller + +Please refer to fsl,imx-pinctrl.txt in this directory for common binding part +and usage. + +Required properties: +- compatible: "fsl,vf610-iomuxc" +- fsl,pins: two integers array, represents a group of pins mux and config + setting. The format is fsl,pins = <PIN_FUNC_ID CONFIG>, PIN_FUNC_ID is + a pin working on a specific function, CONFIG is the pad setting value + such as pull-up, speed, ode for this pin. Please refer to Vybrid VF610 + datasheet for the valid pad config settings. + +CONFIG bits definition: +PAD_CTL_SPEED_LOW (1 << 12) +PAD_CTL_SPEED_MED (2 << 12) +PAD_CTL_SPEED_HIGH (3 << 12) +PAD_CTL_SRE_FAST (1 << 11) +PAD_CTL_SRE_SLOW (0 << 11) +PAD_CTL_ODE (1 << 10) +PAD_CTL_HYS (1 << 9) +PAD_CTL_DSE_DISABLE (0 << 6) +PAD_CTL_DSE_150ohm (1 << 6) +PAD_CTL_DSE_75ohm (2 << 6) +PAD_CTL_DSE_50ohm (3 << 6) +PAD_CTL_DSE_37ohm (4 << 6) +PAD_CTL_DSE_30ohm (5 << 6) +PAD_CTL_DSE_25ohm (6 << 6) +PAD_CTL_DSE_20ohm (7 << 6) +PAD_CTL_PUS_100K_DOWN (0 << 4) +PAD_CTL_PUS_47K_UP (1 << 4) +PAD_CTL_PUS_100K_UP (2 << 4) +PAD_CTL_PUS_22K_UP (3 << 4) +PAD_CTL_PKE (1 << 3) +PAD_CTL_PUE (1 << 2) +PAD_CTL_OBE_ENABLE (1 << 1) +PAD_CTL_IBE_ENABLE (1 << 0) +PAD_CTL_OBE_IBE_ENABLE (3 << 0) + +Please refer to vf610-pinfunc.h in device tree source folder +for all available PIN_FUNC_ID for Vybrid VF610.
drivers/pinctrl/Kconfig +8 -0
@@ -108,6 +108,14 @@ config PINCTRL_IMX6SL help Say Y here to enable the imx6sl pinctrl driver +config PINCTRL_VF610 + bool "Freescale Vybrid VF610 pinctrl driver" + depends on OF + depends on SOC_VF610 + select PINCTRL_IMX + help + Say Y here to enable the Freescale Vybrid VF610 pinctrl driver + config PINCTRL_LANTIQ bool depends on LANTIQ
drivers/pinctrl/Makefile +1 -0
@@ -47,6 +47,7 @@ obj-$(CONFIG_PINCTRL_S3C24XX) += pinctrl-s3c24xx.o obj-$(CONFIG_PINCTRL_S3C64XX) += pinctrl-s3c64xx.o obj-$(CONFIG_PINCTRL_XWAY) += pinctrl-xway.o obj-$(CONFIG_PINCTRL_LANTIQ) += pinctrl-lantiq.o +obj-$(CONFIG_PINCTRL_VF610) += pinctrl-vf610.o obj-$(CONFIG_PLAT_ORION) += mvebu/ obj-$(CONFIG_ARCH_SHMOBILE) += sh-pfc/
drivers/pinctrl/pinctrl-vf610.c new file +338 -0
338 lines not on this page · raw message
Signature · 1 line
1.8.0
PATCH v4 2/2 pinctrl: add VF610 pinctrl driver
Quoted 4 lines · Jingchang Lu
Adds Freescale Vybrid VF610 pin controller
driver to IMX common pinctrl driver framework.Signed-off-by Jingchang Lu <[email protected]>
PATCH v4 2/2 pinctrl: add VF610 pinctrl driver
In reply to Jingchang LuQuoted 6 lines · Jingchang Lu
Adds Freescale Vybrid VF610 pin controller
driver to IMX common pinctrl driver framework.Signed-off-by Jingchang Lu <[email protected]>---
v4:
Patch applied with Shawn's ACK.
Thanks!
Linus Walleij
PATCH RESEND v3 1/2 pinctrl: imx: add VF610 support to imx pinctrl framework
In reply to Jingchang LuQuoted 6 lines · Jingchang Lu
On some platforms such as VF610, offset of mux and pad ctrl register may be zero, and the
mux_modeandconfig_valare in one 32-bit register. This patch adds support to imx core pinctrl framework to handle these cases.Signed-off-by Jingchang Lu <[email protected]>
PATCH RESEND v3 1/2 pinctrl: imx: add VF610 support to imx pinctrl framework
In reply to Jingchang LuQuoted 11 lines · Jingchang Lu
On some platforms such as VF610, offset of mux and pad ctrl register may be zero, and the
mux_modeandconfig_valare in one 32-bit register. This patch adds support to imx core pinctrl framework to handle these cases.Signed-off-by Jingchang Lu <[email protected]>---
v3:
AddZERO_OFFSET_VALIDflag to handle register offset from zero on Vybrid vf610. AddSHARE_MUX_CONF_REGflag to handle mux mode and config value in one 32-bit
register on Vybrid vf610.
Patch applied with Shawn's ACK.
Thanks,
Linus Walleij