* [PATCH v5 1/6] dt-bindings: pinctrl: add a 'drive-strength-microamp' property
2019-05-10 8:23 [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver Guillaume La Roque
@ 2019-05-10 8:23 ` Guillaume La Roque
2019-05-11 16:20 ` Martin Blumenstingl
2019-05-13 15:24 ` Rob Herring
2019-05-10 8:23 ` [PATCH v5 2/6] pinctrl: generic: add new 'drive-strength-microamp' property support Guillaume La Roque
` (5 subsequent siblings)
6 siblings, 2 replies; 15+ messages in thread
From: Guillaume La Roque @ 2019-05-10 8:23 UTC (permalink / raw)
To: linus.walleij, khilman
Cc: linux-gpio, devicetree, linux-amlogic, linux-kernel, jbrunet
This property allow drive-strength parameter in uA instead of mA.
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
---
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
index cef2b5855d60..fcd37e93ed4d 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
@@ -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
--
2.17.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v5 1/6] dt-bindings: pinctrl: add a 'drive-strength-microamp' property
2019-05-10 8:23 ` [PATCH v5 1/6] dt-bindings: pinctrl: add a 'drive-strength-microamp' property Guillaume La Roque
@ 2019-05-11 16:20 ` Martin Blumenstingl
2019-05-13 15:24 ` Rob Herring
1 sibling, 0 replies; 15+ messages in thread
From: Martin Blumenstingl @ 2019-05-11 16:20 UTC (permalink / raw)
To: Guillaume La Roque
Cc: devicetree, khilman, linus.walleij, linux-kernel, linux-gpio,
linux-amlogic, jbrunet
On Fri, May 10, 2019 at 10:23 AM Guillaume La Roque
<glaroque@baylibre.com> wrote:
>
> This property allow drive-strength parameter in uA instead of mA.
>
> Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
Reviewed-by: Martin Blumenstingl<martin.blumenstingl@googlemail.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 1/6] dt-bindings: pinctrl: add a 'drive-strength-microamp' property
2019-05-10 8:23 ` [PATCH v5 1/6] dt-bindings: pinctrl: add a 'drive-strength-microamp' property Guillaume La Roque
2019-05-11 16:20 ` Martin Blumenstingl
@ 2019-05-13 15:24 ` Rob Herring
1 sibling, 0 replies; 15+ messages in thread
From: Rob Herring @ 2019-05-13 15:24 UTC (permalink / raw)
To: Guillaume La Roque
Cc: devicetree, khilman, linus.walleij, linux-kernel, linux-gpio,
linux-amlogic, jbrunet
On Fri, 10 May 2019 10:23:19 +0200, Guillaume La Roque wrote:
> This property allow drive-strength parameter in uA instead of mA.
>
> Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
> ---
> Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt | 3 +++
> 1 file changed, 3 insertions(+)
>
Reviewed-by: Rob Herring <robh@kernel.org>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v5 2/6] pinctrl: generic: add new 'drive-strength-microamp' property support
2019-05-10 8:23 [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver Guillaume La Roque
2019-05-10 8:23 ` [PATCH v5 1/6] dt-bindings: pinctrl: add a 'drive-strength-microamp' property Guillaume La Roque
@ 2019-05-10 8:23 ` Guillaume La Roque
2019-05-10 8:23 ` [PATCH v5 3/6] dt-bindings: pinctrl: meson: Add drive-strength-microamp property Guillaume La Roque
` (4 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Guillaume La Roque @ 2019-05-10 8:23 UTC (permalink / raw)
To: linus.walleij, khilman
Cc: linux-gpio, devicetree, linux-amlogic, linux-kernel, jbrunet
Add drive-strength-microamp property support to allow drive strength in uA
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
---
drivers/pinctrl/pinconf-generic.c | 2 ++
include/linux/pinctrl/pinconf-generic.h | 3 +++
2 files changed, 5 insertions(+)
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index b4f7f8a458ea..d0cbdb1ad76a 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -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 },
diff --git a/include/linux/pinctrl/pinconf-generic.h b/include/linux/pinctrl/pinconf-generic.h
index 6c0680641108..72d06d6a3099 100644
--- a/include/linux/pinctrl/pinconf-generic.h
+++ b/include/linux/pinctrl/pinconf-generic.h
@@ -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,
--
2.17.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v5 3/6] dt-bindings: pinctrl: meson: Add drive-strength-microamp property
2019-05-10 8:23 [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver Guillaume La Roque
2019-05-10 8:23 ` [PATCH v5 1/6] dt-bindings: pinctrl: add a 'drive-strength-microamp' property Guillaume La Roque
2019-05-10 8:23 ` [PATCH v5 2/6] pinctrl: generic: add new 'drive-strength-microamp' property support Guillaume La Roque
@ 2019-05-10 8:23 ` Guillaume La Roque
2019-05-11 16:20 ` Martin Blumenstingl
2019-05-13 15:25 ` Rob Herring
2019-05-10 8:23 ` [PATCH v5 4/6] pinctrl: meson: Rework enable/disable bias part Guillaume La Roque
` (3 subsequent siblings)
6 siblings, 2 replies; 15+ messages in thread
From: Guillaume La Roque @ 2019-05-10 8:23 UTC (permalink / raw)
To: linus.walleij, khilman
Cc: linux-gpio, devicetree, linux-amlogic, linux-kernel, jbrunet
Add optional drive-strength-microamp property
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
---
Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
index a47dd990a8d3..a7618605bf1e 100644
--- a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
@@ -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 {
--
2.17.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v5 3/6] dt-bindings: pinctrl: meson: Add drive-strength-microamp property
2019-05-10 8:23 ` [PATCH v5 3/6] dt-bindings: pinctrl: meson: Add drive-strength-microamp property Guillaume La Roque
@ 2019-05-11 16:20 ` Martin Blumenstingl
2019-05-13 15:25 ` Rob Herring
1 sibling, 0 replies; 15+ messages in thread
From: Martin Blumenstingl @ 2019-05-11 16:20 UTC (permalink / raw)
To: Guillaume La Roque
Cc: devicetree, khilman, linus.walleij, linux-kernel, linux-gpio,
linux-amlogic, jbrunet
On Fri, May 10, 2019 at 10:23 AM Guillaume La Roque
<glaroque@baylibre.com> wrote:
>
> Add optional drive-strength-microamp property
>
> Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
Reviewed-by: Martin Blumenstingl<martin.blumenstingl@googlemail.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 3/6] dt-bindings: pinctrl: meson: Add drive-strength-microamp property
2019-05-10 8:23 ` [PATCH v5 3/6] dt-bindings: pinctrl: meson: Add drive-strength-microamp property Guillaume La Roque
2019-05-11 16:20 ` Martin Blumenstingl
@ 2019-05-13 15:25 ` Rob Herring
1 sibling, 0 replies; 15+ messages in thread
From: Rob Herring @ 2019-05-13 15:25 UTC (permalink / raw)
To: Guillaume La Roque
Cc: devicetree, khilman, linus.walleij, linux-kernel, linux-gpio,
linux-amlogic, jbrunet
On Fri, 10 May 2019 10:23:21 +0200, Guillaume La Roque wrote:
> Add optional drive-strength-microamp property
>
> Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
> ---
> Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt | 4 ++++
> 1 file changed, 4 insertions(+)
>
Reviewed-by: Rob Herring <robh@kernel.org>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v5 4/6] pinctrl: meson: Rework enable/disable bias part
2019-05-10 8:23 [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver Guillaume La Roque
` (2 preceding siblings ...)
2019-05-10 8:23 ` [PATCH v5 3/6] dt-bindings: pinctrl: meson: Add drive-strength-microamp property Guillaume La Roque
@ 2019-05-10 8:23 ` Guillaume La Roque
2019-05-11 16:29 ` Martin Blumenstingl
2019-05-10 8:23 ` [PATCH v5 5/6] pinctrl: meson: add support of drive-strength-microamp Guillaume La Roque
` (2 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Guillaume La Roque @ 2019-05-10 8:23 UTC (permalink / raw)
To: linus.walleij, khilman
Cc: linux-gpio, devicetree, linux-amlogic, linux-kernel, jbrunet
rework bias enable/disable part to prepare drive-strength integration
no functional changes
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
---
drivers/pinctrl/meson/pinctrl-meson.c | 85 +++++++++++++++------------
1 file changed, 49 insertions(+), 36 deletions(-)
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 96a4a72708e4..8ea5c1527064 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -174,62 +174,75 @@ int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector,
return 0;
}
-static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
- unsigned long *configs, unsigned num_configs)
+static int meson_pinconf_disable_bias(struct meson_pinctrl *pc,
+ unsigned int pin)
{
- 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;
+ 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);
+ enum pin_config_param param;
+ int i, ret;
+
for (i = 0; i < num_configs; i++) {
param = pinconf_to_config_param(configs[i]);
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, true);
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, false);
if (ret)
return ret;
break;
--
2.17.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v5 5/6] pinctrl: meson: add support of drive-strength-microamp
2019-05-10 8:23 [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver Guillaume La Roque
` (3 preceding siblings ...)
2019-05-10 8:23 ` [PATCH v5 4/6] pinctrl: meson: Rework enable/disable bias part Guillaume La Roque
@ 2019-05-10 8:23 ` Guillaume La Roque
2019-05-11 16:46 ` Martin Blumenstingl
2019-05-10 8:23 ` [PATCH v5 6/6] pinctrl: meson: g12a: add DS bank value Guillaume La Roque
2019-05-10 8:52 ` [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver Jerome Brunet
6 siblings, 1 reply; 15+ messages in thread
From: Guillaume La Roque @ 2019-05-10 8:23 UTC (permalink / raw)
To: linus.walleij, khilman
Cc: linux-gpio, devicetree, linux-amlogic, linux-kernel, jbrunet
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.c | 99 +++++++++++++++++++++++++++
drivers/pinctrl/meson/pinctrl-meson.h | 18 ++++-
2 files changed, 116 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 8ea5c1527064..33b4b141baac 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -220,11 +220,54 @@ 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, 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);
enum pin_config_param param;
+ unsigned int drive_strength_ua;
int i, ret;
for (i = 0; i < num_configs; i++) {
@@ -246,6 +289,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;
}
@@ -288,12 +339,55 @@ 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)
+ 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:
@@ -304,6 +398,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;
}
diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h
index 5eaab925f427..cd955fb7c2ce 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.h
+++ b/drivers/pinctrl/meson/pinctrl-meson.h
@@ -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 */
--
2.17.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v5 5/6] pinctrl: meson: add support of drive-strength-microamp
2019-05-10 8:23 ` [PATCH v5 5/6] pinctrl: meson: add support of drive-strength-microamp Guillaume La Roque
@ 2019-05-11 16:46 ` Martin Blumenstingl
0 siblings, 0 replies; 15+ messages in thread
From: Martin Blumenstingl @ 2019-05-11 16:46 UTC (permalink / raw)
To: Guillaume La Roque
Cc: devicetree, khilman, linus.walleij, linux-kernel, linux-gpio,
linux-amlogic, jbrunet
Hi Guillaume,
On Fri, May 10, 2019 at 10:23 AM Guillaume La Roque
<glaroque@baylibre.com> 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@baylibre.com>
Reviewed-by: Martin Blumenstingl<martin.blumenstingl@googlemail.com>
the warning messages when printing pinconf-pins (in debugfs) are gone
on my Meson8m2 board so:
Tested-by: Martin Blumenstingl<martin.blumenstingl@googlemail.com>
[...]
> +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
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v5 6/6] pinctrl: meson: g12a: add DS bank value
2019-05-10 8:23 [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver Guillaume La Roque
` (4 preceding siblings ...)
2019-05-10 8:23 ` [PATCH v5 5/6] pinctrl: meson: add support of drive-strength-microamp Guillaume La Roque
@ 2019-05-10 8:23 ` Guillaume La Roque
2019-05-11 16:30 ` Martin Blumenstingl
2019-05-10 8:52 ` [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver Jerome Brunet
6 siblings, 1 reply; 15+ messages in thread
From: Guillaume La Roque @ 2019-05-10 8:23 UTC (permalink / raw)
To: linus.walleij, khilman
Cc: linux-gpio, devicetree, linux-amlogic, linux-kernel, jbrunet
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 | 36 +++++++++++-----------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/pinctrl/meson/pinctrl-meson-g12a.c b/drivers/pinctrl/meson/pinctrl-meson-g12a.c
index d494492e98e9..3475cd7bd2af 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-g12a.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-g12a.c
@@ -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[] = {
--
2.17.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver
2019-05-10 8:23 [PATCH v5 0/6] Add drive-strength in Meson pinctrl driver Guillaume La Roque
` (5 preceding siblings ...)
2019-05-10 8:23 ` [PATCH v5 6/6] pinctrl: meson: g12a: add DS bank value Guillaume La Roque
@ 2019-05-10 8:52 ` Jerome Brunet
6 siblings, 0 replies; 15+ messages in thread
From: Jerome Brunet @ 2019-05-10 8:52 UTC (permalink / raw)
To: Guillaume La Roque, linus.walleij, khilman
Cc: linux-gpio, linux-amlogic, linux-kernel, devicetree
On Fri, 2019-05-10 at 10:23 +0200, Guillaume La Roque wrote:
> 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-microamp". The change to do so
> would be minimal and could be benefit to other platforms later on.
>
> Cheers
> Guillaume
Guillaume,
Several tags, such as Acked-by, Reviewed-by or Tested-by have been given on this
series.
Please remember to collect and add them to the commit description when posting newer
revision of a series
If you didn't already, please have a look at Documentation/process/submitting-patches.rst
Thanks
>
> Changes since v4:
> - fix dt-binding documentation
> - rename drive-strength-uA to drive-strength-microamp in coverletter
>
> Changes since v3:
> - remove dev_err in meson_get_drive_strength
> - cleanup code
>
> Changes since v2:
> - rename driver-strength-uA property to drive-strength-microamp
> - 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/20190314163725.7918-1-jbrunet@baylibre.com
>
> 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 | 180 ++++++++++++++----
> drivers/pinctrl/meson/pinctrl-meson.h | 18 +-
> drivers/pinctrl/pinconf-generic.c | 2 +
> include/linux/pinctrl/pinconf-generic.h | 3 +
> 7 files changed, 193 insertions(+), 53 deletions(-)
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 15+ messages in thread