Skip to content

Commit 2f4281f

Browse files
committed
Merge tag 'soundwire-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire into char-misc-next
Vinod writes: soundwire updates for v5.3-rc1 Updates for 5.3 include: - module_sdw_driver macro for drivers - Documentation updates for code-blocks - Improvement from Pierre on intel and cadence driver - Clarification of DisCo properties and updates * tag 'soundwire-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire: soundwire: add module_sdw_driver helper macro docs: soundwire: locking: fix tags for a code-block soundwire: intel_init: add checks on link numbers soundwire: fix typo in comments soundwire: Intel: add log for number of PCM and PDM PDIs soundwire: cadence_master: check the number of bidir PDIs soundwire: cadence_master: log Slave status mask on errors soundwire: cadence_master: use rate_limited dynamic debug soundwire: rename/clarify MIPI DisCo properties soundwire: clarify comment soundwire: mipi-disco: fix clock stop modes soundwire: rename 'freq' fields soundwire: mipi-disco: remove master_count property for masters soundwire: remove master data port properties soundwire: add port-related definitions soundwire: mipi_disco: fix master/link error soundwire: intel: filter SoundWire controller device search soundwire: cdns: Fix compilation error on arm64
2 parents 996cdfa + 2aeac95 commit 2f4281f

10 files changed

Lines changed: 162 additions & 64 deletions

File tree

‎Documentation/driver-api/soundwire/locking.rst‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ Message transfer.
4444
b. Transfer message (Read/Write) to Slave1 or broadcast message on
4545
Bus in case of bank switch.
4646

47-
c. Release Message lock ::
47+
c. Release Message lock
48+
49+
::
4850

4951
+----------+ +---------+
5052
| | | |

‎drivers/soundwire/bus.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ int sdw_add_bus_master(struct sdw_bus *bus)
8787

8888
/*
8989
* Initialize clock values based on Master properties. The max
90-
* frequency is read from max_freq property. Current assumption
90+
* frequency is read from max_clk_freq property. Current assumption
9191
* is that the bus will start at highest clock frequency when
9292
* powered on.
9393
*
9494
* Default active bank will be 0 as out of reset the Slaves have
9595
* to start with bank 0 (Table 40 of Spec)
9696
*/
9797
prop = &bus->prop;
98-
bus->params.max_dr_freq = prop->max_freq * SDW_DOUBLE_RATE_FACTOR;
98+
bus->params.max_dr_freq = prop->max_clk_freq * SDW_DOUBLE_RATE_FACTOR;
9999
bus->params.curr_dr_freq = bus->params.max_dr_freq;
100100
bus->params.curr_bank = SDW_BANK0;
101101
bus->params.next_bank = SDW_BANK1;
@@ -648,7 +648,7 @@ static int sdw_initialize_slave(struct sdw_slave *slave)
648648
return 0;
649649

650650
/* Enable DP0 interrupts */
651-
val = prop->dp0_prop->device_interrupts;
651+
val = prop->dp0_prop->imp_def_interrupts;
652652
val |= SDW_DP0_INT_PORT_READY | SDW_DP0_INT_BRA_FAILURE;
653653

654654
ret = sdw_update(slave, SDW_DP0_INTMASK, val, val);

‎drivers/soundwire/cadence_master.c‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/delay.h>
1010
#include <linux/device.h>
1111
#include <linux/interrupt.h>
12+
#include <linux/io.h>
1213
#include <linux/module.h>
1314
#include <linux/mod_devicetable.h>
1415
#include <linux/soundwire/sdw_registers.h>
@@ -236,19 +237,19 @@ cdns_fill_msg_resp(struct sdw_cdns *cdns,
236237
for (i = 0; i < count; i++) {
237238
if (!(cdns->response_buf[i] & CDNS_MCP_RESP_ACK)) {
238239
no_ack = 1;
239-
dev_dbg(cdns->dev, "Msg Ack not received\n");
240+
dev_dbg_ratelimited(cdns->dev, "Msg Ack not received\n");
240241
if (cdns->response_buf[i] & CDNS_MCP_RESP_NACK) {
241242
nack = 1;
242-
dev_err(cdns->dev, "Msg NACK received\n");
243+
dev_err_ratelimited(cdns->dev, "Msg NACK received\n");
243244
}
244245
}
245246
}
246247

247248
if (nack) {
248-
dev_err(cdns->dev, "Msg NACKed for Slave %d\n", msg->dev_num);
249+
dev_err_ratelimited(cdns->dev, "Msg NACKed for Slave %d\n", msg->dev_num);
249250
return SDW_CMD_FAIL;
250251
} else if (no_ack) {
251-
dev_dbg(cdns->dev, "Msg ignored for Slave %d\n", msg->dev_num);
252+
dev_dbg_ratelimited(cdns->dev, "Msg ignored for Slave %d\n", msg->dev_num);
252253
return SDW_CMD_IGNORED;
253254
}
254255

@@ -356,12 +357,12 @@ cdns_program_scp_addr(struct sdw_cdns *cdns, struct sdw_msg *msg)
356357

357358
/* For NACK, NO ack, don't return err if we are in Broadcast mode */
358359
if (nack) {
359-
dev_err(cdns->dev,
360-
"SCP_addrpage NACKed for Slave %d\n", msg->dev_num);
360+
dev_err_ratelimited(cdns->dev,
361+
"SCP_addrpage NACKed for Slave %d\n", msg->dev_num);
361362
return SDW_CMD_FAIL;
362363
} else if (no_ack) {
363-
dev_dbg(cdns->dev,
364-
"SCP_addrpage ignored for Slave %d\n", msg->dev_num);
364+
dev_dbg_ratelimited(cdns->dev,
365+
"SCP_addrpage ignored for Slave %d\n", msg->dev_num);
365366
return SDW_CMD_IGNORED;
366367
}
367368

@@ -486,7 +487,8 @@ static int cdns_update_slave_status(struct sdw_cdns *cdns,
486487
{
487488
enum sdw_slave_status status[SDW_MAX_DEVICES + 1];
488489
bool is_slave = false;
489-
u64 slave, mask;
490+
u64 slave;
491+
u32 mask;
490492
int i, set_status;
491493

492494
/* combine the two status */
@@ -524,9 +526,9 @@ static int cdns_update_slave_status(struct sdw_cdns *cdns,
524526

525527
/* first check if Slave reported multiple status */
526528
if (set_status > 1) {
527-
dev_warn(cdns->dev,
528-
"Slave reported multiple Status: %d\n",
529-
status[i]);
529+
dev_warn_ratelimited(cdns->dev,
530+
"Slave reported multiple Status: %d\n",
531+
mask);
530532
/*
531533
* TODO: we need to reread the status here by
532534
* issuing a PING cmd
@@ -612,7 +614,7 @@ irqreturn_t sdw_cdns_thread(int irq, void *dev_id)
612614
struct sdw_cdns *cdns = dev_id;
613615
u32 slave0, slave1;
614616

615-
dev_dbg(cdns->dev, "Slave status change\n");
617+
dev_dbg_ratelimited(cdns->dev, "Slave status change\n");
616618

617619
slave0 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT0);
618620
slave1 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT1);
@@ -716,6 +718,8 @@ int sdw_cdns_pdi_init(struct sdw_cdns *cdns,
716718
stream = &cdns->pcm;
717719

718720
/* First two PDIs are reserved for bulk transfers */
721+
if (stream->num_bd < CDNS_PCM_PDI_OFFSET)
722+
return -EINVAL;
719723
stream->num_bd -= CDNS_PCM_PDI_OFFSET;
720724
offset = CDNS_PCM_PDI_OFFSET;
721725

‎drivers/soundwire/intel.c‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ static void intel_pdi_init(struct sdw_intel *sdw,
263263
config->pcm_out = (pcm_cap & SDW_SHIM_PCMSCAP_OSS) >>
264264
SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_OSS);
265265

266+
dev_dbg(sdw->cdns.dev, "PCM cap bd:%d in:%d out:%d\n",
267+
config->pcm_bd, config->pcm_in, config->pcm_out);
268+
266269
/* PDM Stream Capability */
267270
pdm_cap = intel_readw(shim, SDW_SHIM_PDMSCAP(link_id));
268271

@@ -272,6 +275,9 @@ static void intel_pdi_init(struct sdw_intel *sdw,
272275
SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_ISS);
273276
config->pdm_out = (pdm_cap & SDW_SHIM_PDMSCAP_OSS) >>
274277
SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_OSS);
278+
279+
dev_dbg(sdw->cdns.dev, "PDM cap bd:%d in:%d out:%d\n",
280+
config->pdm_bd, config->pdm_in, config->pdm_out);
275281
}
276282

277283
static int
@@ -796,13 +802,14 @@ static int intel_prop_read(struct sdw_bus *bus)
796802
sdw_master_read_prop(bus);
797803

798804
/* BIOS is not giving some values correctly. So, lets override them */
799-
bus->prop.num_freq = 1;
800-
bus->prop.freq = devm_kcalloc(bus->dev, bus->prop.num_freq,
801-
sizeof(*bus->prop.freq), GFP_KERNEL);
802-
if (!bus->prop.freq)
805+
bus->prop.num_clk_freq = 1;
806+
bus->prop.clk_freq = devm_kcalloc(bus->dev, bus->prop.num_clk_freq,
807+
sizeof(*bus->prop.clk_freq),
808+
GFP_KERNEL);
809+
if (!bus->prop.clk_freq)
803810
return -ENOMEM;
804811

805-
bus->prop.freq[0] = bus->prop.max_freq;
812+
bus->prop.clk_freq[0] = bus->prop.max_clk_freq;
806813
bus->prop.err_threshold = 5;
807814

808815
return 0;

‎drivers/soundwire/intel.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define __SDW_INTEL_LOCAL_H
66

77
/**
8-
* struct sdw_intel_res - Soundwire link resources
8+
* struct sdw_intel_link_res - Soundwire link resources
99
* @registers: Link IO registers base
1010
* @shim: Audio shim pointer
1111
* @alh: ALH (Audio Link Hub) pointer

‎drivers/soundwire/intel_init.c‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/soundwire/sdw_intel.h>
1515
#include "intel.h"
1616

17+
#define SDW_LINK_TYPE 4 /* from Intel ACPI documentation */
1718
#define SDW_MAX_LINKS 4
1819
#define SDW_SHIM_LCAP 0x0
1920
#define SDW_SHIM_BASE 0x2C000
@@ -80,6 +81,7 @@ static struct sdw_intel_ctx
8081

8182
/* Check SNDWLCAP.LCOUNT */
8283
caps = ioread32(res->mmio_base + SDW_SHIM_BASE + SDW_SHIM_LCAP);
84+
caps &= GENMASK(2, 0);
8385

8486
/* Check HW supported vs property value and use min of two */
8587
count = min_t(u8, caps, count);
@@ -89,6 +91,9 @@ static struct sdw_intel_ctx
8991
dev_err(&adev->dev, "Link count %d exceeds max %d\n",
9092
count, SDW_MAX_LINKS);
9193
return NULL;
94+
} else if (!count) {
95+
dev_warn(&adev->dev, "No SoundWire links detected\n");
96+
return NULL;
9297
}
9398

9499
dev_dbg(&adev->dev, "Creating %d SDW Link devices\n", count);
@@ -150,14 +155,32 @@ static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level,
150155
{
151156
struct sdw_intel_res *res = cdata;
152157
struct acpi_device *adev;
158+
acpi_status status;
159+
u64 adr;
160+
161+
status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
162+
if (ACPI_FAILURE(status))
163+
return AE_OK; /* keep going */
153164

154165
if (acpi_bus_get_device(handle, &adev)) {
155166
pr_err("%s: Couldn't find ACPI handle\n", __func__);
156167
return AE_NOT_FOUND;
157168
}
158169

159170
res->handle = handle;
160-
return AE_OK;
171+
172+
/*
173+
* On some Intel platforms, multiple children of the HDAS
174+
* device can be found, but only one of them is the SoundWire
175+
* controller. The SNDW device is always exposed with
176+
* Name(_ADR, 0x40000000), with bits 31..28 representing the
177+
* SoundWire link so filter accordingly
178+
*/
179+
if ((adr & GENMASK(31, 28)) >> 28 != SDW_LINK_TYPE)
180+
return AE_OK; /* keep going */
181+
182+
/* device found, stop namespace walk */
183+
return AE_CTRL_TERMINATE;
161184
}
162185

163186
/**

‎drivers/soundwire/mipi_disco.c‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int sdw_master_read_prop(struct sdw_bus *bus)
4040

4141
/* Find master handle */
4242
snprintf(name, sizeof(name),
43-
"mipi-sdw-master-%d-subproperties", bus->link_id);
43+
"mipi-sdw-link-%d-subproperties", bus->link_id);
4444

4545
link = device_get_named_child_node(bus->dev, name);
4646
if (!link) {
@@ -50,39 +50,40 @@ int sdw_master_read_prop(struct sdw_bus *bus)
5050

5151
if (fwnode_property_read_bool(link,
5252
"mipi-sdw-clock-stop-mode0-supported"))
53-
prop->clk_stop_mode = SDW_CLK_STOP_MODE0;
53+
prop->clk_stop_modes |= BIT(SDW_CLK_STOP_MODE0);
5454

5555
if (fwnode_property_read_bool(link,
5656
"mipi-sdw-clock-stop-mode1-supported"))
57-
prop->clk_stop_mode |= SDW_CLK_STOP_MODE1;
57+
prop->clk_stop_modes |= BIT(SDW_CLK_STOP_MODE1);
5858

5959
fwnode_property_read_u32(link,
6060
"mipi-sdw-max-clock-frequency",
61-
&prop->max_freq);
61+
&prop->max_clk_freq);
6262

6363
nval = fwnode_property_read_u32_array(link,
6464
"mipi-sdw-clock-frequencies-supported", NULL, 0);
6565
if (nval > 0) {
66-
prop->num_freq = nval;
67-
prop->freq = devm_kcalloc(bus->dev, prop->num_freq,
68-
sizeof(*prop->freq), GFP_KERNEL);
69-
if (!prop->freq)
66+
prop->num_clk_freq = nval;
67+
prop->clk_freq = devm_kcalloc(bus->dev, prop->num_clk_freq,
68+
sizeof(*prop->clk_freq),
69+
GFP_KERNEL);
70+
if (!prop->clk_freq)
7071
return -ENOMEM;
7172

7273
fwnode_property_read_u32_array(link,
7374
"mipi-sdw-clock-frequencies-supported",
74-
prop->freq, prop->num_freq);
75+
prop->clk_freq, prop->num_clk_freq);
7576
}
7677

7778
/*
7879
* Check the frequencies supported. If FW doesn't provide max
7980
* freq, then populate here by checking values.
8081
*/
81-
if (!prop->max_freq && prop->freq) {
82-
prop->max_freq = prop->freq[0];
83-
for (i = 1; i < prop->num_freq; i++) {
84-
if (prop->freq[i] > prop->max_freq)
85-
prop->max_freq = prop->freq[i];
82+
if (!prop->max_clk_freq && prop->clk_freq) {
83+
prop->max_clk_freq = prop->clk_freq[0];
84+
for (i = 1; i < prop->num_clk_freq; i++) {
85+
if (prop->clk_freq[i] > prop->max_clk_freq)
86+
prop->max_clk_freq = prop->clk_freq[i];
8687
}
8788
}
8889

@@ -149,13 +150,13 @@ static int sdw_slave_read_dp0(struct sdw_slave *slave,
149150
dp0->words, dp0->num_words);
150151
}
151152

152-
dp0->flow_controlled = fwnode_property_read_bool(port,
153+
dp0->BRA_flow_controlled = fwnode_property_read_bool(port,
153154
"mipi-sdw-bra-flow-controlled");
154155

155156
dp0->simple_ch_prep_sm = fwnode_property_read_bool(port,
156157
"mipi-sdw-simplified-channel-prepare-sm");
157158

158-
dp0->device_interrupts = fwnode_property_read_bool(port,
159+
dp0->imp_def_interrupts = fwnode_property_read_bool(port,
159160
"mipi-sdw-imp-def-dp0-interrupts-supported");
160161

161162
return 0;
@@ -224,7 +225,7 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
224225

225226
fwnode_property_read_u32(node,
226227
"mipi-sdw-imp-def-dpn-interrupts-supported",
227-
&dpn[i].device_interrupts);
228+
&dpn[i].imp_def_interrupts);
228229

229230
fwnode_property_read_u32(node, "mipi-sdw-min-channel-number",
230231
&dpn[i].min_ch);

‎drivers/soundwire/stream.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
439439

440440
prep_ch.bank = bus->params.next_bank;
441441

442-
if (dpn_prop->device_interrupts || !dpn_prop->simple_ch_prep_sm)
442+
if (dpn_prop->imp_def_interrupts || !dpn_prop->simple_ch_prep_sm)
443443
intr = true;
444444

445445
/*
@@ -449,7 +449,7 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
449449
*/
450450
if (prep && intr) {
451451
ret = sdw_configure_dpn_intr(s_rt->slave, p_rt->num, prep,
452-
dpn_prop->device_interrupts);
452+
dpn_prop->imp_def_interrupts);
453453
if (ret < 0)
454454
return ret;
455455
}
@@ -493,7 +493,7 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
493493
/* Disable interrupt after Port de-prepare */
494494
if (!prep && intr)
495495
ret = sdw_configure_dpn_intr(s_rt->slave, p_rt->num, prep,
496-
dpn_prop->device_interrupts);
496+
dpn_prop->imp_def_interrupts);
497497

498498
return ret;
499499
}
@@ -1473,7 +1473,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream)
14731473
memcpy(&params, &bus->params, sizeof(params));
14741474

14751475
/* TODO: Support Asynchronous mode */
1476-
if ((prop->max_freq % stream->params.rate) != 0) {
1476+
if ((prop->max_clk_freq % stream->params.rate) != 0) {
14771477
dev_err(bus->dev, "Async mode not supported\n");
14781478
return -EINVAL;
14791479
}

0 commit comments

Comments
 (0)