Add drive-strength in Meson pinctrl driver
Subsystems (4)
v3 cover Add drive-strength in Meson pinctrl driver
The purpose of this patchset is to add drive-strength support in meson pinconf driver. This is a new feature that was added on the g12a. It is critical for us to support this since many functions are failing with default pad drive-strength.
The value achievable by the SoC are 0.5mA, 2.5mA, 3mA and 4mA and the DT property 'drive-strength' is expressed in mA.
So this patch add another generic property "drive-strength-uA". The change to do so would be minimal and could be benefit to other platforms later on.
Cheers
Guillaume
Changes since v2:
- update driver-strength-uA property to be compliant with DT documentation
- rework patch series for better understanding
- rework set_bias function
Changes since v1:
- fix missing break
- implement new pinctrl generic property "drive-strength-uA"
[1] https://lkml.kernel.org/r/[email protected]
Guillaume La Roque (6):
dt-bindings: pinctrl: add a 'drive-strength-microamp' property
pinctrl: generic: add new 'drive-strength-microamp' property support
dt-bindings: pinctrl: meson: Add drive-strength-microamp property
pinctrl: meson: Rework enable/disable bias part
pinctrl: meson: add support of drive-strength-microamp
pinctrl: meson: g12a: add DS bank value
.../bindings/pinctrl/meson,pinctrl.txt | 4 + .../bindings/pinctrl/pinctrl-bindings.txt | 3 + drivers/pinctrl/meson/pinctrl-meson-g12a.c | 36 ++-- drivers/pinctrl/meson/pinctrl-meson.c | 177 +++++++++++++++--- drivers/pinctrl/meson/pinctrl-meson.h | 18 +- drivers/pinctrl/pinconf-generic.c | 2 + include/linux/pinctrl/pinconf-generic.h | 3 + 7 files changed, 195 insertions(+), 48 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/6 dt-bindings: pinctrl: add a 'drive-strength-microamp' property
This property allow drive-strength parameter in uA instead of mA.
--- Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +3 -0
@@ -258,6 +258,7 @@ drive-push-pull - drive actively high and low drive-open-drain - drive with open drain drive-open-source - drive with open source drive-strength - sink or source at most X mA +drive-strength-microamp - sink or source at most X uA input-enable - enable input on pin (no effect on output, such as enabling an input buffer) input-disable - disable input on pin (no effect on output, such as
@@ -326,6 +327,8 @@ arguments are described below. - drive-strength takes as argument the target strength in mA. +- drive-strength-microamp takes as argument the target strength in uA. + - input-debounce takes the debounce time in usec as argument or 0 to disable debouncing
Signature · 1 line
2.17.1
Re: [PATCH v3 1/6] dt-bindings: pinctrl: add a 'drive-strength-microamp' property
Quoted 4 lines · Guillaume La Roque
This property allow drive-strength parameter in uA instead of mA.
Signed-off-by Guillaume La Roque <[email protected]>
PATCH v3 2/6 pinctrl: generic: add new 'drive-strength-microamp' property support
In reply to Guillaume La RoqueAdd drive-strength-microamp property support to allow drive strength in uA
--- drivers/pinctrl/pinconf-generic.c | 2 ++ include/linux/pinctrl/pinconf-generic.h | 3 +++ 2 files changed, 5 insertions(+)
drivers/pinctrl/pinconf-generic.c +2 -0
@@ -39,6 +39,7 @@ static const struct pin_config_item conf_items[] = {PCONFDUMP (PIN_CONFIG_DRIVE_OPEN_SOURCE ,"output drive open source" ,NULL , false),PCONFDUMP (PIN_CONFIG_DRIVE_PUSH_PULL ,"output drive push pull" ,NULL , false),PCONFDUMP (PIN_CONFIG_DRIVE_STRENGTH ,"output drive strength" ,"mA" , true), +PCONFDUMP (PIN_CONFIG_DRIVE_STRENGTH_UA ,"output drive strength" ,"uA" , true),PCONFDUMP (PIN_CONFIG_INPUT_DEBOUNCE ,"input debounce" ,"usec" , true),PCONFDUMP (PIN_CONFIG_INPUT_ENABLE ,"input enabled" ,NULL , false), PCONFDUMP(PIN_CONFIG_INPUT_SCHMITT, "input schmitt trigger", NULL, false),
@@ -167,6 +168,7 @@ static const struct pinconf_generic_params dt_params[] = { { "drive-open-source", PIN_CONFIG_DRIVE_OPEN_SOURCE, 0 }, { "drive-push-pull", PIN_CONFIG_DRIVE_PUSH_PULL, 0 }, { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 0 }, + { "drive-strength-microamp", PIN_CONFIG_DRIVE_STRENGTH_UA, 0 }, { "input-debounce", PIN_CONFIG_INPUT_DEBOUNCE, 0 }, { "input-disable", PIN_CONFIG_INPUT_ENABLE, 0 }, { "input-enable", PIN_CONFIG_INPUT_ENABLE, 1 },
include/linux/pinctrl/pinconf-generic.h +3 -0
@@ -55,6 +55,8 @@* push-pull mode, the argument is ignored. * @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current * passed as argument. The argument is in mA. +* @PIN_CONFIG_DRIVE_STRENGTH_UA: the pin will sink or source at most the current +* passed as argument. The argument is in uA. * @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode, * which means it will wait for signals to settle when reading inputs. The * argument gives the debounce time in usecs. Setting the
@@ -112,6 +114,7 @@ enum pin_config_param {PIN_CONFIG_DRIVE_OPEN_SOURCE ,PIN_CONFIG_DRIVE_PUSH_PULL ,PIN_CONFIG_DRIVE_STRENGTH , +PIN_CONFIG_DRIVE_STRENGTH_UA ,PIN_CONFIG_INPUT_DEBOUNCE ,PIN_CONFIG_INPUT_ENABLE , PIN_CONFIG_INPUT_SCHMITT,
Signature · 1 line
2.17.1
PATCH v3 3/6 dt-bindings: pinctrl: meson: Add drive-strength-microamp property
In reply to Guillaume La RoqueAdd optional drive-strength-microamp property
--- Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt +4 -0
@@ -51,6 +51,10 @@ Configuration nodes support the generic properties "bias-disable", "bias-pull-up" and "bias-pull-down", described in file pinctrl-bindings.txt +Optional properties : + - drive-strength-microamp: Drive strength for the specified pins in uA. + This property is only valid for G12A and newer. + === Example === pinctrl: pinctrl@c1109880 {
Signature · 1 line
2.17.1
Re: [PATCH v3 3/6] dt-bindings: pinctrl: meson: Add drive-strength-microamp property
Quoted 4 lines · Guillaume La Roque
Add optional drive-strength-microamp property
Signed-off-by Guillaume La Roque <[email protected]>
PATCH v3 4/6 pinctrl: meson: Rework enable/disable bias part
In reply to Guillaume La Roquerework bias enable/disable part to prepare drive-strength integration
--- drivers/pinctrl/meson/pinctrl-meson.c | 79 ++++++++++++++++----------- 1 file changed, 48 insertions(+), 31 deletions(-)
drivers/pinctrl/meson/pinctrl-meson.c +48 -31
@@ -174,13 +174,57 @@ int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector,return 0 ; } +static int meson_pinconf_disable_bias (struct meson_pinctrl *pc, +unsigned int pin) +{ +struct meson_bank *bank; +unsigned int reg, bit =0 ; +int ret; + + ret =meson_get_bank (pc, pin, &bank); +if (ret) +return ret; +meson_calc_reg_and_bit (bank, pin,REG_PULLEN , ®, &bit); + ret =regmap_update_bits (pc->reg_pullen, reg,BIT (bit),0 ); +if (ret) +return ret; + +return 0 ; +} + +static int meson_pinconf_enable_bias (struct meson_pinctrl *pc,unsigned int pin, +bool pull_up) +{ +struct meson_bank *bank; +unsigned int reg, bit, val =0 ; +int ret; + + ret =meson_get_bank (pc, pin, &bank); +if (ret) +return ret; + +meson_calc_reg_and_bit (bank, pin,REG_PULL , ®, &bit); +if (pull_up) + val =BIT (bit); + + ret =regmap_update_bits (pc->reg_pull, reg,BIT (bit), val); +if (ret) +return ret; + +meson_calc_reg_and_bit (bank, pin,REG_PULLEN , ®, &bit); + ret =regmap_update_bits (pc->reg_pullen, reg,BIT (bit),BIT (bit)); +if (ret) +return ret; + +return 0 ; +} +static int meson_pinconf_set (struct pinctrl_dev *pcdev,unsigned int pin,unsigned long *configs,unsigned num_configs) {struct meson_pinctrl *pc =pinctrl_dev_get_drvdata (pcdev);struct meson_bank *bank;enum pin_config_param param; -unsigned int reg, bit;int i, ret; ret =meson_get_bank (pc, pin, &bank);
@@ -192,44 +236,17 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,switch (param) {case PIN_CONFIG_BIAS_DISABLE : -dev_dbg (pc->dev,"pin %u: disable bias\n" , pin); - -meson_calc_reg_and_bit (bank, pin,REG_PULLEN , ®, - &bit); - ret =regmap_update_bits (pc->reg_pullen, reg, -BIT (bit),0 ); + ret =meson_pinconf_disable_bias (pc, pin);if (ret)return ret;break ;case PIN_CONFIG_BIAS_PULL_UP : -dev_dbg (pc->dev,"pin %u: enable pull-up\n" , pin); - -meson_calc_reg_and_bit (bank, pin,REG_PULLEN , - ®, &bit); - ret =regmap_update_bits (pc->reg_pullen, reg, -BIT (bit),BIT (bit)); -if (ret) -return ret; - -meson_calc_reg_and_bit (bank, pin,REG_PULL , ®, &bit); - ret =regmap_update_bits (pc->reg_pull, reg, -BIT (bit),BIT (bit)); + ret =meson_pinconf_enable_bias (pc, pin,1 );if (ret)return ret;break ;case PIN_CONFIG_BIAS_PULL_DOWN : -dev_dbg (pc->dev,"pin %u: enable pull-down\n" , pin); - -meson_calc_reg_and_bit (bank, pin,REG_PULLEN , - ®, &bit); - ret =regmap_update_bits (pc->reg_pullen, reg, -BIT (bit),BIT (bit)); -if (ret) -return ret; - -meson_calc_reg_and_bit (bank, pin,REG_PULL , ®, &bit); - ret =regmap_update_bits (pc->reg_pull, reg, -BIT (bit),0 ); + ret =meson_pinconf_enable_bias (pc, pin,0 );if (ret)return ret;break ;
Signature · 1 line
2.17.1
Re: [PATCH v3 4/6] pinctrl: meson: Rework enable/disable bias part
Hi Guillaume,
Quoted 2 lines · Guillaume La Roque
rework bias enable/disable part to prepare drive-strength integration
if it was my patch I would add "no functional changes" at the end to make it explicit that this only changes the structure of the code.
Quoted 2 lines
Signed-off-by Guillaume La Roque <[email protected]>
with the minor comments from below addressed:
Quoted 12 lines
--- drivers/pinctrl/meson/pinctrl-meson.c | 79 ++++++++++++++++----------- 1 file changed, 48 insertions(+), 31 deletions(-)drivers/pinctrl/meson/pinctrl-meson.c +0
-0@@ -174,13 +174,57 @@ int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector,return 0 ; }
drivers/pinctrl/meson/pinctrl-meson.c int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector, · line 186
Quoted 10 lines
drivers/pinctrl/meson/pinctrl-meson.c +10
-0+static int meson_pinconf_disable_bias (struct meson_pinctrl *pc, +unsigned int pin) +{ +struct meson_bank *bank; +unsigned int reg, bit =0 ; +int ret; + + ret =meson_get_bank (pc, pin, &bank); +if (ret) +return ret;
add an empty line here to keep it consistent with the rest of the code
[...]
drivers/pinctrl/meson/pinctrl-meson.c int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector, · line 226
Quoted 5 lines
drivers/pinctrl/meson/pinctrl-meson.c +0
-0static int meson_pinconf_set (struct pinctrl_dev *pcdev,unsigned int pin,unsigned long *configs,unsigned num_configs) {struct meson_pinctrl *pc =pinctrl_dev_get_drvdata (pcdev);struct meson_bank *bank;
bank is not read anymore (it's passed to meson_get_bank to set it, but then it's not read, which is probably why my compiler doesn't complain)
Quoted 23 lines
drivers/pinctrl/meson/pinctrl-meson.c +1
-10enum pin_config_param param; -unsigned int reg, bit;int i, ret; ret =meson_get_bank (pc, pin, &bank);@@ -192,44 +236,17 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,switch (param) {case PIN_CONFIG_BIAS_DISABLE : -dev_dbg (pc->dev,"pin %u: disable bias\n" , pin); - -meson_calc_reg_and_bit (bank, pin,REG_PULLEN , ®, - &bit); - ret =regmap_update_bits (pc->reg_pullen, reg, -BIT (bit),0 ); + ret =meson_pinconf_disable_bias (pc, pin);if (ret)return ret;break ;case PIN_CONFIG_BIAS_PULL_UP : -dev_dbg (pc->dev,"pin %u: enable pull-up\n" , pin); - - meson_calc_reg_and_bit(bank, pin, REG_PULLEN,
drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, · line 244
Quoted 10 lines
drivers/pinctrl/meson/pinctrl-meson.c +1
-9- ®, &bit); - ret =regmap_update_bits (pc->reg_pullen, reg, -BIT (bit),BIT (bit)); -if (ret) -return ret; - -meson_calc_reg_and_bit (bank, pin,REG_PULL , ®, &bit); - ret =regmap_update_bits (pc->reg_pull, reg, -BIT (bit),BIT (bit)); + ret =meson_pinconf_enable_bias (pc, pin,1 );
use "true" instead of "1"?
Quoted 7 lines
drivers/pinctrl/meson/pinctrl-meson.c +0
-3if (ret)return ret;break ;case PIN_CONFIG_BIAS_PULL_DOWN : -dev_dbg (pc->dev,"pin %u: enable pull-down\n" , pin); - - meson_calc_reg_and_bit(bank, pin, REG_PULLEN,
drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, · line 249
Quoted 10 lines
drivers/pinctrl/meson/pinctrl-meson.c +1
-9- ®, &bit); - ret =regmap_update_bits (pc->reg_pullen, reg, -BIT (bit),BIT (bit)); -if (ret) -return ret; - -meson_calc_reg_and_bit (bank, pin,REG_PULL , ®, &bit); - ret =regmap_update_bits (pc->reg_pull, reg, -BIT (bit),0 ); + ret =meson_pinconf_enable_bias (pc, pin,0 );
use "false" instead of "0"?
one overall comment: thank you for working on this! in my opinion it's a good preparation step to ensure that meson_pinconf_set is easy to understand even if we add more functionality here
Regards
Martin
Re: [PATCH v3 4/6] pinctrl: meson: Rework enable/disable bias part
hi Martin,
same as previous patch i will do a new serie with your comments.
Quoted 99 lines · Martin Blumenstingl
Hi Guillaume,
Quoted 1 line · Guillaume La Roque
rework bias enable/disable part to prepare drive-strength integration
if it was my patch I would add "no functional changes" at the end to make it explicit that this only changes the structure of the code.
Quoted 1 line
Signed-off-by Guillaume La Roque <[email protected]>with the minor comments from below addressed:
Reviewed-by Martin Blumenstingl <[email protected]>Quoted 12 lines
--- drivers/pinctrl/meson/pinctrl-meson.c | 79 ++++++++++++++++----------- 1 file changed, 48 insertions(+), 31 deletions(-)drivers/pinctrl/meson/pinctrl-meson.c +0
-0@@ -174,13 +174,57 @@ int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector,return 0 ; }drivers/pinctrl/meson/pinctrl-meson.c int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector, · line 186
Quoted 10 lines
drivers/pinctrl/meson/pinctrl-meson.c +10
-0+static int meson_pinconf_disable_bias (struct meson_pinctrl *pc, +unsigned int pin) +{ +struct meson_bank *bank; +unsigned int reg, bit =0 ; +int ret; + + ret =meson_get_bank (pc, pin, &bank); +if (ret) +return ret;add an empty line here to keep it consistent with the rest of the code
[...]
drivers/pinctrl/meson/pinctrl-meson.c int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector, · line 226
Quoted 5 lines
drivers/pinctrl/meson/pinctrl-meson.c +0
-0static int meson_pinconf_set (struct pinctrl_dev *pcdev,unsigned int pin,unsigned long *configs,unsigned num_configs) {struct meson_pinctrl *pc =pinctrl_dev_get_drvdata (pcdev);struct meson_bank *bank;bank is not read anymore (it's passed to
meson_get_bankto set it, but then it's not read, which is probably why my compiler doesn't complain)Quoted 23 lines
drivers/pinctrl/meson/pinctrl-meson.c +1
-10enum pin_config_param param; -unsigned int reg, bit;int i, ret; ret =meson_get_bank (pc, pin, &bank);@@ -192,44 +236,17 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,switch (param) {case PIN_CONFIG_BIAS_DISABLE : -dev_dbg (pc->dev,"pin %u: disable bias\n" , pin); - -meson_calc_reg_and_bit (bank, pin,REG_PULLEN , ®, - &bit); - ret =regmap_update_bits (pc->reg_pullen, reg, -BIT (bit),0 ); + ret =meson_pinconf_disable_bias (pc, pin);if (ret)return ret;break ;case PIN_CONFIG_BIAS_PULL_UP : -dev_dbg (pc->dev,"pin %u: enable pull-up\n" , pin); - - meson_calc_reg_and_bit(bank, pin, REG_PULLEN,drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, · line 244
Quoted 10 lines
drivers/pinctrl/meson/pinctrl-meson.c +1
-9- ®, &bit); - ret =regmap_update_bits (pc->reg_pullen, reg, -BIT (bit),BIT (bit)); -if (ret) -return ret; - -meson_calc_reg_and_bit (bank, pin,REG_PULL , ®, &bit); - ret =regmap_update_bits (pc->reg_pull, reg, -BIT (bit),BIT (bit)); + ret =meson_pinconf_enable_bias (pc, pin,1 );use "true" instead of "1"?
Quoted 7 lines
drivers/pinctrl/meson/pinctrl-meson.c +0
-3if (ret)return ret;break ;case PIN_CONFIG_BIAS_PULL_DOWN : -dev_dbg (pc->dev,"pin %u: enable pull-down\n" , pin); - - meson_calc_reg_and_bit(bank, pin, REG_PULLEN,drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, · line 249
Quoted 10 lines
drivers/pinctrl/meson/pinctrl-meson.c +1
-9- ®, &bit); - ret =regmap_update_bits (pc->reg_pullen, reg, -BIT (bit),BIT (bit)); -if (ret) -return ret; - -meson_calc_reg_and_bit (bank, pin,REG_PULL , ®, &bit); - ret =regmap_update_bits (pc->reg_pull, reg, -BIT (bit),0 ); + ret =meson_pinconf_enable_bias (pc, pin,0 );use "false" instead of "0"?
Quoted 8 lines
one overall comment: thank you for working on this! in my opinion it's a good preparation step to ensure that
meson_pinconf_setis easy to understand even if we add more functionality hereRegards
Martin
guillaume
PATCH v3 5/6 pinctrl: meson: add support of drive-strength-microamp
In reply to Guillaume La Roquedrive-strength-microamp is a new feature needed for G12A SoC. the default DS setting after boot is usually 500uA and it is not enough for many functions. We need to be able to set the drive strength to reliably enable things like MMC, I2C, etc ...
--- drivers/pinctrl/meson/pinctrl-meson.c | 102 ++++++++++++++++++++++++++ drivers/pinctrl/meson/pinctrl-meson.h | 18 ++++- 2 files changed, 119 insertions(+), 1 deletion(-)
drivers/pinctrl/meson/pinctrl-meson.c +102 -0
@@ -219,12 +219,56 @@ static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin,return 0 ; } +static int meson_pinconf_set_drive_strength (struct meson_pinctrl *pc, +unsigned int pin, +u16 drive_strength_ua) +{ +struct meson_bank *bank; +unsigned int reg, bit; +unsigned int ds_val; +int ret; + +if (!pc->reg_ds) { +dev_err (pc->dev,"drive-strength not supported\n" ); +return -ENOTSUPP ; + } + + ret =meson_get_bank (pc, pin, &bank); +if (ret) +return ret; + +meson_calc_reg_and_bit (bank, pin,REG_DS , ®, &bit); + bit = bit <<1 ; + +if (drive_strength_ua <=500 ) { + ds_val =MESON_PINCONF_DRV_500UA ; + }else if (drive_strength_ua <=2500 ) { + ds_val =MESON_PINCONF_DRV_2500UA ; + }else if (drive_strength_ua <=3000 ) { + ds_val =MESON_PINCONF_DRV_3000UA ; + }else if (drive_strength_ua <=4000 ) { + ds_val =MESON_PINCONF_DRV_4000UA ; + }else { +dev_warn_once (pc->dev, +"pin %u: invalid drive-strength : %d , default to 4mA\n" , + pin, drive_strength_ua); + ds_val =MESON_PINCONF_DRV_4000UA ; + } + + ret =regmap_update_bits (pc->reg_ds, reg,0x3 << bit, ds_val << bit); +if (ret) +return ret; + +return 0 ; +} +static int meson_pinconf_set (struct pinctrl_dev *pcdev,unsigned int pin,unsigned long *configs,unsigned num_configs) {struct meson_pinctrl *pc =pinctrl_dev_get_drvdata (pcdev);struct meson_bank *bank;enum pin_config_param param; +unsigned int drive_strength_ua;int i, ret; ret =meson_get_bank (pc, pin, &bank);
@@ -250,6 +294,14 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,if (ret)return ret;break ; +case PIN_CONFIG_DRIVE_STRENGTH_UA : + drive_strength_ua = +pinconf_to_config_argument (configs[i]); + ret =meson_pinconf_set_drive_strength + (pc, pin, drive_strength_ua); +if (ret) +return ret; +break ;default :return -ENOTSUPP ; }
@@ -292,12 +344,57 @@ static int meson_pinconf_get_pull(struct meson_pinctrl *pc, unsigned int pin)return conf; } +static int meson_pinconf_get_drive_strength (struct meson_pinctrl *pc, +unsigned int pin, +u16 *drive_strength_ua) +{ +struct meson_bank *bank; +unsigned int reg, bit; +unsigned int val; +int ret; + +if (!pc->reg_ds) { +dev_err (pc->dev,"drive-strength not supported\n" ); +return -ENOTSUPP ; + } + + ret =meson_get_bank (pc, pin, &bank); +if (ret) +return ret; + +meson_calc_reg_and_bit (bank, pin,REG_DS , ®, &bit); + + ret =regmap_read (pc->reg_ds, reg, &val); +if (ret) +return ret; + +switch ((val >> bit) &0x3 ) { +case MESON_PINCONF_DRV_500UA : + *drive_strength_ua =500 ; +break ; +case MESON_PINCONF_DRV_2500UA : + *drive_strength_ua =2500 ; +break ; +case MESON_PINCONF_DRV_3000UA : + *drive_strength_ua =3000 ; +break ; +case MESON_PINCONF_DRV_4000UA : + *drive_strength_ua =4000 ; +break ; +default : +return -EINVAL ; + } + +return 0 ; +} +static int meson_pinconf_get (struct pinctrl_dev *pcdev,unsigned int pin,unsigned long *config) {struct meson_pinctrl *pc =pinctrl_dev_get_drvdata (pcdev);enum pin_config_param param =pinconf_to_config_param (*config);u16 arg; +int ret;switch (param) {case PIN_CONFIG_BIAS_DISABLE :
@@ -308,6 +405,11 @@ static int meson_pinconf_get(struct pinctrl_dev *pcdev, unsigned int pin,else return -EINVAL ;break ; +case PIN_CONFIG_DRIVE_STRENGTH_UA : + ret =meson_pinconf_get_drive_strength (pc, pin, &arg); +if (ret) +return ret; +break ;default :return -ENOTSUPP ; }
drivers/pinctrl/meson/pinctrl-meson.h +17 -1
@@ -71,9 +71,20 @@ enum meson_reg_type {REG_DIR ,REG_OUT ,REG_IN , +REG_DS , NUM_REG, }; +/** +* enum meson_pinconf_drv - value of drive-strength supported +*/ +enum meson_pinconf_drv { +MESON_PINCONF_DRV_500UA , +MESON_PINCONF_DRV_2500UA , +MESON_PINCONF_DRV_3000UA , +MESON_PINCONF_DRV_4000UA , +}; +/** * struct meson bank *
@@ -132,7 +143,8 @@ struct meson_pinctrl { .num_groups = ARRAY_SIZE(fn ## _groups), \ } -#define BANK (n, f, l, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib) \ +#define BANK_DS (n, f, l, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib, \ + dsr, dsb) \ { \ .name = n, \ .first = f, \
@@ -145,9 +157,13 @@ struct meson_pinctrl { [REG_DIR] = { dr, db }, \ [REG_OUT] = { or, ob }, \ [REG_IN] = { ir, ib }, \ + [REG_DS] = { dsr, dsb }, \ }, \ } +#define BANK(n, f, l, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib) \ + BANK_DS(n, f, l, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib, 0, 0) + #define MESON_PIN(x) PINCTRL_PIN(x, #x)/* Common pmx functions */
Signature · 1 line
2.17.1
Re: [PATCH v3 5/6] pinctrl: meson: add support of drive-strength-microamp
Quoted 7 lines · Guillaume La Roque
drive-strength-microamp is a new feature needed for G12A SoC. the default DS setting after boot is usually 500uA and it is not enough for many functions. We need to be able to set the drive strength to reliably enable things like MMC, I2C, etc ...
Signed-off-by Guillaume La Roque <[email protected]>
with the comments below addressed:
Quoted 10 lines
--- drivers/pinctrl/meson/pinctrl-meson.c | 102 ++++++++++++++++++++++++++ drivers/pinctrl/meson/pinctrl-meson.h | 18 ++++- 2 files changed, 119 insertions(+), 1 deletion(-)drivers/pinctrl/meson/pinctrl-meson.c +0
-0
drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin, · line 228
Quoted 10 lines
drivers/pinctrl/meson/pinctrl-meson.c +7
-0@@ -219,12 +219,56 @@ static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin,return 0 ; } +static int meson_pinconf_set_drive_strength (struct meson_pinctrl *pc, +unsigned int pin, +u16 drive_strength_ua) +{ +struct meson_bank *bank; +unsigned int reg, bit; +unsigned int ds_val;
you can move ds_val to the line above
[...]
drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin, · line 230
Quoted 2 lines
drivers/pinctrl/meson/pinctrl-meson.c +2
-0+if (!pc->reg_ds) { +dev_err (pc->dev,"drive-strength not supported\n" );
I'm getting this on one of my Meson8m2 boards:
$ # cat /sys/kernel/debug/pinctrl/c1109880.pinctrl-pinctrl-meson/pinconf-pins ... [ 874.748531] meson8-pinctrl c1109880.pinctrl: drive-strength not supported [ 874.755278] meson8-pinctrl c1109880.pinctrl: drive-strength not supported [ 874.762086] meson8-pinctrl c1109880.pinctrl: drive-strength not supported Pin config settings per pin Format: pin (name): configs pin 0 (GPIOX_0): input bias disabled pin 1 (GPIOX_1): input bias disabled pin 2 (GPIOX_2): input bias disabled ...
I believe we are not supposed to complain when getting the drive-strength when reg_ds is absent.
all pre-G12A SoCs don't have reg_ds, so we don't need to error-out in that case (because that's perfectly valid)
[...]
drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_get_pull(struct meson_pinctrl *pc, unsigned int pin) · line 357
Quoted 11 lines
drivers/pinctrl/meson/pinctrl-meson.c +11
-0+static int meson_pinconf_get_drive_strength (struct meson_pinctrl *pc, +unsigned int pin, +u16 *drive_strength_ua) +{ +struct meson_bank *bank; +unsigned int reg, bit; +unsigned int val; +int ret; + +if (!pc->reg_ds) { +dev_err (pc->dev,"drive-strength not supported\n" );
based on your previous explanation (that you want to inform the .dts author that he's doing something wrong) I'm happy with this error if Linus W. doesn't veto this.
Regards
Martin
Re: [PATCH v3 5/6] pinctrl: meson: add support of drive-strength-microamp
hi martin,
thanks for review, i will do a new series to remove err log on get_drive_strength
and integrate your comment
Quoted 70 lines · Martin Blumenstingl
Quoted 6 lines · Guillaume La Roque
drive-strength-microamp is a new feature needed for G12A SoC. the default DS setting after boot is usually 500uA and it is not enough for many functions. We need to be able to set the drive strength to reliably enable things like MMC, I2C, etc ...
Signed-off-by Guillaume La Roque <[email protected]>with the comments below addressed:
Reviewed-by Martin Blumenstingl <[email protected]>Quoted 10 lines
--- drivers/pinctrl/meson/pinctrl-meson.c | 102 ++++++++++++++++++++++++++ drivers/pinctrl/meson/pinctrl-meson.h | 18 ++++- 2 files changed, 119 insertions(+), 1 deletion(-)drivers/pinctrl/meson/pinctrl-meson.c +0
-0drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin, · line 228
Quoted 10 lines
drivers/pinctrl/meson/pinctrl-meson.c +7
-0@@ -219,12 +219,56 @@ static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin,return 0 ; } +static int meson_pinconf_set_drive_strength (struct meson_pinctrl *pc, +unsigned int pin, +u16 drive_strength_ua) +{ +struct meson_bank *bank; +unsigned int reg, bit; +unsigned int ds_val;you can move
ds_valto the line above[...]
drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin, · line 230
Quoted 2 lines
drivers/pinctrl/meson/pinctrl-meson.c +2
-0+if (!pc->reg_ds) { +dev_err (pc->dev,"drive-strength not supported\n" );I'm getting this on one of my Meson8m2 boards:
$ # cat /sys/kernel/debug/pinctrl/c1109880.pinctrl-pinctrl-meson/pinconf-pins ... [ 874.748531] meson8-pinctrl c1109880.pinctrl: drive-strength not supported [ 874.755278] meson8-pinctrl c1109880.pinctrl: drive-strength not supported [ 874.762086] meson8-pinctrl c1109880.pinctrl: drive-strength not supported Pin config settings per pin Format: pin (name): configs pin 0 (GPIOX_0): input bias disabled pin 1 (GPIOX_1): input bias disabled pin 2 (GPIOX_2): input bias disabled ...I believe we are not supposed to complain when getting the drive-strength when
reg_dsis absent.
all pre-G12A SoCs don't havereg_ds, so we don't need to error-out in that case (because that's perfectly valid)[...]
drivers/pinctrl/meson/pinctrl-meson.c static int meson_pinconf_get_pull(struct meson_pinctrl *pc, unsigned int pin) · line 357
Quoted 11 lines
drivers/pinctrl/meson/pinctrl-meson.c +11
-0+static int meson_pinconf_get_drive_strength (struct meson_pinctrl *pc, +unsigned int pin, +u16 *drive_strength_ua) +{ +struct meson_bank *bank; +unsigned int reg, bit; +unsigned int val; +int ret; + +if (!pc->reg_ds) { +dev_err (pc->dev,"drive-strength not supported\n" );based on your previous explanation (that you want to inform the .dts author that he's doing something wrong) I'm happy with this error if Linus W. doesn't veto this.
Quoted 2 lines
Regards
Martin
Guillaume
PATCH v3 6/6 pinctrl: meson: g12a: add DS bank value
In reply to Guillaume La Roqueadd drive-strength bank register and bit value for G12A SoC
--- drivers/pinctrl/meson/pinctrl-meson-g12a.c | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/pinctrl/meson/pinctrl-meson-g12a.c +18 -18
@@ -1304,28 +1304,28 @@ static struct meson_pmx_func meson_g12a_aobus_functions[] = { };static struct meson_bank meson_g12a_periphs_banks[] = { -/* name first last irq pullen pull dir out in */ -BANK ("Z" ,GPIOZ_0 ,GPIOZ_15 ,12 ,27 , -4 ,0 ,4 ,0 ,12 ,0 ,13 ,0 ,14 ,0 ), -BANK ("H" ,GPIOH_0 ,GPIOH_8 ,28 ,36 , -3 ,0 ,3 ,0 ,9 ,0 ,10 ,0 ,11 ,0 ), -BANK ("BOOT" ,BOOT_0 ,BOOT_15 ,37 ,52 , -0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,2 ,0 ), -BANK ("C" ,GPIOC_0 ,GPIOC_7 ,53 ,60 , -1 ,0 ,1 ,0 ,3 ,0 ,4 ,0 ,5 ,0 ), -BANK ("A" ,GPIOA_0 ,GPIOA_15 ,61 ,76 , -5 ,0 ,5 ,0 ,16 ,0 ,17 ,0 ,18 ,0 ), -BANK ("X" ,GPIOX_0 ,GPIOX_19 ,77 ,96 , -2 ,0 ,2 ,0 ,6 ,0 ,7 ,0 ,8 ,0 ), +/* name first last irq pullen pull dir out in ds */ +BANK_DS ("Z" ,GPIOZ_0 ,GPIOZ_15 ,12 ,27 , +4 ,0 ,4 ,0 ,12 ,0 ,13 ,0 ,14 ,0 ,5 ,0 ), +BANK_DS ("H" ,GPIOH_0 ,GPIOH_8 ,28 ,36 , +3 ,0 ,3 ,0 ,9 ,0 ,10 ,0 ,11 ,0 ,4 ,0 ), +BANK_DS ("BOOT" ,BOOT_0 ,BOOT_15 ,37 ,52 , +0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,2 ,0 ,0 ,0 ), +BANK_DS ("C" ,GPIOC_0 ,GPIOC_7 ,53 ,60 , +1 ,0 ,1 ,0 ,3 ,0 ,4 ,0 ,5 ,0 ,1 ,0 ), +BANK_DS ("A" ,GPIOA_0 ,GPIOA_15 ,61 ,76 , +5 ,0 ,5 ,0 ,16 ,0 ,17 ,0 ,18 ,0 ,6 ,0 ), +BANK_DS ("X" ,GPIOX_0 ,GPIOX_19 ,77 ,96 , +2 ,0 ,2 ,0 ,6 ,0 ,7 ,0 ,8 ,0 ,2 ,0 ), };static struct meson_bank meson_g12a_aobus_banks[] = { -/* name first last irq pullen pull dir out in */ -BANK ("AO" ,GPIOAO_0 ,GPIOAO_11 ,0 ,11 , -3 ,0 ,2 ,0 ,0 ,0 ,4 ,0 ,1 ,0 ), +/* name first last irq pullen pull dir out in ds */ +BANK_DS ("AO" ,GPIOAO_0 ,GPIOAO_11 ,0 ,11 ,3 ,0 ,2 ,0 ,0 ,0 ,4 ,0 ,1 ,0 , +0 ,0 ),/* GPIOE actually located in the AO bank */ -BANK ("E" ,GPIOE_0 ,GPIOE_2 ,97 ,99 , -3 ,16 ,2 ,16 ,0 ,16 ,4 ,16 ,1 ,16 ), +BANK_DS ("E" ,GPIOE_0 ,GPIOE_2 ,97 ,99 ,3 ,16 ,2 ,16 ,0 ,16 ,4 ,16 ,1 , +16 ,1 ,0 ), };static struct meson_pmx_bank meson_g12a_periphs_pmx_banks[] = {
Signature · 1 line
2.17.1
Re: [PATCH v3 6/6] pinctrl: meson: g12a: add DS bank value
Quoted 4 lines · Guillaume La Roque
add drive-strength bank register and bit value for G12A SoC
Signed-off-by Guillaume La Roque <[email protected]>
[...]
drivers/pinctrl/meson/pinctrl-meson-g12a.c static struct meson_pmx_func meson_g12a_aobus_functions[] = { · line 1311
Quoted 5 lines
drivers/pinctrl/meson/pinctrl-meson-g12a.c +5
-0+/* name first last irq pullen pull dir out in ds */ +BANK_DS ("Z" ,GPIOZ_0 ,GPIOZ_15 ,12 ,27 , +4 ,0 ,4 ,0 ,12 ,0 ,13 ,0 ,14 ,0 ,5 ,0 ), +BANK_DS ("H" ,GPIOH_0 ,GPIOH_8 ,28 ,36 , + 3, 0, 3, 0, 9, 0, 10, 0, 11, 0, 4, 0),
a note for myself (because I keep forgetting this)
"5, 0" stands for:
- the register PAD_DS_REG5A as seen in the public S922X datasheet from Hardkernel on page 224
- starting at bit 0
Quoted 32 lines · Guillaume La Roque
The purpose of this patchset is to add drive-strength support in meson pinconf driver. This is a new feature that was added on the g12a. It is critical for us to support this since many functions are failing with default pad drive-strength.
The value achievable by the SoC are 0.5mA, 2.5mA, 3mA and 4mA and the DT property 'drive-strength' is expressed in mA.
So this patch add another generic property "drive-strength-uA". The change to do so would be minimal and could be benefit to other platforms later on.Cheers
GuillaumeChanges since v2:
- update driver-strength-uA property to be compliant with DT documentation
- rework patch series for better understanding
- reworkset_biasfunctionChanges since v1:
- fix missing break
- implement new pinctrl generic property "drive-strength-uA"[1] https://lkml.kernel.org/r/[email protected]
Guillaume La Roque (6):
dt-bindings: pinctrl: add a 'drive-strength-microamp' property
pinctrl: generic: add new 'drive-strength-microamp' property support
dt-bindings: pinctrl: meson: Add drive-strength-microamp property
pinctrl: meson: Rework enable/disable bias part
pinctrl: meson: add support of drive-strength-microamp
pinctrl: meson: g12a: add DS bank value
Quoted 9 lines
.../bindings/pinctrl/meson,pinctrl.txt | 4 + .../bindings/pinctrl/pinctrl-bindings.txt | 3 + drivers/pinctrl/meson/pinctrl-meson-g12a.c | 36 ++-- drivers/pinctrl/meson/pinctrl-meson.c | 177 +++++++++++++++--- drivers/pinctrl/meson/pinctrl-meson.h | 18 +- drivers/pinctrl/pinconf-generic.c | 2 + include/linux/pinctrl/pinconf-generic.h | 3 + 7 files changed, 195 insertions(+), 48 deletions(-)
Quoted 33 lines · Guillaume La Roque
The purpose of this patchset is to add drive-strength support in meson pinconf driver. This is a new feature that was added on the g12a. It is critical for us to support this since many functions are failing with default pad drive-strength.
The value achievable by the SoC are 0.5mA, 2.5mA, 3mA and 4mA and the DT property 'drive-strength' is expressed in mA.
So this patch add another generic property "drive-strength-uA". The change to do so would be minimal and could be benefit to other platforms later on.Cheers
GuillaumeChanges since v2:
- update driver-strength-uA property to be compliant with DT documentation
- rework patch series for better understanding
- reworkset_biasfunctionChanges since v1:
- fix missing break
- implement new pinctrl generic property "drive-strength-uA"[1] https://lkml.kernel.org/r/[email protected]
Guillaume La Roque (6):
dt-bindings: pinctrl: add a 'drive-strength-microamp' property
pinctrl: generic: add new 'drive-strength-microamp' property support
dt-bindings: pinctrl: meson: Add drive-strength-microamp property
pinctrl: meson: Rework enable/disable bias part
pinctrl: meson: add support of drive-strength-microamp
pinctrl: meson: g12a: add DS bank value
Quoted 8 lines
.../bindings/pinctrl/meson,pinctrl.txt | 4 + .../bindings/pinctrl/pinctrl-bindings.txt | 3 + drivers/pinctrl/meson/pinctrl-meson-g12a.c | 36 ++-- drivers/pinctrl/meson/pinctrl-meson.c | 177 +++++++++++++++--- drivers/pinctrl/meson/pinctrl-meson.h | 18 +- drivers/pinctrl/pinconf-generic.c | 2 + include/linux/pinctrl/pinconf-generic.h | 3 + 7 files changed, 195 insertions(+), 48 deletions(-)
I gave this a go on one of my Meson8m2 boards:
[Meson8m2 doesn't support drive strength and still boots without any crashes or obvious regressions]