#include <linux/cleanup.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/debugfs.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/pm_runtime.h>
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <linux/workqueue.h>
#include "bus.h"
#include "cadence_master.h"
static int interrupt_mask;
module_param_named(cnds_mcp_int_mask, interrupt_mask, int, 0444);
MODULE_PARM_DESC(…) …;
#define CDNS_MCP_CONFIG …
#define CDNS_MCP_CONFIG_BUS_REL …
#define CDNS_IP_MCP_CONFIG …
#define CDNS_IP_MCP_CONFIG_MCMD_RETRY …
#define CDNS_IP_MCP_CONFIG_MPREQ_DELAY …
#define CDNS_IP_MCP_CONFIG_MMASTER …
#define CDNS_IP_MCP_CONFIG_SNIFFER …
#define CDNS_IP_MCP_CONFIG_CMD …
#define CDNS_IP_MCP_CONFIG_OP …
#define CDNS_IP_MCP_CONFIG_OP_NORMAL …
#define CDNS_MCP_CONTROL …
#define CDNS_MCP_CONTROL_CMD_RST …
#define CDNS_MCP_CONTROL_SOFT_RST …
#define CDNS_MCP_CONTROL_HW_RST …
#define CDNS_MCP_CONTROL_CLK_STOP_CLR …
#define CDNS_IP_MCP_CONTROL …
#define CDNS_IP_MCP_CONTROL_RST_DELAY …
#define CDNS_IP_MCP_CONTROL_SW_RST …
#define CDNS_IP_MCP_CONTROL_CLK_PAUSE …
#define CDNS_IP_MCP_CONTROL_CMD_ACCEPT …
#define CDNS_IP_MCP_CONTROL_BLOCK_WAKEUP …
#define CDNS_IP_MCP_CMDCTRL …
#define CDNS_IP_MCP_CMDCTRL_INSERT_PARITY_ERR …
#define CDNS_MCP_SSPSTAT …
#define CDNS_MCP_FRAME_SHAPE …
#define CDNS_MCP_FRAME_SHAPE_INIT …
#define CDNS_MCP_FRAME_SHAPE_COL_MASK …
#define CDNS_MCP_FRAME_SHAPE_ROW_MASK …
#define CDNS_MCP_CONFIG_UPDATE …
#define CDNS_MCP_CONFIG_UPDATE_BIT …
#define CDNS_MCP_PHYCTRL …
#define CDNS_MCP_SSP_CTRL0 …
#define CDNS_MCP_SSP_CTRL1 …
#define CDNS_MCP_CLK_CTRL0 …
#define CDNS_MCP_CLK_CTRL1 …
#define CDNS_MCP_CLK_MCLKD_MASK …
#define CDNS_MCP_STAT …
#define CDNS_MCP_STAT_ACTIVE_BANK …
#define CDNS_MCP_STAT_CLK_STOP …
#define CDNS_MCP_INTSTAT …
#define CDNS_MCP_INTMASK …
#define CDNS_MCP_INT_IRQ …
#define CDNS_MCP_INT_RESERVED1 …
#define CDNS_MCP_INT_WAKEUP …
#define CDNS_MCP_INT_SLAVE_RSVD …
#define CDNS_MCP_INT_SLAVE_ALERT …
#define CDNS_MCP_INT_SLAVE_ATTACH …
#define CDNS_MCP_INT_SLAVE_NATTACH …
#define CDNS_MCP_INT_SLAVE_MASK …
#define CDNS_MCP_INT_DPINT …
#define CDNS_MCP_INT_CTRL_CLASH …
#define CDNS_MCP_INT_DATA_CLASH …
#define CDNS_MCP_INT_PARITY …
#define CDNS_MCP_INT_CMD_ERR …
#define CDNS_MCP_INT_RESERVED2 …
#define CDNS_MCP_INT_RX_NE …
#define CDNS_MCP_INT_RX_WL …
#define CDNS_MCP_INT_TXE …
#define CDNS_MCP_INT_TXF …
#define CDNS_MCP_INT_RESERVED …
#define CDNS_MCP_INTSET …
#define CDNS_MCP_SLAVE_STAT …
#define CDNS_MCP_SLAVE_STAT_MASK …
#define CDNS_MCP_SLAVE_INTSTAT0 …
#define CDNS_MCP_SLAVE_INTSTAT1 …
#define CDNS_MCP_SLAVE_INTSTAT_NPRESENT …
#define CDNS_MCP_SLAVE_INTSTAT_ATTACHED …
#define CDNS_MCP_SLAVE_INTSTAT_ALERT …
#define CDNS_MCP_SLAVE_INTSTAT_RESERVED …
#define CDNS_MCP_SLAVE_STATUS_BITS …
#define CDNS_MCP_SLAVE_STATUS_NUM …
#define CDNS_MCP_SLAVE_INTMASK0 …
#define CDNS_MCP_SLAVE_INTMASK1 …
#define CDNS_MCP_SLAVE_INTMASK0_MASK …
#define CDNS_MCP_SLAVE_INTMASK1_MASK …
#define CDNS_MCP_PORT_INTSTAT …
#define CDNS_MCP_PDI_STAT …
#define CDNS_MCP_FIFOLEVEL …
#define CDNS_MCP_FIFOSTAT …
#define CDNS_MCP_RX_FIFO_AVAIL …
#define CDNS_IP_MCP_CMD_BASE …
#define CDNS_IP_MCP_RESP_BASE …
#define CDNS_MCP_CMD_LEN …
#define CDNS_MCP_CMD_WORD_LEN …
#define CDNS_MCP_CMD_SSP_TAG …
#define CDNS_MCP_CMD_COMMAND …
#define CDNS_MCP_CMD_DEV_ADDR …
#define CDNS_MCP_CMD_REG_ADDR …
#define CDNS_MCP_CMD_REG_DATA …
#define CDNS_MCP_CMD_READ …
#define CDNS_MCP_CMD_WRITE …
#define CDNS_MCP_RESP_RDATA …
#define CDNS_MCP_RESP_ACK …
#define CDNS_MCP_RESP_NACK …
#define CDNS_DP_SIZE …
#define CDNS_DPN_B0_CONFIG(n) …
#define CDNS_DPN_B0_CH_EN(n) …
#define CDNS_DPN_B0_SAMPLE_CTRL(n) …
#define CDNS_DPN_B0_OFFSET_CTRL(n) …
#define CDNS_DPN_B0_HCTRL(n) …
#define CDNS_DPN_B0_ASYNC_CTRL(n) …
#define CDNS_DPN_B1_CONFIG(n) …
#define CDNS_DPN_B1_CH_EN(n) …
#define CDNS_DPN_B1_SAMPLE_CTRL(n) …
#define CDNS_DPN_B1_OFFSET_CTRL(n) …
#define CDNS_DPN_B1_HCTRL(n) …
#define CDNS_DPN_B1_ASYNC_CTRL(n) …
#define CDNS_DPN_CONFIG_BPM …
#define CDNS_DPN_CONFIG_BGC …
#define CDNS_DPN_CONFIG_WL …
#define CDNS_DPN_CONFIG_PORT_DAT …
#define CDNS_DPN_CONFIG_PORT_FLOW …
#define CDNS_DPN_SAMPLE_CTRL_SI …
#define CDNS_DPN_OFFSET_CTRL_1 …
#define CDNS_DPN_OFFSET_CTRL_2 …
#define CDNS_DPN_HCTRL_HSTOP …
#define CDNS_DPN_HCTRL_HSTART …
#define CDNS_DPN_HCTRL_LCTRL …
#define CDNS_PORTCTRL …
#define CDNS_PORTCTRL_TEST_FAILED …
#define CDNS_PORTCTRL_DIRN …
#define CDNS_PORTCTRL_BANK_INVERT …
#define CDNS_PORT_OFFSET …
#define CDNS_PDI_CONFIG(n) …
#define CDNS_PDI_CONFIG_SOFT_RESET …
#define CDNS_PDI_CONFIG_CHANNEL …
#define CDNS_PDI_CONFIG_PORT …
#define CDNS_TX_TIMEOUT …
#define CDNS_SCP_RX_FIFOLEVEL …
static inline u32 cdns_readl(struct sdw_cdns *cdns, int offset)
{ … }
static inline void cdns_writel(struct sdw_cdns *cdns, int offset, u32 value)
{ … }
static inline u32 cdns_ip_readl(struct sdw_cdns *cdns, int offset)
{ … }
static inline void cdns_ip_writel(struct sdw_cdns *cdns, int offset, u32 value)
{ … }
static inline void cdns_updatel(struct sdw_cdns *cdns,
int offset, u32 mask, u32 val)
{ … }
static inline void cdns_ip_updatel(struct sdw_cdns *cdns,
int offset, u32 mask, u32 val)
{ … }
static int cdns_set_wait(struct sdw_cdns *cdns, int offset, u32 mask, u32 value)
{ … }
static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value)
{ … }
static int cdns_config_update(struct sdw_cdns *cdns)
{ … }
void sdw_cdns_config_update(struct sdw_cdns *cdns)
{ … }
EXPORT_SYMBOL(…);
int sdw_cdns_config_update_set_wait(struct sdw_cdns *cdns)
{ … }
EXPORT_SYMBOL(…);
#ifdef CONFIG_DEBUG_FS
#define RD_BUF …
static ssize_t cdns_sprintf(struct sdw_cdns *cdns,
char *buf, size_t pos, unsigned int reg)
{ … }
static int cdns_reg_show(struct seq_file *s, void *data)
{ … }
DEFINE_SHOW_ATTRIBUTE(…);
static int cdns_hw_reset(void *data, u64 value)
{ … }
DEFINE_DEBUGFS_ATTRIBUTE(…);
static int cdns_parity_error_injection(void *data, u64 value)
{ … }
DEFINE_DEBUGFS_ATTRIBUTE(…);
static int cdns_set_pdi_loopback_source(void *data, u64 value)
{ … }
DEFINE_DEBUGFS_ATTRIBUTE(…);
static int cdns_set_pdi_loopback_target(void *data, u64 value)
{ … }
DEFINE_DEBUGFS_ATTRIBUTE(…);
void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root)
{ … }
EXPORT_SYMBOL_GPL(…);
#endif
static enum sdw_command_response
cdns_fill_msg_resp(struct sdw_cdns *cdns,
struct sdw_msg *msg, int count, int offset)
{ … }
static void cdns_read_response(struct sdw_cdns *cdns)
{ … }
static enum sdw_command_response
_cdns_xfer_msg(struct sdw_cdns *cdns, struct sdw_msg *msg, int cmd,
int offset, int count, bool defer)
{ … }
static enum sdw_command_response
cdns_program_scp_addr(struct sdw_cdns *cdns, struct sdw_msg *msg)
{ … }
static int cdns_prep_msg(struct sdw_cdns *cdns, struct sdw_msg *msg, int *cmd)
{ … }
enum sdw_command_response
cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg)
{ … }
EXPORT_SYMBOL(…);
enum sdw_command_response
cdns_xfer_msg_defer(struct sdw_bus *bus)
{ … }
EXPORT_SYMBOL(…);
u32 cdns_read_ping_status(struct sdw_bus *bus)
{ … }
EXPORT_SYMBOL(…);
static int cdns_update_slave_status(struct sdw_cdns *cdns,
u64 slave_intstat)
{ … }
irqreturn_t sdw_cdns_irq(int irq, void *dev_id)
{ … }
EXPORT_SYMBOL(…);
static void cdns_check_attached_status_dwork(struct work_struct *work)
{ … }
static void cdns_update_slave_status_work(struct work_struct *work)
{ … }
void sdw_cdns_check_self_clearing_bits(struct sdw_cdns *cdns, const char *string,
bool initial_delay, int reset_iterations)
{ … }
EXPORT_SYMBOL(…);
int sdw_cdns_exit_reset(struct sdw_cdns *cdns)
{ … }
EXPORT_SYMBOL(…);
static void cdns_enable_slave_interrupts(struct sdw_cdns *cdns, bool state)
{ … }
int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state)
{ … }
EXPORT_SYMBOL(…);
static int cdns_allocate_pdi(struct sdw_cdns *cdns,
struct sdw_cdns_pdi **stream,
u32 num)
{ … }
int sdw_cdns_pdi_init(struct sdw_cdns *cdns,
struct sdw_cdns_stream_config config)
{ … }
EXPORT_SYMBOL(…);
static u32 cdns_set_initial_frame_shape(int n_rows, int n_cols)
{ … }
static void cdns_init_clock_ctrl(struct sdw_cdns *cdns)
{ … }
int sdw_cdns_init(struct sdw_cdns *cdns)
{ … }
EXPORT_SYMBOL(…);
int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params)
{ … }
EXPORT_SYMBOL(…);
static int cdns_port_params(struct sdw_bus *bus,
struct sdw_port_params *p_params, unsigned int bank)
{ … }
static int cdns_transport_params(struct sdw_bus *bus,
struct sdw_transport_params *t_params,
enum sdw_reg_bank bank)
{ … }
static int cdns_port_enable(struct sdw_bus *bus,
struct sdw_enable_ch *enable_ch, unsigned int bank)
{ … }
static const struct sdw_master_port_ops cdns_port_ops = …;
bool sdw_cdns_is_clock_stop(struct sdw_cdns *cdns)
{ … }
EXPORT_SYMBOL(…);
int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake)
{ … }
EXPORT_SYMBOL(…);
int sdw_cdns_clock_restart(struct sdw_cdns *cdns, bool bus_reset)
{ … }
EXPORT_SYMBOL(…);
int sdw_cdns_probe(struct sdw_cdns *cdns)
{ … }
EXPORT_SYMBOL(…);
int cdns_set_sdw_stream(struct snd_soc_dai *dai,
void *stream, int direction)
{ … }
EXPORT_SYMBOL(…);
static struct sdw_cdns_pdi *cdns_find_pdi(struct sdw_cdns *cdns,
unsigned int num,
struct sdw_cdns_pdi *pdi,
int dai_id)
{ … }
void sdw_cdns_config_stream(struct sdw_cdns *cdns,
u32 ch, u32 dir, struct sdw_cdns_pdi *pdi)
{ … }
EXPORT_SYMBOL(…);
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
struct sdw_cdns_streams *stream,
u32 ch, u32 dir, int dai_id)
{ … }
EXPORT_SYMBOL(…);
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;