Skip to contentSkip to conversation

TAS2562 issue fixes and slot programming

PATCH Superseded Dan Murphy 2 participants 13 messages Jun 24, 2020

Subsystems (5)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

v5 cover TAS2562 issue fixes and slot programming

Hello

This series fixes issues tih the shut-down gpio device tree allocation and a code format issue found.

While working on a project slot programming for the tx and rx paths needed to be enabled. In addition the vsense slot programming needed to be configurable and not directly a simpler adder to the isense slot.

Finally the yaml conversion patch was moved to be the last patch in the series so that the fixes can be applied and the yaml can be reviewed appropriately and does not hold up the rest of the fixes.

Dan

Dan Murphy (7):
dt-bindings: tas2562: Fix shut-down gpio property
ASoC: tas2562: Update shutdown GPIO property
ASoC: tas2562: Fix format issue for extra space before a comma
ASoC: tas2562: Add rx and tx slot programming
dt-bindings: tas2562: Add voltage sense slot property
ASoC: tas2562: Add voltage sense slot configuration
dt-bindings: tas2562: Convert the tas2562 binding to yaml

 .../devicetree/bindings/sound/tas2562.txt     |   34 -
 .../devicetree/bindings/sound/tas2562.yaml    |   77 +
 arch/arm/boot/compressed/fdt.h                |   66 +
 arch/arm/boot/compressed/libfdt.h             | 2072 +++++++++++++++++
 arch/arm/boot/compressed/libfdt_internal.h    |  173 ++
 sound/soc/codecs/tas2562.c                    |   88 +-
 sound/soc/codecs/tas2562.h                    |    4 +
 7 files changed, 2462 insertions(+), 52 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/sound/tas2562.txt
 create mode 100644 Documentation/devicetree/bindings/sound/tas2562.yaml
 create mode 100644 arch/arm/boot/compressed/fdt.h
 create mode 100644 arch/arm/boot/compressed/libfdt.h
 create mode 100644 arch/arm/boot/compressed/libfdt_internal.h
Signature · 1 line
2.26.2
author
#1 lore raw

PATCH v5 1/7 dt-bindings: tas2562: Fix shut-down gpio property

Fix the shut-down gpio property to be shut-down-gpio and fix the example.

---
 Documentation/devicetree/bindings/sound/tas2562.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/sound/tas2562.txt +2 -2
index 94796b547184..fd0ac8636c01 100644
@@ -16,7 +16,7 @@ Optional properties:
 - interrupt-parent: phandle to the interrupt controller which provides
                     the interrupt.
 - interrupts: (GPIO) interrupt to which the chip is connected.
-- shut-down: GPIO used to control the state of the device.
+- shut-down-gpio: GPIO used to control the state of the device.
 
 Examples:
 tas2562@4c {
@@ -28,7 +28,7 @@ tas2562@4c {
         interrupt-parent = <&gpio1>;
         interrupts = <14>;
 
-	shut-down = <&gpio1 15 0>;
+	shut-down-gpio = <&gpio1 15 0>;
         ti,imon-slot-no = <0>;
 };
 
Signature · 1 line
2.26.2
author
#2 lore raw

PATCH v5 2/7 ASoC: tas2562: Update shutdown GPIO property

In reply to Dan Murphy

Update the shutdown GPIO property to be shutdown from shut-down.

Fixes c173dba44c2d2 ("ASoC: tas2562: Introduce the TAS2562 amplifier")
---
 sound/soc/codecs/tas2562.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/tas2562.c +2 -2
index 7fae88655a0f..f6495426f562 100644
@@ -619,8 +619,8 @@ static int tas2562_parse_dt(struct tas2562_data *tas2562)
 	struct device *dev = tas2562->dev;
 	int ret = 0;
 
-	tas2562->sdz_gpio = devm_gpiod_get_optional(dev, "shut-down-gpio",
-						      GPIOD_OUT_HIGH);
+	tas2562->sdz_gpio = devm_gpiod_get_optional(dev, "shut-down",
+						    GPIOD_OUT_HIGH);
 	if (IS_ERR(tas2562->sdz_gpio)) {
 		if (PTR_ERR(tas2562->sdz_gpio) == -EPROBE_DEFER) {
 			tas2562->sdz_gpio = NULL;
Signature · 1 line
2.26.2
author
#10 lore raw

PATCH v5 5/7 dt-bindings: tas2562: Add voltage sense slot property

In reply to Dan Murphy

Add a property to configure the slot for the voltage sense monitoring of the device. Vsense data will be sent to the processor via the slot defined by the property

---
 Documentation/devicetree/bindings/sound/tas2562.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/sound/tas2562.txt +3 -0
index fd0ac8636c01..dc6d7362ded7 100644
@@ -11,6 +11,8 @@ Required properties:
  - compatible:	   - Should contain "ti,tas2562", "ti,tas2563".
  - reg:		   - The i2c address. Should be 0x4c, 0x4d, 0x4e or 0x4f.
  - ti,imon-slot-no:- TDM TX current sense time slot.
+ - ti,vmon-slot-no:- TDM TX voltage sense time slot. This slot must always be
+		     greater then ti,imon-slot-no.
 
 Optional properties:
 - interrupt-parent: phandle to the interrupt controller which provides
@@ -30,5 +32,6 @@ tas2562@4c {
 
 	shut-down-gpio = <&gpio1 15 0>;
         ti,imon-slot-no = <0>;
+        ti,vmon-slot-no = <1>;
 };
 
Signature · 1 line
2.26.2
author
#3 lore raw

PATCH v5 3/7 ASoC: tas2562: Fix format issue for extra space before a comma

In reply to Dan Murphy

Fix the issue found that there is an extra space before a comma in the volume control.

Fixes bf726b1c86f2c ("ASoC: tas2562: Add support for digital volume control")
---
 arch/arm/boot/compressed/fdt.h             |   66 +
 arch/arm/boot/compressed/libfdt.h          | 2072 ++++++++++++++++++++
 arch/arm/boot/compressed/libfdt_internal.h |  173 ++
 sound/soc/codecs/tas2562.c                 |    2 +-
 4 files changed, 2312 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/compressed/fdt.h
 create mode 100644 arch/arm/boot/compressed/libfdt.h
 create mode 100644 arch/arm/boot/compressed/libfdt_internal.h
arch/arm/boot/compressed/fdt.h new file +66 -0
new file mode 100644
index 000000000000..f2e68807f277
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
+#ifndef FDT_H
+#define FDT_H
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ * Copyright 2012 Kim Phillips, Freescale Semiconductor.
+ */
+
+#ifndef __ASSEMBLY__
+
+struct fdt_header {
+	fdt32_t magic;			 /* magic word FDT_MAGIC */
+	fdt32_t totalsize;		 /* total size of DT block */
+	fdt32_t off_dt_struct;		 /* offset to structure */
+	fdt32_t off_dt_strings;		 /* offset to strings */
+	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
+	fdt32_t version;		 /* format version */
+	fdt32_t last_comp_version;	 /* last compatible version */
+
+	/* version 2 fields below */
+	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+					    booting on */
+	/* version 3 fields below */
+	fdt32_t size_dt_strings;	 /* size of the strings block */
+
+	/* version 17 fields below */
+	fdt32_t size_dt_struct;		 /* size of the structure block */
+};
+
+struct fdt_reserve_entry {
+	fdt64_t address;
+	fdt64_t size;
+};
+
+struct fdt_node_header {
+	fdt32_t tag;
+	char name[0];
+};
+
+struct fdt_property {
+	fdt32_t tag;
+	fdt32_t len;
+	fdt32_t nameoff;
+	char data[0];
+};
+
+#endif /* !__ASSEMBLY */
+
+#define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
+#define FDT_TAGSIZE	sizeof(fdt32_t)
+
+#define FDT_BEGIN_NODE	0x1		/* Start node: full name */
+#define FDT_END_NODE	0x2		/* End node */
+#define FDT_PROP	0x3		/* Property: name off,
+					   size, content */
+#define FDT_NOP		0x4		/* nop */
+#define FDT_END		0x9
+
+#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
+#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
+#define FDT_V16_SIZE	FDT_V3_SIZE
+#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
+
+#endif /* FDT_H */
arch/arm/boot/compressed/libfdt.h new file +2072 -0

2,072 lines not on this page · raw message

arch/arm/boot/compressed/libfdt_internal.h new file +173 -0

173 lines not on this page · raw message

sound/soc/codecs/tas2562.c +1 -1
index f6495426f562..d26e30a2948c 100644
@@ -504,7 +504,7 @@ static const struct snd_kcontrol_new tas2562_snd_controls[] = {
 		.info = snd_soc_info_volsw,
 		.get = tas2562_volume_control_get,
 		.put = tas2562_volume_control_put,
-		.private_value = SOC_SINGLE_VALUE(TAS2562_DVC_CFG1, 0, 110, 0, 0) ,
+		.private_value = SOC_SINGLE_VALUE(TAS2562_DVC_CFG1, 0, 110, 0, 0),
 	},
 };
 
Signature · 1 line
2.26.2
author
#12 lore raw

PATCH v5 7/7 dt-bindings: tas2562: Convert the tas2562 binding to yaml

In reply to Dan Murphy

Convert the TAS2562 text file to yaml format.

---
 .../devicetree/bindings/sound/tas2562.txt     | 37 ---------
 .../devicetree/bindings/sound/tas2562.yaml    | 77 +++++++++++++++++++
 2 files changed, 77 insertions(+), 37 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/sound/tas2562.txt
 create mode 100644 Documentation/devicetree/bindings/sound/tas2562.yaml
Documentation/devicetree/bindings/sound/tas2562.txt deleted +0 -37
deleted file mode 100644
index dc6d7362ded7..000000000000
@@ -1,37 +0,0 @@
-Texas Instruments TAS2562 Smart PA
-
-The TAS2562 is a mono, digital input Class-D audio amplifier optimized for
-efficiently driving high peak power into small loudspeakers.
-Integrated speaker voltage and current sense provides for
-real time monitoring of loudspeaker behavior.
-
-Required properties:
- - #address-cells  - Should be <1>.
- - #size-cells     - Should be <0>.
- - compatible:	   - Should contain "ti,tas2562", "ti,tas2563".
- - reg:		   - The i2c address. Should be 0x4c, 0x4d, 0x4e or 0x4f.
- - ti,imon-slot-no:- TDM TX current sense time slot.
- - ti,vmon-slot-no:- TDM TX voltage sense time slot. This slot must always be
-		     greater then ti,imon-slot-no.
-
-Optional properties:
-- interrupt-parent: phandle to the interrupt controller which provides
-                    the interrupt.
-- interrupts: (GPIO) interrupt to which the chip is connected.
-- shut-down-gpio: GPIO used to control the state of the device.
-
-Examples:
-tas2562@4c {
-        #address-cells = <1>;
-        #size-cells = <0>;
-        compatible = "ti,tas2562";
-        reg = <0x4c>;
-
-        interrupt-parent = <&gpio1>;
-        interrupts = <14>;
-
-	shut-down-gpio = <&gpio1 15 0>;
-        ti,imon-slot-no = <0>;
-        ti,vmon-slot-no = <1>;
-};
-
Documentation/devicetree/bindings/sound/tas2562.yaml new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.26.2
author
#11 lore raw

PATCH v5 6/7 ASoC: tas2562: Add voltage sense slot configuration

In reply to Dan Murphy

Add Vsense slot configuration based on the device tree. Adding this property enables the slot programming to be moved to the tdm_set_slot callback. This in affect sets the slots for the Isense and Vsense and enabling this these modes are now based on whether these features were powered on or not.

---
 sound/soc/codecs/tas2562.c | 65 ++++++++++++++++++++++++++++++--------
 1 file changed, 51 insertions(+), 14 deletions(-)
sound/soc/codecs/tas2562.c +51 -14
index 2f1d4b697f01..b0b7cef79433 100644
@@ -224,12 +224,26 @@ static int tas2562_set_dai_tdm_slot(struct snd_soc_dai *dai,
 	if (ret < 0)
 		return ret;
 
+	ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG5,
+					    TAS2562_TDM_CFG5_VSNS_SLOT_MASK,
+					    tas2562->v_sense_slot);
+	if (ret < 0)
+		return ret;
+
+	ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG6,
+					    TAS2562_TDM_CFG6_ISNS_SLOT_MASK,
+					    tas2562->i_sense_slot);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
 
 static int tas2562_set_bitwidth(struct tas2562_data *tas2562, int bitwidth)
 {
 	int ret;
+	int val;
+	int sense_en;
 
 	switch (bitwidth) {
 	case SNDRV_PCM_FORMAT_S16_LE:
@@ -237,21 +251,18 @@ static int tas2562_set_bitwidth(struct tas2562_data *tas2562, int bitwidth)
 					      TAS2562_TDM_CFG2,
 					      TAS2562_TDM_CFG2_RXWLEN_MASK,
 					      TAS2562_TDM_CFG2_RXWLEN_16B);
-		tas2562->v_sense_slot = tas2562->i_sense_slot + 2;
 		break;
 	case SNDRV_PCM_FORMAT_S24_LE:
 		snd_soc_component_update_bits(tas2562->component,
 					      TAS2562_TDM_CFG2,
 					      TAS2562_TDM_CFG2_RXWLEN_MASK,
 					      TAS2562_TDM_CFG2_RXWLEN_24B);
-		tas2562->v_sense_slot = tas2562->i_sense_slot + 4;
 		break;
 	case SNDRV_PCM_FORMAT_S32_LE:
 		snd_soc_component_update_bits(tas2562->component,
 					      TAS2562_TDM_CFG2,
 					      TAS2562_TDM_CFG2_RXWLEN_MASK,
 					      TAS2562_TDM_CFG2_RXWLEN_32B);
-		tas2562->v_sense_slot = tas2562->i_sense_slot + 4;
 		break;
 
 	default:
@@ -259,17 +270,27 @@ static int tas2562_set_bitwidth(struct tas2562_data *tas2562, int bitwidth)
 		return -EINVAL;
 	}
 
-	ret = snd_soc_component_update_bits(tas2562->component,
-		TAS2562_TDM_CFG5,
-		TAS2562_TDM_CFG5_VSNS_EN | TAS2562_TDM_CFG5_VSNS_SLOT_MASK,
-		TAS2562_TDM_CFG5_VSNS_EN | tas2562->v_sense_slot);
+	val = snd_soc_component_read(tas2562->component, TAS2562_PWR_CTRL);
+	if (val < 0)
+		return val;
+
+	if (val & (1 << TAS2562_VSENSE_POWER_EN))
+		sense_en = 0;
+	else
+		sense_en = TAS2562_TDM_CFG5_VSNS_EN;
+
+	ret = snd_soc_component_update_bits(tas2562->component, TAS2562_TDM_CFG5,
+		TAS2562_TDM_CFG5_VSNS_EN, sense_en);
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_component_update_bits(tas2562->component,
-		TAS2562_TDM_CFG6,
-		TAS2562_TDM_CFG6_ISNS_EN | TAS2562_TDM_CFG6_ISNS_SLOT_MASK,
-		TAS2562_TDM_CFG6_ISNS_EN | tas2562->i_sense_slot);
+	if (val & (1 << TAS2562_ISENSE_POWER_EN))
+		sense_en = 0;
+	else
+		sense_en = TAS2562_TDM_CFG6_ISNS_EN;
+
+	ret = snd_soc_component_update_bits(tas2562->component, TAS2562_TDM_CFG6,
+		TAS2562_TDM_CFG6_ISNS_EN, sense_en);
 	if (ret < 0)
 		return ret;
 
@@ -645,9 +666,25 @@ static int tas2562_parse_dt(struct tas2562_data *tas2562)
 
 	ret = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no",
 			&tas2562->i_sense_slot);
-	if (ret)
-		dev_err(dev, "Looking up %s property failed %d\n",
-			"ti,imon-slot-no", ret);
+	if (ret) {
+		dev_err(dev, "Property %s is missing setting default slot\n",
+			"ti,imon-slot-no");
+		tas2562->i_sense_slot = 0;
+	}
+
+
+	ret = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no",
+			&tas2562->v_sense_slot);
+	if (ret) {
+		dev_info(dev, "Property %s is missing setting default slot\n",
+			"ti,vmon-slot-no");
+		tas2562->v_sense_slot = 2;
+	}
+
+	if (tas2562->v_sense_slot < tas2562->i_sense_slot) {
+		dev_err(dev, "Vsense slot must be greater than Isense slot\n");
+		return -EINVAL;
+	}
 
 	return ret;
 }
Signature · 1 line
2.26.2
author
#9 lore raw

PATCH v5 4/7 ASoC: tas2562: Add rx and tx slot programming

In reply to Dan Murphy

Add programming for the tdm slots for both tx and rx offsets.

---
 sound/soc/codecs/tas2562.c | 17 ++++++++++++++++-
 sound/soc/codecs/tas2562.h |  4 ++++
 2 files changed, 20 insertions(+), 1 deletion(-)
sound/soc/codecs/tas2562.c +16 -1
index d26e30a2948c..2f1d4b697f01 100644
@@ -208,6 +208,22 @@ static int tas2562_set_dai_tdm_slot(struct snd_soc_dai *dai,
 	if (ret < 0)
 		return ret;
 
+	if (tx_mask > TAS2562_TX_OFF_MAX) {
+		dev_err(tas2562->dev, "TX slot is larger then %d",
+			TAS2562_TX_OFF_MAX);
+		return -EINVAL;
+	}
+
+	ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG1,
+					    TAS2562_RX_OFF_MASK, rx_mask << 1);
+	if (ret < 0)
+		return ret;
+
+	ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG4,
+					    TAS2562_TX_OFF_MASK, tx_mask << 1);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
 
@@ -327,7 +343,6 @@ static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 	ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG1,
 					    TAS2562_TDM_CFG1_RX_OFFSET_MASK,
 					    tdm_rx_start_slot);
-
 	if (ret < 0)
 		return ret;
 
sound/soc/codecs/tas2562.h +4 -0
index 28e75fc431d0..47e59c82eef3 100644
@@ -34,6 +34,10 @@
 #define TAS2562_TDM_DET		TAS2562_REG(0, 0x11)
 #define TAS2562_REV_ID		TAS2562_REG(0, 0x7d)
 
+#define TAS2562_RX_OFF_MASK	GENMASK(5, 1)
+#define TAS2562_TX_OFF_MASK	GENMASK(3, 1)
+#define TAS2562_TX_OFF_MAX	7
+
 /* Page 2 */
 #define TAS2562_DVC_CFG1	TAS2562_REG(2, 0x0c)
 #define TAS2562_DVC_CFG2	TAS2562_REG(2, 0x0d)
Signature · 1 line
2.26.2
maintainer
#4 lore raw

Re: [PATCH v5 3/7] ASoC: tas2562: Fix format issue for extra space before a comma

In reply to Dan Murphy
Quoted 10 lines · Dan Murphy

Fix the issue found that there is an extra space before a comma in the volume control.

Fixes bf726b1c86f2c ("ASoC: tas2562: Add support for digital volume control")
---
 arch/arm/boot/compressed/fdt.h             |   66 +
 arch/arm/boot/compressed/libfdt.h          | 2072 ++++++++++++++++++++
 arch/arm/boot/compressed/libfdt_internal.h |  173 ++
 sound/soc/codecs/tas2562.c                 |    2 +-

I'm guessing those libfdt changes weren't supposed to be here?

author
#5 lore raw

Re: [PATCH v5 3/7] ASoC: tas2562: Fix format issue for extra space before a comma

Mark

Quoted 4 lines · Mark Brown
Quoted 3 lines · Dan Murphy

Fix the issue found that there is an extra space before a comma in the volume control.

Quoted 8 lines
Quoted 7 lines
Fixes bf726b1c86f2c ("ASoC: tas2562: Add support for digital volume control")
---
  arch/arm/boot/compressed/fdt.h             |   66 +
  arch/arm/boot/compressed/libfdt.h          | 2072 ++++++++++++++++++++
  arch/arm/boot/compressed/libfdt_internal.h |  173 ++
  sound/soc/codecs/tas2562.c                 |    2 +-

I'm guessing those libfdt changes weren't supposed to be here?

No they were not those must have been added when I verified the build.

Dan

author
#6 lore raw

Re: [PATCH v5 3/7] ASoC: tas2562: Fix format issue for extra space before a comma

Mark

Quoted 15 lines · Dan Murphy

Mark

Quoted 12 lines · Mark Brown
Quoted 11 lines · Dan Murphy

Fix the issue found that there is an extra space before a comma in the volume control.

Fixes bf726b1c86f2c ("ASoC: tas2562: Add support for digital volume control")

---
  arch/arm/boot/compressed/fdt.h             |   66 + arch/arm/boot/compressed/libfdt.h          | 2072
++++++++++++++++++++
  arch/arm/boot/compressed/libfdt_internal.h |  173 ++ sound/soc/codecs/tas2562.c                 |    2 +-

Quoted 4 lines
Quoted 1 line

I'm guessing those libfdt changes weren't supposed to be here?

No they were not those must have been added when I verified the build.

Can this patchset get a review as well so I can fix before I post v6?

Not sure what the current work load is for review or merge.

Dan

Quoted 2 lines

Dan

maintainer
#7 lore raw

Re: [PATCH v5 3/7] ASoC: tas2562: Fix format issue for extra space before a comma

Quoted 3 lines · Dan Murphy

Can this patchset get a review as well so I can fix before I post v6?

Not sure what the current work load is for review or merge.

Well, it's less work to review if it's been fixed...

author
#8 lore raw

Re: [PATCH v5 3/7] ASoC: tas2562: Fix format issue for extra space before a comma

Mark

Quoted 5 lines · Mark Brown
Quoted 2 lines · Dan Murphy

Can this patchset get a review as well so I can fix before I post v6? Not sure what the current work load is for review or merge.

Well, it's less work to review if it's been fixed...

Ok fixed and sent v6