Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+62 -44
+10 -2
drivers/soundwire/amd_manager.c
··· 927 927 amd_manager->bus.clk_stop_timeout = 200; 928 928 amd_manager->bus.link_id = amd_manager->instance; 929 929 930 + /* 931 + * Due to BIOS compatibility, the two links are exposed within 932 + * the scope of a single controller. If this changes, the 933 + * controller_id will have to be updated with drv_data 934 + * information. 935 + */ 936 + amd_manager->bus.controller_id = 0; 937 + 930 938 switch (amd_manager->instance) { 931 939 case ACP_SDW0: 932 940 amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS; ··· 950 942 951 943 amd_manager->reg_mask = &sdw_manager_reg_mask_array[amd_manager->instance]; 952 944 params = &amd_manager->bus.params; 953 - params->max_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2; 954 - params->curr_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2; 945 + 955 946 params->col = AMD_SDW_DEFAULT_COLUMNS; 956 947 params->row = AMD_SDW_DEFAULT_ROWS; 957 948 prop = &amd_manager->bus.prop; 958 949 prop->clk_freq = &amd_sdw_freq_tbl[0]; 959 950 prop->mclk_freq = AMD_SDW_BUS_BASE_FREQ; 951 + prop->max_clk_freq = AMD_SDW_DEFAULT_CLK_FREQ; 960 952 961 953 ret = sdw_bus_master_add(&amd_manager->bus, dev, dev->fwnode); 962 954 if (ret) {
+4
drivers/soundwire/bus.c
··· 22 22 return rc; 23 23 24 24 bus->id = rc; 25 + 26 + if (bus->controller_id == -1) 27 + bus->controller_id = rc; 28 + 25 29 return 0; 26 30 } 27 31
+1 -1
drivers/soundwire/debugfs.c
··· 20 20 return; 21 21 22 22 /* create the debugfs master-N */ 23 - snprintf(name, sizeof(name), "master-%d-%d", bus->id, bus->link_id); 23 + snprintf(name, sizeof(name), "master-%d-%d", bus->controller_id, bus->link_id); 24 24 bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root); 25 25 } 26 26
+3 -5
drivers/soundwire/generic_bandwidth_allocation.c
··· 333 333 */ 334 334 static int sdw_compute_bus_params(struct sdw_bus *bus) 335 335 { 336 - unsigned int max_dr_freq, curr_dr_freq = 0; 336 + unsigned int curr_dr_freq = 0; 337 337 struct sdw_master_prop *mstr_prop = &bus->prop; 338 338 int i, clk_values, ret; 339 339 bool is_gear = false; ··· 351 351 clk_buf = NULL; 352 352 } 353 353 354 - max_dr_freq = mstr_prop->max_clk_freq * SDW_DOUBLE_RATE_FACTOR; 355 - 356 354 for (i = 0; i < clk_values; i++) { 357 355 if (!clk_buf) 358 - curr_dr_freq = max_dr_freq; 356 + curr_dr_freq = bus->params.max_dr_freq; 359 357 else 360 358 curr_dr_freq = (is_gear) ? 361 - (max_dr_freq >> clk_buf[i]) : 359 + (bus->params.max_dr_freq >> clk_buf[i]) : 362 360 clk_buf[i] * SDW_DOUBLE_RATE_FACTOR; 363 361 364 362 if (curr_dr_freq <= bus->params.bandwidth)
+3
drivers/soundwire/intel_auxdevice.c
··· 234 234 cdns->instance = sdw->instance; 235 235 cdns->msg_count = 0; 236 236 237 + /* single controller for all SoundWire links */ 238 + bus->controller_id = 0; 239 + 237 240 bus->link_id = auxdev->id; 238 241 bus->clk_stop_timeout = 1; 239 242
+1 -1
drivers/soundwire/master.c
··· 145 145 md->dev.fwnode = fwnode; 146 146 md->dev.dma_mask = parent->dma_mask; 147 147 148 - dev_set_name(&md->dev, "sdw-master-%d", bus->id); 148 + dev_set_name(&md->dev, "sdw-master-%d-%d", bus->controller_id, bus->link_id); 149 149 150 150 ret = device_register(&md->dev); 151 151 if (ret) {
+21 -18
drivers/soundwire/qcom.c
··· 1157 1157 struct sdw_port_runtime *p_rt; 1158 1158 struct sdw_slave *slave; 1159 1159 unsigned long *port_mask; 1160 - int i, maxport, pn, nports = 0, ret = 0; 1160 + int maxport, pn, nports = 0, ret = 0; 1161 1161 unsigned int m_port; 1162 + 1163 + if (direction == SNDRV_PCM_STREAM_CAPTURE) 1164 + sconfig.direction = SDW_DATA_DIR_TX; 1165 + else 1166 + sconfig.direction = SDW_DATA_DIR_RX; 1167 + 1168 + /* hw parameters wil be ignored as we only support PDM */ 1169 + sconfig.ch_count = 1; 1170 + sconfig.frame_rate = params_rate(params); 1171 + sconfig.type = stream->type; 1172 + sconfig.bps = 1; 1162 1173 1163 1174 mutex_lock(&ctrl->port_lock); 1164 1175 list_for_each_entry(m_rt, &stream->master_list, stream_node) { ··· 1194 1183 if (pn > maxport) { 1195 1184 dev_err(ctrl->dev, "All ports busy\n"); 1196 1185 ret = -EBUSY; 1197 - goto err; 1186 + goto out; 1198 1187 } 1199 1188 set_bit(pn, port_mask); 1200 1189 pconfig[nports].num = pn; ··· 1204 1193 } 1205 1194 } 1206 1195 1207 - if (direction == SNDRV_PCM_STREAM_CAPTURE) 1208 - sconfig.direction = SDW_DATA_DIR_TX; 1209 - else 1210 - sconfig.direction = SDW_DATA_DIR_RX; 1211 - 1212 - /* hw parameters wil be ignored as we only support PDM */ 1213 - sconfig.ch_count = 1; 1214 - sconfig.frame_rate = params_rate(params); 1215 - sconfig.type = stream->type; 1216 - sconfig.bps = 1; 1217 1196 sdw_stream_add_master(&ctrl->bus, &sconfig, pconfig, 1218 1197 nports, stream); 1219 - err: 1220 - if (ret) { 1221 - for (i = 0; i < nports; i++) 1222 - clear_bit(pconfig[i].num, port_mask); 1223 - } 1224 - 1198 + out: 1225 1199 mutex_unlock(&ctrl->port_lock); 1226 1200 1227 1201 return ret; ··· 1587 1591 dev_err(dev, "Failed to request soundwire wake irq\n"); 1588 1592 goto err_init; 1589 1593 } 1594 + } 1595 + 1596 + ctrl->bus.controller_id = -1; 1597 + 1598 + if (ctrl->version > SWRM_VERSION_1_3_0) { 1599 + ctrl->reg_read(ctrl, SWRM_COMP_MASTER_ID, &val); 1600 + ctrl->bus.controller_id = val; 1590 1601 } 1591 1602 1592 1603 ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode);
+6 -6
drivers/soundwire/slave.c
··· 39 39 slave->dev.fwnode = fwnode; 40 40 41 41 if (id->unique_id == SDW_IGNORED_UNIQUE_ID) { 42 - /* name shall be sdw:link:mfg:part:class */ 43 - dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x", 44 - bus->link_id, id->mfg_id, id->part_id, 42 + /* name shall be sdw:ctrl:link:mfg:part:class */ 43 + dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x", 44 + bus->controller_id, bus->link_id, id->mfg_id, id->part_id, 45 45 id->class_id); 46 46 } else { 47 - /* name shall be sdw:link:mfg:part:class:unique */ 48 - dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x:%01x", 49 - bus->link_id, id->mfg_id, id->part_id, 47 + /* name shall be sdw:ctrl:link:mfg:part:class:unique */ 48 + dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x:%01x", 49 + bus->controller_id, bus->link_id, id->mfg_id, id->part_id, 50 50 id->class_id, id->unique_id); 51 51 } 52 52
+5 -5
drivers/soundwire/stream.c
··· 898 898 } 899 899 900 900 static int sdw_port_config(struct sdw_port_runtime *p_rt, 901 - struct sdw_port_config *port_config, 901 + const struct sdw_port_config *port_config, 902 902 int port_index) 903 903 { 904 904 p_rt->ch_mask = port_config[port_index].ch_mask; ··· 971 971 972 972 static int sdw_slave_port_config(struct sdw_slave *slave, 973 973 struct sdw_slave_runtime *s_rt, 974 - struct sdw_port_config *port_config) 974 + const struct sdw_port_config *port_config) 975 975 { 976 976 struct sdw_port_runtime *p_rt; 977 977 int ret; ··· 1027 1027 } 1028 1028 1029 1029 static int sdw_master_port_config(struct sdw_master_runtime *m_rt, 1030 - struct sdw_port_config *port_config) 1030 + const struct sdw_port_config *port_config) 1031 1031 { 1032 1032 struct sdw_port_runtime *p_rt; 1033 1033 int ret; ··· 1862 1862 */ 1863 1863 int sdw_stream_add_master(struct sdw_bus *bus, 1864 1864 struct sdw_stream_config *stream_config, 1865 - struct sdw_port_config *port_config, 1865 + const struct sdw_port_config *port_config, 1866 1866 unsigned int num_ports, 1867 1867 struct sdw_stream_runtime *stream) 1868 1868 { ··· 1982 1982 */ 1983 1983 int sdw_stream_add_slave(struct sdw_slave *slave, 1984 1984 struct sdw_stream_config *stream_config, 1985 - struct sdw_port_config *port_config, 1985 + const struct sdw_port_config *port_config, 1986 1986 unsigned int num_ports, 1987 1987 struct sdw_stream_runtime *stream) 1988 1988 {
+6 -4
include/linux/soundwire/sdw.h
··· 886 886 * struct sdw_bus - SoundWire bus 887 887 * @dev: Shortcut to &bus->md->dev to avoid changing the entire code. 888 888 * @md: Master device 889 - * @link_id: Link id number, can be 0 to N, unique for each Master 889 + * @controller_id: system-unique controller ID. If set to -1, the bus @id will be used. 890 + * @link_id: Link id number, can be 0 to N, unique for each Controller 890 891 * @id: bus system-wide unique id 891 892 * @slaves: list of Slaves on this bus 892 893 * @assigned: Bitmap for Slave device numbers. ··· 919 918 struct sdw_bus { 920 919 struct device *dev; 921 920 struct sdw_master_device *md; 921 + int controller_id; 922 922 unsigned int link_id; 923 923 int id; 924 924 struct list_head slaves; ··· 1042 1040 1043 1041 int sdw_stream_add_master(struct sdw_bus *bus, 1044 1042 struct sdw_stream_config *stream_config, 1045 - struct sdw_port_config *port_config, 1043 + const struct sdw_port_config *port_config, 1046 1044 unsigned int num_ports, 1047 1045 struct sdw_stream_runtime *stream); 1048 1046 int sdw_stream_remove_master(struct sdw_bus *bus, ··· 1064 1062 1065 1063 int sdw_stream_add_slave(struct sdw_slave *slave, 1066 1064 struct sdw_stream_config *stream_config, 1067 - struct sdw_port_config *port_config, 1065 + const struct sdw_port_config *port_config, 1068 1066 unsigned int num_ports, 1069 1067 struct sdw_stream_runtime *stream); 1070 1068 int sdw_stream_remove_slave(struct sdw_slave *slave, ··· 1086 1084 1087 1085 static inline int sdw_stream_add_slave(struct sdw_slave *slave, 1088 1086 struct sdw_stream_config *stream_config, 1089 - struct sdw_port_config *port_config, 1087 + const struct sdw_port_config *port_config, 1090 1088 unsigned int num_ports, 1091 1089 struct sdw_stream_runtime *stream) 1092 1090 {
+2 -2
sound/soc/intel/boards/sof_sdw.c
··· 1256 1256 else if (is_unique_device(adr_link, sdw_version, mfg_id, part_id, 1257 1257 class_id, adr_index)) 1258 1258 codec->name = devm_kasprintf(dev, GFP_KERNEL, 1259 - "sdw:%01x:%04x:%04x:%02x", link_id, 1259 + "sdw:0:%01x:%04x:%04x:%02x", link_id, 1260 1260 mfg_id, part_id, class_id); 1261 1261 else 1262 1262 codec->name = devm_kasprintf(dev, GFP_KERNEL, 1263 - "sdw:%01x:%04x:%04x:%02x:%01x", link_id, 1263 + "sdw:0:%01x:%04x:%04x:%02x:%01x", link_id, 1264 1264 mfg_id, part_id, class_id, unique_id); 1265 1265 1266 1266 if (!codec->name)