2019-05-01 15:57:25 +00:00
|
|
|
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
|
|
|
|
/* Copyright(c) 2015-17 Intel Corporation. */
|
2018-04-26 13:08:53 +00:00
|
|
|
#include <sound/soc.h>
|
2017-12-14 05:49:41 +00:00
|
|
|
|
|
|
|
#ifndef __SDW_CADENCE_H
|
|
|
|
#define __SDW_CADENCE_H
|
|
|
|
|
2018-04-26 13:08:48 +00:00
|
|
|
/**
|
|
|
|
* struct sdw_cdns_pdi: PDI (Physical Data Interface) instance
|
|
|
|
*
|
|
|
|
* @num: pdi number
|
|
|
|
* @intel_alh_id: link identifier
|
|
|
|
* @l_ch_num: low channel for PDI
|
|
|
|
* @h_ch_num: high channel for PDI
|
|
|
|
* @ch_count: total channel count for PDI
|
|
|
|
* @dir: data direction
|
|
|
|
* @type: stream type, PDM or PCM
|
|
|
|
*/
|
|
|
|
struct sdw_cdns_pdi {
|
|
|
|
int num;
|
|
|
|
int intel_alh_id;
|
|
|
|
int l_ch_num;
|
|
|
|
int h_ch_num;
|
|
|
|
int ch_count;
|
|
|
|
enum sdw_data_direction dir;
|
|
|
|
enum sdw_stream_type type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct sdw_cdns_streams: Cadence stream data structure
|
|
|
|
*
|
|
|
|
* @num_bd: number of bidirectional streams
|
|
|
|
* @num_in: number of input streams
|
|
|
|
* @num_out: number of output streams
|
|
|
|
* @num_ch_bd: number of bidirectional stream channels
|
|
|
|
* @num_ch_bd: number of input stream channels
|
|
|
|
* @num_ch_bd: number of output stream channels
|
|
|
|
* @num_pdi: total number of PDIs
|
|
|
|
* @bd: bidirectional streams
|
|
|
|
* @in: input streams
|
|
|
|
* @out: output streams
|
|
|
|
*/
|
|
|
|
struct sdw_cdns_streams {
|
|
|
|
unsigned int num_bd;
|
|
|
|
unsigned int num_in;
|
|
|
|
unsigned int num_out;
|
|
|
|
unsigned int num_ch_bd;
|
|
|
|
unsigned int num_ch_in;
|
|
|
|
unsigned int num_ch_out;
|
|
|
|
unsigned int num_pdi;
|
|
|
|
struct sdw_cdns_pdi *bd;
|
|
|
|
struct sdw_cdns_pdi *in;
|
|
|
|
struct sdw_cdns_pdi *out;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct sdw_cdns_stream_config: stream configuration
|
|
|
|
*
|
|
|
|
* @pcm_bd: number of bidirectional PCM streams supported
|
|
|
|
* @pcm_in: number of input PCM streams supported
|
|
|
|
* @pcm_out: number of output PCM streams supported
|
|
|
|
* @pdm_bd: number of bidirectional PDM streams supported
|
|
|
|
* @pdm_in: number of input PDM streams supported
|
|
|
|
* @pdm_out: number of output PDM streams supported
|
|
|
|
*/
|
|
|
|
struct sdw_cdns_stream_config {
|
|
|
|
unsigned int pcm_bd;
|
|
|
|
unsigned int pcm_in;
|
|
|
|
unsigned int pcm_out;
|
|
|
|
unsigned int pdm_bd;
|
|
|
|
unsigned int pdm_in;
|
|
|
|
unsigned int pdm_out;
|
|
|
|
};
|
|
|
|
|
2018-04-26 13:08:53 +00:00
|
|
|
/**
|
|
|
|
* struct sdw_cdns_dma_data: Cadence DMA data
|
|
|
|
*
|
|
|
|
* @name: SoundWire stream name
|
2019-09-16 19:23:46 +00:00
|
|
|
* @stream: stream runtime
|
|
|
|
* @pdi: PDI used for this dai
|
2018-04-26 13:08:53 +00:00
|
|
|
* @bus: Bus handle
|
|
|
|
* @stream_type: Stream type
|
|
|
|
* @link_id: Master link id
|
|
|
|
*/
|
|
|
|
struct sdw_cdns_dma_data {
|
|
|
|
char *name;
|
|
|
|
struct sdw_stream_runtime *stream;
|
2019-09-16 19:23:46 +00:00
|
|
|
struct sdw_cdns_pdi *pdi;
|
2018-04-26 13:08:53 +00:00
|
|
|
struct sdw_bus *bus;
|
|
|
|
enum sdw_stream_type stream_type;
|
|
|
|
int link_id;
|
|
|
|
};
|
|
|
|
|
2017-12-14 05:49:41 +00:00
|
|
|
/**
|
|
|
|
* struct sdw_cdns - Cadence driver context
|
|
|
|
* @dev: Linux device
|
|
|
|
* @bus: Bus handle
|
|
|
|
* @instance: instance number
|
2017-12-14 05:49:42 +00:00
|
|
|
* @response_buf: SoundWire response buffer
|
|
|
|
* @tx_complete: Tx completion
|
|
|
|
* @defer: Defer pointer
|
2018-04-26 13:08:48 +00:00
|
|
|
* @ports: Data ports
|
|
|
|
* @num_ports: Total number of data ports
|
|
|
|
* @pcm: PCM streams
|
|
|
|
* @pdm: PDM streams
|
2017-12-14 05:49:41 +00:00
|
|
|
* @registers: Cadence registers
|
|
|
|
* @link_up: Link status
|
2017-12-14 05:49:42 +00:00
|
|
|
* @msg_count: Messages sent on bus
|
2017-12-14 05:49:41 +00:00
|
|
|
*/
|
|
|
|
struct sdw_cdns {
|
|
|
|
struct device *dev;
|
|
|
|
struct sdw_bus bus;
|
|
|
|
unsigned int instance;
|
|
|
|
|
2017-12-14 05:49:42 +00:00
|
|
|
u32 response_buf[0x80];
|
|
|
|
struct completion tx_complete;
|
|
|
|
struct sdw_defer *defer;
|
|
|
|
|
2018-04-26 13:08:48 +00:00
|
|
|
struct sdw_cdns_port *ports;
|
|
|
|
int num_ports;
|
|
|
|
|
|
|
|
struct sdw_cdns_streams pcm;
|
|
|
|
struct sdw_cdns_streams pdm;
|
|
|
|
|
2017-12-14 05:49:41 +00:00
|
|
|
void __iomem *registers;
|
|
|
|
|
|
|
|
bool link_up;
|
2017-12-14 05:49:42 +00:00
|
|
|
unsigned int msg_count;
|
2017-12-14 05:49:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus)
|
|
|
|
|
|
|
|
/* Exported symbols */
|
|
|
|
|
2017-12-14 05:49:42 +00:00
|
|
|
int sdw_cdns_probe(struct sdw_cdns *cdns);
|
|
|
|
extern struct sdw_master_ops sdw_cdns_master_ops;
|
|
|
|
|
2017-12-14 05:49:41 +00:00
|
|
|
irqreturn_t sdw_cdns_irq(int irq, void *dev_id);
|
|
|
|
irqreturn_t sdw_cdns_thread(int irq, void *dev_id);
|
|
|
|
|
2019-10-22 23:54:48 +00:00
|
|
|
int sdw_cdns_init(struct sdw_cdns *cdns, bool clock_stop_exit);
|
2018-04-26 13:08:48 +00:00
|
|
|
int sdw_cdns_pdi_init(struct sdw_cdns *cdns,
|
2019-05-01 15:57:26 +00:00
|
|
|
struct sdw_cdns_stream_config config);
|
2019-10-22 23:54:44 +00:00
|
|
|
int sdw_cdns_exit_reset(struct sdw_cdns *cdns);
|
2019-10-22 23:54:47 +00:00
|
|
|
int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state);
|
2017-12-14 05:49:42 +00:00
|
|
|
|
2019-08-21 18:58:19 +00:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root);
|
|
|
|
#endif
|
|
|
|
|
2018-04-26 13:08:53 +00:00
|
|
|
int sdw_cdns_get_stream(struct sdw_cdns *cdns,
|
|
|
|
struct sdw_cdns_streams *stream,
|
|
|
|
u32 ch, u32 dir);
|
2019-09-16 19:23:46 +00:00
|
|
|
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
|
|
|
|
struct sdw_cdns_streams *stream,
|
2019-09-16 19:23:48 +00:00
|
|
|
u32 ch, u32 dir, int dai_id);
|
2019-09-16 19:23:46 +00:00
|
|
|
void sdw_cdns_config_stream(struct sdw_cdns *cdns,
|
2019-05-01 15:57:26 +00:00
|
|
|
u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
|
2018-04-26 13:08:53 +00:00
|
|
|
|
|
|
|
int sdw_cdns_pcm_set_stream(struct snd_soc_dai *dai,
|
2019-05-01 15:57:26 +00:00
|
|
|
void *stream, int direction);
|
2018-04-26 13:08:53 +00:00
|
|
|
int sdw_cdns_pdm_set_stream(struct snd_soc_dai *dai,
|
2019-05-01 15:57:26 +00:00
|
|
|
void *stream, int direction);
|
2018-04-26 13:08:53 +00:00
|
|
|
|
|
|
|
enum sdw_command_response
|
|
|
|
cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
|
|
|
|
|
2018-04-26 13:08:43 +00:00
|
|
|
enum sdw_command_response
|
|
|
|
cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg);
|
2017-12-14 05:49:41 +00:00
|
|
|
|
2018-04-26 13:08:43 +00:00
|
|
|
enum sdw_command_response
|
|
|
|
cdns_xfer_msg_defer(struct sdw_bus *bus,
|
2019-05-01 15:57:26 +00:00
|
|
|
struct sdw_msg *msg, struct sdw_defer *defer);
|
2018-04-26 13:08:43 +00:00
|
|
|
|
|
|
|
enum sdw_command_response
|
|
|
|
cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
|
2018-04-26 13:08:48 +00:00
|
|
|
|
|
|
|
int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params);
|
2018-04-26 13:08:53 +00:00
|
|
|
|
|
|
|
int cdns_set_sdw_stream(struct snd_soc_dai *dai,
|
2019-05-01 15:57:26 +00:00
|
|
|
void *stream, bool pcm, int direction);
|
2017-12-14 05:49:41 +00:00
|
|
|
#endif /* __SDW_CADENCE_H */
|