Skip to content

Commit 47b1b03

Browse files
charleskeepaxlag-linaro
authored andcommitted
mfd: cs42l43: Correct SoundWire port list
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: ace6d14 ("mfd: cs42l43: Add support for cs42l43 core driver") Signed-off-by: Charles Keepax <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 1fe13d8 commit 47b1b03

File tree

1 file changed

+28
-46
lines changed

1 file changed

+28
-46
lines changed

drivers/mfd/cs42l43-sdw.c

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717

1818
#include "cs42l43.h"
1919

20-
enum cs42l43_sdw_ports {
21-
CS42L43_DMIC_DEC_ASP_PORT = 1,
22-
CS42L43_SPK_TX_PORT,
23-
CS42L43_SPDIF_HP_PORT,
24-
CS42L43_SPK_RX_PORT,
25-
CS42L43_ASP_PORT,
26-
};
20+
#define CS42L43_SDW_PORT(port, chans) { \
21+
.num = port, \
22+
.max_ch = chans, \
23+
.type = SDW_DPN_FULL, \
24+
.max_word = 24, \
25+
}
2726

2827
static const struct regmap_config cs42l43_sdw_regmap = {
2928
.reg_bits = 32,
@@ -42,65 +41,48 @@ static const struct regmap_config cs42l43_sdw_regmap = {
4241
.num_reg_defaults = ARRAY_SIZE(cs42l43_reg_default),
4342
};
4443

44+
static const struct sdw_dpn_prop cs42l43_src_port_props[] = {
45+
CS42L43_SDW_PORT(1, 4),
46+
CS42L43_SDW_PORT(2, 2),
47+
CS42L43_SDW_PORT(3, 2),
48+
CS42L43_SDW_PORT(4, 2),
49+
};
50+
51+
static const struct sdw_dpn_prop cs42l43_sink_port_props[] = {
52+
CS42L43_SDW_PORT(5, 2),
53+
CS42L43_SDW_PORT(6, 2),
54+
CS42L43_SDW_PORT(7, 2),
55+
};
56+
4557
static int cs42l43_read_prop(struct sdw_slave *sdw)
4658
{
4759
struct sdw_slave_prop *prop = &sdw->prop;
4860
struct device *dev = &sdw->dev;
49-
struct sdw_dpn_prop *dpn;
50-
unsigned long addr;
51-
int nval;
5261
int i;
53-
u32 bit;
5462

5563
prop->use_domain_irq = true;
5664
prop->paging_support = true;
5765
prop->wake_capable = true;
58-
prop->source_ports = BIT(CS42L43_DMIC_DEC_ASP_PORT) | BIT(CS42L43_SPK_TX_PORT);
59-
prop->sink_ports = BIT(CS42L43_SPDIF_HP_PORT) |
60-
BIT(CS42L43_SPK_RX_PORT) | BIT(CS42L43_ASP_PORT);
6166
prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY;
6267
prop->scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY |
6368
SDW_SCP_INT1_IMPL_DEF;
6469

65-
nval = hweight32(prop->source_ports);
66-
prop->src_dpn_prop = devm_kcalloc(dev, nval, sizeof(*prop->src_dpn_prop),
67-
GFP_KERNEL);
70+
for (i = 0; i < ARRAY_SIZE(cs42l43_src_port_props); i++)
71+
prop->source_ports |= BIT(cs42l43_src_port_props[i].num);
72+
73+
prop->src_dpn_prop = devm_kmemdup(dev, cs42l43_src_port_props,
74+
sizeof(cs42l43_src_port_props), GFP_KERNEL);
6875
if (!prop->src_dpn_prop)
6976
return -ENOMEM;
7077

71-
i = 0;
72-
dpn = prop->src_dpn_prop;
73-
addr = prop->source_ports;
74-
for_each_set_bit(bit, &addr, 32) {
75-
dpn[i].num = bit;
76-
dpn[i].max_ch = 2;
77-
dpn[i].type = SDW_DPN_FULL;
78-
dpn[i].max_word = 24;
79-
i++;
80-
}
81-
/*
82-
* All ports are 2 channels max, except the first one,
83-
* CS42L43_DMIC_DEC_ASP_PORT.
84-
*/
85-
dpn[CS42L43_DMIC_DEC_ASP_PORT].max_ch = 4;
78+
for (i = 0; i < ARRAY_SIZE(cs42l43_sink_port_props); i++)
79+
prop->sink_ports |= BIT(cs42l43_sink_port_props[i].num);
8680

87-
nval = hweight32(prop->sink_ports);
88-
prop->sink_dpn_prop = devm_kcalloc(dev, nval, sizeof(*prop->sink_dpn_prop),
89-
GFP_KERNEL);
81+
prop->sink_dpn_prop = devm_kmemdup(dev, cs42l43_sink_port_props,
82+
sizeof(cs42l43_sink_port_props), GFP_KERNEL);
9083
if (!prop->sink_dpn_prop)
9184
return -ENOMEM;
9285

93-
i = 0;
94-
dpn = prop->sink_dpn_prop;
95-
addr = prop->sink_ports;
96-
for_each_set_bit(bit, &addr, 32) {
97-
dpn[i].num = bit;
98-
dpn[i].max_ch = 2;
99-
dpn[i].type = SDW_DPN_FULL;
100-
dpn[i].max_word = 24;
101-
i++;
102-
}
103-
10486
return 0;
10587
}
10688

0 commit comments

Comments
 (0)