mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 1/2] mfd: cs42l43: Correct SoundWire port list
@ 2023-11-30 11:57 Charles Keepax
  2023-11-30 11:57 ` [PATCH 2/2] mfd: cs42l43: Correct order of include files to be alphabetical Charles Keepax
  2023-12-01 11:28 ` [PATCH v3 1/2] mfd: cs42l43: Correct SoundWire port list Lee Jones
  0 siblings, 2 replies; 4+ messages in thread
From: Charles Keepax @ 2023-11-30 11:57 UTC (permalink / raw)
  To: lee; +Cc: patches, linux-kernel

Two ports are missing from the port list, and the wrong port is set
to 4 channels. Also the attempt to list them by function is rather
misguided, there is nothing in the hardware that fixes a particular
port to one function. Factor out the port properties to an actual
struct, fixing the missing ports and correcting the port set to 4
channels.

Fixes: ace6d1448138 ("mfd: cs42l43: Add support for cs42l43 core driver")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---

Changes since v2:
 - Generate the port mask from the port list rather than the other way
   around.

Thanks,
Charles

 drivers/mfd/cs42l43-sdw.c | 74 +++++++++++++++------------------------
 1 file changed, 28 insertions(+), 46 deletions(-)

diff --git a/drivers/mfd/cs42l43-sdw.c b/drivers/mfd/cs42l43-sdw.c
index 7392b3d2e6b96..4be4df9dd8cf1 100644
--- a/drivers/mfd/cs42l43-sdw.c
+++ b/drivers/mfd/cs42l43-sdw.c
@@ -17,13 +17,12 @@
 
 #include "cs42l43.h"
 
-enum cs42l43_sdw_ports {
-	CS42L43_DMIC_DEC_ASP_PORT = 1,
-	CS42L43_SPK_TX_PORT,
-	CS42L43_SPDIF_HP_PORT,
-	CS42L43_SPK_RX_PORT,
-	CS42L43_ASP_PORT,
-};
+#define CS42L43_SDW_PORT(port, chans) { \
+	.num = port, \
+	.max_ch = chans, \
+	.type = SDW_DPN_FULL, \
+	.max_word = 24, \
+}
 
 static const struct regmap_config cs42l43_sdw_regmap = {
 	.reg_bits		= 32,
@@ -42,65 +41,48 @@ static const struct regmap_config cs42l43_sdw_regmap = {
 	.num_reg_defaults	= ARRAY_SIZE(cs42l43_reg_default),
 };
 
+static const struct sdw_dpn_prop cs42l43_src_port_props[] = {
+	CS42L43_SDW_PORT(1, 4),
+	CS42L43_SDW_PORT(2, 2),
+	CS42L43_SDW_PORT(3, 2),
+	CS42L43_SDW_PORT(4, 2),
+};
+
+static const struct sdw_dpn_prop cs42l43_sink_port_props[] = {
+	CS42L43_SDW_PORT(5, 2),
+	CS42L43_SDW_PORT(6, 2),
+	CS42L43_SDW_PORT(7, 2),
+};
+
 static int cs42l43_read_prop(struct sdw_slave *sdw)
 {
 	struct sdw_slave_prop *prop = &sdw->prop;
 	struct device *dev = &sdw->dev;
-	struct sdw_dpn_prop *dpn;
-	unsigned long addr;
-	int nval;
 	int i;
-	u32 bit;
 
 	prop->use_domain_irq = true;
 	prop->paging_support = true;
 	prop->wake_capable = true;
-	prop->source_ports = BIT(CS42L43_DMIC_DEC_ASP_PORT) | BIT(CS42L43_SPK_TX_PORT);
-	prop->sink_ports = BIT(CS42L43_SPDIF_HP_PORT) |
-			   BIT(CS42L43_SPK_RX_PORT) | BIT(CS42L43_ASP_PORT);
 	prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY;
 	prop->scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY |
 			      SDW_SCP_INT1_IMPL_DEF;
 
-	nval = hweight32(prop->source_ports);
-	prop->src_dpn_prop = devm_kcalloc(dev, nval, sizeof(*prop->src_dpn_prop),
-					  GFP_KERNEL);
+	for (i = 0; i < ARRAY_SIZE(cs42l43_src_port_props); i++)
+		prop->source_ports |= BIT(cs42l43_src_port_props[i].num);
+
+	prop->src_dpn_prop = devm_kmemdup(dev, cs42l43_src_port_props,
+					  sizeof(cs42l43_src_port_props), GFP_KERNEL);
 	if (!prop->src_dpn_prop)
 		return -ENOMEM;
 
-	i = 0;
-	dpn = prop->src_dpn_prop;
-	addr = prop->source_ports;
-	for_each_set_bit(bit, &addr, 32) {
-		dpn[i].num = bit;
-		dpn[i].max_ch = 2;
-		dpn[i].type = SDW_DPN_FULL;
-		dpn[i].max_word = 24;
-		i++;
-	}
-	/*
-	 * All ports are 2 channels max, except the first one,
-	 * CS42L43_DMIC_DEC_ASP_PORT.
-	 */
-	dpn[CS42L43_DMIC_DEC_ASP_PORT].max_ch = 4;
+	for (i = 0; i < ARRAY_SIZE(cs42l43_sink_port_props); i++)
+		prop->sink_ports |= BIT(cs42l43_sink_port_props[i].num);
 
-	nval = hweight32(prop->sink_ports);
-	prop->sink_dpn_prop = devm_kcalloc(dev, nval, sizeof(*prop->sink_dpn_prop),
-					   GFP_KERNEL);
+	prop->sink_dpn_prop = devm_kmemdup(dev, cs42l43_sink_port_props,
+					   sizeof(cs42l43_sink_port_props), GFP_KERNEL);
 	if (!prop->sink_dpn_prop)
 		return -ENOMEM;
 
-	i = 0;
-	dpn = prop->sink_dpn_prop;
-	addr = prop->sink_ports;
-	for_each_set_bit(bit, &addr, 32) {
-		dpn[i].num = bit;
-		dpn[i].max_ch = 2;
-		dpn[i].type = SDW_DPN_FULL;
-		dpn[i].max_word = 24;
-		i++;
-	}
-
 	return 0;
 }
 
-- 
2.39.2


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

* [PATCH 2/2] mfd: cs42l43: Correct order of include files to be alphabetical
  2023-11-30 11:57 [PATCH v3 1/2] mfd: cs42l43: Correct SoundWire port list Charles Keepax
@ 2023-11-30 11:57 ` Charles Keepax
  2023-12-01 11:28   ` (subset) " Lee Jones
  2023-12-01 11:28 ` [PATCH v3 1/2] mfd: cs42l43: Correct SoundWire port list Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Charles Keepax @ 2023-11-30 11:57 UTC (permalink / raw)
  To: lee; +Cc: patches, linux-kernel

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 drivers/mfd/cs42l43-sdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/cs42l43-sdw.c b/drivers/mfd/cs42l43-sdw.c
index 4be4df9dd8cf1..1d85bbf8cdd5d 100644
--- a/drivers/mfd/cs42l43-sdw.c
+++ b/drivers/mfd/cs42l43-sdw.c
@@ -6,11 +6,11 @@
  *                         Cirrus Logic International Semiconductor Ltd.
  */
 
+#include <linux/device.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/mfd/cs42l43-regs.h>
 #include <linux/module.h>
-#include <linux/device.h>
 #include <linux/soundwire/sdw.h>
 #include <linux/soundwire/sdw_registers.h>
 #include <linux/soundwire/sdw_type.h>
-- 
2.39.2


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

* Re: [PATCH v3 1/2] mfd: cs42l43: Correct SoundWire port list
  2023-11-30 11:57 [PATCH v3 1/2] mfd: cs42l43: Correct SoundWire port list Charles Keepax
  2023-11-30 11:57 ` [PATCH 2/2] mfd: cs42l43: Correct order of include files to be alphabetical Charles Keepax
@ 2023-12-01 11:28 ` Lee Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2023-12-01 11:28 UTC (permalink / raw)
  To: lee, Charles Keepax; +Cc: patches, linux-kernel

On Thu, 30 Nov 2023 11:57:11 +0000, Charles Keepax wrote:
> Two ports are missing from the port list, and the wrong port is set
> to 4 channels. Also the attempt to list them by function is rather
> misguided, there is nothing in the hardware that fixes a particular
> port to one function. Factor out the port properties to an actual
> struct, fixing the missing ports and correcting the port set to 4
> channels.
> 
> [...]

Applied, thanks!

[1/2] mfd: cs42l43: Correct SoundWire port list
      commit: 9498ccf50edaba2f21ed209af22adf9a0ca8d1c3

--
Lee Jones [李琼斯]


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

* Re: (subset) [PATCH 2/2] mfd: cs42l43: Correct order of include files to be alphabetical
  2023-11-30 11:57 ` [PATCH 2/2] mfd: cs42l43: Correct order of include files to be alphabetical Charles Keepax
@ 2023-12-01 11:28   ` Lee Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2023-12-01 11:28 UTC (permalink / raw)
  To: lee, Charles Keepax; +Cc: patches, linux-kernel

On Thu, 30 Nov 2023 11:57:12 +0000, Charles Keepax wrote:
> 


Applied, thanks!

[2/2] mfd: cs42l43: Correct order of include files to be alphabetical
      commit: c09588105fc8d26d9b63a699c705fec4ac2ca379

--
Lee Jones [李琼斯]


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

end of thread, other threads:[~2023-12-01 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30 11:57 [PATCH v3 1/2] mfd: cs42l43: Correct SoundWire port list Charles Keepax
2023-11-30 11:57 ` [PATCH 2/2] mfd: cs42l43: Correct order of include files to be alphabetical Charles Keepax
2023-12-01 11:28   ` (subset) " Lee Jones
2023-12-01 11:28 ` [PATCH v3 1/2] mfd: cs42l43: Correct SoundWire port list Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®