Skip to content

Commit a479ebb

Browse files
committed
Merge tag 'soundwire-6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire
Pull soundwire updates from Vinod Koul: "A couple of small core changes and an Intel driver change: - sdw_assign_device_num() logic simplification, using internal slave id for irqs and optimizing computing of port params in specific stream states - Intel driver updates for ACE3+ microphone privacy status reporting and enabling the status in HDA Intel driver" * tag 'soundwire-6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire: soundwire: only compute port params in specific stream states ASoC: SOF: Intel: hda: Set the mic_privacy flag for soundwire with ACE3+ soundwire: intel: Add awareness of ACE3+ microphone privacy soundwire: bus: Add internal slave ID and use for IRQs soundwire: bus: Simplify sdw_assign_device_num()
2 parents ec7714e + 62ada17 commit a479ebb

File tree

10 files changed

+57
-20
lines changed

10 files changed

+57
-20
lines changed

drivers/soundwire/bus.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,
5656
return ret;
5757
}
5858

59+
ida_init(&bus->slave_ida);
60+
5961
ret = sdw_master_device_add(bus, parent, fwnode);
6062
if (ret < 0) {
6163
dev_err(parent, "Failed to add master device at link %d\n",
@@ -751,49 +753,44 @@ static int sdw_get_device_num(struct sdw_slave *slave)
751753
static int sdw_assign_device_num(struct sdw_slave *slave)
752754
{
753755
struct sdw_bus *bus = slave->bus;
754-
int ret, dev_num;
755-
bool new_device = false;
756+
struct device *dev = bus->dev;
757+
int ret;
756758

757759
/* check first if device number is assigned, if so reuse that */
758760
if (!slave->dev_num) {
759761
if (!slave->dev_num_sticky) {
762+
int dev_num;
763+
760764
mutex_lock(&slave->bus->bus_lock);
761765
dev_num = sdw_get_device_num(slave);
762766
mutex_unlock(&slave->bus->bus_lock);
763767
if (dev_num < 0) {
764-
dev_err(bus->dev, "Get dev_num failed: %d\n",
765-
dev_num);
768+
dev_err(dev, "Get dev_num failed: %d\n", dev_num);
766769
return dev_num;
767770
}
768-
slave->dev_num = dev_num;
771+
769772
slave->dev_num_sticky = dev_num;
770-
new_device = true;
771773
} else {
772-
slave->dev_num = slave->dev_num_sticky;
774+
dev_dbg(dev, "Slave already registered, reusing dev_num: %d\n",
775+
slave->dev_num_sticky);
773776
}
774777
}
775778

776-
if (!new_device)
777-
dev_dbg(bus->dev,
778-
"Slave already registered, reusing dev_num:%d\n",
779-
slave->dev_num);
780-
781779
/* Clear the slave->dev_num to transfer message on device 0 */
782-
dev_num = slave->dev_num;
783780
slave->dev_num = 0;
784781

785-
ret = sdw_write_no_pm(slave, SDW_SCP_DEVNUMBER, dev_num);
782+
ret = sdw_write_no_pm(slave, SDW_SCP_DEVNUMBER, slave->dev_num_sticky);
786783
if (ret < 0) {
787-
dev_err(bus->dev, "Program device_num %d failed: %d\n",
788-
dev_num, ret);
784+
dev_err(dev, "Program device_num %d failed: %d\n",
785+
slave->dev_num_sticky, ret);
789786
return ret;
790787
}
791788

792789
/* After xfer of msg, restore dev_num */
793790
slave->dev_num = slave->dev_num_sticky;
794791

795792
if (bus->ops && bus->ops->new_peripheral_assigned)
796-
bus->ops->new_peripheral_assigned(bus, slave, dev_num);
793+
bus->ops->new_peripheral_assigned(bus, slave, slave->dev_num);
797794

798795
return 0;
799796
}

drivers/soundwire/bus_type.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,17 @@ static int sdw_drv_probe(struct device *dev)
105105
if (ret)
106106
return ret;
107107

108+
ret = ida_alloc_max(&slave->bus->slave_ida, SDW_FW_MAX_DEVICES, GFP_KERNEL);
109+
if (ret < 0) {
110+
dev_err(dev, "Failed to allocated ID: %d\n", ret);
111+
return ret;
112+
}
113+
slave->index = ret;
114+
108115
ret = drv->probe(slave, id);
109116
if (ret) {
110117
dev_pm_domain_detach(dev, false);
118+
ida_free(&slave->bus->slave_ida, slave->index);
111119
return ret;
112120
}
113121

@@ -174,6 +182,8 @@ static int sdw_drv_remove(struct device *dev)
174182

175183
dev_pm_domain_detach(dev, false);
176184

185+
ida_free(&slave->bus->slave_ida, slave->index);
186+
177187
return ret;
178188
}
179189

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ static void _sdw_compute_port_params(struct sdw_bus *bus,
204204
port_bo = 1;
205205

206206
list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) {
207+
/*
208+
* Only runtimes with CONFIGURED, PREPARED, ENABLED, and DISABLED
209+
* states should be included in the bandwidth calculation.
210+
*/
211+
if (m_rt->stream->state > SDW_STREAM_DISABLED ||
212+
m_rt->stream->state < SDW_STREAM_CONFIGURED)
213+
continue;
207214
sdw_compute_master_ports(m_rt, &params[i], &port_bo, hstop);
208215
}
209216

drivers/soundwire/intel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct hdac_bus;
2222
* @shim_lock: mutex to handle access to shared SHIM registers
2323
* @shim_mask: global pointer to check SHIM register initialization
2424
* @clock_stop_quirks: mask defining requested behavior on pm_suspend
25+
* @mic_privacy: ACE version supports microphone privacy
2526
* @link_mask: global mask needed for power-up/down sequences
2627
* @cdns: Cadence master descriptor
2728
* @list: used to walk-through all masters exposed by the same controller
@@ -42,6 +43,7 @@ struct sdw_intel_link_res {
4243
struct mutex *shim_lock; /* protect shared registers */
4344
u32 *shim_mask;
4445
u32 clock_stop_quirks;
46+
bool mic_privacy;
4547
u32 link_mask;
4648
struct sdw_cdns *cdns;
4749
struct list_head list;

drivers/soundwire/intel_ace2x_debugfs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ static int intel_reg_show(struct seq_file *s_file, void *data)
7676
ret += intel_sprintf(vs_s, false, buf, ret, SDW_SHIM2_INTEL_VS_IOCTL);
7777
ret += intel_sprintf(vs_s, false, buf, ret, SDW_SHIM2_INTEL_VS_ACTMCTL);
7878

79+
if (sdw->link_res->mic_privacy) {
80+
ret += scnprintf(buf + ret, RD_BUF - ret, "\nVS PVCCS\n");
81+
ret += intel_sprintf(vs_s, false, buf, ret,
82+
SDW_SHIM2_INTEL_VS_PVCCS);
83+
}
84+
7985
seq_printf(s_file, "%s", buf);
8086
kfree(buf);
8187

drivers/soundwire/intel_init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static struct sdw_intel_link_dev *intel_link_dev_register(struct sdw_intel_res *
7777
link->shim = res->mmio_base + SDW_SHIM2_GENERIC_BASE(link_id);
7878
link->shim_vs = res->mmio_base + SDW_SHIM2_VS_BASE(link_id);
7979
link->shim_lock = res->eml_lock;
80+
link->mic_privacy = res->mic_privacy;
8081
}
8182

8283
link->ops = res->ops;

drivers/soundwire/irq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int sdw_irq_create(struct sdw_bus *bus,
3131
{
3232
bus->irq_chip.name = dev_name(bus->dev);
3333

34-
bus->domain = irq_domain_create_linear(fwnode, SDW_MAX_DEVICES,
34+
bus->domain = irq_domain_create_linear(fwnode, SDW_FW_MAX_DEVICES,
3535
&sdw_domain_ops, bus);
3636
if (!bus->domain) {
3737
dev_err(bus->dev, "Failed to add IRQ domain\n");
@@ -50,12 +50,12 @@ static void sdw_irq_dispose_mapping(void *data)
5050
{
5151
struct sdw_slave *slave = data;
5252

53-
irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num));
53+
irq_dispose_mapping(slave->irq);
5454
}
5555

5656
void sdw_irq_create_mapping(struct sdw_slave *slave)
5757
{
58-
slave->irq = irq_create_mapping(slave->bus->domain, slave->dev_num);
58+
slave->irq = irq_create_mapping(slave->bus->domain, slave->index);
5959
if (!slave->irq)
6060
dev_warn(&slave->dev, "Failed to map IRQ\n");
6161

include/linux/soundwire/sdw.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/bug.h>
99
#include <linux/completion.h>
1010
#include <linux/device.h>
11+
#include <linux/idr.h>
1112
#include <linux/irq.h>
1213
#include <linux/irqdomain.h>
1314
#include <linux/lockdep_types.h>
@@ -50,6 +51,7 @@ struct sdw_slave;
5051

5152
#define SDW_FRAME_CTRL_BITS 48
5253
#define SDW_MAX_DEVICES 11
54+
#define SDW_FW_MAX_DEVICES 16
5355

5456
#define SDW_MAX_PORTS 15
5557
#define SDW_VALID_PORT_RANGE(n) ((n) < SDW_MAX_PORTS && (n) >= 1)
@@ -630,6 +632,7 @@ struct sdw_slave_ops {
630632
* struct sdw_slave - SoundWire Slave
631633
* @id: MIPI device ID
632634
* @dev: Linux device
635+
* @index: internal ID for this slave
633636
* @irq: IRQ number
634637
* @status: Status reported by the Slave
635638
* @bus: Bus handle
@@ -661,6 +664,7 @@ struct sdw_slave_ops {
661664
struct sdw_slave {
662665
struct sdw_slave_id id;
663666
struct device dev;
667+
int index;
664668
int irq;
665669
enum sdw_slave_status status;
666670
struct sdw_bus *bus;
@@ -968,6 +972,7 @@ struct sdw_stream_runtime {
968972
* @md: Master device
969973
* @bus_lock_key: bus lock key associated to @bus_lock
970974
* @bus_lock: bus lock
975+
* @slave_ida: IDA for allocating internal slave IDs
971976
* @slaves: list of Slaves on this bus
972977
* @msg_lock_key: message lock key associated to @msg_lock
973978
* @msg_lock: message lock
@@ -1010,6 +1015,7 @@ struct sdw_bus {
10101015
struct sdw_master_device *md;
10111016
struct lock_class_key bus_lock_key;
10121017
struct mutex bus_lock;
1018+
struct ida slave_ida;
10131019
struct list_head slaves;
10141020
struct lock_class_key msg_lock_key;
10151021
struct mutex msg_lock;

include/linux/soundwire/sdw_intel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@
189189
#define SDW_SHIM3_INTEL_VS_ACTMCTL_DOAISE2 BIT(14)
190190
#define SDW_SHIM3_INTEL_VS_ACTMCTL_CLDE BIT(15)
191191

192+
/* ACE3+ Mic privacy control and status register */
193+
#define SDW_SHIM2_INTEL_VS_PVCCS 0x10
194+
192195
/**
193196
* struct sdw_intel_stream_params_data: configuration passed during
194197
* the @params_stream callback, e.g. for interaction with DSP
@@ -331,6 +334,7 @@ struct sdw_intel_ctx {
331334
* @shim_base: sdw shim base.
332335
* @alh_base: sdw alh base.
333336
* @ext: extended HDaudio link support
337+
* @mic_privacy: ACE version supports microphone privacy
334338
* @hbus: hdac_bus pointer, needed for power management
335339
* @eml_lock: mutex protecting shared registers in the HDaudio multi-link
336340
* space
@@ -349,6 +353,7 @@ struct sdw_intel_res {
349353
u32 shim_base;
350354
u32 alh_base;
351355
bool ext;
356+
bool mic_privacy;
352357
struct hdac_bus *hbus;
353358
struct mutex *eml_lock;
354359
};

sound/soc/sof/intel/hda.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ static int hda_sdw_probe(struct snd_sof_dev *sdev)
192192
res.ext = true;
193193
res.ops = &sdw_ace2x_callback;
194194

195+
/* ACE3+ supports microphone privacy */
196+
if (chip->hw_ip_version >= SOF_INTEL_ACE_3_0)
197+
res.mic_privacy = true;
195198
}
196199
res.irq = sdev->ipc_irq;
197200
res.handle = hdev->info.handle;

0 commit comments

Comments
 (0)