[U-Boot] [PATCH 0/3] Add drive-strength-microamp in Meson pinctrl driver

The purpose of this patchset is to add drive-strength-microamp 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 500uA, 2500uA, 3000uA and 4000uA and the DT property 'drive-strength-microamp' is expressed in uA. So this patch add another generic property "drive-strength-microamp". The change to do so would be minimal and could be benefit to other platforms later on.
it's backport from linux : https://lore.kernel.org/lkml/20190514082652.20686-1-glaroque@baylibre.com/
Cheers Guillaume
Guillaume La Roque (3): dm: pinctrl: Add driver-strength-microamp property pinctrl: meson: add support of drive-strength-microamp pinctrl: meson: g12a: add DS bank value
drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 1 + drivers/pinctrl/meson/pinctrl-meson-g12a.c | 20 ++++---- drivers/pinctrl/meson/pinctrl-meson.c | 46 ++++++++++++++++++- drivers/pinctrl/meson/pinctrl-meson.h | 43 +++++++++++------ include/dm/pinctrl.h | 3 ++ 5 files changed, 89 insertions(+), 24 deletions(-)

Add drive-strength-microamp property support to allow drive strength in uA
Signed-off-by: Guillaume La Roque glaroque@baylibre.com --- include/dm/pinctrl.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/include/dm/pinctrl.h b/include/dm/pinctrl.h index e7b8ad9078..3eca34fbf7 100644 --- a/include/dm/pinctrl.h +++ b/include/dm/pinctrl.h @@ -225,6 +225,8 @@ struct pinctrl_ops { * 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 @@ -281,6 +283,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,

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 glaroque@baylibre.com --- drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 1 + drivers/pinctrl/meson/pinctrl-meson.c | 46 ++++++++++++++++++- drivers/pinctrl/meson/pinctrl-meson.h | 43 +++++++++++------ 3 files changed, 76 insertions(+), 14 deletions(-)
diff --git a/drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c b/drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c index f23b188f2f..6af404ed68 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c +++ b/drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c @@ -97,6 +97,7 @@ const struct pinconf_param meson_axg_pinconf_params[] = { { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 }, { "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 }, { "bias-pull-down", PIN_CONFIG_BIAS_PULL_DOWN, 1 }, + { "drive-strength-microamp", PIN_CONFIG_DRIVE_STRENGTH_UA, 0 }, };
const struct pinctrl_ops meson_axg_pinctrl_ops = { diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 8735418c5b..432aaed02e 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -198,6 +198,47 @@ static int meson_pinconf_bias_set(struct udevice *dev, unsigned int pin, return 0; }
+static int meson_pinconf_drive_strength_set(struct udevice *dev, + unsigned int pin, + unsigned int drive_strength_ua) +{ + struct meson_pinctrl *priv = dev_get_priv(dev); + unsigned int offset = pin - priv->data->pin_base; + unsigned int reg, bit; + unsigned int ds_val; + int ret; + + if (!priv->reg_ds) { + dev_err(dev, "drive-strength-microamp not supported\n"); + return -ENOTSUPP; + } + + ret = meson_gpio_calc_reg_and_bit(dev, offset, REG_DS, ®, &bit); + if (ret) + return ret; + + 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(dev, + "pin %u: invalid drive-strength-microamp : %d , default to 4mA\n", + pin, drive_strength_ua); + ds_val = MESON_PINCONF_DRV_4000UA; + } + + clrsetbits_le32(priv->reg_ds + reg, 0x3 << bit, ds_val << bit); + + return 0; +} + int meson_pinconf_set(struct udevice *dev, unsigned int pin, unsigned int param, unsigned int arg) { @@ -209,7 +251,9 @@ int meson_pinconf_set(struct udevice *dev, unsigned int pin, case PIN_CONFIG_BIAS_PULL_DOWN: ret = meson_pinconf_bias_set(dev, pin, param); break; - + case PIN_CONFIG_DRIVE_STRENGTH_UA: + ret = meson_pinconf_drive_strength_set(dev, pin, arg); + break; default: dev_err(dev, "unsupported configuration parameter %u\n", param); return -EINVAL; diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h index b3683e2073..9261910948 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.h +++ b/drivers/pinctrl/meson/pinctrl-meson.h @@ -58,6 +58,16 @@ struct meson_reg_desc { unsigned int bit; };
+/** + * 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, +}; + /** * enum meson_reg_type - type of registers encoded in @meson_reg_desc */ @@ -67,6 +78,7 @@ enum meson_reg_type { REG_DIR, REG_OUT, REG_IN, + REG_DS, NUM_REG, };
@@ -99,19 +111,24 @@ struct meson_bank { .num_groups = ARRAY_SIZE(fn ## _groups), \ }
-#define BANK(n, f, l, per, peb, pr, pb, dr, db, or, ob, ir, ib) \ - { \ - .name = n, \ - .first = f, \ - .last = l, \ - .regs = { \ - [REG_PULLEN] = { per, peb }, \ - [REG_PULL] = { pr, pb }, \ - [REG_DIR] = { dr, db }, \ - [REG_OUT] = { or, ob }, \ - [REG_IN] = { ir, ib }, \ - }, \ - } +#define BANK_DS(n, f, l, per, peb, pr, pb, dr, db, or, ob, ir, ib, \ + dsr, dsb) \ + { \ + .name = n, \ + .first = f, \ + .last = l, \ + .regs = { \ + [REG_PULLEN] = {per, peb}, \ + [REG_PULL] = {pr, pb}, \ + [REG_DIR] = {dr, db}, \ + [REG_OUT] = { or, ob}, \ + [REG_IN] = {ir, ib}, \ + [REG_DS] = {dsr, dsb}, \ + }, \ + } + +#define BANK(n, f, l, per, peb, pr, pb, dr, db, or, ob, ir, ib) \ + BANK_DS(n, f, l, per, peb, pr, pb, dr, db, or, ob, ir, ib, 0, 0)
#define MESON_PIN(x, b) PINCTRL_PIN(PIN(x, b), #x)

add drive-strength bank regiter and bit value for G12A SoC
Signed-off-by: Guillaume La Roque glaroque@baylibre.com --- drivers/pinctrl/meson/pinctrl-meson-g12a.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/pinctrl/meson/pinctrl-meson-g12a.c b/drivers/pinctrl/meson/pinctrl-meson-g12a.c index 9cc2b9d52b..115e8b5616 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-g12a.c +++ b/drivers/pinctrl/meson/pinctrl-meson-g12a.c @@ -1204,19 +1204,19 @@ static struct meson_pmx_func meson_g12a_aobus_functions[] = { };
static struct meson_bank meson_g12a_periphs_banks[] = { - /* name first last pullen pull dir out in */ - BANK("Z", PIN(GPIOZ_0, EE_OFF), PIN(GPIOZ_15, EE_OFF), 4, 0, 4, 0, 12, 0, 13, 0, 14, 0), - BANK("H", PIN(GPIOH_0, EE_OFF), PIN(GPIOH_8, EE_OFF), 3, 0, 3, 0, 9, 0, 10, 0, 11, 0), - BANK("BOOT", PIN(BOOT_0, EE_OFF), PIN(BOOT_15, EE_OFF), 0, 0, 0, 0, 0, 0, 1, 0, 2, 0), - BANK("C", PIN(GPIOC_0, EE_OFF), PIN(GPIOC_7, EE_OFF), 1, 0, 1, 0, 3, 0, 4, 0, 5, 0), - BANK("A", PIN(GPIOA_0, EE_OFF), PIN(GPIOA_15, EE_OFF), 5, 0, 5, 0, 16, 0, 17, 0, 18, 0), - BANK("X", PIN(GPIOX_0, EE_OFF), PIN(GPIOX_19, EE_OFF), 2, 0, 2, 0, 6, 0, 7, 0, 8, 0), + /* name first last pullen pull dir out in ds*/ + BANK_DS("Z", PIN(GPIOZ_0, EE_OFF), PIN(GPIOZ_15, EE_OFF), 4, 0, 4, 0, 12, 0, 13, 0, 14, 0, 5, 0), + BANK_DS("H", PIN(GPIOH_0, EE_OFF), PIN(GPIOH_8, EE_OFF), 3, 0, 3, 0, 9, 0, 10, 0, 11, 0, 4, 0), + BANK_DS("BOOT", PIN(BOOT_0, EE_OFF), PIN(BOOT_15, EE_OFF), 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0), + BANK_DS("C", PIN(GPIOC_0, EE_OFF), PIN(GPIOC_7, EE_OFF), 1, 0, 1, 0, 3, 0, 4, 0, 5, 0, 1, 0), + BANK_DS("A", PIN(GPIOA_0, EE_OFF), PIN(GPIOA_15, EE_OFF), 5, 0, 5, 0, 16, 0, 17, 0, 18, 0, 6, 0), + BANK_DS("X", PIN(GPIOX_0, EE_OFF), PIN(GPIOX_19, EE_OFF), 2, 0, 2, 0, 6, 0, 7, 0, 8, 0, 2, 0), };
static struct meson_bank meson_g12a_aobus_banks[] = { - /* name first last pullen pull dir out in */ - BANK("AO", PIN(GPIOAO_0, 0), PIN(GPIOAO_11, 0), 3, 0, 2, 0, 0, 0, 4, 0, 1, 0), - BANK("E", PIN(GPIOE_0, 0), PIN(GPIOE_2, 0), 3, 16, 2, 16, 0, 16, 4, 16, 1, 16), + /* name first last pullen pull dir out in ds*/ + BANK_DS("AO", PIN(GPIOAO_0, 0), PIN(GPIOAO_11, 0), 3, 0, 2, 0, 0, 0, 4, 0, 1, 0, 0, 0), + BANK_DS("E", PIN(GPIOE_0, 0), PIN(GPIOE_2, 0), 3, 16, 2, 16, 0, 16, 4, 16, 1, 16, 1, 0), };
static struct meson_pmx_bank meson_g12a_periphs_pmx_banks[] = {

Hi Guillaume,
On 04/06/2019 13:53, Guillaume La Roque wrote:
The purpose of this patchset is to add drive-strength-microamp 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 500uA, 2500uA, 3000uA and 4000uA and the DT property 'drive-strength-microamp' is expressed in uA. So this patch add another generic property "drive-strength-microamp". The change to do so would be minimal and could be benefit to other platforms later on.
it's backport from linux : https://lore.kernel.org/lkml/20190514082652.20686-1-glaroque@baylibre.com/
Cheers Guillaume
Guillaume La Roque (3): dm: pinctrl: Add driver-strength-microamp property pinctrl: meson: add support of drive-strength-microamp pinctrl: meson: g12a: add DS bank value
drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 1 + drivers/pinctrl/meson/pinctrl-meson-g12a.c | 20 ++++---- drivers/pinctrl/meson/pinctrl-meson.c | 46 ++++++++++++++++++- drivers/pinctrl/meson/pinctrl-meson.h | 43 +++++++++++------ include/dm/pinctrl.h | 3 ++ 5 files changed, 89 insertions(+), 24 deletions(-)
Thanks
Tested on an Odroid-N2 !
Tested-by: Neil Armstrong narmstrong@baylibre.com
Neil

On 04/06/2019 13:53, Guillaume La Roque wrote:
The purpose of this patchset is to add drive-strength-microamp 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 500uA, 2500uA, 3000uA and 4000uA and the DT property 'drive-strength-microamp' is expressed in uA. So this patch add another generic property "drive-strength-microamp". The change to do so would be minimal and could be benefit to other platforms later on.
it's backport from linux : https://lore.kernel.org/lkml/20190514082652.20686-1-glaroque@baylibre.com/
Cheers Guillaume
Guillaume La Roque (3): dm: pinctrl: Add driver-strength-microamp property pinctrl: meson: add support of drive-strength-microamp pinctrl: meson: g12a: add DS bank value
drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 1 + drivers/pinctrl/meson/pinctrl-meson-g12a.c | 20 ++++---- drivers/pinctrl/meson/pinctrl-meson.c | 46 ++++++++++++++++++- drivers/pinctrl/meson/pinctrl-meson.h | 43 +++++++++++------ include/dm/pinctrl.h | 3 ++ 5 files changed, 89 insertions(+), 24 deletions(-)
Applied to u-boot-amlogic
participants (2)
-
Guillaume La Roque
-
Neil Armstrong