Commit 8c61951b authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'soundwire-5.15-rc1' of...

Merge tag 'soundwire-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire into char-misc-next

Vinod writes:

soundwire updates for 5.15-rc1

- Core has updates to support SoundWire mockup device (includes tag from
  asoc), improved error handling and slave status.

- Drivers has update on Intel driver for new quriks and better handling of
  errors and suspend routines

* tag 'soundwire-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire:
  soundwire: cadence: do not extend reset delay
  soundwire: intel: conditionally exit clock stop mode on system suspend
  soundwire: intel: skip suspend/resume/wake when link was not started
  soundwire: intel: fix potential race condition during power down
  soundwire: cadence: override PDI configurations to create loopback
  soundwire: cadence: add debugfs interface for PDI loopbacks
  soundwire: stream: don't program mockup device ports
  soundwire: bus: squelch error returned by mockup devices
  soundwire: add flag to ignore all command/control for mockup devices
  soundwire: stream: don't abort bank switch on Command_Ignored/-ENODATA
  soundwire: cadence: add paranoid check on self-clearing bits
  soundwire: dmi-quirks: add quirk for Intel 'Bishop County' NUC M15
  soundwire: bus: update Slave status in sdw_clear_slave_status
  soundwire: cadence: Remove ret variable from sdw_cdns_irq()
  soundwire: bus: filter out more -EDATA errors on clock stop
  soundwire: dmi-quirks: add ull suffix for SoundWire _ADR values
  ASoC: Intel: boards: sof_sdw: add SoundWire mockup codecs for tests
  ASoC: soc-acpi: tgl: add table for SoundWire mockup devices
  ASoC: soc-acpi: cnl: add table for SoundWire mockup devices
  ASoC: codecs: add SoundWire mockup device support
parents 96e9df33 2564a2d4
...@@ -390,7 +390,10 @@ sdw_nread_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val) ...@@ -390,7 +390,10 @@ sdw_nread_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
if (ret < 0) if (ret < 0)
return ret; return ret;
return sdw_transfer(slave->bus, &msg); ret = sdw_transfer(slave->bus, &msg);
if (slave->is_mockup_device)
ret = 0;
return ret;
} }
static int static int
...@@ -404,7 +407,10 @@ sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val) ...@@ -404,7 +407,10 @@ sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val)
if (ret < 0) if (ret < 0)
return ret; return ret;
return sdw_transfer(slave->bus, &msg); ret = sdw_transfer(slave->bus, &msg);
if (slave->is_mockup_device)
ret = 0;
return ret;
} }
int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value) int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value)
...@@ -896,6 +902,7 @@ static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num) ...@@ -896,6 +902,7 @@ static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num)
do { do {
val = sdw_bread_no_pm(bus, dev_num, SDW_SCP_STAT); val = sdw_bread_no_pm(bus, dev_num, SDW_SCP_STAT);
if (val < 0) { if (val < 0) {
if (val != -ENODATA)
dev_err(bus->dev, "SDW_SCP_STAT bread failed:%d\n", val); dev_err(bus->dev, "SDW_SCP_STAT bread failed:%d\n", val);
return val; return val;
} }
...@@ -1853,6 +1860,7 @@ void sdw_clear_slave_status(struct sdw_bus *bus, u32 request) ...@@ -1853,6 +1860,7 @@ void sdw_clear_slave_status(struct sdw_bus *bus, u32 request)
if (slave->status != SDW_SLAVE_UNATTACHED) { if (slave->status != SDW_SLAVE_UNATTACHED) {
sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED); sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
slave->first_interrupt_done = false; slave->first_interrupt_done = false;
sdw_update_slave_status(slave, SDW_SLAVE_UNATTACHED);
} }
/* keep track of request, used in pm_runtime resume */ /* keep track of request, used in pm_runtime resume */
......
...@@ -450,6 +450,40 @@ static int cdns_parity_error_injection(void *data, u64 value) ...@@ -450,6 +450,40 @@ static int cdns_parity_error_injection(void *data, u64 value)
DEFINE_DEBUGFS_ATTRIBUTE(cdns_parity_error_fops, NULL, DEFINE_DEBUGFS_ATTRIBUTE(cdns_parity_error_fops, NULL,
cdns_parity_error_injection, "%llu\n"); cdns_parity_error_injection, "%llu\n");
static int cdns_set_pdi_loopback_source(void *data, u64 value)
{
struct sdw_cdns *cdns = data;
unsigned int pdi_out_num = cdns->pcm.num_bd + cdns->pcm.num_out;
if (value > pdi_out_num)
return -EINVAL;
/* Userspace changed the hardware state behind the kernel's back */
add_taint(TAINT_USER, LOCKDEP_STILL_OK);
cdns->pdi_loopback_source = value;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(cdns_pdi_loopback_source_fops, NULL, cdns_set_pdi_loopback_source, "%llu\n");
static int cdns_set_pdi_loopback_target(void *data, u64 value)
{
struct sdw_cdns *cdns = data;
unsigned int pdi_in_num = cdns->pcm.num_bd + cdns->pcm.num_in;
if (value > pdi_in_num)
return -EINVAL;
/* Userspace changed the hardware state behind the kernel's back */
add_taint(TAINT_USER, LOCKDEP_STILL_OK);
cdns->pdi_loopback_target = value;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(cdns_pdi_loopback_target_fops, NULL, cdns_set_pdi_loopback_target, "%llu\n");
/** /**
* sdw_cdns_debugfs_init() - Cadence debugfs init * sdw_cdns_debugfs_init() - Cadence debugfs init
* @cdns: Cadence instance * @cdns: Cadence instance
...@@ -464,6 +498,16 @@ void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root) ...@@ -464,6 +498,16 @@ void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root)
debugfs_create_file("cdns-parity-error-injection", 0200, root, cdns, debugfs_create_file("cdns-parity-error-injection", 0200, root, cdns,
&cdns_parity_error_fops); &cdns_parity_error_fops);
cdns->pdi_loopback_source = -1;
cdns->pdi_loopback_target = -1;
debugfs_create_file("cdns-pdi-loopback-source", 0200, root, cdns,
&cdns_pdi_loopback_source_fops);
debugfs_create_file("cdns-pdi-loopback-target", 0200, root, cdns,
&cdns_pdi_loopback_target_fops);
} }
EXPORT_SYMBOL_GPL(sdw_cdns_debugfs_init); EXPORT_SYMBOL_GPL(sdw_cdns_debugfs_init);
...@@ -822,7 +866,6 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id) ...@@ -822,7 +866,6 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id)
{ {
struct sdw_cdns *cdns = dev_id; struct sdw_cdns *cdns = dev_id;
u32 int_status; u32 int_status;
int ret = IRQ_HANDLED;
/* Check if the link is up */ /* Check if the link is up */
if (!cdns->link_up) if (!cdns->link_up)
...@@ -900,7 +943,7 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id) ...@@ -900,7 +943,7 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id)
} }
cdns_writel(cdns, CDNS_MCP_INTSTAT, int_status); cdns_writel(cdns, CDNS_MCP_INTSTAT, int_status);
return ret; return IRQ_HANDLED;
} }
EXPORT_SYMBOL(sdw_cdns_irq); EXPORT_SYMBOL(sdw_cdns_irq);
...@@ -936,6 +979,49 @@ static void cdns_update_slave_status_work(struct work_struct *work) ...@@ -936,6 +979,49 @@ static void cdns_update_slave_status_work(struct work_struct *work)
} }
/* paranoia check to make sure self-cleared bits are indeed cleared */
void sdw_cdns_check_self_clearing_bits(struct sdw_cdns *cdns, const char *string,
bool initial_delay, int reset_iterations)
{
u32 mcp_control;
u32 mcp_config_update;
int i;
if (initial_delay)
usleep_range(1000, 1500);
mcp_control = cdns_readl(cdns, CDNS_MCP_CONTROL);
/* the following bits should be cleared immediately */
if (mcp_control & CDNS_MCP_CONTROL_CMD_RST)
dev_err(cdns->dev, "%s failed: MCP_CONTROL_CMD_RST is not cleared\n", string);
if (mcp_control & CDNS_MCP_CONTROL_SOFT_RST)
dev_err(cdns->dev, "%s failed: MCP_CONTROL_SOFT_RST is not cleared\n", string);
if (mcp_control & CDNS_MCP_CONTROL_SW_RST)
dev_err(cdns->dev, "%s failed: MCP_CONTROL_SW_RST is not cleared\n", string);
if (mcp_control & CDNS_MCP_CONTROL_CLK_STOP_CLR)
dev_err(cdns->dev, "%s failed: MCP_CONTROL_CLK_STOP_CLR is not cleared\n", string);
mcp_config_update = cdns_readl(cdns, CDNS_MCP_CONFIG_UPDATE);
if (mcp_config_update & CDNS_MCP_CONFIG_UPDATE_BIT)
dev_err(cdns->dev, "%s failed: MCP_CONFIG_UPDATE_BIT is not cleared\n", string);
i = 0;
while (mcp_control & CDNS_MCP_CONTROL_HW_RST) {
if (i == reset_iterations) {
dev_err(cdns->dev, "%s failed: MCP_CONTROL_HW_RST is not cleared\n", string);
break;
}
dev_dbg(cdns->dev, "%s: MCP_CONTROL_HW_RST is not cleared at iteration %d\n", string, i);
i++;
usleep_range(1000, 1500);
mcp_control = cdns_readl(cdns, CDNS_MCP_CONTROL);
}
}
EXPORT_SYMBOL(sdw_cdns_check_self_clearing_bits);
/* /*
* init routines * init routines
*/ */
...@@ -946,10 +1032,7 @@ static void cdns_update_slave_status_work(struct work_struct *work) ...@@ -946,10 +1032,7 @@ static void cdns_update_slave_status_work(struct work_struct *work)
*/ */
int sdw_cdns_exit_reset(struct sdw_cdns *cdns) int sdw_cdns_exit_reset(struct sdw_cdns *cdns)
{ {
/* program maximum length reset to be safe */ /* keep reset delay unchanged to 4096 cycles */
cdns_updatel(cdns, CDNS_MCP_CONTROL,
CDNS_MCP_CONTROL_RST_DELAY,
CDNS_MCP_CONTROL_RST_DELAY);
/* use hardware generated reset */ /* use hardware generated reset */
cdns_updatel(cdns, CDNS_MCP_CONTROL, cdns_updatel(cdns, CDNS_MCP_CONTROL,
...@@ -1213,6 +1296,8 @@ int sdw_cdns_init(struct sdw_cdns *cdns) ...@@ -1213,6 +1296,8 @@ int sdw_cdns_init(struct sdw_cdns *cdns)
cdns_init_clock_ctrl(cdns); cdns_init_clock_ctrl(cdns);
sdw_cdns_check_self_clearing_bits(cdns, __func__, false, 0);
/* reset msg_count to default value of FIFOLEVEL */ /* reset msg_count to default value of FIFOLEVEL */
cdns->msg_count = cdns_readl(cdns, CDNS_MCP_FIFOLEVEL); cdns->msg_count = cdns_readl(cdns, CDNS_MCP_FIFOLEVEL);
...@@ -1286,20 +1371,37 @@ static int cdns_port_params(struct sdw_bus *bus, ...@@ -1286,20 +1371,37 @@ static int cdns_port_params(struct sdw_bus *bus,
struct sdw_port_params *p_params, unsigned int bank) struct sdw_port_params *p_params, unsigned int bank)
{ {
struct sdw_cdns *cdns = bus_to_cdns(bus); struct sdw_cdns *cdns = bus_to_cdns(bus);
int dpn_config = 0, dpn_config_off; int dpn_config_off_source;
int dpn_config_off_target;
int target_num = p_params->num;
int source_num = p_params->num;
bool override = false;
int dpn_config;
if (target_num == cdns->pdi_loopback_target &&
cdns->pdi_loopback_source != -1) {
source_num = cdns->pdi_loopback_source;
override = true;
}
if (bank) if (bank) {
dpn_config_off = CDNS_DPN_B1_CONFIG(p_params->num); dpn_config_off_source = CDNS_DPN_B1_CONFIG(source_num);
else dpn_config_off_target = CDNS_DPN_B1_CONFIG(target_num);
dpn_config_off = CDNS_DPN_B0_CONFIG(p_params->num); } else {
dpn_config_off_source = CDNS_DPN_B0_CONFIG(source_num);
dpn_config_off_target = CDNS_DPN_B0_CONFIG(target_num);
}
dpn_config = cdns_readl(cdns, dpn_config_off); dpn_config = cdns_readl(cdns, dpn_config_off_source);
u32p_replace_bits(&dpn_config, (p_params->bps - 1), CDNS_DPN_CONFIG_WL); /* use port params if there is no loopback, otherwise use source as is */
if (!override) {
u32p_replace_bits(&dpn_config, p_params->bps - 1, CDNS_DPN_CONFIG_WL);
u32p_replace_bits(&dpn_config, p_params->flow_mode, CDNS_DPN_CONFIG_PORT_FLOW); u32p_replace_bits(&dpn_config, p_params->flow_mode, CDNS_DPN_CONFIG_PORT_FLOW);
u32p_replace_bits(&dpn_config, p_params->data_mode, CDNS_DPN_CONFIG_PORT_DAT); u32p_replace_bits(&dpn_config, p_params->data_mode, CDNS_DPN_CONFIG_PORT_DAT);
}
cdns_writel(cdns, dpn_config_off, dpn_config); cdns_writel(cdns, dpn_config_off_target, dpn_config);
return 0; return 0;
} }
...@@ -1309,11 +1411,27 @@ static int cdns_transport_params(struct sdw_bus *bus, ...@@ -1309,11 +1411,27 @@ static int cdns_transport_params(struct sdw_bus *bus,
enum sdw_reg_bank bank) enum sdw_reg_bank bank)
{ {
struct sdw_cdns *cdns = bus_to_cdns(bus); struct sdw_cdns *cdns = bus_to_cdns(bus);
int dpn_offsetctrl = 0, dpn_offsetctrl_off; int dpn_config;
int dpn_config = 0, dpn_config_off; int dpn_config_off_source;
int dpn_hctrl = 0, dpn_hctrl_off; int dpn_config_off_target;
int num = t_params->port_num; int dpn_hctrl;
int dpn_samplectrl_off; int dpn_hctrl_off_source;
int dpn_hctrl_off_target;
int dpn_offsetctrl;
int dpn_offsetctrl_off_source;
int dpn_offsetctrl_off_target;
int dpn_samplectrl;
int dpn_samplectrl_off_source;
int dpn_samplectrl_off_target;
int source_num = t_params->port_num;
int target_num = t_params->port_num;
bool override = false;
if (target_num == cdns->pdi_loopback_target &&
cdns->pdi_loopback_source != -1) {
source_num = cdns->pdi_loopback_source;
override = true;
}
/* /*
* Note: Only full data port is supported on the Master side for * Note: Only full data port is supported on the Master side for
...@@ -1321,32 +1439,59 @@ static int cdns_transport_params(struct sdw_bus *bus, ...@@ -1321,32 +1439,59 @@ static int cdns_transport_params(struct sdw_bus *bus,
*/ */
if (bank) { if (bank) {
dpn_config_off = CDNS_DPN_B1_CONFIG(num); dpn_config_off_source = CDNS_DPN_B1_CONFIG(source_num);
dpn_samplectrl_off = CDNS_DPN_B1_SAMPLE_CTRL(num); dpn_hctrl_off_source = CDNS_DPN_B1_HCTRL(source_num);
dpn_hctrl_off = CDNS_DPN_B1_HCTRL(num); dpn_offsetctrl_off_source = CDNS_DPN_B1_OFFSET_CTRL(source_num);
dpn_offsetctrl_off = CDNS_DPN_B1_OFFSET_CTRL(num); dpn_samplectrl_off_source = CDNS_DPN_B1_SAMPLE_CTRL(source_num);
dpn_config_off_target = CDNS_DPN_B1_CONFIG(target_num);
dpn_hctrl_off_target = CDNS_DPN_B1_HCTRL(target_num);
dpn_offsetctrl_off_target = CDNS_DPN_B1_OFFSET_CTRL(target_num);
dpn_samplectrl_off_target = CDNS_DPN_B1_SAMPLE_CTRL(target_num);
} else { } else {
dpn_config_off = CDNS_DPN_B0_CONFIG(num); dpn_config_off_source = CDNS_DPN_B0_CONFIG(source_num);
dpn_samplectrl_off = CDNS_DPN_B0_SAMPLE_CTRL(num); dpn_hctrl_off_source = CDNS_DPN_B0_HCTRL(source_num);
dpn_hctrl_off = CDNS_DPN_B0_HCTRL(num); dpn_offsetctrl_off_source = CDNS_DPN_B0_OFFSET_CTRL(source_num);
dpn_offsetctrl_off = CDNS_DPN_B0_OFFSET_CTRL(num); dpn_samplectrl_off_source = CDNS_DPN_B0_SAMPLE_CTRL(source_num);
dpn_config_off_target = CDNS_DPN_B0_CONFIG(target_num);
dpn_hctrl_off_target = CDNS_DPN_B0_HCTRL(target_num);
dpn_offsetctrl_off_target = CDNS_DPN_B0_OFFSET_CTRL(target_num);
dpn_samplectrl_off_target = CDNS_DPN_B0_SAMPLE_CTRL(target_num);
} }
dpn_config = cdns_readl(cdns, dpn_config_off); dpn_config = cdns_readl(cdns, dpn_config_off_source);
if (!override) {
u32p_replace_bits(&dpn_config, t_params->blk_grp_ctrl, CDNS_DPN_CONFIG_BGC); u32p_replace_bits(&dpn_config, t_params->blk_grp_ctrl, CDNS_DPN_CONFIG_BGC);
u32p_replace_bits(&dpn_config, t_params->blk_pkg_mode, CDNS_DPN_CONFIG_BPM); u32p_replace_bits(&dpn_config, t_params->blk_pkg_mode, CDNS_DPN_CONFIG_BPM);
cdns_writel(cdns, dpn_config_off, dpn_config); }
cdns_writel(cdns, dpn_config_off_target, dpn_config);
if (!override) {
dpn_offsetctrl = 0;
u32p_replace_bits(&dpn_offsetctrl, t_params->offset1, CDNS_DPN_OFFSET_CTRL_1); u32p_replace_bits(&dpn_offsetctrl, t_params->offset1, CDNS_DPN_OFFSET_CTRL_1);
u32p_replace_bits(&dpn_offsetctrl, t_params->offset2, CDNS_DPN_OFFSET_CTRL_2); u32p_replace_bits(&dpn_offsetctrl, t_params->offset2, CDNS_DPN_OFFSET_CTRL_2);
cdns_writel(cdns, dpn_offsetctrl_off, dpn_offsetctrl); } else {
dpn_offsetctrl = cdns_readl(cdns, dpn_offsetctrl_off_source);
}
cdns_writel(cdns, dpn_offsetctrl_off_target, dpn_offsetctrl);
if (!override) {
dpn_hctrl = 0;
u32p_replace_bits(&dpn_hctrl, t_params->hstart, CDNS_DPN_HCTRL_HSTART); u32p_replace_bits(&dpn_hctrl, t_params->hstart, CDNS_DPN_HCTRL_HSTART);
u32p_replace_bits(&dpn_hctrl, t_params->hstop, CDNS_DPN_HCTRL_HSTOP); u32p_replace_bits(&dpn_hctrl, t_params->hstop, CDNS_DPN_HCTRL_HSTOP);
u32p_replace_bits(&dpn_hctrl, t_params->lane_ctrl, CDNS_DPN_HCTRL_LCTRL); u32p_replace_bits(&dpn_hctrl, t_params->lane_ctrl, CDNS_DPN_HCTRL_LCTRL);
} else {
dpn_hctrl = cdns_readl(cdns, dpn_hctrl_off_source);
}
cdns_writel(cdns, dpn_hctrl_off_target, dpn_hctrl);
cdns_writel(cdns, dpn_hctrl_off, dpn_hctrl); if (!override)
cdns_writel(cdns, dpn_samplectrl_off, (t_params->sample_interval - 1)); dpn_samplectrl = t_params->sample_interval - 1;
else
dpn_samplectrl = cdns_readl(cdns, dpn_samplectrl_off_source);
cdns_writel(cdns, dpn_samplectrl_off_target, dpn_samplectrl);
return 0; return 0;
} }
...@@ -1397,6 +1542,8 @@ int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake) ...@@ -1397,6 +1542,8 @@ int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake)
struct sdw_slave *slave; struct sdw_slave *slave;
int ret; int ret;
sdw_cdns_check_self_clearing_bits(cdns, __func__, false, 0);
/* Check suspend status */ /* Check suspend status */
if (sdw_cdns_is_clock_stop(cdns)) { if (sdw_cdns_is_clock_stop(cdns)) {
dev_dbg(cdns->dev, "Clock is already stopped\n"); dev_dbg(cdns->dev, "Clock is already stopped\n");
......
...@@ -129,6 +129,9 @@ struct sdw_cdns { ...@@ -129,6 +129,9 @@ struct sdw_cdns {
struct sdw_cdns_streams pcm; struct sdw_cdns_streams pcm;
struct sdw_cdns_streams pdm; struct sdw_cdns_streams pdm;
int pdi_loopback_source;
int pdi_loopback_target;
void __iomem *registers; void __iomem *registers;
bool link_up; bool link_up;
...@@ -184,4 +187,8 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params); ...@@ -184,4 +187,8 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params);
int cdns_set_sdw_stream(struct snd_soc_dai *dai, int cdns_set_sdw_stream(struct snd_soc_dai *dai,
void *stream, bool pcm, int direction); void *stream, bool pcm, int direction);
void sdw_cdns_check_self_clearing_bits(struct sdw_cdns *cdns, const char *string,
bool initial_delay, int reset_iterations);
#endif /* __SDW_CADENCE_H */ #endif /* __SDW_CADENCE_H */
...@@ -16,18 +16,18 @@ struct adr_remap { ...@@ -16,18 +16,18 @@ struct adr_remap {
}; };
/* /*
* HP Spectre 360 Convertible devices do not expose the correct _ADR * Some TigerLake devices based on an initial Intel BIOS do not expose
* in the DSDT. * the correct _ADR in the DSDT.
* Remap the bad _ADR values to the ones reported by hardware * Remap the bad _ADR values to the ones reported by hardware
*/ */
static const struct adr_remap hp_spectre_360[] = { static const struct adr_remap intel_tgl_bios[] = {
{ {
0x000010025D070100, 0x000010025D070100ull,
0x000020025D071100 0x000020025D071100ull
}, },
{ {
0x000110025d070100, 0x000110025d070100ull,
0x000120025D130800 0x000120025D130800ull
}, },
{} {}
}; };
...@@ -39,18 +39,18 @@ static const struct adr_remap hp_spectre_360[] = { ...@@ -39,18 +39,18 @@ static const struct adr_remap hp_spectre_360[] = {
static const struct adr_remap dell_sku_0A3E[] = { static const struct adr_remap dell_sku_0A3E[] = {
/* rt715 on link0 */ /* rt715 on link0 */
{ {
0x00020025d071100, 0x00020025d071100ull,
0x00021025d071500 0x00021025d071500ull
}, },
/* rt711 on link1 */ /* rt711 on link1 */
{ {
0x000120025d130800, 0x000120025d130800ull,
0x000120025d071100, 0x000120025d071100ull,
}, },
/* rt1308 on link2 */ /* rt1308 on link2 */
{ {
0x000220025d071500, 0x000220025d071500ull,
0x000220025d130800 0x000220025d130800ull
}, },
{} {}
}; };
...@@ -61,7 +61,15 @@ static const struct dmi_system_id adr_remap_quirk_table[] = { ...@@ -61,7 +61,15 @@ static const struct dmi_system_id adr_remap_quirk_table[] = {
DMI_MATCH(DMI_SYS_VENDOR, "HP"), DMI_MATCH(DMI_SYS_VENDOR, "HP"),
DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible"), DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible"),
}, },
.driver_data = (void *)hp_spectre_360, .driver_data = (void *)intel_tgl_bios,
},
{
/* quirk used for NUC15 'Bishop County' LAPBC510 and LAPBC710 skews */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Intel(R) Client Systems"),
DMI_MATCH(DMI_PRODUCT_NAME, "LAPBC"),
},
.driver_data = (void *)intel_tgl_bios,
}, },
{ {
.matches = { .matches = {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "intel.h" #include "intel.h"
#define INTEL_MASTER_SUSPEND_DELAY_MS 3000 #define INTEL_MASTER_SUSPEND_DELAY_MS 3000
#define INTEL_MASTER_RESET_ITERATIONS 10
/* /*
* debug/config flags for the Intel SoundWire Master. * debug/config flags for the Intel SoundWire Master.
...@@ -537,12 +538,14 @@ static int intel_link_power_down(struct sdw_intel *sdw) ...@@ -537,12 +538,14 @@ static int intel_link_power_down(struct sdw_intel *sdw)
mutex_lock(sdw->link_res->shim_lock); mutex_lock(sdw->link_res->shim_lock);
intel_shim_master_ip_to_glue(sdw);
if (!(*shim_mask & BIT(link_id))) if (!(*shim_mask & BIT(link_id)))
dev_err(sdw->cdns.dev, dev_err(sdw->cdns.dev,
"%s: Unbalanced power-up/down calls\n", __func__); "%s: Unbalanced power-up/down calls\n", __func__);
sdw->cdns.link_up = false;
intel_shim_master_ip_to_glue(sdw);
*shim_mask &= ~BIT(link_id); *shim_mask &= ~BIT(link_id);
if (!*shim_mask) { if (!*shim_mask) {
...@@ -559,18 +562,19 @@ static int intel_link_power_down(struct sdw_intel *sdw) ...@@ -559,18 +562,19 @@ static int intel_link_power_down(struct sdw_intel *sdw)
link_control &= spa_mask; link_control &= spa_mask;
ret = intel_clear_bit(shim, SDW_SHIM_LCTL, link_control, cpa_mask); ret = intel_clear_bit(shim, SDW_SHIM_LCTL, link_control, cpa_mask);
}
mutex_unlock(sdw->link_res->shim_lock);
if (ret < 0) { if (ret < 0) {
dev_err(sdw->cdns.dev, "%s: could not power down link\n", __func__); dev_err(sdw->cdns.dev, "%s: could not power down link\n", __func__);
return ret; /*
* we leave the sdw->cdns.link_up flag as false since we've disabled
* the link at this point and cannot handle interrupts any longer.
*/
}
} }
sdw->cdns.link_up = false; mutex_unlock(sdw->link_res->shim_lock);
return 0;
return ret;
} }
static void intel_shim_sync_arm(struct sdw_intel *sdw) static void intel_shim_sync_arm(struct sdw_intel *sdw)
...@@ -1467,6 +1471,8 @@ int intel_link_startup(struct auxiliary_device *auxdev) ...@@ -1467,6 +1471,8 @@ int intel_link_startup(struct auxiliary_device *auxdev)
goto err_interrupt; goto err_interrupt;
} }
} }
sdw_cdns_check_self_clearing_bits(cdns, __func__,
true, INTEL_MASTER_RESET_ITERATIONS);
/* Register DAIs */ /* Register DAIs */
ret = intel_register_dai(sdw); ret = intel_register_dai(sdw);
...@@ -1519,6 +1525,7 @@ int intel_link_startup(struct auxiliary_device *auxdev) ...@@ -1519,6 +1525,7 @@ int intel_link_startup(struct auxiliary_device *auxdev)
if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE)) if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE))
pm_runtime_idle(dev); pm_runtime_idle(dev);
sdw->startup_done = true;
return 0; return 0;
err_interrupt: err_interrupt:
...@@ -1558,8 +1565,9 @@ int intel_link_process_wakeen_event(struct auxiliary_device *auxdev) ...@@ -1558,8 +1565,9 @@ int intel_link_process_wakeen_event(struct auxiliary_device *auxdev)
sdw = dev_get_drvdata(dev); sdw = dev_get_drvdata(dev);
bus = &sdw->cdns.bus; bus = &sdw->cdns.bus;
if (bus->prop.hw_disabled) { if (bus->prop.hw_disabled || !sdw->startup_done) {
dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", bus->link_id); dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
bus->link_id);
return 0; return 0;
} }
...@@ -1588,6 +1596,87 @@ int intel_link_process_wakeen_event(struct auxiliary_device *auxdev) ...@@ -1588,6 +1596,87 @@ int intel_link_process_wakeen_event(struct auxiliary_device *auxdev)
* PM calls * PM calls
*/ */
static int intel_resume_child_device(struct device *dev, void *data)
{
int ret;
struct sdw_slave *slave = dev_to_sdw_dev(dev);
if (!slave->probed) {
dev_dbg(dev, "%s: skipping device, no probed driver\n", __func__);
return 0;
}
if (!slave->dev_num_sticky) {
dev_dbg(dev, "%s: skipping device, never detected on bus\n", __func__);
return 0;
}
ret = pm_request_resume(dev);
if (ret < 0)
dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret);
return ret;
}
static int __maybe_unused intel_pm_prepare(struct device *dev)
{
struct sdw_cdns *cdns = dev_get_drvdata(dev);
struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_bus *bus = &cdns->bus;
u32 clock_stop_quirks;
int ret = 0;
if (bus->prop.hw_disabled || !sdw->startup_done) {
dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
bus->link_id);
return 0;
}
clock_stop_quirks = sdw->link_res->clock_stop_quirks;
if (pm_runtime_suspended(dev) &&
pm_runtime_suspended(dev->parent) &&
((clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) ||
!clock_stop_quirks)) {
/*
* if we've enabled clock stop, and the parent is suspended, the SHIM registers
* are not accessible and the shim wake cannot be disabled.
* The only solution is to resume the entire bus to full power
*/
/*
* If any operation in this block fails, we keep going since we don't want
* to prevent system suspend from happening and errors should be recoverable
* on resume.
*/
/*
* first resume the device for this link. This will also by construction
* resume the PCI parent device.
*/
ret = pm_request_resume(dev);
if (ret < 0) {
dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret);
return 0;
}
/*
* Continue resuming the entire bus (parent + child devices) to exit
* the clock stop mode. If there are no devices connected on this link
* this is a no-op.
* The resume to full power could have been implemented with a .prepare
* step in SoundWire codec drivers. This would however require a lot
* of code to handle an Intel-specific corner case. It is simpler in
* practice to add a loop at the link level.
*/
ret = device_for_each_child(bus->dev, NULL, intel_resume_child_device);
if (ret < 0)
dev_err(dev, "%s: intel_resume_child_device failed: %d\n", __func__, ret);
}
return 0;
}
static int __maybe_unused intel_suspend(struct device *dev) static int __maybe_unused intel_suspend(struct device *dev)
{ {
struct sdw_cdns *cdns = dev_get_drvdata(dev); struct sdw_cdns *cdns = dev_get_drvdata(dev);
...@@ -1596,8 +1685,8 @@ static int __maybe_unused intel_suspend(struct device *dev) ...@@ -1596,8 +1685,8 @@ static int __maybe_unused intel_suspend(struct device *dev)
u32 clock_stop_quirks; u32 clock_stop_quirks;
int ret; int ret;
if (bus->prop.hw_disabled) { if (bus->prop.hw_disabled || !sdw->startup_done) {
dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
bus->link_id); bus->link_id);
return 0; return 0;
} }
...@@ -1607,20 +1696,19 @@ static int __maybe_unused intel_suspend(struct device *dev) ...@@ -1607,20 +1696,19 @@ static int __maybe_unused intel_suspend(struct device *dev)
clock_stop_quirks = sdw->link_res->clock_stop_quirks; clock_stop_quirks = sdw->link_res->clock_stop_quirks;
if ((clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET || if ((clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) ||
!clock_stop_quirks) && !clock_stop_quirks) {
!pm_runtime_suspended(dev->parent)) {
if (pm_runtime_suspended(dev->parent)) {
/* /*
* if we've enabled clock stop, and the parent * paranoia check: this should not happen with the .prepare
* is still active, disable shim wake. The * resume to full power
* SHIM registers are not accessible if the
* parent is already pm_runtime suspended so
* it's too late to change that configuration
*/ */
dev_err(dev, "%s: invalid config: parent is suspended\n", __func__);
} else {
intel_shim_wake(sdw, false); intel_shim_wake(sdw, false);
} }
}
return 0; return 0;
} }
...@@ -1650,8 +1738,8 @@ static int __maybe_unused intel_suspend_runtime(struct device *dev) ...@@ -1650,8 +1738,8 @@ static int __maybe_unused intel_suspend_runtime(struct device *dev)
u32 clock_stop_quirks; u32 clock_stop_quirks;
int ret; int ret;
if (bus->prop.hw_disabled) { if (bus->prop.hw_disabled || !sdw->startup_done) {
dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
bus->link_id); bus->link_id);
return 0; return 0;
} }
...@@ -1715,8 +1803,8 @@ static int __maybe_unused intel_resume(struct device *dev) ...@@ -1715,8 +1803,8 @@ static int __maybe_unused intel_resume(struct device *dev)
bool multi_link; bool multi_link;
int ret; int ret;
if (bus->prop.hw_disabled) { if (bus->prop.hw_disabled || !sdw->startup_done) {
dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
bus->link_id); bus->link_id);
return 0; return 0;
} }
...@@ -1783,6 +1871,8 @@ static int __maybe_unused intel_resume(struct device *dev) ...@@ -1783,6 +1871,8 @@ static int __maybe_unused intel_resume(struct device *dev)
return ret; return ret;
} }
} }
sdw_cdns_check_self_clearing_bits(cdns, __func__,
true, INTEL_MASTER_RESET_ITERATIONS);
/* /*
* after system resume, the pm_runtime suspend() may kick in * after system resume, the pm_runtime suspend() may kick in
...@@ -1811,8 +1901,8 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) ...@@ -1811,8 +1901,8 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
int status; int status;
int ret; int ret;
if (bus->prop.hw_disabled) { if (bus->prop.hw_disabled || !sdw->startup_done) {
dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
bus->link_id); bus->link_id);
return 0; return 0;
} }
...@@ -1867,6 +1957,9 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) ...@@ -1867,6 +1957,9 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
return ret; return ret;
} }
} }
sdw_cdns_check_self_clearing_bits(cdns, "intel_resume_runtime TEARDOWN",
true, INTEL_MASTER_RESET_ITERATIONS);
} else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) { } else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) {
ret = intel_init(sdw); ret = intel_init(sdw);
if (ret) { if (ret) {
...@@ -1940,6 +2033,9 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) ...@@ -1940,6 +2033,9 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
} }
} }
} }
sdw_cdns_check_self_clearing_bits(cdns, "intel_resume_runtime BUS_RESET",
true, INTEL_MASTER_RESET_ITERATIONS);
} else if (!clock_stop_quirks) { } else if (!clock_stop_quirks) {
clock_stop0 = sdw_cdns_is_clock_stop(&sdw->cdns); clock_stop0 = sdw_cdns_is_clock_stop(&sdw->cdns);
...@@ -1963,6 +2059,9 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) ...@@ -1963,6 +2059,9 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
dev_err(dev, "unable to resume master during resume\n"); dev_err(dev, "unable to resume master during resume\n");
return ret; return ret;
} }
sdw_cdns_check_self_clearing_bits(cdns, "intel_resume_runtime no_quirks",
true, INTEL_MASTER_RESET_ITERATIONS);
} else { } else {
dev_err(dev, "%s clock_stop_quirks %x unsupported\n", dev_err(dev, "%s clock_stop_quirks %x unsupported\n",
__func__, clock_stop_quirks); __func__, clock_stop_quirks);
...@@ -1973,6 +2072,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) ...@@ -1973,6 +2072,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
} }
static const struct dev_pm_ops intel_pm = { static const struct dev_pm_ops intel_pm = {
.prepare = intel_pm_prepare,
SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume) SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)
SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL) SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL)
}; };
......
...@@ -41,6 +41,7 @@ struct sdw_intel { ...@@ -41,6 +41,7 @@ struct sdw_intel {
struct sdw_cdns cdns; struct sdw_cdns cdns;
int instance; int instance;
struct sdw_intel_link_res *link_res; struct sdw_intel_link_res *link_res;
bool startup_done;
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct dentry *debugfs; struct dentry *debugfs;
#endif #endif
......
...@@ -133,6 +133,9 @@ static int sdw_program_slave_port_params(struct sdw_bus *bus, ...@@ -133,6 +133,9 @@ static int sdw_program_slave_port_params(struct sdw_bus *bus,
int ret; int ret;
u8 wbuf; u8 wbuf;
if (s_rt->slave->is_mockup_device)
return 0;
dpn_prop = sdw_get_slave_dpn_prop(s_rt->slave, dpn_prop = sdw_get_slave_dpn_prop(s_rt->slave,
s_rt->direction, s_rt->direction,
t_params->port_num); t_params->port_num);
...@@ -697,7 +700,7 @@ static int sdw_bank_switch(struct sdw_bus *bus, int m_rt_count) ...@@ -697,7 +700,7 @@ static int sdw_bank_switch(struct sdw_bus *bus, int m_rt_count)
else else
ret = sdw_transfer(bus, wr_msg); ret = sdw_transfer(bus, wr_msg);
if (ret < 0) { if (ret < 0 && ret != -ENODATA) {
dev_err(bus->dev, "Slave frame_ctrl reg write failed\n"); dev_err(bus->dev, "Slave frame_ctrl reg write failed\n");
goto error; goto error;
} }
......
...@@ -661,6 +661,8 @@ struct sdw_slave_ops { ...@@ -661,6 +661,8 @@ struct sdw_slave_ops {
* initialized * initialized
* @first_interrupt_done: status flag tracking if the interrupt handling * @first_interrupt_done: status flag tracking if the interrupt handling
* for a Slave happens for the first time after enumeration * for a Slave happens for the first time after enumeration
* @is_mockup_device: status flag used to squelch errors in the command/control
* protocol for SoundWire mockup devices
*/ */
struct sdw_slave { struct sdw_slave {
struct sdw_slave_id id; struct sdw_slave_id id;
...@@ -683,6 +685,7 @@ struct sdw_slave { ...@@ -683,6 +685,7 @@ struct sdw_slave {
struct completion initialization_complete; struct completion initialization_complete;
u32 unattach_request; u32 unattach_request;
bool first_interrupt_done; bool first_interrupt_done;
bool is_mockup_device;
}; };
#define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev) #define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev)
......
...@@ -187,6 +187,7 @@ config SND_SOC_ALL_CODECS ...@@ -187,6 +187,7 @@ config SND_SOC_ALL_CODECS
imply SND_SOC_RT715_SDCA_SDW imply SND_SOC_RT715_SDCA_SDW
imply SND_SOC_RT1308_SDW imply SND_SOC_RT1308_SDW
imply SND_SOC_RT1316_SDW imply SND_SOC_RT1316_SDW
imply SND_SOC_SDW_MOCKUP
imply SND_SOC_SGTL5000 imply SND_SOC_SGTL5000
imply SND_SOC_SI476X imply SND_SOC_SI476X
imply SND_SOC_SIMPLE_AMPLIFIER imply SND_SOC_SIMPLE_AMPLIFIER
...@@ -1287,6 +1288,23 @@ config SND_SOC_RT715_SDCA_SDW ...@@ -1287,6 +1288,23 @@ config SND_SOC_RT715_SDCA_SDW
select REGMAP_SOUNDWIRE select REGMAP_SOUNDWIRE
select REGMAP_SOUNDWIRE_MBQ select REGMAP_SOUNDWIRE_MBQ
config SND_SOC_SDW_MOCKUP
tristate "SoundWire mockup codec"
depends on EXPERT
depends on SOUNDWIRE
help
This option enables a SoundWire mockup codec that does not drive the
bus, take part in the command/command protocol or generate data on a
Source port.
This option is only intended to be used for tests on a device
with a connector, in combination with a bus analyzer, or to test new
topologies that differ from the actual hardware layout.
This mockup device could be totally virtual but could also be a
real physical one with one key restriction: it is not allowed by the
SoundWire specification to be configured via a sideband mechanism and
generate audio data for capture. However, nothing prevents such a
peripheral device from snooping the bus.
#Freescale sgtl5000 codec #Freescale sgtl5000 codec
config SND_SOC_SGTL5000 config SND_SOC_SGTL5000
tristate "Freescale SGTL5000 CODEC" tristate "Freescale SGTL5000 CODEC"
......
...@@ -203,6 +203,7 @@ snd-soc-rt711-objs := rt711.o rt711-sdw.o ...@@ -203,6 +203,7 @@ snd-soc-rt711-objs := rt711.o rt711-sdw.o
snd-soc-rt711-sdca-objs := rt711-sdca.o rt711-sdca-sdw.o snd-soc-rt711-sdca-objs := rt711-sdca.o rt711-sdca-sdw.o
snd-soc-rt715-objs := rt715.o rt715-sdw.o snd-soc-rt715-objs := rt715.o rt715-sdw.o
snd-soc-rt715-sdca-objs := rt715-sdca.o rt715-sdca-sdw.o snd-soc-rt715-sdca-objs := rt715-sdca.o rt715-sdca-sdw.o
snd-soc-sdw-mockup-objs := sdw-mockup.o
snd-soc-sgtl5000-objs := sgtl5000.o snd-soc-sgtl5000-objs := sgtl5000.o
snd-soc-alc5623-objs := alc5623.o snd-soc-alc5623-objs := alc5623.o
snd-soc-alc5632-objs := alc5632.o snd-soc-alc5632-objs := alc5632.o
...@@ -530,6 +531,7 @@ obj-$(CONFIG_SND_SOC_RT711) += snd-soc-rt711.o ...@@ -530,6 +531,7 @@ obj-$(CONFIG_SND_SOC_RT711) += snd-soc-rt711.o
obj-$(CONFIG_SND_SOC_RT711_SDCA_SDW) += snd-soc-rt711-sdca.o obj-$(CONFIG_SND_SOC_RT711_SDCA_SDW) += snd-soc-rt711-sdca.o
obj-$(CONFIG_SND_SOC_RT715) += snd-soc-rt715.o obj-$(CONFIG_SND_SOC_RT715) += snd-soc-rt715.o
obj-$(CONFIG_SND_SOC_RT715_SDCA_SDW) += snd-soc-rt715-sdca.o obj-$(CONFIG_SND_SOC_RT715_SDCA_SDW) += snd-soc-rt715-sdca.o
obj-$(CONFIG_SND_SOC_SDW_MOCKUP) += snd-soc-sdw-mockup.o
obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o
obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o
obj-$(CONFIG_SND_SOC_SIGMADSP_I2C) += snd-soc-sigmadsp-i2c.o obj-$(CONFIG_SND_SOC_SIGMADSP_I2C) += snd-soc-sigmadsp-i2c.o
......
// SPDX-License-Identifier: GPL-2.0-only
//
// sdw-mockup.c -- a mockup SoundWire codec for tests where only the host
// drives the bus.
//
// Copyright(c) 2021 Intel Corporation
//
//
#include <linux/device.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_type.h>
#include <linux/soundwire/sdw_registers.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
struct sdw_mockup_priv {
struct sdw_slave *slave;
};
struct sdw_stream_data {
struct sdw_stream_runtime *sdw_stream;
};
static int sdw_mockup_component_probe(struct snd_soc_component *component)
{
return 0;
}
static void sdw_mockup_component_remove(struct snd_soc_component *component)
{
}
static const struct snd_soc_component_driver snd_soc_sdw_mockup_component = {
.probe = sdw_mockup_component_probe,
.remove = sdw_mockup_component_remove,
};
static int sdw_mockup_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
int direction)
{
struct sdw_stream_data *stream;
if (!sdw_stream)
return 0;
stream = kzalloc(sizeof(*stream), GFP_KERNEL);
if (!stream)
return -ENOMEM;
stream->sdw_stream = sdw_stream;
/* Use tx_mask or rx_mask to configure stream tag and set dma_data */
if (direction == SNDRV_PCM_STREAM_PLAYBACK)
dai->playback_dma_data = stream;
else
dai->capture_dma_data = stream;
return 0;
}
static void sdw_mockup_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct sdw_stream_data *stream;
stream = snd_soc_dai_get_dma_data(dai, substream);
snd_soc_dai_set_dma_data(dai, substream, NULL);
kfree(stream);
}
static int sdw_mockup_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct sdw_mockup_priv *sdw_mockup = snd_soc_component_get_drvdata(component);
struct sdw_stream_config stream_config;
struct sdw_port_config port_config;
enum sdw_data_direction direction;
struct sdw_stream_data *stream;
int num_channels;
int port;
int ret;
stream = snd_soc_dai_get_dma_data(dai, substream);
if (!stream)
return -EINVAL;
if (!sdw_mockup->slave)
return -EINVAL;
/* SoundWire specific configuration */
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
direction = SDW_DATA_DIR_RX;
port = 1;
} else {
direction = SDW_DATA_DIR_TX;
port = 8;
}
stream_config.frame_rate = params_rate(params);
stream_config.ch_count = params_channels(params);
stream_config.bps = snd_pcm_format_width(params_format(params));
stream_config.direction = direction;
num_channels = params_channels(params);
port_config.ch_mask = (1 << num_channels) - 1;
port_config.num = port;
ret = sdw_stream_add_slave(sdw_mockup->slave, &stream_config,
&port_config, 1, stream->sdw_stream);
if (ret)
dev_err(dai->dev, "Unable to configure port\n");
return ret;
}
static int sdw_mockup_pcm_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct sdw_mockup_priv *sdw_mockup = snd_soc_component_get_drvdata(component);
struct sdw_stream_data *stream =
snd_soc_dai_get_dma_data(dai, substream);
if (!sdw_mockup->slave)
return -EINVAL;
sdw_stream_remove_slave(sdw_mockup->slave, stream->sdw_stream);
return 0;
}
static const struct snd_soc_dai_ops sdw_mockup_ops = {
.hw_params = sdw_mockup_pcm_hw_params,
.hw_free = sdw_mockup_pcm_hw_free,
.set_sdw_stream = sdw_mockup_set_sdw_stream,
.shutdown = sdw_mockup_shutdown,
};
static struct snd_soc_dai_driver sdw_mockup_dai[] = {
{
.name = "sdw-mockup-aif1",
.id = 1,
.playback = {
.stream_name = "DP1 Playback",
.channels_min = 1,
.channels_max = 2,
},
.capture = {
.stream_name = "DP8 Capture",
.channels_min = 1,
.channels_max = 2,
},
.ops = &sdw_mockup_ops,
},
};
static int sdw_mockup_update_status(struct sdw_slave *slave,
enum sdw_slave_status status)
{
return 0;
}
static int sdw_mockup_read_prop(struct sdw_slave *slave)
{
struct sdw_slave_prop *prop = &slave->prop;
int nval;
int i, j;
u32 bit;
unsigned long addr;
struct sdw_dpn_prop *dpn;
prop->paging_support = false;
/*
* first we need to allocate memory for set bits in port lists
* the port allocation is completely arbitrary:
* DP0 is not supported
* DP1 is sink
* DP8 is source
*/
prop->source_ports = BIT(8);
prop->sink_ports = BIT(1);
nval = hweight32(prop->source_ports);
prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval,
sizeof(*prop->src_dpn_prop),
GFP_KERNEL);
if (!prop->src_dpn_prop)
return -ENOMEM;
i = 0;
dpn = prop->src_dpn_prop;
addr = prop->source_ports;
for_each_set_bit(bit, &addr, 32) {
dpn[i].num = bit;
dpn[i].type = SDW_DPN_FULL;
dpn[i].simple_ch_prep_sm = true;
i++;
}
/* do this again for sink now */
nval = hweight32(prop->sink_ports);
prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval,
sizeof(*prop->sink_dpn_prop),
GFP_KERNEL);
if (!prop->sink_dpn_prop)
return -ENOMEM;
j = 0;
dpn = prop->sink_dpn_prop;
addr = prop->sink_ports;
for_each_set_bit(bit, &addr, 32) {
dpn[j].num = bit;
dpn[j].type = SDW_DPN_FULL;
dpn[j].simple_ch_prep_sm = true;
j++;
}
prop->simple_clk_stop_capable = true;
/* wake-up event */
prop->wake_capable = 0;
return 0;
}
static int sdw_mockup_bus_config(struct sdw_slave *slave,
struct sdw_bus_params *params)
{
return 0;
}
static int sdw_mockup_interrupt_callback(struct sdw_slave *slave,
struct sdw_slave_intr_status *status)
{
return 0;
}
static const struct sdw_slave_ops sdw_mockup_slave_ops = {
.read_prop = sdw_mockup_read_prop,
.interrupt_callback = sdw_mockup_interrupt_callback,
.update_status = sdw_mockup_update_status,
.bus_config = sdw_mockup_bus_config,
};
static int sdw_mockup_sdw_probe(struct sdw_slave *slave,
const struct sdw_device_id *id)
{
struct device *dev = &slave->dev;
struct sdw_mockup_priv *sdw_mockup;
int ret;
sdw_mockup = devm_kzalloc(dev, sizeof(*sdw_mockup), GFP_KERNEL);
if (!sdw_mockup)
return -ENOMEM;
dev_set_drvdata(dev, sdw_mockup);
sdw_mockup->slave = slave;
slave->is_mockup_device = true;
ret = devm_snd_soc_register_component(dev,
&snd_soc_sdw_mockup_component,
sdw_mockup_dai,
ARRAY_SIZE(sdw_mockup_dai));
return ret;
}
static int sdw_mockup_sdw_remove(struct sdw_slave *slave)
{
return 0;
}
/*
* Intel reserved parts ID with the following mapping expected:
* 0xAAAA: generic full-duplex codec
* 0xAA55: headset codec (mock-up of RT711/RT5682) - full-duplex
* 0x55AA: amplifier (mock-up of RT1308/Maxim 98373) - playback only with
* IV feedback
* 0x5555: mic codec (mock-up of RT715) - capture-only
*/
static const struct sdw_device_id sdw_mockup_id[] = {
SDW_SLAVE_ENTRY_EXT(0x0105, 0xAAAA, 0x0, 0, 0),
SDW_SLAVE_ENTRY_EXT(0x0105, 0xAA55, 0x0, 0, 0),
SDW_SLAVE_ENTRY_EXT(0x0105, 0x55AA, 0x0, 0, 0),
SDW_SLAVE_ENTRY_EXT(0x0105, 0x5555, 0x0, 0, 0),
{},
};
MODULE_DEVICE_TABLE(sdw, sdw_mockup_id);
static struct sdw_driver sdw_mockup_sdw_driver = {
.driver = {
.name = "sdw-mockup",
.owner = THIS_MODULE,
},
.probe = sdw_mockup_sdw_probe,
.remove = sdw_mockup_sdw_remove,
.ops = &sdw_mockup_slave_ops,
.id_table = sdw_mockup_id,
};
module_sdw_driver(sdw_mockup_sdw_driver);
MODULE_DESCRIPTION("ASoC SDW mockup codec driver");
MODULE_AUTHOR("Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>");
MODULE_LICENSE("GPL");
...@@ -602,6 +602,7 @@ config SND_SOC_INTEL_SOUNDWIRE_SOF_MACH ...@@ -602,6 +602,7 @@ config SND_SOC_INTEL_SOUNDWIRE_SOF_MACH
select SND_SOC_DMIC select SND_SOC_DMIC
select SND_SOC_INTEL_HDA_DSP_COMMON select SND_SOC_INTEL_HDA_DSP_COMMON
select SND_SOC_INTEL_SOF_MAXIM_COMMON select SND_SOC_INTEL_SOF_MAXIM_COMMON
select SND_SOC_SDW_MOCKUP
help help
Add support for Intel SoundWire-based platforms connected to Add support for Intel SoundWire-based platforms connected to
MAX98373, RT700, RT711, RT1308 and RT715 MAX98373, RT700, RT711, RT1308 and RT715
......
...@@ -328,6 +328,19 @@ static const struct snd_soc_ops sdw_ops = { ...@@ -328,6 +328,19 @@ static const struct snd_soc_ops sdw_ops = {
.shutdown = sdw_shutdown, .shutdown = sdw_shutdown,
}; };
static int sof_sdw_mic_codec_mockup_init(const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)
{
/*
* force DAI link to use same ID as RT715 and DMIC
* to reuse topologies
*/
dai_links->id = SDW_DMIC_DAI_ID;
return 0;
}
static struct sof_sdw_codec_info codec_info_list[] = { static struct sof_sdw_codec_info codec_info_list[] = {
{ {
.part_id = 0x700, .part_id = 0x700,
...@@ -410,6 +423,34 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -410,6 +423,34 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_name = "rt5682-sdw", .dai_name = "rt5682-sdw",
.init = sof_sdw_rt5682_init, .init = sof_sdw_rt5682_init,
}, },
{
.part_id = 0xaaaa, /* generic codec mockup */
.version_id = 0,
.direction = {true, true},
.dai_name = "sdw-mockup-aif1",
.init = NULL,
},
{
.part_id = 0xaa55, /* headset codec mockup */
.version_id = 0,
.direction = {true, true},
.dai_name = "sdw-mockup-aif1",
.init = NULL,
},
{
.part_id = 0x55aa, /* amplifier mockup */
.version_id = 0,
.direction = {true, false},
.dai_name = "sdw-mockup-aif1",
.init = NULL,
},
{
.part_id = 0x5555,
.version_id = 0,
.direction = {false, true},
.dai_name = "sdw-mockup-aif1",
.init = sof_sdw_mic_codec_mockup_init,
},
}; };
static inline int find_codec_info_part(u64 adr) static inline int find_codec_info_part(u64 adr)
......
...@@ -9,7 +9,8 @@ snd-soc-acpi-intel-match-objs := soc-acpi-intel-byt-match.o soc-acpi-intel-cht-m ...@@ -9,7 +9,8 @@ snd-soc-acpi-intel-match-objs := soc-acpi-intel-byt-match.o soc-acpi-intel-cht-m
soc-acpi-intel-cml-match.o soc-acpi-intel-icl-match.o \ soc-acpi-intel-cml-match.o soc-acpi-intel-icl-match.o \
soc-acpi-intel-tgl-match.o soc-acpi-intel-ehl-match.o \ soc-acpi-intel-tgl-match.o soc-acpi-intel-ehl-match.o \
soc-acpi-intel-jsl-match.o soc-acpi-intel-adl-match.o \ soc-acpi-intel-jsl-match.o soc-acpi-intel-adl-match.o \
soc-acpi-intel-hda-match.o soc-acpi-intel-hda-match.o \
soc-acpi-intel-sdw-mockup-match.o
obj-$(CONFIG_SND_SOC_INTEL_SST) += snd-soc-sst-dsp.o snd-soc-sst-ipc.o obj-$(CONFIG_SND_SOC_INTEL_SST) += snd-soc-sst-dsp.o snd-soc-sst-ipc.o
obj-$(CONFIG_SND_SOC_ACPI_INTEL_MATCH) += snd-soc-acpi-intel-match.o obj-$(CONFIG_SND_SOC_ACPI_INTEL_MATCH) += snd-soc-acpi-intel-match.o
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h> #include <sound/soc-acpi-intel-match.h>
#include "../skylake/skl.h" #include "../skylake/skl.h"
#include "soc-acpi-intel-sdw-mockup-match.h"
static struct skl_machine_pdata cnl_pdata = { static struct skl_machine_pdata cnl_pdata = {
.use_tplg_pcm = true, .use_tplg_pcm = true,
...@@ -60,6 +61,20 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_sdw_machines[] = { ...@@ -60,6 +61,20 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_sdw_machines[] = {
.sof_fw_filename = "sof-cnl.ri", .sof_fw_filename = "sof-cnl.ri",
.sof_tplg_filename = "sof-cnl-rt5682-sdw2.tplg" .sof_tplg_filename = "sof-cnl-rt5682-sdw2.tplg"
}, },
{
.link_mask = GENMASK(3, 0),
.links = sdw_mockup_headset_2amps_mic,
.drv_name = "sof_sdw",
.sof_fw_filename = "sof-cnl.ri",
.sof_tplg_filename = "sof-cml-rt711-rt1308-rt715.tplg",
},
{
.link_mask = BIT(0) | BIT(1) | BIT(3),
.links = sdw_mockup_headset_1amp_mic,
.drv_name = "sof_sdw",
.sof_fw_filename = "sof-cnl.ri",
.sof_tplg_filename = "sof-cml-rt711-rt1308-mono-rt715.tplg",
},
{} {}
}; };
EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cnl_sdw_machines); EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cnl_sdw_machines);
// SPDX-License-Identifier: GPL-2.0-only
//
// soc-acpi-intel-sdw-mockup-match.c - tables and support for SoundWire
// mockup device ACPI enumeration.
//
// Copyright (c) 2021, Intel Corporation.
//
#include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h>
#include "soc-acpi-intel-sdw-mockup-match.h"
static const struct snd_soc_acpi_endpoint sdw_mockup_single_endpoint = {
.num = 0,
.aggregated = 0,
.group_position = 0,
.group_id = 0,
};
static const struct snd_soc_acpi_endpoint sdw_mockup_l_endpoint = {
.num = 0,
.aggregated = 1,
.group_position = 0,
.group_id = 1,
};
static const struct snd_soc_acpi_endpoint sdw_mockup_r_endpoint = {
.num = 0,
.aggregated = 1,
.group_position = 1,
.group_id = 1,
};
static const struct snd_soc_acpi_adr_device sdw_mockup_headset_0_adr[] = {
{
.adr = 0x0000000105AA5500ull,
.num_endpoints = 1,
.endpoints = &sdw_mockup_single_endpoint,
.name_prefix = "sdw_mockup_headset0"
}
};
static const struct snd_soc_acpi_adr_device sdw_mockup_headset_1_adr[] = {
{
.adr = 0x0001000105AA5500ull,
.num_endpoints = 1,
.endpoints = &sdw_mockup_single_endpoint,
.name_prefix = "sdw_mockup_headset1"
}
};
static const struct snd_soc_acpi_adr_device sdw_mockup_amp_1_adr[] = {
{
.adr = 0x000100010555AA00ull,
.num_endpoints = 1,
.endpoints = &sdw_mockup_single_endpoint,
.name_prefix = "sdw_mockup_amp1"
}
};
static const struct snd_soc_acpi_adr_device sdw_mockup_amp_2_adr[] = {
{
.adr = 0x000200010555AA00ull,
.num_endpoints = 1,
.endpoints = &sdw_mockup_single_endpoint,
.name_prefix = "sdw_mockup_amp2"
}
};
static const struct snd_soc_acpi_adr_device sdw_mockup_mic_0_adr[] = {
{
.adr = 0x0000000105555500ull,
.num_endpoints = 1,
.endpoints = &sdw_mockup_single_endpoint,
.name_prefix = "sdw_mockup_mic0"
}
};
static const struct snd_soc_acpi_adr_device sdw_mockup_mic_3_adr[] = {
{
.adr = 0x0003000105555500ull,
.num_endpoints = 1,
.endpoints = &sdw_mockup_single_endpoint,
.name_prefix = "sdw_mockup_mic3"
}
};
static const struct snd_soc_acpi_adr_device sdw_mockup_amp_1_group1_adr[] = {
{
.adr = 0x000100010555AA00ull,
.num_endpoints = 1,
.endpoints = &sdw_mockup_l_endpoint,
.name_prefix = "sdw_mockup_amp1_l"
}
};
static const struct snd_soc_acpi_adr_device sdw_mockup_amp_2_group1_adr[] = {
{
.adr = 0x000200010555AA00ull,
.num_endpoints = 1,
.endpoints = &sdw_mockup_r_endpoint,
.name_prefix = "sdw_mockup_amp2_r"
}
};
const struct snd_soc_acpi_link_adr sdw_mockup_headset_1amp_mic[] = {
{
.mask = BIT(0),
.num_adr = ARRAY_SIZE(sdw_mockup_headset_0_adr),
.adr_d = sdw_mockup_headset_0_adr,
},
{
.mask = BIT(1),
.num_adr = ARRAY_SIZE(sdw_mockup_amp_1_adr),
.adr_d = sdw_mockup_amp_1_adr,
},
{
.mask = BIT(3),
.num_adr = ARRAY_SIZE(sdw_mockup_mic_3_adr),
.adr_d = sdw_mockup_mic_3_adr,
},
{}
};
const struct snd_soc_acpi_link_adr sdw_mockup_headset_2amps_mic[] = {
{
.mask = BIT(0),
.num_adr = ARRAY_SIZE(sdw_mockup_headset_0_adr),
.adr_d = sdw_mockup_headset_0_adr,
},
{
.mask = BIT(1),
.num_adr = ARRAY_SIZE(sdw_mockup_amp_1_group1_adr),
.adr_d = sdw_mockup_amp_1_group1_adr,
},
{
.mask = BIT(2),
.num_adr = ARRAY_SIZE(sdw_mockup_amp_2_group1_adr),
.adr_d = sdw_mockup_amp_2_group1_adr,
},
{
.mask = BIT(3),
.num_adr = ARRAY_SIZE(sdw_mockup_mic_3_adr),
.adr_d = sdw_mockup_mic_3_adr,
},
{}
};
const struct snd_soc_acpi_link_adr sdw_mockup_mic_headset_1amp[] = {
{
.mask = BIT(1),
.num_adr = ARRAY_SIZE(sdw_mockup_headset_1_adr),
.adr_d = sdw_mockup_headset_1_adr,
},
{
.mask = BIT(2),
.num_adr = ARRAY_SIZE(sdw_mockup_amp_2_adr),
.adr_d = sdw_mockup_amp_2_adr,
},
{
.mask = BIT(0),
.num_adr = ARRAY_SIZE(sdw_mockup_mic_0_adr),
.adr_d = sdw_mockup_mic_0_adr,
},
{}
};
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* soc-acpi-intel-sdw-mockup-match.h - tables and support for SoundWire
* mockup device ACPI enumeration.
*
* Copyright (c) 2021, Intel Corporation.
*
*/
#ifndef _SND_SOC_ACPI_INTEL_SDW_MOCKUP_MATCH
#define _SND_SOC_ACPI_INTEL_SDW_MOCKUP_MATCH
extern const struct snd_soc_acpi_link_adr sdw_mockup_headset_1amp_mic[];
extern const struct snd_soc_acpi_link_adr sdw_mockup_headset_2amps_mic[];
extern const struct snd_soc_acpi_link_adr sdw_mockup_mic_headset_1amp[];
#endif
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h> #include <sound/soc-acpi-intel-match.h>
#include "soc-acpi-intel-sdw-mockup-match.h"
static const struct snd_soc_acpi_codecs tgl_codecs = { static const struct snd_soc_acpi_codecs tgl_codecs = {
.num_codecs = 1, .num_codecs = 1,
...@@ -351,6 +352,28 @@ EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_tgl_machines); ...@@ -351,6 +352,28 @@ EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_tgl_machines);
/* this table is used when there is no I2S codec present */ /* this table is used when there is no I2S codec present */
struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_sdw_machines[] = { struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_sdw_machines[] = {
/* mockup tests need to be first */
{
.link_mask = GENMASK(3, 0),
.links = sdw_mockup_headset_2amps_mic,
.drv_name = "sof_sdw",
.sof_fw_filename = "sof-tgl.ri",
.sof_tplg_filename = "sof-tgl-rt711-rt1308-rt715.tplg",
},
{
.link_mask = BIT(0) | BIT(1) | BIT(3),
.links = sdw_mockup_headset_1amp_mic,
.drv_name = "sof_sdw",
.sof_fw_filename = "sof-tgl.ri",
.sof_tplg_filename = "sof-tgl-rt711-rt1308-mono-rt715.tplg",
},
{
.link_mask = BIT(0) | BIT(1) | BIT(2),
.links = sdw_mockup_mic_headset_1amp,
.drv_name = "sof_sdw",
.sof_fw_filename = "sof-tgl.ri",
.sof_tplg_filename = "sof-tgl-rt715-rt711-rt1308-mono.tplg",
},
{ {
.link_mask = 0x7, .link_mask = 0x7,
.links = tgl_sdw_rt711_link1_rt1308_link2_rt715_link0, .links = tgl_sdw_rt711_link1_rt1308_link2_rt715_link0,
......
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