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

Configure Feed

Select the types of activity you want to include in your feed.

soundwire: qcom: deprecate qcom,din/out-ports

Number of input and output ports can be dynamically read from the
controller registers, getting this value from Device Tree is redundant
and potentially lead to bugs.

Remove the code parsing this property along with marking this as
deprecated in device tree bindings.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Tested-by: Alexey Klimov <alexey.klimov@linaro.org> # sm8550
Link: https://patch.msgid.link/20250912083225.228778-5-srinivas.kandagatla@oss.qualcomm.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Srinivas Kandagatla and committed by
Vinod Koul
9e53a66a 8114a05c

+62 -79
+62 -79
drivers/soundwire/qcom.c
··· 128 128 #define MAX_FREQ_NUM 1 129 129 #define TIMEOUT_MS 100 130 130 #define QCOM_SWRM_MAX_RD_LEN 0x1 131 - #define QCOM_SDW_MAX_PORTS 14 132 131 #define DEFAULT_CLK_FREQ 9600000 133 132 #define SWRM_MAX_DAIS 0xF 134 133 #define SWR_INVALID_PARAM 0xFF ··· 194 195 int wake_irq; 195 196 int num_din_ports; 196 197 int num_dout_ports; 198 + int nports; 197 199 int cols_index; 198 200 int rows_index; 199 201 unsigned long port_mask; ··· 202 202 u8 rcmd_id; 203 203 u8 wcmd_id; 204 204 /* Port numbers are 1 - 14 */ 205 - struct qcom_swrm_port_config pconfig[QCOM_SDW_MAX_PORTS + 1]; 205 + struct qcom_swrm_port_config *pconfig; 206 206 struct sdw_stream_runtime *sruntime[SWRM_MAX_DAIS]; 207 207 enum sdw_slave_status status[SDW_MAX_DEVICES + 1]; 208 208 int (*reg_read)(struct qcom_swrm_ctrl *ctrl, int reg, u32 *val); ··· 1153 1153 struct snd_pcm_hw_params *params, 1154 1154 int direction) 1155 1155 { 1156 - struct sdw_port_config pconfig[QCOM_SDW_MAX_PORTS]; 1157 1156 struct sdw_stream_config sconfig; 1158 1157 struct sdw_master_runtime *m_rt; 1159 1158 struct sdw_slave_runtime *s_rt; ··· 1161 1162 unsigned long *port_mask; 1162 1163 int maxport, pn, nports = 0, ret = 0; 1163 1164 unsigned int m_port; 1165 + struct sdw_port_config *pconfig __free(kfree) = kcalloc(ctrl->nports, 1166 + sizeof(*pconfig), GFP_KERNEL); 1167 + if (!pconfig) 1168 + return -ENOMEM; 1164 1169 1165 1170 if (direction == SNDRV_PCM_STREAM_CAPTURE) 1166 1171 sconfig.direction = SDW_DATA_DIR_TX; ··· 1189 1186 continue; 1190 1187 1191 1188 port_mask = &ctrl->port_mask; 1192 - maxport = ctrl->num_dout_ports + ctrl->num_din_ports; 1193 - 1189 + maxport = ctrl->nports; 1194 1190 1195 1191 list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { 1196 1192 slave = s_rt->slave; ··· 1349 1347 static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl) 1350 1348 { 1351 1349 struct device_node *np = ctrl->dev->of_node; 1352 - u8 off1[QCOM_SDW_MAX_PORTS]; 1353 - u8 off2[QCOM_SDW_MAX_PORTS]; 1354 - u16 si[QCOM_SDW_MAX_PORTS]; 1355 - u8 bp_mode[QCOM_SDW_MAX_PORTS] = { 0, }; 1356 - u8 hstart[QCOM_SDW_MAX_PORTS]; 1357 - u8 hstop[QCOM_SDW_MAX_PORTS]; 1358 - u8 word_length[QCOM_SDW_MAX_PORTS]; 1359 - u8 blk_group_count[QCOM_SDW_MAX_PORTS]; 1360 - u8 lane_control[QCOM_SDW_MAX_PORTS]; 1361 - int i, ret, nports, val; 1362 - bool si_16 = false; 1350 + struct qcom_swrm_port_config *pcfg; 1351 + int i, ret, val; 1363 1352 1364 1353 ctrl->reg_read(ctrl, SWRM_COMP_PARAMS, &val); 1365 1354 ··· 1358 1365 ctrl->num_din_ports = FIELD_GET(SWRM_COMP_PARAMS_DIN_PORTS_MASK, val); 1359 1366 1360 1367 ret = of_property_read_u32(np, "qcom,din-ports", &val); 1361 - if (ret) 1362 - return ret; 1368 + if (!ret) { /* only if present */ 1369 + if (val != ctrl->num_din_ports) { 1370 + dev_err(ctrl->dev, "din-ports (%d) mismatch with controller (%d)", 1371 + val, ctrl->num_din_ports); 1372 + } 1363 1373 1364 - if (val > ctrl->num_din_ports) 1365 - return -EINVAL; 1366 - 1367 - ctrl->num_din_ports = val; 1374 + ctrl->num_din_ports = val; 1375 + } 1368 1376 1369 1377 ret = of_property_read_u32(np, "qcom,dout-ports", &val); 1370 - if (ret) 1371 - return ret; 1378 + if (!ret) { /* only if present */ 1379 + if (val != ctrl->num_dout_ports) { 1380 + dev_err(ctrl->dev, "dout-ports (%d) mismatch with controller (%d)", 1381 + val, ctrl->num_dout_ports); 1382 + } 1372 1383 1373 - if (val > ctrl->num_dout_ports) 1374 - return -EINVAL; 1384 + ctrl->num_dout_ports = val; 1385 + } 1375 1386 1376 - ctrl->num_dout_ports = val; 1387 + ctrl->nports = ctrl->num_dout_ports + ctrl->num_din_ports; 1377 1388 1378 - nports = ctrl->num_dout_ports + ctrl->num_din_ports; 1379 - if (nports > QCOM_SDW_MAX_PORTS) 1380 - return -EINVAL; 1389 + ctrl->pconfig = devm_kcalloc(ctrl->dev, ctrl->nports + 1, 1390 + sizeof(*ctrl->pconfig), GFP_KERNEL); 1391 + if (!ctrl->pconfig) 1392 + return -ENOMEM; 1381 1393 1382 - /* Valid port numbers are from 1-14, so mask out port 0 explicitly */ 1383 1394 set_bit(0, &ctrl->port_mask); 1395 + /* Valid port numbers are from 1, so mask out port 0 explicitly */ 1396 + for (i = 0; i < ctrl->nports; i++) { 1397 + pcfg = &ctrl->pconfig[i + 1]; 1384 1398 1385 - ret = of_property_read_u8_array(np, "qcom,ports-offset1", 1386 - off1, nports); 1387 - if (ret) 1388 - return ret; 1389 - 1390 - ret = of_property_read_u8_array(np, "qcom,ports-offset2", 1391 - off2, nports); 1392 - if (ret) 1393 - return ret; 1394 - 1395 - ret = of_property_read_u8_array(np, "qcom,ports-sinterval-low", 1396 - (u8 *)si, nports); 1397 - if (ret) { 1398 - ret = of_property_read_u16_array(np, "qcom,ports-sinterval", 1399 - si, nports); 1399 + ret = of_property_read_u8_index(np, "qcom,ports-offset1", i, &pcfg->off1); 1400 1400 if (ret) 1401 1401 return ret; 1402 - si_16 = true; 1403 - } 1404 1402 1405 - ret = of_property_read_u8_array(np, "qcom,ports-block-pack-mode", 1406 - bp_mode, nports); 1407 - if (ret) { 1408 - if (ctrl->version <= SWRM_VERSION_1_3_0) 1409 - memset(bp_mode, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); 1410 - else 1403 + ret = of_property_read_u8_index(np, "qcom,ports-offset2", i, &pcfg->off2); 1404 + if (ret) 1411 1405 return ret; 1412 - } 1413 1406 1414 - memset(hstart, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); 1415 - of_property_read_u8_array(np, "qcom,ports-hstart", hstart, nports); 1407 + ret = of_property_read_u8_index(np, "qcom,ports-sinterval-low", i, (u8 *)&pcfg->si); 1408 + if (ret) { 1409 + ret = of_property_read_u16_index(np, "qcom,ports-sinterval", i, &pcfg->si); 1410 + if (ret) 1411 + return ret; 1412 + } 1416 1413 1417 - memset(hstop, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); 1418 - of_property_read_u8_array(np, "qcom,ports-hstop", hstop, nports); 1414 + ret = of_property_read_u8_index(np, "qcom,ports-block-pack-mode", 1415 + i, &pcfg->bp_mode); 1416 + if (ret) { 1417 + if (ctrl->version <= SWRM_VERSION_1_3_0) 1418 + pcfg->bp_mode = SWR_INVALID_PARAM; 1419 + else 1420 + return ret; 1421 + } 1419 1422 1420 - memset(word_length, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); 1421 - of_property_read_u8_array(np, "qcom,ports-word-length", word_length, nports); 1423 + /* Optional properties */ 1424 + pcfg->hstart = SWR_INVALID_PARAM; 1425 + pcfg->hstop = SWR_INVALID_PARAM; 1426 + pcfg->word_length = SWR_INVALID_PARAM; 1427 + pcfg->blk_group_count = SWR_INVALID_PARAM; 1428 + pcfg->lane_control = SWR_INVALID_PARAM; 1422 1429 1423 - memset(blk_group_count, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); 1424 - of_property_read_u8_array(np, "qcom,ports-block-group-count", blk_group_count, nports); 1430 + of_property_read_u8_index(np, "qcom,ports-hstart", i, &pcfg->hstart); 1425 1431 1426 - memset(lane_control, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS); 1427 - of_property_read_u8_array(np, "qcom,ports-lane-control", lane_control, nports); 1432 + of_property_read_u8_index(np, "qcom,ports-hstop", i, &pcfg->hstop); 1428 1433 1429 - for (i = 0; i < nports; i++) { 1430 - /* Valid port number range is from 1-14 */ 1431 - if (si_16) 1432 - ctrl->pconfig[i + 1].si = si[i]; 1433 - else 1434 - ctrl->pconfig[i + 1].si = ((u8 *)si)[i]; 1435 - ctrl->pconfig[i + 1].off1 = off1[i]; 1436 - ctrl->pconfig[i + 1].off2 = off2[i]; 1437 - ctrl->pconfig[i + 1].bp_mode = bp_mode[i]; 1438 - ctrl->pconfig[i + 1].hstart = hstart[i]; 1439 - ctrl->pconfig[i + 1].hstop = hstop[i]; 1440 - ctrl->pconfig[i + 1].word_length = word_length[i]; 1441 - ctrl->pconfig[i + 1].blk_group_count = blk_group_count[i]; 1442 - ctrl->pconfig[i + 1].lane_control = lane_control[i]; 1434 + of_property_read_u8_index(np, "qcom,ports-word-length", i, &pcfg->word_length); 1435 + 1436 + of_property_read_u8_index(np, "qcom,ports-block-group-count", 1437 + i, &pcfg->blk_group_count); 1438 + 1439 + of_property_read_u8_index(np, "qcom,ports-lane-control", i, &pcfg->lane_control); 1443 1440 } 1444 1441 1445 1442 return 0;