All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: ADAU7118: add bindings for managing pins drive strength
@ 2022-05-11 20:34 Dylan Laduranty
  2022-05-12  7:21 ` Sa, Nuno
  0 siblings, 1 reply; 2+ messages in thread
From: Dylan Laduranty @ 2022-05-11 20:34 UTC (permalink / raw)
  To: alsa-devel; +Cc: Dylan Laduranty, nuno.sa

This allows users to change SDATA and both PDM clocks pins drive strength during device probing according to their need.

Update yaml documentation accordingly.

Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
---
 .../bindings/sound/adi,adau7118.yaml          | 24 +++++++
 sound/soc/codecs/adau7118.c                   | 62 +++++++++++++++++--
 2 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/adi,adau7118.yaml b/Documentation/devicetree/bindings/sound/adi,adau7118.yaml
index fb78967ee17b..71e8a9ff2edf 100644
--- a/Documentation/devicetree/bindings/sound/adi,adau7118.yaml
+++ b/Documentation/devicetree/bindings/sound/adi,adau7118.yaml
@@ -51,6 +51,27 @@ properties:
       maximum: 1
     default: [0, 0, 1, 1]
 
+  adi,pdm-clk0-ds:
+    description: |
+      This property set the drive strength of PDM CLK0 output pad.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [3, 2, 1, 0]
+    default: 2
+
+  adi,pdm-clk1-ds:
+    description: |
+      This property set the drive strength of PDM CLK1 output pad.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [3, 2, 1, 0]
+    default: 2
+
+  adi,sdata-ds:
+    description: |
+      This property set the drive strength of SDATA output pad.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [3, 2, 1, 0]
+    default: 2
+
 required:
   - "#sound-dai-cells"
   - compatible
@@ -73,6 +94,9 @@ examples:
                 dvdd-supply = <&supply>;
                 adi,pdm-clk-map = <1 1 0 0>;
                 adi,decimation-ratio = <16>;
+                adi,pdm-clk0-ds = <3>;
+                adi,pdm-clk1-ds = <3>;
+                adi,sdata-ds = <3>;
         };
     };
 
diff --git a/sound/soc/codecs/adau7118.c b/sound/soc/codecs/adau7118.c
index 841229dcbca1..18c1f246f911 100644
--- a/sound/soc/codecs/adau7118.c
+++ b/sound/soc/codecs/adau7118.c
@@ -29,6 +29,12 @@
 				FIELD_PREP(ADAU7118_LRCLK_BCLK_POL_MASK, x)
 #define ADAU7118_SPT_SLOT_MASK		GENMASK(7, 4)
 #define ADAU7118_SPT_SLOT(x)		FIELD_PREP(ADAU7118_SPT_SLOT_MASK, x)
+#define ADAU7118_DS_PDM_CLK0_MASK	GENMASK(1, 0)
+#define ADAU7118_DS_PDM_CLK0(x)		FIELD_PREP(ADAU7118_DS_PDM_CLK0_MASK, x)
+#define ADAU7118_DS_PDM_CLK1_MASK	GENMASK(3, 2)
+#define ADAU7118_DS_PDM_CLK1(x)		FIELD_PREP(ADAU7118_DS_PDM_CLK1_MASK, x)
+#define ADAU7118_DS_SDATA_MASK		GENMASK(5, 4)
+#define ADAU7118_DS_SDATA(x)		FIELD_PREP(ADAU7118_DS_SDATA_MASK, x)
 #define ADAU7118_FULL_SOFT_R_MASK	BIT(1)
 #define ADAU7118_FULL_SOFT_R(x)		FIELD_PREP(ADAU7118_FULL_SOFT_R_MASK, x)
 
@@ -489,7 +495,7 @@ static int adau7118_regulator_setup(struct adau7118_data *st)
 static int adau7118_parset_dt(const struct adau7118_data *st)
 {
 	int ret;
-	u32 dec_ratio = 0;
+	u32 val32 = 0;
 	/* 4 inputs */
 	u32 clk_map[4], regval;
 
@@ -497,9 +503,9 @@ static int adau7118_parset_dt(const struct adau7118_data *st)
 		return 0;
 
 	ret = device_property_read_u32(st->dev, "adi,decimation-ratio",
-				       &dec_ratio);
+				       &val32);
 	if (!ret) {
-		switch (dec_ratio) {
+		switch (val32) {
 		case 64:
 			regval = ADAU7118_DEC_RATIO(0);
 			break;
@@ -510,7 +516,7 @@ static int adau7118_parset_dt(const struct adau7118_data *st)
 			regval = ADAU7118_DEC_RATIO(2);
 			break;
 		default:
-			dev_err(st->dev, "Invalid dec ratio: %u", dec_ratio);
+			dev_err(st->dev, "Invalid dec ratio: %u", val32);
 			return -EINVAL;
 		}
 
@@ -537,6 +543,54 @@ static int adau7118_parset_dt(const struct adau7118_data *st)
 			return ret;
 	}
 
+	ret = device_property_read_u32(st->dev, "adi,pdm-clk0-ds",
+					&val32);
+	if (!ret) {
+		if (val32 > 3) {
+			dev_err(st->dev, "Invalid pdm-clk0-ds: %u", val32);
+			return -EINVAL;
+		}
+
+		ret = regmap_update_bits(st->map,
+					ADAU7118_REG_DRIVE_STRENGTH,
+					ADAU7118_DS_PDM_CLK0_MASK,
+					ADAU7118_DS_PDM_CLK0(val32));
+		if (ret)
+			return ret;
+	}
+
+	ret = device_property_read_u32(st->dev, "adi,pdm-clk1-ds",
+					&val32);
+	if (!ret) {
+		if (val32 > 3) {
+			dev_err(st->dev, "Invalid pdm-clk1-ds: %u", val32);
+			return -EINVAL;
+		}
+
+		ret = regmap_update_bits(st->map,
+					ADAU7118_REG_DRIVE_STRENGTH,
+					ADAU7118_DS_PDM_CLK1_MASK,
+					ADAU7118_DS_PDM_CLK1(val32));
+		if (ret)
+			return ret;
+	}
+
+	ret = device_property_read_u32(st->dev, "adi,sdata-ds",
+					&val32);
+	if (!ret) {
+		if (val32 > 3) {
+			dev_err(st->dev, "Invalid sdata-ds: %u", val32);
+			return -EINVAL;
+		}
+
+		ret = regmap_update_bits(st->map,
+					ADAU7118_REG_DRIVE_STRENGTH,
+					ADAU7118_DS_SDATA_MASK,
+					ADAU7118_DS_SDATA(val32));
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] ASoC: ADAU7118: add bindings for managing pins drive strength
  2022-05-11 20:34 [PATCH] ASoC: ADAU7118: add bindings for managing pins drive strength Dylan Laduranty
@ 2022-05-12  7:21 ` Sa, Nuno
  0 siblings, 0 replies; 2+ messages in thread
From: Sa, Nuno @ 2022-05-12  7:21 UTC (permalink / raw)
  To: Dylan Laduranty, alsa-devel

Hi Dylan,

Thanks for your patch. It looks good to me. I just have a small
remark in the bindings. Also, I don't think that both bindinds and
driver code should be on the same patch. You separate this
into 2 patches...

> From: Dylan Laduranty <dylan.laduranty@mesotic.com>
> Sent: Wednesday, May 11, 2022 10:34 PM
> To: alsa-devel@alsa-project.org
> Cc: Sa, Nuno <Nuno.Sa@analog.com>; Dylan Laduranty
> <dylan.laduranty@mesotic.com>
> Subject: [PATCH] ASoC: ADAU7118: add bindings for managing pins
> drive strength
> 
> 
> This allows users to change SDATA and both PDM clocks pins drive
> strength during device probing according to their need.
> 
> Update yaml documentation accordingly.
> 
> Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
> ---
>  .../bindings/sound/adi,adau7118.yaml          | 24 +++++++
>  sound/soc/codecs/adau7118.c                   | 62 +++++++++++++++++--
>  2 files changed, 82 insertions(+), 4 deletions(-)
> 
> diff --git
> a/Documentation/devicetree/bindings/sound/adi,adau7118.yaml
> b/Documentation/devicetree/bindings/sound/adi,adau7118.yaml
> index fb78967ee17b..71e8a9ff2edf 100644
> --- a/Documentation/devicetree/bindings/sound/adi,adau7118.yaml
> +++ b/Documentation/devicetree/bindings/sound/adi,adau7118.yaml
> @@ -51,6 +51,27 @@ properties:
>        maximum: 1
>      default: [0, 0, 1, 1]
> 
> +  adi,pdm-clk0-ds:
> +    description: |
> +      This property set the drive strength of PDM CLK0 output pad.
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [3, 2, 1, 0]
> +    default: 2
> +
> +  adi,pdm-clk1-ds:
> +    description: |
> +      This property set the drive strength of PDM CLK1 output pad.
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [3, 2, 1, 0]
> +    default: 2
> +
> +  adi,sdata-ds:
> +    description: |
> +      This property set the drive strength of SDATA output pad.
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [3, 2, 1, 0]
> +    default: 2

It would be nice to state here what's the meaning of 3,2,1,0...

- Nuno Sá

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-12  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 20:34 [PATCH] ASoC: ADAU7118: add bindings for managing pins drive strength Dylan Laduranty
2022-05-12  7:21 ` Sa, Nuno

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.