Re: [PATCH v5 5/6] pinctrl: meson: add support of drive-strength-microamp
From: Martin Blumenstingl
Date: Sat May 11 2019 - 12:47:57 EST
Hi Guillaume,
On Fri, May 10, 2019 at 10:23 AM Guillaume La Roque
<glaroque@xxxxxxxxxxxx> wrote:
>
> 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@xxxxxxxxxxxx>
Reviewed-by: Martin Blumenstingl<martin.blumenstingl@xxxxxxxxxxxxxx>
the warning messages when printing pinconf-pins (in debugfs) are gone
on my Meson8m2 board so:
Tested-by: Martin Blumenstingl<martin.blumenstingl@xxxxxxxxxxxxxx>
[...]
> +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, 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;
I was confused by this shifting (not sure why I haven't noticed this
in earlier revisions). however, it all made sense after I did the
maths for two examples:
BOOT_0 uses drive-strength register 0x0 bits [1:0] so the result
should be "bit = 0"
meson_calc_reg_and_bit returns bit = 0
0 << 1 = 0, so this seems right
BOOT_15 uses drive-strength register 0x0 bits [31:30] so the result
should be "bit = 30"
meson_calc_reg_and_bit returns bit = 15
15 << 1 = 30
so all seems fine, even though it wasn't obvious to me at first sight
that it's all good
Martin