Skip to contentSkip to conversation

soundwire: qcom: add support for mmio soundwire master

PATCH Applied Jonathan Marek 4 participants 10 messages Sep 5, 2020 – Sep 8, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover soundwire: qcom: add support for mmio soundwire master

This adds initial support for soundwire device on sm8250.

Tested with the "wsa" sdw device, which is simpler than the others.

v2 addresses some feedback, but I kept this series as simple as possible. In particular, I didn't implement CMD_NACKED from FIFO_STATUS, because the downstream driver doesn't define this bit, so I can't implement it. Soundwire works without it and It shouldn't be difficult to implement later.

Jonathan Marek (4):
soundwire: qcom: fix abh/ahb typo
soundwire: qcom: avoid dependency on CONFIG_SLIMBUS
soundwire: qcom: add support for mmio soundwire master devices
soundwire: qcom: add v1.5.1 compatible

 .../bindings/soundwire/qcom,sdw.txt           |  1 +
 drivers/soundwire/Kconfig                     |  2 +-
 drivers/soundwire/qcom.c                      | 38 +++++++++++++++++--
 3 files changed, 36 insertions(+), 5 deletions(-)
Signature · 1 line
2.26.1
#1 lore raw

PATCH v2 1/4 soundwire: qcom: fix abh/ahb typo

The function name qcom_swrm_abh_reg_read should say ahb, fix that.

---
 drivers/soundwire/qcom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soundwire/qcom.c +2 -2
index 915c2cf0c274..d1e33ef1afac 100644
@@ -114,7 +114,7 @@ struct qcom_swrm_ctrl {
 
 #define to_qcom_sdw(b)	container_of(b, struct qcom_swrm_ctrl, bus)
 
-static int qcom_swrm_abh_reg_read(struct qcom_swrm_ctrl *ctrl, int reg,
+static int qcom_swrm_ahb_reg_read(struct qcom_swrm_ctrl *ctrl, int reg,
 				  u32 *val)
 {
 	struct regmap *wcd_regmap = ctrl->regmap;
@@ -754,7 +754,7 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	if (dev->parent->bus == &slimbus_bus) {
-		ctrl->reg_read = qcom_swrm_abh_reg_read;
+		ctrl->reg_read = qcom_swrm_ahb_reg_read;
 		ctrl->reg_write = qcom_swrm_ahb_reg_write;
 		ctrl->regmap = dev_get_regmap(dev->parent, NULL);
 		if (!ctrl->regmap)
Signature · 1 line
2.26.1
#2 lore raw

PATCH v2 2/4 soundwire: qcom: avoid dependency on CONFIG_SLIMBUS

In reply to Jonathan Marek

The driver may be used without slimbus, so don't depend on slimbus.

---
 drivers/soundwire/Kconfig | 2 +-
 drivers/soundwire/qcom.c  | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/soundwire/Kconfig +1 -1
index fa2b4ab92ed9..f83d02c9c60a 100644
@@ -33,7 +33,7 @@ config SOUNDWIRE_INTEL
 
 config SOUNDWIRE_QCOM
 	tristate "Qualcomm SoundWire Master driver"
-	depends on SLIMBUS
+	imply SLIMBUS
 	depends on SND_SOC
 	help
 	  SoundWire Qualcomm Master driver.
drivers/soundwire/qcom.c +4 -0
index d1e33ef1afac..6401ad451eee 100644
@@ -753,7 +753,11 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 	if (!ctrl)
 		return -ENOMEM;
 
+#if IS_ENABLED(CONFIG_SLIBMUS)
 	if (dev->parent->bus == &slimbus_bus) {
+#else
+	if (false) {
+#endif
 		ctrl->reg_read = qcom_swrm_ahb_reg_read;
 		ctrl->reg_write = qcom_swrm_ahb_reg_write;
 		ctrl->regmap = dev_get_regmap(dev->parent, NULL);
Signature · 1 line
2.26.1
#3 lore raw

Re: [PATCH v2 2/4] soundwire: qcom: avoid dependency on CONFIG_SLIMBUS

Quoted 26 lines · Jonathan Marek

The driver may be used without slimbus, so don't depend on slimbus.

---
  drivers/soundwire/Kconfig | 2 +-
  drivers/soundwire/qcom.c  | 4 ++++
  2 files changed, 5 insertions(+), 1 deletion(-)
drivers/soundwire/Kconfig +1 -1
index fa2b4ab92ed9..f83d02c9c60a 100644
@@ -33,7 +33,7 @@ config SOUNDWIRE_INTEL
 
  config SOUNDWIRE_QCOM
  	tristate "Qualcomm SoundWire Master driver"
-	depends on SLIMBUS
+	imply SLIMBUS
  	depends on SND_SOC
  	help
  	  SoundWire Qualcomm Master driver.
drivers/soundwire/qcom.c +0 -0
index d1e33ef1afac..6401ad451eee 100644

drivers/soundwire/qcom.c static int qcom_swrm_probe(struct platform_device *pdev) · line 756

Quoted 4 lines
drivers/soundwire/qcom.c +1 -0
@@ -753,7 +753,11 @@ static int qcom_swrm_probe(struct platform_device *pdev)
  	if (!ctrl)
  		return -ENOMEM;
 
+#if IS_ENABLED(CONFIG_SLIBMUS)

typo: SLIMBUS.

Quoted 8 lines
drivers/soundwire/qcom.c +3 -0
  	if (dev->parent->bus == &slimbus_bus) {
+#else
+	if (false) {
+#endif
  		ctrl->reg_read = qcom_swrm_ahb_reg_read;
  		ctrl->reg_write = qcom_swrm_ahb_reg_write;
  		ctrl->regmap = dev_get_regmap(dev->parent, NULL);
#4 lore raw

PATCH v2 3/4 soundwire: qcom: add support for mmio soundwire master devices

In reply to Jonathan Marek

Adds support for qcom soundwire devices with memory mapped IO registers.

---
 drivers/soundwire/qcom.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
drivers/soundwire/qcom.c +27 -2
index 6401ad451eee..ff28794868ca 100644
@@ -34,6 +34,7 @@
 #define SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED		BIT(10)
 #define SWRM_INTERRUPT_MASK_ADDR				0x204
 #define SWRM_INTERRUPT_CLEAR					0x208
+#define SWRM_INTERRUPT_CPU_EN					0x210
 #define SWRM_CMD_FIFO_WR_CMD					0x300
 #define SWRM_CMD_FIFO_RD_CMD					0x304
 #define SWRM_CMD_FIFO_CMD					0x308
@@ -90,6 +91,7 @@ struct qcom_swrm_ctrl {
 	struct sdw_bus bus;
 	struct device *dev;
 	struct regmap *regmap;
+	void __iomem *mmio;
 	struct completion *comp;
 	struct work_struct slave_work;
 	/* read/write lock */
@@ -154,6 +156,20 @@ static int qcom_swrm_ahb_reg_write(struct qcom_swrm_ctrl *ctrl,
 	return SDW_CMD_OK;
 }
 
+static int qcom_swrm_cpu_reg_read(struct qcom_swrm_ctrl *ctrl, int reg,
+				  u32 *val)
+{
+	*val = readl(ctrl->mmio + reg);
+	return SDW_CMD_OK;
+}
+
+static int qcom_swrm_cpu_reg_write(struct qcom_swrm_ctrl *ctrl, int reg,
+				   int val)
+{
+	writel(val, ctrl->mmio + reg);
+	return SDW_CMD_OK;
+}
+
 static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *ctrl, u8 cmd_data,
 				     u8 dev_addr, u16 reg_addr)
 {
@@ -310,6 +326,12 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
 	ctrl->reg_write(ctrl, SWRM_COMP_CFG_ADDR,
 			SWRM_COMP_CFG_IRQ_LEVEL_OR_PULSE_MSK |
 			SWRM_COMP_CFG_ENABLE_MSK);
+
+	/* enable CPU IRQs */
+	if (ctrl->mmio) {
+		ctrl->reg_write(ctrl, SWRM_INTERRUPT_CPU_EN,
+				SWRM_INTERRUPT_STATUS_RMSK);
+	}
 	return 0;
 }
 
@@ -764,8 +786,11 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 		if (!ctrl->regmap)
 			return -EINVAL;
 	} else {
-		/* Only WCD based SoundWire controller is supported */
-		return -ENOTSUPP;
+		ctrl->reg_read = qcom_swrm_cpu_reg_read;
+		ctrl->reg_write = qcom_swrm_cpu_reg_write;
+		ctrl->mmio = devm_platform_ioremap_resource(pdev, 0);
+		if (IS_ERR(ctrl->mmio))
+			return PTR_ERR(ctrl->mmio);
 	}
 
 	ctrl->irq = of_irq_get(dev->of_node, 0);
Signature · 1 line
2.26.1
#5 lore raw

Re: [PATCH v2 3/4] soundwire: qcom: add support for mmio soundwire master devices

Quoted 4 lines

drivers/soundwire/qcom.c static int qcom_swrm_probe(struct platform_device *pdev) · line 793

Quoted 10 lines
drivers/soundwire/qcom.c +5 -2
@@ -764,8 +786,11 @@ static int qcom_swrm_probe(struct platform_device *pdev)
  		if (!ctrl->regmap)
  			return -EINVAL;
  	} else {
-		/* Only WCD based SoundWire controller is supported */
-		return -ENOTSUPP;
+		ctrl->reg_read = qcom_swrm_cpu_reg_read;
+		ctrl->reg_write = qcom_swrm_cpu_reg_write;
+		ctrl->mmio = devm_platform_ioremap_resource(pdev, 0);
+		if (IS_ERR(ctrl->mmio))
+			return PTR_ERR(ctrl->mmio);

Shouldn't this be conditional on SLIMBUS being enabled, as done in your patch2?

Quoted 4 lines
drivers/soundwire/qcom.c +0 -0
  	}
 
  	ctrl->irq = of_irq_get(dev->of_node, 0);
#6 lore raw

Re: [PATCH v2 3/4] soundwire: qcom: add support for mmio soundwire master devices

Quoted 18 lines · Pierre-Louis Bossart
Quoted 5 lines
drivers/soundwire/qcom.c +0 -0
@@ -764,8 +786,11 @@ static int qcom_swrm_probe(struct platform_device 
 *pdev)

drivers/soundwire/qcom.c static int qcom_swrm_probe(struct platform_device · line 794

Quoted 10 lines
drivers/soundwire/qcom.c +5 -2
           if (!ctrl->regmap)
               return -EINVAL;
       } else {
-        /* Only WCD based SoundWire controller is supported */
-        return -ENOTSUPP;
+        ctrl->reg_read = qcom_swrm_cpu_reg_read;
+        ctrl->reg_write = qcom_swrm_cpu_reg_write;
+        ctrl->mmio = devm_platform_ioremap_resource(pdev, 0);
+        if (IS_ERR(ctrl->mmio))
+            return PTR_ERR(ctrl->mmio);

Shouldn't this be conditional on SLIMBUS being enabled, as done in your patch2?

No, the case above is the SLIMBUS case. This patch is adding support for the non-SLIMBUS case.

Quoted 3 lines
Quoted 3 lines
drivers/soundwire/qcom.c +0 -0
       }
       ctrl->irq = of_irq_get(dev->of_node, 0);
#7 lore raw

PATCH v2 4/4 soundwire: qcom: add v1.5.1 compatible

In reply to Jonathan Marek

Add a compatible string for HW version v1.5.1 on sm8250 SoCs.

---
 Documentation/devicetree/bindings/soundwire/qcom,sdw.txt | 1 +
 drivers/soundwire/qcom.c                                 | 1 +
 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/soundwire/qcom,sdw.txt +1 -0
index 436547f3b155..b104be131235 100644
@@ -11,6 +11,7 @@ board specific bus parameters.
 		    Example:
 			"qcom,soundwire-v1.3.0"
 			"qcom,soundwire-v1.5.0"
+			"qcom,soundwire-v1.5.1"
 			"qcom,soundwire-v1.6.0"
 - reg:
 	Usage: required
drivers/soundwire/qcom.c +1 -0
index ff28794868ca..41dda3b85413 100644
@@ -888,6 +888,7 @@ static int qcom_swrm_remove(struct platform_device *pdev)
 
 static const struct of_device_id qcom_swrm_of_match[] = {
 	{ .compatible = "qcom,soundwire-v1.3.0", },
+	{ .compatible = "qcom,soundwire-v1.5.1", },
 	{/* sentinel */},
 };
 
Signature · 1 line
2.26.1
Reviewed-by Tested-by on the v2 series
#8 lore raw
In reply to Jonathan Marek
Quoted 9 lines · Jonathan Marek

This adds initial support for soundwire device on sm8250.

Tested with the "wsa" sdw device, which is simpler than the others.

v2 addresses some feedback, but I kept this series as simple as possible. In particular, I didn't implement CMD_NACKED from FIFO_STATUS, because the downstream driver doesn't define this bit, so I can't implement it. Soundwire works without it and It shouldn't be difficult to implement later.

Quoted 6 lines

Jonathan Marek (4):
soundwire: qcom: fix abh/ahb typo
soundwire: qcom: avoid dependency on CONFIG_SLIMBUS
soundwire: qcom: add support for mmio soundwire master devices
soundwire: qcom: add v1.5.1 compatible

Hi Jonathan,
I have tested these patches on RB5 with WSA8810 and they work fine.

I can try to add support to command ignored in future, but for now these look good to me!

Thanks,
srini

Quoted 5 lines
  .../bindings/soundwire/qcom,sdw.txt           |  1 +
  drivers/soundwire/Kconfig                     |  2 +-
  drivers/soundwire/qcom.c                      | 38 +++++++++++++++++--
  3 files changed, 36 insertions(+), 5 deletions(-)
maintainer Applied
#9 lore raw
In reply to Jonathan Marek
Quoted 8 lines · Jonathan Marek

This adds initial support for soundwire device on sm8250.

Tested with the "wsa" sdw device, which is simpler than the others.

v2 addresses some feedback, but I kept this series as simple as possible. In particular, I didn't implement CMD_NACKED from FIFO_STATUS, because the downstream driver doesn't define this bit, so I can't implement it. Soundwire works without it and It shouldn't be difficult to implement later.

Applied all, thanks

Signature · 1 line
~Vinod