Commit 4d5d604c authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'soundwire-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire

Pull soundwire updates from Vinod Koul:

 - Core: add concept of controller_id to deal with clear Controller /
   Manager hierarchy

 - bunch of qcom driver refactoring for qcom_swrm_stream_alloc_ports(),
   qcom_swrm_stream_alloc_ports() and setting controller id to hw master
   id

* tag 'soundwire-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire:
  soundwire: amd: drop bus freq calculation and set 'max_clk_freq'
  soundwire: generic_bandwidth_allocation use bus->params.max_dr_freq
  soundwire: qcom: set controller id to hw master id
  soundwire: fix initializing sysfs for same devices on different buses
  soundwire: bus: introduce controller_id
  soundwire: stream: constify sdw_port_config when adding devices
  soundwire: qcom: move sconfig in qcom_swrm_stream_alloc_ports() out of critical section
  soundwire: qcom: drop unneeded qcom_swrm_stream_alloc_ports() cleanup
parents 34551358 becfce52
...@@ -927,6 +927,14 @@ static int amd_sdw_manager_probe(struct platform_device *pdev) ...@@ -927,6 +927,14 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
amd_manager->bus.clk_stop_timeout = 200; amd_manager->bus.clk_stop_timeout = 200;
amd_manager->bus.link_id = amd_manager->instance; amd_manager->bus.link_id = amd_manager->instance;
/*
* Due to BIOS compatibility, the two links are exposed within
* the scope of a single controller. If this changes, the
* controller_id will have to be updated with drv_data
* information.
*/
amd_manager->bus.controller_id = 0;
switch (amd_manager->instance) { switch (amd_manager->instance) {
case ACP_SDW0: case ACP_SDW0:
amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS; amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS;
...@@ -942,13 +950,13 @@ static int amd_sdw_manager_probe(struct platform_device *pdev) ...@@ -942,13 +950,13 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
amd_manager->reg_mask = &sdw_manager_reg_mask_array[amd_manager->instance]; amd_manager->reg_mask = &sdw_manager_reg_mask_array[amd_manager->instance];
params = &amd_manager->bus.params; params = &amd_manager->bus.params;
params->max_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2;
params->curr_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2;
params->col = AMD_SDW_DEFAULT_COLUMNS; params->col = AMD_SDW_DEFAULT_COLUMNS;
params->row = AMD_SDW_DEFAULT_ROWS; params->row = AMD_SDW_DEFAULT_ROWS;
prop = &amd_manager->bus.prop; prop = &amd_manager->bus.prop;
prop->clk_freq = &amd_sdw_freq_tbl[0]; prop->clk_freq = &amd_sdw_freq_tbl[0];
prop->mclk_freq = AMD_SDW_BUS_BASE_FREQ; prop->mclk_freq = AMD_SDW_BUS_BASE_FREQ;
prop->max_clk_freq = AMD_SDW_DEFAULT_CLK_FREQ;
ret = sdw_bus_master_add(&amd_manager->bus, dev, dev->fwnode); ret = sdw_bus_master_add(&amd_manager->bus, dev, dev->fwnode);
if (ret) { if (ret) {
......
...@@ -22,6 +22,10 @@ static int sdw_get_id(struct sdw_bus *bus) ...@@ -22,6 +22,10 @@ static int sdw_get_id(struct sdw_bus *bus)
return rc; return rc;
bus->id = rc; bus->id = rc;
if (bus->controller_id == -1)
bus->controller_id = rc;
return 0; return 0;
} }
......
...@@ -20,7 +20,7 @@ void sdw_bus_debugfs_init(struct sdw_bus *bus) ...@@ -20,7 +20,7 @@ void sdw_bus_debugfs_init(struct sdw_bus *bus)
return; return;
/* create the debugfs master-N */ /* create the debugfs master-N */
snprintf(name, sizeof(name), "master-%d-%d", bus->id, bus->link_id); snprintf(name, sizeof(name), "master-%d-%d", bus->controller_id, bus->link_id);
bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root); bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root);
} }
......
...@@ -333,7 +333,7 @@ static int sdw_select_row_col(struct sdw_bus *bus, int clk_freq) ...@@ -333,7 +333,7 @@ static int sdw_select_row_col(struct sdw_bus *bus, int clk_freq)
*/ */
static int sdw_compute_bus_params(struct sdw_bus *bus) static int sdw_compute_bus_params(struct sdw_bus *bus)
{ {
unsigned int max_dr_freq, curr_dr_freq = 0; unsigned int curr_dr_freq = 0;
struct sdw_master_prop *mstr_prop = &bus->prop; struct sdw_master_prop *mstr_prop = &bus->prop;
int i, clk_values, ret; int i, clk_values, ret;
bool is_gear = false; bool is_gear = false;
...@@ -351,14 +351,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus) ...@@ -351,14 +351,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
clk_buf = NULL; clk_buf = NULL;
} }
max_dr_freq = mstr_prop->max_clk_freq * SDW_DOUBLE_RATE_FACTOR;
for (i = 0; i < clk_values; i++) { for (i = 0; i < clk_values; i++) {
if (!clk_buf) if (!clk_buf)
curr_dr_freq = max_dr_freq; curr_dr_freq = bus->params.max_dr_freq;
else else
curr_dr_freq = (is_gear) ? curr_dr_freq = (is_gear) ?
(max_dr_freq >> clk_buf[i]) : (bus->params.max_dr_freq >> clk_buf[i]) :
clk_buf[i] * SDW_DOUBLE_RATE_FACTOR; clk_buf[i] * SDW_DOUBLE_RATE_FACTOR;
if (curr_dr_freq <= bus->params.bandwidth) if (curr_dr_freq <= bus->params.bandwidth)
......
...@@ -234,6 +234,9 @@ static int intel_link_probe(struct auxiliary_device *auxdev, ...@@ -234,6 +234,9 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
cdns->instance = sdw->instance; cdns->instance = sdw->instance;
cdns->msg_count = 0; cdns->msg_count = 0;
/* single controller for all SoundWire links */
bus->controller_id = 0;
bus->link_id = auxdev->id; bus->link_id = auxdev->id;
bus->clk_stop_timeout = 1; bus->clk_stop_timeout = 1;
......
...@@ -145,7 +145,7 @@ int sdw_master_device_add(struct sdw_bus *bus, struct device *parent, ...@@ -145,7 +145,7 @@ int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
md->dev.fwnode = fwnode; md->dev.fwnode = fwnode;
md->dev.dma_mask = parent->dma_mask; md->dev.dma_mask = parent->dma_mask;
dev_set_name(&md->dev, "sdw-master-%d", bus->id); dev_set_name(&md->dev, "sdw-master-%d-%d", bus->controller_id, bus->link_id);
ret = device_register(&md->dev); ret = device_register(&md->dev);
if (ret) { if (ret) {
......
...@@ -1157,9 +1157,20 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, ...@@ -1157,9 +1157,20 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
struct sdw_port_runtime *p_rt; struct sdw_port_runtime *p_rt;
struct sdw_slave *slave; struct sdw_slave *slave;
unsigned long *port_mask; unsigned long *port_mask;
int i, maxport, pn, nports = 0, ret = 0; int maxport, pn, nports = 0, ret = 0;
unsigned int m_port; unsigned int m_port;
if (direction == SNDRV_PCM_STREAM_CAPTURE)
sconfig.direction = SDW_DATA_DIR_TX;
else
sconfig.direction = SDW_DATA_DIR_RX;
/* hw parameters wil be ignored as we only support PDM */
sconfig.ch_count = 1;
sconfig.frame_rate = params_rate(params);
sconfig.type = stream->type;
sconfig.bps = 1;
mutex_lock(&ctrl->port_lock); mutex_lock(&ctrl->port_lock);
list_for_each_entry(m_rt, &stream->master_list, stream_node) { list_for_each_entry(m_rt, &stream->master_list, stream_node) {
if (m_rt->direction == SDW_DATA_DIR_RX) { if (m_rt->direction == SDW_DATA_DIR_RX) {
...@@ -1183,7 +1194,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, ...@@ -1183,7 +1194,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
if (pn > maxport) { if (pn > maxport) {
dev_err(ctrl->dev, "All ports busy\n"); dev_err(ctrl->dev, "All ports busy\n");
ret = -EBUSY; ret = -EBUSY;
goto err; goto out;
} }
set_bit(pn, port_mask); set_bit(pn, port_mask);
pconfig[nports].num = pn; pconfig[nports].num = pn;
...@@ -1193,24 +1204,9 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, ...@@ -1193,24 +1204,9 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
} }
} }
if (direction == SNDRV_PCM_STREAM_CAPTURE)
sconfig.direction = SDW_DATA_DIR_TX;
else
sconfig.direction = SDW_DATA_DIR_RX;
/* hw parameters wil be ignored as we only support PDM */
sconfig.ch_count = 1;
sconfig.frame_rate = params_rate(params);
sconfig.type = stream->type;
sconfig.bps = 1;
sdw_stream_add_master(&ctrl->bus, &sconfig, pconfig, sdw_stream_add_master(&ctrl->bus, &sconfig, pconfig,
nports, stream); nports, stream);
err: out:
if (ret) {
for (i = 0; i < nports; i++)
clear_bit(pconfig[i].num, port_mask);
}
mutex_unlock(&ctrl->port_lock); mutex_unlock(&ctrl->port_lock);
return ret; return ret;
...@@ -1593,6 +1589,13 @@ static int qcom_swrm_probe(struct platform_device *pdev) ...@@ -1593,6 +1589,13 @@ static int qcom_swrm_probe(struct platform_device *pdev)
} }
} }
ctrl->bus.controller_id = -1;
if (ctrl->version > SWRM_VERSION_1_3_0) {
ctrl->reg_read(ctrl, SWRM_COMP_MASTER_ID, &val);
ctrl->bus.controller_id = val;
}
ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode); ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode);
if (ret) { if (ret) {
dev_err(dev, "Failed to register Soundwire controller (%d)\n", dev_err(dev, "Failed to register Soundwire controller (%d)\n",
......
...@@ -39,14 +39,14 @@ int sdw_slave_add(struct sdw_bus *bus, ...@@ -39,14 +39,14 @@ int sdw_slave_add(struct sdw_bus *bus,
slave->dev.fwnode = fwnode; slave->dev.fwnode = fwnode;
if (id->unique_id == SDW_IGNORED_UNIQUE_ID) { if (id->unique_id == SDW_IGNORED_UNIQUE_ID) {
/* name shall be sdw:link:mfg:part:class */ /* name shall be sdw:ctrl:link:mfg:part:class */
dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x", dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x",
bus->link_id, id->mfg_id, id->part_id, bus->controller_id, bus->link_id, id->mfg_id, id->part_id,
id->class_id); id->class_id);
} else { } else {
/* name shall be sdw:link:mfg:part:class:unique */ /* name shall be sdw:ctrl:link:mfg:part:class:unique */
dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x:%01x", dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x:%01x",
bus->link_id, id->mfg_id, id->part_id, bus->controller_id, bus->link_id, id->mfg_id, id->part_id,
id->class_id, id->unique_id); id->class_id, id->unique_id);
} }
......
...@@ -898,7 +898,7 @@ static struct sdw_port_runtime *sdw_port_alloc(struct list_head *port_list) ...@@ -898,7 +898,7 @@ static struct sdw_port_runtime *sdw_port_alloc(struct list_head *port_list)
} }
static int sdw_port_config(struct sdw_port_runtime *p_rt, static int sdw_port_config(struct sdw_port_runtime *p_rt,
struct sdw_port_config *port_config, const struct sdw_port_config *port_config,
int port_index) int port_index)
{ {
p_rt->ch_mask = port_config[port_index].ch_mask; p_rt->ch_mask = port_config[port_index].ch_mask;
...@@ -971,7 +971,7 @@ static int sdw_slave_port_is_valid_range(struct device *dev, int num) ...@@ -971,7 +971,7 @@ static int sdw_slave_port_is_valid_range(struct device *dev, int num)
static int sdw_slave_port_config(struct sdw_slave *slave, static int sdw_slave_port_config(struct sdw_slave *slave,
struct sdw_slave_runtime *s_rt, struct sdw_slave_runtime *s_rt,
struct sdw_port_config *port_config) const struct sdw_port_config *port_config)
{ {
struct sdw_port_runtime *p_rt; struct sdw_port_runtime *p_rt;
int ret; int ret;
...@@ -1027,7 +1027,7 @@ static int sdw_master_port_alloc(struct sdw_master_runtime *m_rt, ...@@ -1027,7 +1027,7 @@ static int sdw_master_port_alloc(struct sdw_master_runtime *m_rt,
} }
static int sdw_master_port_config(struct sdw_master_runtime *m_rt, static int sdw_master_port_config(struct sdw_master_runtime *m_rt,
struct sdw_port_config *port_config) const struct sdw_port_config *port_config)
{ {
struct sdw_port_runtime *p_rt; struct sdw_port_runtime *p_rt;
int ret; int ret;
...@@ -1862,7 +1862,7 @@ EXPORT_SYMBOL(sdw_release_stream); ...@@ -1862,7 +1862,7 @@ EXPORT_SYMBOL(sdw_release_stream);
*/ */
int sdw_stream_add_master(struct sdw_bus *bus, int sdw_stream_add_master(struct sdw_bus *bus,
struct sdw_stream_config *stream_config, struct sdw_stream_config *stream_config,
struct sdw_port_config *port_config, const struct sdw_port_config *port_config,
unsigned int num_ports, unsigned int num_ports,
struct sdw_stream_runtime *stream) struct sdw_stream_runtime *stream)
{ {
...@@ -1982,7 +1982,7 @@ EXPORT_SYMBOL(sdw_stream_remove_master); ...@@ -1982,7 +1982,7 @@ EXPORT_SYMBOL(sdw_stream_remove_master);
*/ */
int sdw_stream_add_slave(struct sdw_slave *slave, int sdw_stream_add_slave(struct sdw_slave *slave,
struct sdw_stream_config *stream_config, struct sdw_stream_config *stream_config,
struct sdw_port_config *port_config, const struct sdw_port_config *port_config,
unsigned int num_ports, unsigned int num_ports,
struct sdw_stream_runtime *stream) struct sdw_stream_runtime *stream)
{ {
......
...@@ -886,7 +886,8 @@ struct sdw_master_ops { ...@@ -886,7 +886,8 @@ struct sdw_master_ops {
* struct sdw_bus - SoundWire bus * struct sdw_bus - SoundWire bus
* @dev: Shortcut to &bus->md->dev to avoid changing the entire code. * @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
* @md: Master device * @md: Master device
* @link_id: Link id number, can be 0 to N, unique for each Master * @controller_id: system-unique controller ID. If set to -1, the bus @id will be used.
* @link_id: Link id number, can be 0 to N, unique for each Controller
* @id: bus system-wide unique id * @id: bus system-wide unique id
* @slaves: list of Slaves on this bus * @slaves: list of Slaves on this bus
* @assigned: Bitmap for Slave device numbers. * @assigned: Bitmap for Slave device numbers.
...@@ -918,6 +919,7 @@ struct sdw_master_ops { ...@@ -918,6 +919,7 @@ struct sdw_master_ops {
struct sdw_bus { struct sdw_bus {
struct device *dev; struct device *dev;
struct sdw_master_device *md; struct sdw_master_device *md;
int controller_id;
unsigned int link_id; unsigned int link_id;
int id; int id;
struct list_head slaves; struct list_head slaves;
...@@ -1040,7 +1042,7 @@ int sdw_compute_params(struct sdw_bus *bus); ...@@ -1040,7 +1042,7 @@ int sdw_compute_params(struct sdw_bus *bus);
int sdw_stream_add_master(struct sdw_bus *bus, int sdw_stream_add_master(struct sdw_bus *bus,
struct sdw_stream_config *stream_config, struct sdw_stream_config *stream_config,
struct sdw_port_config *port_config, const struct sdw_port_config *port_config,
unsigned int num_ports, unsigned int num_ports,
struct sdw_stream_runtime *stream); struct sdw_stream_runtime *stream);
int sdw_stream_remove_master(struct sdw_bus *bus, int sdw_stream_remove_master(struct sdw_bus *bus,
...@@ -1062,7 +1064,7 @@ void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id ...@@ -1062,7 +1064,7 @@ void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id
int sdw_stream_add_slave(struct sdw_slave *slave, int sdw_stream_add_slave(struct sdw_slave *slave,
struct sdw_stream_config *stream_config, struct sdw_stream_config *stream_config,
struct sdw_port_config *port_config, const struct sdw_port_config *port_config,
unsigned int num_ports, unsigned int num_ports,
struct sdw_stream_runtime *stream); struct sdw_stream_runtime *stream);
int sdw_stream_remove_slave(struct sdw_slave *slave, int sdw_stream_remove_slave(struct sdw_slave *slave,
...@@ -1084,7 +1086,7 @@ int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 val); ...@@ -1084,7 +1086,7 @@ int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 val);
static inline int sdw_stream_add_slave(struct sdw_slave *slave, static inline int sdw_stream_add_slave(struct sdw_slave *slave,
struct sdw_stream_config *stream_config, struct sdw_stream_config *stream_config,
struct sdw_port_config *port_config, const struct sdw_port_config *port_config,
unsigned int num_ports, unsigned int num_ports,
struct sdw_stream_runtime *stream) struct sdw_stream_runtime *stream)
{ {
......
...@@ -1256,11 +1256,11 @@ static int fill_sdw_codec_dlc(struct device *dev, ...@@ -1256,11 +1256,11 @@ static int fill_sdw_codec_dlc(struct device *dev,
else if (is_unique_device(adr_link, sdw_version, mfg_id, part_id, else if (is_unique_device(adr_link, sdw_version, mfg_id, part_id,
class_id, adr_index)) class_id, adr_index))
codec->name = devm_kasprintf(dev, GFP_KERNEL, codec->name = devm_kasprintf(dev, GFP_KERNEL,
"sdw:%01x:%04x:%04x:%02x", link_id, "sdw:0:%01x:%04x:%04x:%02x", link_id,
mfg_id, part_id, class_id); mfg_id, part_id, class_id);
else else
codec->name = devm_kasprintf(dev, GFP_KERNEL, codec->name = devm_kasprintf(dev, GFP_KERNEL,
"sdw:%01x:%04x:%04x:%02x:%01x", link_id, "sdw:0:%01x:%04x:%04x:%02x:%01x", link_id,
mfg_id, part_id, class_id, unique_id); mfg_id, part_id, class_id, unique_id);
if (!codec->name) if (!codec->name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment