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

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

Pull soundwire updates from Vinod Koul:

- structure optimization of few bus structures and header updates

- support for 2.0 disco spec

- amd driver updates for acp revision, refactoring code and support for
acp6.3

- soft reset support for cadence driver

* tag 'soundwire-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire: (24 commits)
soundwire: Minor formatting fixups in sdw.h header
soundwire: Update the includes on the sdw.h header
soundwire: cadence: clear MCP BLOCK_WAKEUP in init
soundwire: cadence: add soft-reset on startup
soundwire: intel_auxdevice: add kernel parameter for mclk divider
soundwire: mipi-disco: add support for DP0/DPn 'lane-list' property
soundwire: mipi-disco: add new properties from 2.0 spec
soundwire: mipi-disco: add comment on DP0-supported property
soundwire: mipi-disco: add support for peripheral channelprepare timeout
soundwire: mipi_disco: add support for clock-scales property
soundwire: mipi-disco: add error handling for property array read
soundwire: mipi-disco: remove DPn audio-modes
soundwire: optimize sdw_dpn_prop
soundwire: optimize sdw_dp0_prop
soundwire: optimize sdw_slave_prop
soundwire: optimize sdw_bus structure
soundwire: optimize sdw_master_prop
soundwire: optimize sdw_stream_runtime memory layout
soundwire: mipi_disco: add MIPI-specific property_read_bool() helpers
soundwire: Correct some typos in comments
...

+368 -208
+1
Documentation/admin-guide/kernel-parameters.rst
··· 174 174 SCSI Appropriate SCSI support is enabled. 175 175 A lot of drivers have their options described inside 176 176 the Documentation/scsi/ sub-directory. 177 + SDW SoundWire support is enabled. 177 178 SECURITY Different security models are enabled. 178 179 SELINUX SELinux support is enabled. 179 180 SERIAL Serial support is enabled.
+4
Documentation/admin-guide/kernel-parameters.txt
··· 6075 6075 non-zero "wait" parameter. See weight_single 6076 6076 and weight_many. 6077 6077 6078 + sdw_mclk_divider=[SDW] 6079 + Specify the MCLK divider for Intel SoundWire buses in 6080 + case the BIOS does not provide the clock rate properly. 6081 + 6078 6082 skew_tick= [KNL,EARLY] Offset the periodic timer tick per cpu to mitigate 6079 6083 xtime_lock contention on larger systems, and/or RCU lock 6080 6084 contention on all systems with CONFIG_MAXSMP set.
+1
drivers/soundwire/amd_init.c
··· 121 121 122 122 sdw_pdata[index].instance = index; 123 123 sdw_pdata[index].acp_sdw_lock = res->acp_lock; 124 + sdw_pdata[index].acp_rev = res->acp_rev; 124 125 pdevinfo[index].name = "amd_sdw_manager"; 125 126 pdevinfo[index].id = index; 126 127 pdevinfo[index].parent = res->parent;
+64 -35
drivers/soundwire/amd_manager.c
··· 433 433 u32 frame_fmt_reg, dpn_frame_fmt; 434 434 435 435 dev_dbg(amd_manager->dev, "p_params->num:0x%x\n", p_params->num); 436 - switch (amd_manager->instance) { 437 - case ACP_SDW0: 438 - frame_fmt_reg = sdw0_manager_dp_reg[p_params->num].frame_fmt_reg; 439 - break; 440 - case ACP_SDW1: 441 - frame_fmt_reg = sdw1_manager_dp_reg[p_params->num].frame_fmt_reg; 436 + switch (amd_manager->acp_rev) { 437 + case ACP63_PCI_REV_ID: 438 + switch (amd_manager->instance) { 439 + case ACP_SDW0: 440 + frame_fmt_reg = acp63_sdw0_dp_reg[p_params->num].frame_fmt_reg; 441 + break; 442 + case ACP_SDW1: 443 + frame_fmt_reg = acp63_sdw1_dp_reg[p_params->num].frame_fmt_reg; 444 + break; 445 + default: 446 + return -EINVAL; 447 + } 442 448 break; 443 449 default: 444 450 return -EINVAL; ··· 471 465 u32 frame_fmt_reg, sample_int_reg, hctrl_dp0_reg; 472 466 u32 offset_reg, lane_ctrl_ch_en_reg; 473 467 474 - switch (amd_manager->instance) { 475 - case ACP_SDW0: 476 - frame_fmt_reg = sdw0_manager_dp_reg[params->port_num].frame_fmt_reg; 477 - sample_int_reg = sdw0_manager_dp_reg[params->port_num].sample_int_reg; 478 - hctrl_dp0_reg = sdw0_manager_dp_reg[params->port_num].hctrl_dp0_reg; 479 - offset_reg = sdw0_manager_dp_reg[params->port_num].offset_reg; 480 - lane_ctrl_ch_en_reg = sdw0_manager_dp_reg[params->port_num].lane_ctrl_ch_en_reg; 481 - break; 482 - case ACP_SDW1: 483 - frame_fmt_reg = sdw1_manager_dp_reg[params->port_num].frame_fmt_reg; 484 - sample_int_reg = sdw1_manager_dp_reg[params->port_num].sample_int_reg; 485 - hctrl_dp0_reg = sdw1_manager_dp_reg[params->port_num].hctrl_dp0_reg; 486 - offset_reg = sdw1_manager_dp_reg[params->port_num].offset_reg; 487 - lane_ctrl_ch_en_reg = sdw1_manager_dp_reg[params->port_num].lane_ctrl_ch_en_reg; 468 + switch (amd_manager->acp_rev) { 469 + case ACP63_PCI_REV_ID: 470 + switch (amd_manager->instance) { 471 + case ACP_SDW0: 472 + frame_fmt_reg = acp63_sdw0_dp_reg[params->port_num].frame_fmt_reg; 473 + sample_int_reg = acp63_sdw0_dp_reg[params->port_num].sample_int_reg; 474 + hctrl_dp0_reg = acp63_sdw0_dp_reg[params->port_num].hctrl_dp0_reg; 475 + offset_reg = acp63_sdw0_dp_reg[params->port_num].offset_reg; 476 + lane_ctrl_ch_en_reg = 477 + acp63_sdw0_dp_reg[params->port_num].lane_ctrl_ch_en_reg; 478 + break; 479 + case ACP_SDW1: 480 + frame_fmt_reg = acp63_sdw1_dp_reg[params->port_num].frame_fmt_reg; 481 + sample_int_reg = acp63_sdw1_dp_reg[params->port_num].sample_int_reg; 482 + hctrl_dp0_reg = acp63_sdw1_dp_reg[params->port_num].hctrl_dp0_reg; 483 + offset_reg = acp63_sdw1_dp_reg[params->port_num].offset_reg; 484 + lane_ctrl_ch_en_reg = 485 + acp63_sdw1_dp_reg[params->port_num].lane_ctrl_ch_en_reg; 486 + break; 487 + default: 488 + return -EINVAL; 489 + } 488 490 break; 489 491 default: 490 492 return -EINVAL; ··· 534 520 u32 dpn_ch_enable; 535 521 u32 lane_ctrl_ch_en_reg; 536 522 537 - switch (amd_manager->instance) { 538 - case ACP_SDW0: 539 - lane_ctrl_ch_en_reg = sdw0_manager_dp_reg[enable_ch->port_num].lane_ctrl_ch_en_reg; 540 - break; 541 - case ACP_SDW1: 542 - lane_ctrl_ch_en_reg = sdw1_manager_dp_reg[enable_ch->port_num].lane_ctrl_ch_en_reg; 523 + switch (amd_manager->acp_rev) { 524 + case ACP63_PCI_REV_ID: 525 + switch (amd_manager->instance) { 526 + case ACP_SDW0: 527 + lane_ctrl_ch_en_reg = 528 + acp63_sdw0_dp_reg[enable_ch->port_num].lane_ctrl_ch_en_reg; 529 + break; 530 + case ACP_SDW1: 531 + lane_ctrl_ch_en_reg = 532 + acp63_sdw1_dp_reg[enable_ch->port_num].lane_ctrl_ch_en_reg; 533 + break; 534 + default: 535 + return -EINVAL; 536 + } 543 537 break; 544 538 default: 545 539 return -EINVAL; ··· 932 910 amd_manager->mmio = amd_manager->acp_mmio + 933 911 (amd_manager->instance * SDW_MANAGER_REG_OFFSET); 934 912 amd_manager->acp_sdw_lock = pdata->acp_sdw_lock; 913 + amd_manager->acp_rev = pdata->acp_rev; 935 914 amd_manager->cols_index = sdw_find_col_index(AMD_SDW_DEFAULT_COLUMNS); 936 915 amd_manager->rows_index = sdw_find_row_index(AMD_SDW_DEFAULT_ROWS); 937 916 amd_manager->dev = dev; ··· 949 926 * information. 950 927 */ 951 928 amd_manager->bus.controller_id = 0; 952 - 953 - switch (amd_manager->instance) { 954 - case ACP_SDW0: 955 - amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS; 956 - amd_manager->num_din_ports = AMD_SDW0_MAX_RX_PORTS; 957 - break; 958 - case ACP_SDW1: 959 - amd_manager->num_dout_ports = AMD_SDW1_MAX_TX_PORTS; 960 - amd_manager->num_din_ports = AMD_SDW1_MAX_RX_PORTS; 929 + dev_dbg(dev, "acp_rev:0x%x\n", amd_manager->acp_rev); 930 + switch (amd_manager->acp_rev) { 931 + case ACP63_PCI_REV_ID: 932 + switch (amd_manager->instance) { 933 + case ACP_SDW0: 934 + amd_manager->num_dout_ports = AMD_ACP63_SDW0_MAX_TX_PORTS; 935 + amd_manager->num_din_ports = AMD_ACP63_SDW0_MAX_RX_PORTS; 936 + break; 937 + case ACP_SDW1: 938 + amd_manager->num_dout_ports = AMD_ACP63_SDW1_MAX_TX_PORTS; 939 + amd_manager->num_din_ports = AMD_ACP63_SDW1_MAX_RX_PORTS; 940 + break; 941 + default: 942 + return -EINVAL; 943 + } 961 944 break; 962 945 default: 963 946 return -EINVAL;
+8 -8
drivers/soundwire/amd_manager.h
··· 155 155 #define AMD_SDW_IRQ_MASK_8TO11 0x000c7777 156 156 #define AMD_SDW_IRQ_ERROR_MASK 0xff 157 157 #define AMD_SDW_MAX_FREQ_NUM 1 158 - #define AMD_SDW0_MAX_TX_PORTS 3 159 - #define AMD_SDW0_MAX_RX_PORTS 3 160 - #define AMD_SDW1_MAX_TX_PORTS 1 161 - #define AMD_SDW1_MAX_RX_PORTS 1 162 - #define AMD_SDW0_MAX_DAI 6 163 - #define AMD_SDW1_MAX_DAI 2 158 + #define AMD_ACP63_SDW0_MAX_TX_PORTS 3 159 + #define AMD_ACP63_SDW0_MAX_RX_PORTS 3 160 + #define AMD_ACP63_SDW1_MAX_TX_PORTS 1 161 + #define AMD_ACP63_SDW1_MAX_RX_PORTS 1 162 + #define AMD_ACP63_SDW0_MAX_DAI 6 163 + #define AMD_ACP63_SDW1_MAX_DAI 2 164 164 #define AMD_SDW_SLAVE_0_ATTACHED 5 165 165 #define AMD_SDW_SSP_COUNTER_VAL 3 166 166 ··· 222 222 * in SoundWire DMA driver. 223 223 */ 224 224 225 - static struct sdw_manager_dp_reg sdw0_manager_dp_reg[AMD_SDW0_MAX_DAI] = { 225 + static struct sdw_manager_dp_reg acp63_sdw0_dp_reg[AMD_ACP63_SDW0_MAX_DAI] = { 226 226 {ACP_SW_AUDIO0_TX_FRAME_FORMAT, ACP_SW_AUDIO0_TX_SAMPLEINTERVAL, ACP_SW_AUDIO0_TX_HCTRL_DP0, 227 227 ACP_SW_AUDIO0_TX_OFFSET_DP0, ACP_SW_AUDIO0_TX_CHANNEL_ENABLE_DP0}, 228 228 {ACP_SW_AUDIO1_TX_FRAME_FORMAT, ACP_SW_AUDIO1_TX_SAMPLEINTERVAL, ACP_SW_AUDIO1_TX_HCTRL, ··· 237 237 ACP_SW_AUDIO2_RX_OFFSET, ACP_SW_AUDIO2_RX_CHANNEL_ENABLE_DP0}, 238 238 }; 239 239 240 - static struct sdw_manager_dp_reg sdw1_manager_dp_reg[AMD_SDW1_MAX_DAI] = { 240 + static struct sdw_manager_dp_reg acp63_sdw1_dp_reg[AMD_ACP63_SDW1_MAX_DAI] = { 241 241 {ACP_SW_AUDIO1_TX_FRAME_FORMAT, ACP_SW_AUDIO1_TX_SAMPLEINTERVAL, ACP_SW_AUDIO1_TX_HCTRL, 242 242 ACP_SW_AUDIO1_TX_OFFSET, ACP_SW_AUDIO1_TX_CHANNEL_ENABLE_DP0}, 243 243 {ACP_SW_AUDIO1_RX_FRAME_FORMAT, ACP_SW_AUDIO1_RX_SAMPLEINTERVAL, ACP_SW_AUDIO1_RX_HCTRL,
+1 -1
drivers/soundwire/bus.c
··· 112 112 /* Set higher order bits */ 113 113 *bus->assigned = ~GENMASK(SDW_BROADCAST_DEV_NUM, SDW_ENUM_DEV_NUM); 114 114 115 - /* Set enumuration device number and broadcast device number */ 115 + /* Set enumeration device number and broadcast device number */ 116 116 set_bit(SDW_ENUM_DEV_NUM, bus->assigned); 117 117 set_bit(SDW_BROADCAST_DEV_NUM, bus->assigned); 118 118
+30
drivers/soundwire/cadence_master.c
··· 1378 1378 } 1379 1379 1380 1380 /** 1381 + * sdw_cdns_soft_reset() - Cadence soft-reset 1382 + * @cdns: Cadence instance 1383 + */ 1384 + int sdw_cdns_soft_reset(struct sdw_cdns *cdns) 1385 + { 1386 + int ret; 1387 + 1388 + cdns_updatel(cdns, CDNS_MCP_CONTROL, CDNS_MCP_CONTROL_SOFT_RST, 1389 + CDNS_MCP_CONTROL_SOFT_RST); 1390 + 1391 + ret = cdns_config_update(cdns); 1392 + if (ret < 0) { 1393 + dev_err(cdns->dev, "%s: config update failed\n", __func__); 1394 + return ret; 1395 + } 1396 + 1397 + ret = cdns_set_wait(cdns, CDNS_MCP_CONTROL, CDNS_MCP_CONTROL_SOFT_RST, 0); 1398 + if (ret < 0) 1399 + dev_err(cdns->dev, "%s: Soft Reset timed out\n", __func__); 1400 + 1401 + return ret; 1402 + } 1403 + EXPORT_SYMBOL(sdw_cdns_soft_reset); 1404 + 1405 + /** 1381 1406 * sdw_cdns_init() - Cadence initialization 1382 1407 * @cdns: Cadence instance 1383 1408 */ ··· 1424 1399 /* Set cmd accept mode */ 1425 1400 cdns_ip_updatel(cdns, CDNS_IP_MCP_CONTROL, CDNS_IP_MCP_CONTROL_CMD_ACCEPT, 1426 1401 CDNS_IP_MCP_CONTROL_CMD_ACCEPT); 1402 + 1403 + /* disable wakeup */ 1404 + cdns_ip_updatel(cdns, CDNS_IP_MCP_CONTROL, 1405 + CDNS_IP_MCP_CONTROL_BLOCK_WAKEUP, 1406 + 0); 1427 1407 1428 1408 /* Configure mcp config */ 1429 1409 val = cdns_readl(cdns, CDNS_MCP_CONFIG);
+1
drivers/soundwire/cadence_master.h
··· 168 168 irqreturn_t sdw_cdns_irq(int irq, void *dev_id); 169 169 irqreturn_t sdw_cdns_thread(int irq, void *dev_id); 170 170 171 + int sdw_cdns_soft_reset(struct sdw_cdns *cdns); 171 172 int sdw_cdns_init(struct sdw_cdns *cdns); 172 173 int sdw_cdns_pdi_init(struct sdw_cdns *cdns, 173 174 struct sdw_cdns_stream_config config);
+10 -2
drivers/soundwire/intel_auxdevice.c
··· 41 41 module_param_named(sdw_md_flags, md_flags, int, 0444); 42 42 MODULE_PARM_DESC(sdw_md_flags, "SoundWire Intel Master device flags (0x0 all off)"); 43 43 44 + static int mclk_divider; 45 + module_param_named(sdw_mclk_divider, mclk_divider, int, 0444); 46 + MODULE_PARM_DESC(sdw_mclk_divider, "SoundWire Intel mclk divider"); 47 + 44 48 struct wake_capable_part { 45 49 const u16 mfg_id; 46 50 const u16 part_id; ··· 146 142 "intel-sdw-ip-clock", 147 143 &prop->mclk_freq); 148 144 149 - /* the values reported by BIOS are the 2x clock, not the bus clock */ 150 - prop->mclk_freq /= 2; 145 + if (mclk_divider) 146 + /* use kernel parameter for BIOS or board work-arounds */ 147 + prop->mclk_freq /= mclk_divider; 148 + else 149 + /* the values reported by BIOS are the 2x clock, not the bus clock */ 150 + prop->mclk_freq /= 2; 151 151 152 152 fwnode_property_read_u32(link, 153 153 "intel-quirk-mask",
+6
drivers/soundwire/intel_bus_common.c
··· 16 16 struct sdw_bus *bus = &cdns->bus; 17 17 int ret; 18 18 19 + ret = sdw_cdns_soft_reset(cdns); 20 + if (ret < 0) { 21 + dev_err(dev, "%s: unable to soft-reset Cadence IP: %d\n", __func__, ret); 22 + return ret; 23 + } 24 + 19 25 /* 20 26 * follow recommended programming flows to avoid timeouts when 21 27 * gsync is enabled
+115 -29
drivers/soundwire/mipi_disco.c
··· 23 23 #include <linux/soundwire/sdw.h> 24 24 #include "bus.h" 25 25 26 + static bool mipi_fwnode_property_read_bool(const struct fwnode_handle *fwnode, 27 + const char *propname) 28 + { 29 + int ret; 30 + u8 val; 31 + 32 + if (!fwnode_property_present(fwnode, propname)) 33 + return false; 34 + ret = fwnode_property_read_u8_array(fwnode, propname, &val, 1); 35 + if (ret < 0) 36 + return false; 37 + return !!val; 38 + } 39 + 40 + static bool mipi_device_property_read_bool(const struct device *dev, 41 + const char *propname) 42 + { 43 + return mipi_fwnode_property_read_bool(dev_fwnode(dev), propname); 44 + } 45 + 26 46 /** 27 47 * sdw_master_read_prop() - Read Master properties 28 48 * @bus: SDW bus instance ··· 51 31 { 52 32 struct sdw_master_prop *prop = &bus->prop; 53 33 struct fwnode_handle *link; 34 + const char *scales_prop; 54 35 char name[32]; 55 - int nval, i; 36 + int nval; 37 + int ret; 38 + int i; 56 39 57 40 device_property_read_u32(bus->dev, 58 41 "mipi-sdw-sw-interface-revision", ··· 71 48 return -EIO; 72 49 } 73 50 74 - if (fwnode_property_read_bool(link, 51 + if (mipi_fwnode_property_read_bool(link, 75 52 "mipi-sdw-clock-stop-mode0-supported")) 76 53 prop->clk_stop_modes |= BIT(SDW_CLK_STOP_MODE0); 77 54 78 - if (fwnode_property_read_bool(link, 55 + if (mipi_fwnode_property_read_bool(link, 79 56 "mipi-sdw-clock-stop-mode1-supported")) 80 57 prop->clk_stop_modes |= BIT(SDW_CLK_STOP_MODE1); 81 58 ··· 94 71 return -ENOMEM; 95 72 } 96 73 97 - fwnode_property_read_u32_array(link, 74 + ret = fwnode_property_read_u32_array(link, 98 75 "mipi-sdw-clock-frequencies-supported", 99 76 prop->clk_freq, prop->num_clk_freq); 77 + if (ret < 0) 78 + return ret; 100 79 } 101 80 102 81 /* ··· 113 88 } 114 89 } 115 90 116 - nval = fwnode_property_count_u32(link, "mipi-sdw-supported-clock-gears"); 91 + scales_prop = "mipi-sdw-supported-clock-scales"; 92 + nval = fwnode_property_count_u32(link, scales_prop); 93 + if (nval == 0) { 94 + scales_prop = "mipi-sdw-supported-clock-gears"; 95 + nval = fwnode_property_count_u32(link, scales_prop); 96 + } 117 97 if (nval > 0) { 118 98 prop->num_clk_gears = nval; 119 99 prop->clk_gears = devm_kcalloc(bus->dev, prop->num_clk_gears, ··· 129 99 return -ENOMEM; 130 100 } 131 101 132 - fwnode_property_read_u32_array(link, 133 - "mipi-sdw-supported-clock-gears", 102 + ret = fwnode_property_read_u32_array(link, 103 + scales_prop, 134 104 prop->clk_gears, 135 105 prop->num_clk_gears); 106 + if (ret < 0) 107 + return ret; 136 108 } 137 109 138 110 fwnode_property_read_u32(link, "mipi-sdw-default-frame-rate", ··· 146 114 fwnode_property_read_u32(link, "mipi-sdw-default-frame-col-size", 147 115 &prop->default_col); 148 116 149 - prop->dynamic_frame = fwnode_property_read_bool(link, 117 + prop->dynamic_frame = mipi_fwnode_property_read_bool(link, 150 118 "mipi-sdw-dynamic-frame-shape"); 151 119 152 120 fwnode_property_read_u32(link, "mipi-sdw-command-error-threshold", ··· 163 131 struct sdw_dp0_prop *dp0) 164 132 { 165 133 int nval; 134 + int ret; 166 135 167 136 fwnode_property_read_u32(port, "mipi-sdw-port-max-wordlength", 168 137 &dp0->max_word); ··· 181 148 if (!dp0->words) 182 149 return -ENOMEM; 183 150 184 - fwnode_property_read_u32_array(port, 151 + ret = fwnode_property_read_u32_array(port, 185 152 "mipi-sdw-port-wordlength-configs", 186 153 dp0->words, dp0->num_words); 154 + if (ret < 0) 155 + return ret; 187 156 } 188 157 189 - dp0->BRA_flow_controlled = fwnode_property_read_bool(port, 158 + dp0->BRA_flow_controlled = mipi_fwnode_property_read_bool(port, 190 159 "mipi-sdw-bra-flow-controlled"); 191 160 192 - dp0->simple_ch_prep_sm = fwnode_property_read_bool(port, 161 + dp0->simple_ch_prep_sm = mipi_fwnode_property_read_bool(port, 193 162 "mipi-sdw-simplified-channel-prepare-sm"); 194 163 195 - dp0->imp_def_interrupts = fwnode_property_read_bool(port, 164 + dp0->imp_def_interrupts = mipi_fwnode_property_read_bool(port, 196 165 "mipi-sdw-imp-def-dp0-interrupts-supported"); 166 + 167 + nval = fwnode_property_count_u32(port, "mipi-sdw-lane-list"); 168 + if (nval > 0) { 169 + dp0->num_lanes = nval; 170 + dp0->lane_list = devm_kcalloc(&slave->dev, 171 + dp0->num_lanes, sizeof(*dp0->lane_list), 172 + GFP_KERNEL); 173 + if (!dp0->lane_list) 174 + return -ENOMEM; 175 + 176 + ret = fwnode_property_read_u32_array(port, 177 + "mipi-sdw-lane-list", 178 + dp0->lane_list, dp0->num_lanes); 179 + if (ret < 0) 180 + return ret; 181 + } 197 182 198 183 return 0; 199 184 } ··· 222 171 { 223 172 struct fwnode_handle *node; 224 173 u32 bit, i = 0; 225 - int nval; 226 174 unsigned long addr; 227 175 char name[40]; 176 + int nval; 177 + int ret; 228 178 229 179 addr = ports; 230 180 /* valid ports are 1 to 14 so apply mask */ ··· 260 208 return -ENOMEM; 261 209 } 262 210 263 - fwnode_property_read_u32_array(node, 211 + ret = fwnode_property_read_u32_array(node, 264 212 "mipi-sdw-port-wordlength-configs", 265 213 dpn[i].words, dpn[i].num_words); 214 + if (ret < 0) 215 + return ret; 266 216 } 267 217 268 218 fwnode_property_read_u32(node, "mipi-sdw-data-port-type", ··· 274 220 "mipi-sdw-max-grouping-supported", 275 221 &dpn[i].max_grouping); 276 222 277 - dpn[i].simple_ch_prep_sm = fwnode_property_read_bool(node, 223 + dpn[i].simple_ch_prep_sm = mipi_fwnode_property_read_bool(node, 278 224 "mipi-sdw-simplified-channelprepare-sm"); 279 225 280 226 fwnode_property_read_u32(node, ··· 303 249 return -ENOMEM; 304 250 } 305 251 306 - fwnode_property_read_u32_array(node, 252 + ret = fwnode_property_read_u32_array(node, 307 253 "mipi-sdw-channel-number-list", 308 254 dpn[i].channels, dpn[i].num_channels); 255 + if (ret < 0) 256 + return ret; 309 257 } 310 258 311 259 nval = fwnode_property_count_u32(node, "mipi-sdw-channel-combination-list"); ··· 322 266 return -ENOMEM; 323 267 } 324 268 325 - fwnode_property_read_u32_array(node, 269 + ret = fwnode_property_read_u32_array(node, 326 270 "mipi-sdw-channel-combination-list", 327 271 dpn[i].ch_combinations, 328 272 dpn[i].num_ch_combinations); 273 + if (ret < 0) 274 + return ret; 329 275 } 330 276 331 277 fwnode_property_read_u32(node, ··· 336 278 fwnode_property_read_u32(node, "mipi-sdw-max-async-buffer", 337 279 &dpn[i].max_async_buffer); 338 280 339 - dpn[i].block_pack_mode = fwnode_property_read_bool(node, 281 + dpn[i].block_pack_mode = mipi_fwnode_property_read_bool(node, 340 282 "mipi-sdw-block-packing-mode"); 341 283 342 284 fwnode_property_read_u32(node, "mipi-sdw-port-encoding-type", 343 285 &dpn[i].port_encoding); 344 286 345 - /* TODO: Read audio mode */ 287 + nval = fwnode_property_count_u32(node, "mipi-sdw-lane-list"); 288 + if (nval > 0) { 289 + dpn[i].num_lanes = nval; 290 + dpn[i].lane_list = devm_kcalloc(&slave->dev, 291 + dpn[i].num_lanes, sizeof(*dpn[i].lane_list), 292 + GFP_KERNEL); 293 + if (!dpn[i].lane_list) 294 + return -ENOMEM; 295 + 296 + ret = fwnode_property_read_u32_array(node, 297 + "mipi-sdw-lane-list", 298 + dpn[i].lane_list, dpn[i].num_lanes); 299 + if (ret < 0) 300 + return ret; 301 + } 346 302 347 303 fwnode_handle_put(node); 348 304 ··· 376 304 struct device *dev = &slave->dev; 377 305 struct fwnode_handle *port; 378 306 int nval; 307 + int ret; 379 308 380 309 device_property_read_u32(dev, "mipi-sdw-sw-interface-revision", 381 310 &prop->mipi_revision); 382 311 383 - prop->wake_capable = device_property_read_bool(dev, 312 + prop->wake_capable = mipi_device_property_read_bool(dev, 384 313 "mipi-sdw-wake-up-unavailable"); 385 314 prop->wake_capable = !prop->wake_capable; 386 315 387 - prop->test_mode_capable = device_property_read_bool(dev, 316 + prop->test_mode_capable = mipi_device_property_read_bool(dev, 388 317 "mipi-sdw-test-mode-supported"); 389 318 390 319 prop->clk_stop_mode1 = false; 391 - if (device_property_read_bool(dev, 320 + if (mipi_device_property_read_bool(dev, 392 321 "mipi-sdw-clock-stop-mode1-supported")) 393 322 prop->clk_stop_mode1 = true; 394 323 395 - prop->simple_clk_stop_capable = device_property_read_bool(dev, 324 + prop->simple_clk_stop_capable = mipi_device_property_read_bool(dev, 396 325 "mipi-sdw-simplified-clockstopprepare-sm-supported"); 397 326 398 327 device_property_read_u32(dev, "mipi-sdw-clockstopprepare-timeout", 399 328 &prop->clk_stop_timeout); 400 329 401 - device_property_read_u32(dev, "mipi-sdw-slave-channelprepare-timeout", 402 - &prop->ch_prep_timeout); 330 + ret = device_property_read_u32(dev, "mipi-sdw-peripheral-channelprepare-timeout", 331 + &prop->ch_prep_timeout); 332 + if (ret < 0) 333 + device_property_read_u32(dev, "mipi-sdw-slave-channelprepare-timeout", 334 + &prop->ch_prep_timeout); 403 335 404 336 device_property_read_u32(dev, 405 337 "mipi-sdw-clockstopprepare-hard-reset-behavior", 406 338 &prop->reset_behave); 407 339 408 - prop->high_PHY_capable = device_property_read_bool(dev, 340 + prop->high_PHY_capable = mipi_device_property_read_bool(dev, 409 341 "mipi-sdw-highPHY-capable"); 410 342 411 - prop->paging_support = device_property_read_bool(dev, 343 + prop->paging_support = mipi_device_property_read_bool(dev, 412 344 "mipi-sdw-paging-support"); 413 345 414 - prop->bank_delay_support = device_property_read_bool(dev, 346 + prop->bank_delay_support = mipi_device_property_read_bool(dev, 415 347 "mipi-sdw-bank-delay-support"); 416 348 417 349 device_property_read_u32(dev, ··· 430 354 device_property_read_u32(dev, "mipi-sdw-sink-port-list", 431 355 &prop->sink_ports); 432 356 433 - /* Read dp0 properties */ 357 + device_property_read_u32(dev, "mipi-sdw-sdca-interrupt-register-list", 358 + &prop->sdca_interrupt_register_list); 359 + 360 + prop->commit_register_supported = mipi_device_property_read_bool(dev, 361 + "mipi-sdw-commit-register-supported"); 362 + 363 + /* 364 + * Read dp0 properties - we don't rely on the 'mipi-sdw-dp-0-supported' 365 + * property since the 'mipi-sdw-dp0-subproperties' property is logically 366 + * equivalent. 367 + */ 434 368 port = device_get_named_child_node(dev, "mipi-sdw-dp-0-subproperties"); 435 369 if (!port) { 436 370 dev_dbg(dev, "DP0 node not found!!\n");
+1 -1
drivers/soundwire/qcom.c
··· 1173 1173 else 1174 1174 sconfig.direction = SDW_DATA_DIR_RX; 1175 1175 1176 - /* hw parameters wil be ignored as we only support PDM */ 1176 + /* hw parameters will be ignored as we only support PDM */ 1177 1177 sconfig.ch_count = 1; 1178 1178 sconfig.frame_rate = params_rate(params); 1179 1179 sconfig.type = stream->type;
+1 -1
drivers/soundwire/sysfs_slave.c
··· 215 215 216 216 /* 217 217 * the status is shown in capital letters for UNATTACHED and RESERVED 218 - * on purpose, to highligh users to the fact that these status values 218 + * on purpose, to highlight users to the fact that these status values 219 219 * are not expected. 220 220 */ 221 221 static const char *const slave_status[] = {
+114 -131
include/linux/soundwire/sdw.h
··· 4 4 #ifndef __SOUNDWIRE_H 5 5 #define __SOUNDWIRE_H 6 6 7 + #include <linux/bitfield.h> 7 8 #include <linux/bug.h> 8 - #include <linux/lockdep_types.h> 9 + #include <linux/completion.h> 10 + #include <linux/device.h> 9 11 #include <linux/irq.h> 10 12 #include <linux/irqdomain.h> 13 + #include <linux/lockdep_types.h> 11 14 #include <linux/mod_devicetable.h> 12 - #include <linux/bitfield.h> 15 + #include <linux/mutex.h> 16 + #include <linux/types.h> 13 17 #include <sound/sdca.h> 18 + 19 + struct dentry; 20 + struct fwnode_handle; 14 21 15 22 struct sdw_bus; 16 23 struct sdw_slave; ··· 234 227 235 228 /** 236 229 * struct sdw_dp0_prop - DP0 properties 230 + * @words: wordlengths supported 237 231 * @max_word: Maximum number of bits in a Payload Channel Sample, 1 to 64 238 232 * (inclusive) 239 233 * @min_word: Minimum number of bits in a Payload Channel Sample, 1 to 64 240 234 * (inclusive) 241 235 * @num_words: number of wordlengths supported 242 - * @words: wordlengths supported 236 + * @ch_prep_timeout: Port-specific timeout value, in milliseconds 243 237 * @BRA_flow_controlled: Slave implementation results in an OK_NotReady 244 238 * response 245 239 * @simple_ch_prep_sm: If channel prepare sequence is required 246 - * @ch_prep_timeout: Port-specific timeout value, in milliseconds 247 240 * @imp_def_interrupts: If set, each bit corresponds to support for 248 241 * implementation-defined interrupts 242 + * @num_lanes: array size of @lane_list 243 + * @lane_list: indicates which Lanes can be used by DP0 249 244 * 250 245 * The wordlengths are specified by Spec as max, min AND number of 251 246 * discrete values, implementation can define based on the wordlengths they 252 247 * support 253 248 */ 254 249 struct sdw_dp0_prop { 250 + u32 *words; 255 251 u32 max_word; 256 252 u32 min_word; 257 253 u32 num_words; 258 - u32 *words; 254 + u32 ch_prep_timeout; 259 255 bool BRA_flow_controlled; 260 256 bool simple_ch_prep_sm; 261 - u32 ch_prep_timeout; 262 257 bool imp_def_interrupts; 263 - }; 264 - 265 - /** 266 - * struct sdw_dpn_audio_mode - Audio mode properties for DPn 267 - * @bus_min_freq: Minimum bus frequency, in Hz 268 - * @bus_max_freq: Maximum bus frequency, in Hz 269 - * @bus_num_freq: Number of discrete frequencies supported 270 - * @bus_freq: Discrete bus frequencies, in Hz 271 - * @min_freq: Minimum sampling frequency, in Hz 272 - * @max_freq: Maximum sampling bus frequency, in Hz 273 - * @num_freq: Number of discrete sampling frequency supported 274 - * @freq: Discrete sampling frequencies, in Hz 275 - * @prep_ch_behave: Specifies the dependencies between Channel Prepare 276 - * sequence and bus clock configuration 277 - * If 0, Channel Prepare can happen at any Bus clock rate 278 - * If 1, Channel Prepare sequence shall happen only after Bus clock is 279 - * changed to a frequency supported by this mode or compatible modes 280 - * described by the next field 281 - * @glitchless: Bitmap describing possible glitchless transitions from this 282 - * Audio Mode to other Audio Modes 283 - */ 284 - struct sdw_dpn_audio_mode { 285 - u32 bus_min_freq; 286 - u32 bus_max_freq; 287 - u32 bus_num_freq; 288 - u32 *bus_freq; 289 - u32 max_freq; 290 - u32 min_freq; 291 - u32 num_freq; 292 - u32 *freq; 293 - u32 prep_ch_behave; 294 - u32 glitchless; 258 + int num_lanes; 259 + u32 *lane_list; 295 260 }; 296 261 297 262 /** ··· 278 299 * @type: Data port type. Full, Simplified or Reduced 279 300 * @max_grouping: Maximum number of samples that can be grouped together for 280 301 * a full data port 281 - * @simple_ch_prep_sm: If the port supports simplified channel prepare state 282 - * machine 283 302 * @ch_prep_timeout: Port-specific timeout value, in milliseconds 284 303 * @imp_def_interrupts: If set, each bit corresponds to support for 285 304 * implementation-defined interrupts 286 305 * @max_ch: Maximum channels supported 287 306 * @min_ch: Minimum channels supported 288 307 * @num_channels: Number of discrete channels supported 289 - * @channels: Discrete channels supported 290 308 * @num_ch_combinations: Number of channel combinations supported 309 + * @channels: Discrete channels supported 291 310 * @ch_combinations: Channel combinations supported 311 + * @lane_list: indicates which Lanes can be used by DPn 312 + * @num_lanes: array size of @lane_list 292 313 * @modes: SDW mode supported 293 314 * @max_async_buffer: Number of samples that this port can buffer in 294 315 * asynchronous modes 316 + * @port_encoding: Payload Channel Sample encoding schemes supported 295 317 * @block_pack_mode: Type of block port mode supported 296 318 * @read_only_wordlength: Read Only wordlength field in DPN_BlockCtrl1 register 297 - * @port_encoding: Payload Channel Sample encoding schemes supported 298 - * @audio_modes: Audio modes supported 319 + * @simple_ch_prep_sm: If the port supports simplified channel prepare state 320 + * machine 299 321 */ 300 322 struct sdw_dpn_prop { 301 323 u32 num; ··· 306 326 u32 *words; 307 327 enum sdw_dpn_type type; 308 328 u32 max_grouping; 309 - bool simple_ch_prep_sm; 310 329 u32 ch_prep_timeout; 311 330 u32 imp_def_interrupts; 312 331 u32 max_ch; 313 332 u32 min_ch; 314 333 u32 num_channels; 315 - u32 *channels; 316 334 u32 num_ch_combinations; 335 + u32 *channels; 317 336 u32 *ch_combinations; 337 + u32 *lane_list; 338 + int num_lanes; 318 339 u32 modes; 319 340 u32 max_async_buffer; 341 + u32 port_encoding; 320 342 bool block_pack_mode; 321 343 bool read_only_wordlength; 322 - u32 port_encoding; 323 - struct sdw_dpn_audio_mode *audio_modes; 344 + bool simple_ch_prep_sm; 324 345 }; 325 346 326 347 /** 327 348 * struct sdw_slave_prop - SoundWire Slave properties 349 + * @dp0_prop: Data Port 0 properties 350 + * @src_dpn_prop: Source Data Port N properties 351 + * @sink_dpn_prop: Sink Data Port N properties 328 352 * @mipi_revision: Spec version of the implementation 329 353 * @wake_capable: Wake-up events are supported 330 354 * @test_mode_capable: If test mode is supported ··· 345 361 * SCP_AddrPage2 346 362 * @bank_delay_support: Slave implements bank delay/bridge support registers 347 363 * SCP_BankDelay and SCP_NextFrame 364 + * @lane_control_support: Slave supports lane control 348 365 * @p15_behave: Slave behavior when the Master attempts a read to the Port15 349 366 * alias 350 - * @lane_control_support: Slave supports lane control 351 367 * @master_count: Number of Masters present on this Slave 352 368 * @source_ports: Bitmap identifying source ports 353 369 * @sink_ports: Bitmap identifying sink ports 354 - * @dp0_prop: Data Port 0 properties 355 - * @src_dpn_prop: Source Data Port N properties 356 - * @sink_dpn_prop: Sink Data Port N properties 357 - * @scp_int1_mask: SCP_INT1_MASK desired settings 358 370 * @quirks: bitmask identifying deltas from the MIPI specification 371 + * @sdca_interrupt_register_list: indicates which sets of SDCA interrupt status 372 + * and masks are supported 373 + * @commit_register_supported: is PCP_Commit register supported 374 + * @scp_int1_mask: SCP_INT1_MASK desired settings 359 375 * @clock_reg_supported: the Peripheral implements the clock base and scale 360 376 * registers introduced with the SoundWire 1.2 specification. SDCA devices 361 377 * do not need to set this boolean property as the registers are required. 362 378 * @use_domain_irq: call actual IRQ handler on slave, as well as callback 363 379 */ 364 380 struct sdw_slave_prop { 381 + struct sdw_dp0_prop *dp0_prop; 382 + struct sdw_dpn_prop *src_dpn_prop; 383 + struct sdw_dpn_prop *sink_dpn_prop; 365 384 u32 mipi_revision; 366 385 bool wake_capable; 367 386 bool test_mode_capable; ··· 376 389 bool high_PHY_capable; 377 390 bool paging_support; 378 391 bool bank_delay_support; 379 - enum sdw_p15_behave p15_behave; 380 392 bool lane_control_support; 393 + enum sdw_p15_behave p15_behave; 381 394 u32 master_count; 382 395 u32 source_ports; 383 396 u32 sink_ports; 384 - struct sdw_dp0_prop *dp0_prop; 385 - struct sdw_dpn_prop *src_dpn_prop; 386 - struct sdw_dpn_prop *sink_dpn_prop; 387 - u8 scp_int1_mask; 388 397 u32 quirks; 398 + u32 sdca_interrupt_register_list; 399 + u8 commit_register_supported; 400 + u8 scp_int1_mask; 389 401 bool clock_reg_supported; 390 402 bool use_domain_irq; 391 403 }; ··· 393 407 394 408 /** 395 409 * struct sdw_master_prop - Master properties 410 + * @clk_gears: Clock gears supported 411 + * @clk_freq: Clock frequencies supported, in Hz 412 + * @quirks: bitmask identifying optional behavior beyond the scope of the MIPI specification 396 413 * @revision: MIPI spec version of the implementation 397 414 * @clk_stop_modes: Bitmap, bit N set when clock-stop-modeN supported 398 415 * @max_clk_freq: Maximum Bus clock frequency, in Hz 399 416 * @num_clk_gears: Number of clock gears supported 400 - * @clk_gears: Clock gears supported 401 417 * @num_clk_freq: Number of clock frequencies supported, in Hz 402 - * @clk_freq: Clock frequencies supported, in Hz 403 418 * @default_frame_rate: Controller default Frame rate, in Hz 404 419 * @default_row: Number of rows 405 420 * @default_col: Number of columns ··· 409 422 * command 410 423 * @mclk_freq: clock reference passed to SoundWire Master, in Hz. 411 424 * @hw_disabled: if true, the Master is not functional, typically due to pin-mux 412 - * @quirks: bitmask identifying optional behavior beyond the scope of the MIPI specification 413 425 */ 414 426 struct sdw_master_prop { 427 + u32 *clk_gears; 428 + u32 *clk_freq; 429 + u64 quirks; 415 430 u32 revision; 416 431 u32 clk_stop_modes; 417 432 u32 max_clk_freq; 418 433 u32 num_clk_gears; 419 - u32 *clk_gears; 420 434 u32 num_clk_freq; 421 - u32 *clk_freq; 422 435 u32 default_frame_rate; 423 436 u32 default_row; 424 437 u32 default_col; 425 - bool dynamic_frame; 426 438 u32 err_threshold; 427 439 u32 mclk_freq; 440 + bool dynamic_frame; 428 441 bool hw_disabled; 429 - u64 quirks; 430 442 }; 431 443 432 444 /* Definitions for Master quirks */ ··· 617 631 int (*clk_stop)(struct sdw_slave *slave, 618 632 enum sdw_clk_stop_mode mode, 619 633 enum sdw_clk_stop_type type); 620 - 621 634 }; 622 635 623 636 /** ··· 692 707 container_of(d, struct sdw_master_device, dev) 693 708 694 709 struct sdw_driver { 695 - int (*probe)(struct sdw_slave *sdw, 696 - const struct sdw_device_id *id); 710 + int (*probe)(struct sdw_slave *sdw, const struct sdw_device_id *id); 697 711 int (*remove)(struct sdw_slave *sdw); 698 712 void (*shutdown)(struct sdw_slave *sdw); 699 713 ··· 711 727 SDW_SLAVE_ENTRY_EXT((_mfg_id), (_part_id), 0, 0, (_drv_data)) 712 728 713 729 int sdw_handle_slave_status(struct sdw_bus *bus, 714 - enum sdw_slave_status status[]); 730 + enum sdw_slave_status status[]); 715 731 716 732 /* 717 733 * SDW master structures and APIs ··· 793 809 */ 794 810 struct sdw_master_port_ops { 795 811 int (*dpn_set_port_params)(struct sdw_bus *bus, 796 - struct sdw_port_params *port_params, 797 - unsigned int bank); 812 + struct sdw_port_params *port_params, 813 + unsigned int bank); 798 814 int (*dpn_set_port_transport_params)(struct sdw_bus *bus, 799 - struct sdw_transport_params *transport_params, 800 - enum sdw_reg_bank bank); 801 - int (*dpn_port_prep)(struct sdw_bus *bus, 802 - struct sdw_prepare_ch *prepare_ch); 815 + struct sdw_transport_params *transport_params, 816 + enum sdw_reg_bank bank); 817 + int (*dpn_port_prep)(struct sdw_bus *bus, struct sdw_prepare_ch *prepare_ch); 803 818 int (*dpn_port_enable_ch)(struct sdw_bus *bus, 804 - struct sdw_enable_ch *enable_ch, unsigned int bank); 819 + struct sdw_enable_ch *enable_ch, unsigned int bank); 805 820 }; 806 821 807 822 struct sdw_msg; 808 823 809 824 /** 810 - * struct sdw_defer - SDW deffered message 811 - * @length: message length 825 + * struct sdw_defer - SDW deferred message 812 826 * @complete: message completion 813 827 * @msg: SDW message 828 + * @length: message length 814 829 */ 815 830 struct sdw_defer { 831 + struct sdw_msg *msg; 816 832 int length; 817 833 struct completion complete; 818 - struct sdw_msg *msg; 819 834 }; 820 835 821 836 /** ··· 835 852 */ 836 853 struct sdw_master_ops { 837 854 int (*read_prop)(struct sdw_bus *bus); 838 - u64 (*override_adr) 839 - (struct sdw_bus *bus, u64 addr); 840 - enum sdw_command_response (*xfer_msg) 841 - (struct sdw_bus *bus, struct sdw_msg *msg); 842 - enum sdw_command_response (*xfer_msg_defer) 843 - (struct sdw_bus *bus); 855 + u64 (*override_adr)(struct sdw_bus *bus, u64 addr); 856 + enum sdw_command_response (*xfer_msg)(struct sdw_bus *bus, struct sdw_msg *msg); 857 + enum sdw_command_response (*xfer_msg_defer)(struct sdw_bus *bus); 844 858 int (*set_bus_conf)(struct sdw_bus *bus, 845 - struct sdw_bus_params *params); 859 + struct sdw_bus_params *params); 846 860 int (*pre_bank_switch)(struct sdw_bus *bus); 847 861 int (*post_bank_switch)(struct sdw_bus *bus); 848 862 u32 (*read_ping_status)(struct sdw_bus *bus); ··· 854 874 * struct sdw_bus - SoundWire bus 855 875 * @dev: Shortcut to &bus->md->dev to avoid changing the entire code. 856 876 * @md: Master device 857 - * @controller_id: system-unique controller ID. If set to -1, the bus @id will be used. 858 - * @link_id: Link id number, can be 0 to N, unique for each Controller 859 - * @id: bus system-wide unique id 860 - * @slaves: list of Slaves on this bus 861 - * @assigned: Bitmap for Slave device numbers. 862 - * Bit set implies used number, bit clear implies unused number. 877 + * @bus_lock_key: bus lock key associated to @bus_lock 863 878 * @bus_lock: bus lock 879 + * @slaves: list of Slaves on this bus 880 + * @msg_lock_key: message lock key associated to @msg_lock 864 881 * @msg_lock: message lock 865 - * @compute_params: points to Bus resource management implementation 866 - * @ops: Master callback ops 867 - * @port_ops: Master port callback ops 868 - * @params: Current bus parameters 869 - * @prop: Master properties 870 - * @vendor_specific_prop: pointer to non-standard properties 871 882 * @m_rt_list: List of Master instance of all stream(s) running on Bus. This 872 883 * is used to compute and program bus bandwidth, clock, frame shape, 873 884 * transport and port parameters 874 - * @debugfs: Bus debugfs 875 - * @domain: IRQ domain 876 885 * @defer_msg: Defer message 877 - * @clk_stop_timeout: Clock stop timeout computed 878 - * @bank_switch_timeout: Bank switch timeout computed 879 - * @multi_link: Store bus property that indicates if multi links 880 - * are supported. This flag is populated by drivers after reading 881 - * appropriate firmware (ACPI/DT). 886 + * @params: Current bus parameters 887 + * @stream_refcount: number of streams currently using this bus 888 + * @ops: Master callback ops 889 + * @port_ops: Master port callback ops 890 + * @prop: Master properties 891 + * @vendor_specific_prop: pointer to non-standard properties 882 892 * @hw_sync_min_links: Number of links used by a stream above which 883 893 * hardware-based synchronization is required. This value is only 884 894 * meaningful if multi_link is set. If set to 1, hardware-based 885 895 * synchronization will be used even if a stream only uses a single 886 896 * SoundWire segment. 887 - * @stream_refcount: number of streams currently using this bus 897 + * @controller_id: system-unique controller ID. If set to -1, the bus @id will be used. 898 + * @link_id: Link id number, can be 0 to N, unique for each Controller 899 + * @id: bus system-wide unique id 900 + * @compute_params: points to Bus resource management implementation 901 + * @assigned: Bitmap for Slave device numbers. 902 + * Bit set implies used number, bit clear implies unused number. 903 + * @clk_stop_timeout: Clock stop timeout computed 904 + * @bank_switch_timeout: Bank switch timeout computed 905 + * @domain: IRQ domain 906 + * @irq_chip: IRQ chip 907 + * @debugfs: Bus debugfs (optional) 908 + * @multi_link: Store bus property that indicates if multi links 909 + * are supported. This flag is populated by drivers after reading 910 + * appropriate firmware (ACPI/DT). 888 911 */ 889 912 struct sdw_bus { 890 913 struct device *dev; 891 914 struct sdw_master_device *md; 915 + struct lock_class_key bus_lock_key; 916 + struct mutex bus_lock; 917 + struct list_head slaves; 918 + struct lock_class_key msg_lock_key; 919 + struct mutex msg_lock; 920 + struct list_head m_rt_list; 921 + struct sdw_defer defer_msg; 922 + struct sdw_bus_params params; 923 + int stream_refcount; 924 + const struct sdw_master_ops *ops; 925 + const struct sdw_master_port_ops *port_ops; 926 + struct sdw_master_prop prop; 927 + void *vendor_specific_prop; 928 + int hw_sync_min_links; 892 929 int controller_id; 893 930 unsigned int link_id; 894 931 int id; 895 - struct list_head slaves; 896 - DECLARE_BITMAP(assigned, SDW_MAX_DEVICES); 897 - struct mutex bus_lock; 898 - struct lock_class_key bus_lock_key; 899 - struct mutex msg_lock; 900 - struct lock_class_key msg_lock_key; 901 932 int (*compute_params)(struct sdw_bus *bus); 902 - const struct sdw_master_ops *ops; 903 - const struct sdw_master_port_ops *port_ops; 904 - struct sdw_bus_params params; 905 - struct sdw_master_prop prop; 906 - void *vendor_specific_prop; 907 - struct list_head m_rt_list; 933 + DECLARE_BITMAP(assigned, SDW_MAX_DEVICES); 934 + unsigned int clk_stop_timeout; 935 + u32 bank_switch_timeout; 936 + struct irq_chip irq_chip; 937 + struct irq_domain *domain; 908 938 #ifdef CONFIG_DEBUG_FS 909 939 struct dentry *debugfs; 910 940 #endif 911 - struct irq_chip irq_chip; 912 - struct irq_domain *domain; 913 - struct sdw_defer defer_msg; 914 - unsigned int clk_stop_timeout; 915 - u32 bank_switch_timeout; 916 941 bool multi_link; 917 - int hw_sync_min_links; 918 - int stream_refcount; 919 942 }; 920 943 921 944 int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent, ··· 996 1013 * @params: Stream parameters 997 1014 * @state: Current state of the stream 998 1015 * @type: Stream type PCM or PDM 1016 + * @m_rt_count: Count of Master runtime(s) in this stream 999 1017 * @master_list: List of Master runtime(s) in this stream. 1000 1018 * master_list can contain only one m_rt per Master instance 1001 1019 * for a stream 1002 - * @m_rt_count: Count of Master runtime(s) in this stream 1003 1020 */ 1004 1021 struct sdw_stream_runtime { 1005 1022 const char *name; 1006 1023 struct sdw_stream_params params; 1007 1024 enum sdw_stream_state state; 1008 1025 enum sdw_stream_type type; 1009 - struct list_head master_list; 1010 1026 int m_rt_count; 1027 + struct list_head master_list; 1011 1028 }; 1012 1029 1013 1030 struct sdw_stream_runtime *sdw_alloc_stream(const char *stream_name); ··· 1016 1033 int sdw_compute_params(struct sdw_bus *bus); 1017 1034 1018 1035 int sdw_stream_add_master(struct sdw_bus *bus, 1019 - struct sdw_stream_config *stream_config, 1020 - const struct sdw_port_config *port_config, 1021 - unsigned int num_ports, 1022 - struct sdw_stream_runtime *stream); 1036 + struct sdw_stream_config *stream_config, 1037 + const struct sdw_port_config *port_config, 1038 + unsigned int num_ports, 1039 + struct sdw_stream_runtime *stream); 1023 1040 int sdw_stream_remove_master(struct sdw_bus *bus, 1024 - struct sdw_stream_runtime *stream); 1041 + struct sdw_stream_runtime *stream); 1025 1042 int sdw_startup_stream(void *sdw_substream); 1026 1043 int sdw_prepare_stream(struct sdw_stream_runtime *stream); 1027 1044 int sdw_enable_stream(struct sdw_stream_runtime *stream);
+6
include/linux/soundwire/sdw_amd.h
··· 27 27 #define ACP_SDW0 0 28 28 #define ACP_SDW1 1 29 29 #define AMD_SDW_MAX_MANAGER_COUNT 2 30 + #define ACP63_PCI_REV_ID 0x63 30 31 31 32 struct acp_sdw_pdata { 32 33 u16 instance; 34 + u32 acp_rev; 33 35 /* mutex to protect acp common register access */ 34 36 struct mutex *acp_sdw_lock; 35 37 }; ··· 68 66 * @instance: SoundWire manager instance 69 67 * @quirks: SoundWire manager quirks 70 68 * @wake_en_mask: wake enable mask per SoundWire manager 69 + * @acp_rev: acp pci device revision id 71 70 * @clk_stopped: flag set to true when clock is stopped 72 71 * @power_mode_mask: flag interprets amd SoundWire manager power mode 73 72 * @dai_runtime_array: dai runtime array ··· 97 94 u32 quirks; 98 95 u32 wake_en_mask; 99 96 u32 power_mode_mask; 97 + u32 acp_rev; 100 98 bool clk_stopped; 101 99 102 100 struct sdw_amd_dai_runtime **dai_runtime_array; ··· 135 131 * struct sdw_amd_res - Soundwire AMD global resource structure, 136 132 * typically populated by the DSP driver/Legacy driver 137 133 * 134 + * @acp_rev: acp pci device revision id 138 135 * @addr: acp pci device resource start address 139 136 * @reg_range: ACP register range 140 137 * @link_mask: bit-wise mask listing links selected by the DSP driver/ ··· 148 143 * @acp_lock: mutex protecting acp common registers access 149 144 */ 150 145 struct sdw_amd_res { 146 + u32 acp_rev; 151 147 u32 addr; 152 148 u32 reg_range; 153 149 u32 link_mask;
+2
sound/soc/amd/ps/acp63.h
··· 231 231 * @sdw_en_stat: flag set to true when any one of the SoundWire manager instance is enabled 232 232 * @addr: pci ioremap address 233 233 * @reg_range: ACP reigister range 234 + * @acp_rev: ACP PCI revision id 234 235 * @sdw0-dma_intr_stat: DMA interrupt status array for SoundWire manager-SW0 instance 235 236 * @sdw_dma_intr_stat: DMA interrupt status array for SoundWire manager-SW1 instance 236 237 */ ··· 255 254 bool sdw_en_stat; 256 255 u32 addr; 257 256 u32 reg_range; 257 + u32 acp_rev; 258 258 u16 sdw0_dma_intr_stat[ACP63_SDW0_DMA_MAX_STREAMS]; 259 259 u16 sdw1_dma_intr_stat[ACP63_SDW1_DMA_MAX_STREAMS]; 260 260 };
+2
sound/soc/amd/ps/pci-ps.c
··· 267 267 sdw_res.acp_lock = &acp_data->acp_lock; 268 268 sdw_res.count = acp_data->info.count; 269 269 sdw_res.mmio_base = acp_data->acp63_base; 270 + sdw_res.acp_rev = acp_data->acp_rev; 270 271 sdw_res.link_mask = acp_data->info.link_mask; 271 272 ret = sdw_amd_probe(&sdw_res, &acp_data->sdw); 272 273 if (ret) ··· 576 575 } 577 576 adata->addr = addr; 578 577 adata->reg_range = ACP63_REG_END - ACP63_REG_START; 578 + adata->acp_rev = pci->revision; 579 579 pci_set_master(pci); 580 580 pci_set_drvdata(pci, adata); 581 581 mutex_init(&adata->acp_lock);
+1
sound/soc/sof/amd/acp.c
··· 693 693 sdw_res.count = acp_data->info.count; 694 694 sdw_res.link_mask = acp_data->info.link_mask; 695 695 sdw_res.mmio_base = sdev->bar[ACP_DSP_BAR]; 696 + sdw_res.acp_rev = acp_data->pci_rev; 696 697 697 698 ret = sdw_amd_probe(&sdw_res, &acp_data->sdw); 698 699 if (ret)