Support rk3328 pinctrl
Subsystems (4)
PATCH v2 1/3 pinctrl: rockchip: Add 3bit width mux support
In reply to David WuFrom: "david.wu" <[email protected]>
This patch supports 3bit width iomux type.
---
change in v2:
- add the "% 8" in the 3bit width iomux calculating
drivers/pinctrl/pinctrl-rockchip.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/pinctrl/pinctrl-rockchip.c +17 -3
@@ -75,6 +75,7 @@ enum rockchip_pinctrl_type {#define IOMUX_WIDTH_4BIT BIT(1)#define IOMUX_SOURCE_PMU BIT(2)#define IOMUX_UNROUTED BIT(3) +#define IOMUX_WIDTH_3BIT BIT(4)/** * @type: iomux variant using IOMUX_* constants
@@ -538,14 +539,20 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin) ? info->regmap_pmu : info->regmap_base;/* get basic quadrupel of mux registers and the correct reg inside */ - mask = (bank->iomux[iomux_num].type &IOMUX_WIDTH_4BIT ) ?0xf :0x3 ; reg = bank->iomux[iomux_num].offset;if (bank->iomux[iomux_num].type &IOMUX_WIDTH_4BIT ) {if ((pin %8 ) >=4 ) reg +=0x4 ; bit = (pin %4 ) *4 ; + mask =0xf ; + }else if (bank->iomux[iomux_num].type &IOMUX_WIDTH_3BIT ) { +if ((pin %8 ) >=5 ) + reg +=0x4 ; + bit = (pin %8 %5 ) *3 ; + mask =0x7 ; }else { bit = (pin %8 ) *2 ; + mask =0x3 ; } ret =regmap_read (regmap, reg, &val);
@@ -603,14 +610,20 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) ? info->regmap_pmu : info->regmap_base;/* get basic quadrupel of mux registers and the correct reg inside */ - mask = (bank->iomux[iomux_num].type &IOMUX_WIDTH_4BIT ) ?0xf :0x3 ; reg = bank->iomux[iomux_num].offset;if (bank->iomux[iomux_num].type &IOMUX_WIDTH_4BIT ) {if ((pin %8 ) >=4 ) reg +=0x4 ; bit = (pin %4 ) *4 ; + mask =0xf ; + }else if (bank->iomux[iomux_num].type &IOMUX_WIDTH_3BIT ) { +if ((pin %8 ) >=5 ) + reg +=0x4 ; + bit = (pin %8 %5 ) *3 ; + mask =0x7 ; }else { bit = (pin %8 ) *2 ; + mask =0x3 ; }spin_lock_irqsave (&bank->slock, flags);
@@ -2359,7 +2372,8 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(* Increase offset according to iomux width. * 4bit iomux'es are spread over two registers. */ - inc = (iom->type &IOMUX_WIDTH_4BIT ) ?8 :4 ; + inc = (iom->type & (IOMUX_WIDTH_4BIT | +IOMUX_WIDTH_3BIT )) ?8 :4 ;if (iom->type &IOMUX_SOURCE_PMU ) pmu_offs += inc;else
Signature · 1 line
1.9.1
PATCH v2 3/3 pinctrl: rockchip: Add rk3328 pinctrl support
In reply to David WuFrom: "david.wu" <[email protected]>
Note, the iomux of following pins are special, need to be recalculated specially.
- gpio2_b4
- gpio2_b7
- gpio2_c7
---
change in v2:
- only 3 pins need to be recalculated
.../bindings/pinctrl/rockchip,pinctrl.txt | 4 +- drivers/pinctrl/pinctrl-rockchip.c | 70 ++++++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt +2 -2
@@ -22,8 +22,8 @@ Required properties for iomux controller: - compatible: one of "rockchip,rk1108-pinctrl", "rockchip,rk2928-pinctrl" "rockchip,rk3066a-pinctrl", "rockchip,rk3066b-pinctrl" "rockchip,rk3188-pinctrl", "rockchip,rk3228-pinctrl" - "rockchip,rk3288-pinctrl", "rockchip,rk3368-pinctrl" - "rockchip,rk3399-pinctrl" + "rockchip,rk3288-pinctrl", "rockchip,rk3328-pinctrl" + "rockchip,rk3368-pinctrl", "rockchip,rk3399-pinctrl" - rockchip,grf: phandle referencing a syscon providing the "general register files"
drivers/pinctrl/pinctrl-rockchip.c +70 -0
88 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 2/3 pinctrl: rockchip: Add mux recalculation support
In reply to David WuFrom: "david.wu" <[email protected]>
Some pins are special at a bank so that add IOMUX_RECALCED type to indicate which iomux source of the bank need to be recalculated. If the mux recalculateed callback and IOMUX_RECALCED type were set, recalculate the pins' iomux by using mux recalculated data struct.
---
change in v2:
- reorder the entries of the recalced data struct
drivers/pinctrl/pinctrl-rockchip.c | 41 ++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-)
drivers/pinctrl/pinctrl-rockchip.c +35 -6
@@ -76,6 +76,7 @@ enum rockchip_pinctrl_type {#define IOMUX_SOURCE_PMU BIT(2)#define IOMUX_UNROUTED BIT(3)#define IOMUX_WIDTH_3BIT BIT(4) +#define IOMUX_RECALCED BIT(5)/** * @type: iomux variant using IOMUX_* constants
@@ -305,6 +306,8 @@ struct rockchip_pin_ctrl {void (*drv_calc_reg)(struct rockchip_pin_bank *bank,int pin_num,struct regmap **regmap,int *reg,u8 *bit); +void (*iomux_recalc)(u8 bank_num,int pin,int *reg, +u8 *bit,int *mask); };struct rockchip_pin_config {
@@ -356,6 +359,22 @@ struct rockchip_pinctrl {unsigned int nfunctions; }; +/** +* struct rockchip_mux_recalced_data: represent a pin iomux data. +* @num: bank number. +* @pin: pin number. +* @bit: index at register. +* @reg: register offset. +* @mask: mask bit +*/ +struct rockchip_mux_recalced_data { +u8 num; +u8 pin; +u8 reg; +u8 bit; +u8 mask; +}; +static struct regmap_config rockchip_regmap_config = { .reg_bits =32 , .val_bits =32 ,
@@ -518,10 +537,11 @@ static void rockchip_dt_free_map(struct pinctrl_dev *pctldev,static int rockchip_get_mux (struct rockchip_pin_bank *bank,int pin) {struct rockchip_pinctrl *info = bank->drvdata; +struct rockchip_pin_ctrl *ctrl = info->ctrl;int iomux_num = (pin /8 );struct regmap *regmap;unsigned int val; -int reg, ret, mask; +int reg, ret, mask, mux_type;u8 bit;if (iomux_num >3 )
@@ -539,13 +559,14 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin) ? info->regmap_pmu : info->regmap_base;/* get basic quadrupel of mux registers and the correct reg inside */ + mux_type = bank->iomux[iomux_num].type; reg = bank->iomux[iomux_num].offset; -if (bank->iomux[iomux_num].type &IOMUX_WIDTH_4BIT ) { +if (mux_type &IOMUX_WIDTH_4BIT ) {if ((pin %8 ) >=4 ) reg +=0x4 ; bit = (pin %4 ) *4 ; mask =0xf ; - }else if (bank->iomux[iomux_num].type &IOMUX_WIDTH_3BIT ) { + }else if (mux_type &IOMUX_WIDTH_3BIT ) {if ((pin %8 ) >=5 ) reg +=0x4 ; bit = (pin %8 %5 ) *3 ;
@@ -555,6 +576,9 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin) mask =0x3 ; } +if (ctrl->iomux_recalc && (mux_type &IOMUX_RECALCED )) + ctrl->iomux_recalc (bank->bank_num, pin, ®, &bit, &mask); + ret =regmap_read (regmap, reg, &val);if (ret)return ret;
@@ -578,9 +602,10 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin)static int rockchip_set_mux (struct rockchip_pin_bank *bank,int pin,int mux) {struct rockchip_pinctrl *info = bank->drvdata; +struct rockchip_pin_ctrl *ctrl = info->ctrl;int iomux_num = (pin /8 );struct regmap *regmap; -int reg, ret, mask; +int reg, ret, mask, mux_type;unsigned long flags;u8 bit;u32 data, rmask;
@@ -610,13 +635,14 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) ? info->regmap_pmu : info->regmap_base;/* get basic quadrupel of mux registers and the correct reg inside */ + mux_type = bank->iomux[iomux_num].type; reg = bank->iomux[iomux_num].offset; -if (bank->iomux[iomux_num].type &IOMUX_WIDTH_4BIT ) { +if (mux_type &IOMUX_WIDTH_4BIT ) {if ((pin %8 ) >=4 ) reg +=0x4 ; bit = (pin %4 ) *4 ; mask =0xf ; - }else if (bank->iomux[iomux_num].type &IOMUX_WIDTH_3BIT ) { + }else if (mux_type &IOMUX_WIDTH_3BIT ) {if ((pin %8 ) >=5 ) reg +=0x4 ; bit = (pin %8 %5 ) *3 ;
@@ -626,6 +652,9 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) mask =0x3 ; } +if (ctrl->iomux_recalc && (mux_type &IOMUX_RECALCED )) + ctrl->iomux_recalc (bank->bank_num, pin, ®, &bit, &mask); +spin_lock_irqsave (&bank->slock, flags); data = (mask << (bit +16 ));
Signature · 1 line
1.9.1
v2 cover Support rk3328 pinctrl
From: "david.wu" <[email protected]>
The rk3328 soc pinctrl iomux is different from other socs. The one is that it needs the pinctrl driver supports 3bit width iomux supported.
The other one is that three special pins need to be recalculated, because they are out of the rlues.
So add the three patches to support rk3328 pinctrl.
david.wu (3):
pinctrl: rockchip: Add 3bit width mux support
pinctrl: rockchip: Add mux recalculation support
pinctrl: rockchip: Add rk3328 pinctrl support
.../bindings/pinctrl/rockchip,pinctrl.txt | 4 +- drivers/pinctrl/pinctrl-rockchip.c | 127 +++++++++++++++++++-- 2 files changed, 122 insertions(+), 9 deletions(-)
Signature · 1 line
1.9.1
Re: [PATCH v2 1/3] pinctrl: rockchip: Add 3bit width mux support
In reply to David WuAm Freitag, 10. Februar 2017, 18:23:47 CET schrieb David Wu:
Quoted 5 lines
From: "david.wu" <[email protected]>
This patch supports 3bit width iomux type.
Signed-off-by david.wu <[email protected]>
change looks good and calculations do checkout out, so
Re: [PATCH v2 2/3] pinctrl: rockchip: Add mux recalculation support
In reply to David WuAm Freitag, 10. Februar 2017, 18:23:48 CET schrieb David Wu:
Quoted 10 lines
From: "david.wu" <[email protected]>
Some pins are special at a bank so that add
IOMUX_RECALCEDtype to indicate which iomux source of the bank need to be recalculated. If the mux recalculateed callback andIOMUX_RECALCEDtype were set, recalculate the pins' iomux by using mux recalculated data struct.Signed-off-by david.wu <[email protected]>
Re: [PATCH v2 3/3] pinctrl: rockchip: Add rk3328 pinctrl support
In reply to David WuAm Freitag, 10. Februar 2017, 18:23:49 CET schrieb David Wu:
Quoted 9 lines
From: "david.wu" <[email protected]>
Note, the iomux of following pins are special, need to be recalculated specially.
-gpio2_b4
-gpio2_b7
-gpio2_c7Signed-off-by david.wu <[email protected]>
Re: [PATCH v2 1/3] pinctrl: rockchip: Add 3bit width mux support
In reply to David WuQuoted 8 lines · David Wu
From: "david.wu" <[email protected]>
This patch supports 3bit width iomux type.
Signed-off-by david.wu <[email protected]>---
change in v2:
- add the "% 8" in the 3bit width iomux calculating
Patch applied for v4.12 with Heiko's review tag.
Will appear in my tree after the merge window.
Same applies to any other patch I apply now except fixes.
Yours,
Linus Walleij
Re: [PATCH v2 2/3] pinctrl: rockchip: Add mux recalculation support
In reply to David WuQuoted 9 lines · David Wu
From: "david.wu" <[email protected]>
Some pins are special at a bank so that add
IOMUX_RECALCEDtype to indicate which iomux source of the bank need to be recalculated. If the mux recalculateed callback andIOMUX_RECALCEDtype were set, recalculate the pins' iomux by using mux recalculated data struct.
Quoted 4 lines
Signed-off-by david.wu <[email protected]>---
change in v2:
- reorder the entries of the recalced data struct
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 3/3] pinctrl: rockchip: Add rk3328 pinctrl support
In reply to David WuQuoted 8 lines · David Wu
From: "david.wu" <[email protected]>
Note, the iomux of following pins are special, need to be recalculated specially.
-gpio2_b4
-gpio2_b7
-gpio2_c7
Quoted 4 lines
Signed-off-by david.wu <[email protected]>---
change in v2:
- only 3 pins need to be recalculated
Patch applied for v4.12.
Yours,
Linus Walleij