soundwire: Add stream support
Subsystems (4)
Vinod Koul
maintainerv6 cover soundwire: Add stream support
This series adds support in SoundWire subsystem for:
- Documentation for stream support
- stream management
- data port management
- DAI ops in cadence and Intel drivers
- ASoC API to propagate SDW stream
Updates in v6:
- Fix return error as pointed by Sanyog
- Update stream state enum documentation as pointed by Pierre and few other nits
Updated in v5:
- Add todo for device-device changes in future and some comment updates based on feedback from Pierre
Updates in v4:
- Add more comments for sdw_release_master_stream()
- Make sure ports are freed upon sdw_stream_remove_slave()
- Clarify snd_soc_dai_set_sdw_stream() and setting of NULL upon release.
Updates in v3:
- Remove stream state transition checks and redefine stream states
- Update bansk switch routines
- Other nitpicks pointed out by Pierre.
Updates in v2:
- Make ASoC API inlined
- Make stream states as states and not action
- Update the direction enum
- Fix some typos and comment updates
*** SUBJECT HERE ***
*** BLURB HERE ***
Sanyog Kale (7):
Documentation: soundwire: Add more documentation
soundwire: Add support for SoundWire stream management
soundwire: Add support for port management
soundwire: Add Master and Slave port programming
soundwire: Add helpers for ports operations
soundwire: Add bank switch routine
soundwire: Add stream configuration APIs
Shreyas NC (2):
ASoC: Add SoundWire stream programming interface
soundwire: Remove cdns_master_ops
Vinod Koul (4):
soundwire: cdns: Add port routines
soundwire: cdns: Add stream routines
soundwire: intel: Add stream initialization
soundwire: intel: Add audio DAI ops
.../driver-api/soundwire/error_handling.rst | 65 + Documentation/driver-api/soundwire/index.rst | 3 + Documentation/driver-api/soundwire/locking.rst | 106 ++ Documentation/driver-api/soundwire/stream.rst | 372 +++++ drivers/soundwire/Kconfig | 2 +- drivers/soundwire/Makefile | 2 +- drivers/soundwire/bus.c | 43 + drivers/soundwire/bus.h | 72 + drivers/soundwire/cadence_master.c | 451 +++++- drivers/soundwire/cadence_master.h | 151 ++ drivers/soundwire/intel.c | 525 ++++++- drivers/soundwire/intel.h | 4 + drivers/soundwire/intel_init.c | 3 + drivers/soundwire/stream.c | 1479 ++++++++++++++++++++ include/linux/soundwire/sdw.h | 332 ++++- include/linux/soundwire/sdw_intel.h | 14 + include/sound/soc-dai.h | 23 + 17 files changed, 3633 insertions(+), 14 deletions(-) create mode 100644 Documentation/driver-api/soundwire/error_handling.rst create mode 100644 Documentation/driver-api/soundwire/locking.rst create mode 100644 Documentation/driver-api/soundwire/stream.rst create mode 100644 drivers/soundwire/stream.c
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 1/13 Documentation: soundwire: Add more documentation
From: Sanyog Kale <[email protected]>
This adds documentation for error handling, locking and streams.
--- .../driver-api/soundwire/error_handling.rst | 65 ++++ Documentation/driver-api/soundwire/index.rst | 3 + Documentation/driver-api/soundwire/locking.rst | 106 ++++++ Documentation/driver-api/soundwire/stream.rst | 372 +++++++++++++++++++++ 4 files changed, 546 insertions(+) create mode 100644 Documentation/driver-api/soundwire/error_handling.rst create mode 100644 Documentation/driver-api/soundwire/locking.rst create mode 100644 Documentation/driver-api/soundwire/stream.rst
Documentation/driver-api/soundwire/error_handling.rst new file +65 -0
@@ -0,0 +1,65 @@ +======================== +SoundWire Error Handling +======================== + +The SoundWire PHY was designed with care and errors on the bus are going to +be very unlikely, and if they happen it should be limited to single bit +errors. Examples of this design can be found in the synchronization +mechanism (sync loss after two errors) and short CRCs used for the Bulk +Register Access. + +The errors can be detected with multiple mechanisms: + +1. Bus clash or parity errors: This mechanism relies on low-level detectors + that are independent of the payload and usages, and they cover both control + and audio data. The current implementation only logs such errors. + Improvements could be invalidating an entire programming sequence and + restarting from a known position. In the case of such errors outside of a + control/command sequence, there is no concealment or recovery for audio + data enabled by the SoundWire protocol, the location of the error will also + impact its audibility (most-significant bits will be more impacted in PCM), + and after a number of such errors are detected the bus might be reset. Note + that bus clashes due to programming errors (two streams using the same bit + slots) or electrical issues during the transmit/receive transition cannot + be distinguished, although a recurring bus clash when audio is enabled is a + indication of a bus allocation issue. The interrupt mechanism can also help + identify Slaves which detected a Bus Clash or a Parity Error, but they may + not be responsible for the errors so resetting them individually is not a + viable recovery strategy. + +2. Command status: Each command is associated with a status, which only + covers transmission of the data between devices. The ACK status indicates + that the command was received and will be executed by the end of the + current frame. A NAK indicates that the command was in error and will not + be applied. In case of a bad programming (command sent to non-existent + Slave or to a non-implemented register) or electrical issue, no response + signals the command was ignored. Some Master implementations allow for a + command to be retransmitted several times. If the retransmission fails, + backtracking and restarting the entire programming sequence might be a + solution. Alternatively some implementations might directly issue a bus + reset and re-enumerate all devices. + +3. Timeouts: In a number of cases such as ChannelPrepare or + ClockStopPrepare, the bus driver is supposed to poll a register field until + it transitions to a NotFinished value of zero. The MIPI SoundWire spec 1.1 + does not define timeouts but the MIPI SoundWire DisCo document adds + recommendation on timeouts. If such configurations do not complete, the + driver will return a -ETIMEOUT. Such timeouts are symptoms of a faulty + Slave device and are likely impossible to recover from. + +Errors during global reconfiguration sequences are extremely difficult to +handle: + +1. BankSwitch: An error during the last command issuing a BankSwitch is + difficult to backtrack from. Retransmitting the Bank Switch command may be + possible in a single segment setup, but this can lead to synchronization + problems when enabling multiple bus segments (a command with side effects + such as frame reconfiguration would be handled at different times). A global + hard-reset might be the best solution. + +Note that SoundWire does not provide a mechanism to detect illegal values +written in valid registers. In a number of cases the standard even mentions +that the Slave might behave in implementation-defined ways. The bus +implementation does not provide a recovery mechanism for such errors, Slave +or Master driver implementers are responsible for writing valid values in +valid registers and implement additional range checking if needed.
Documentation/driver-api/soundwire/index.rst +3 -0
@@ -6,6 +6,9 @@ SoundWire Documentation :maxdepth: 1 summary + stream + error_handling + locking .. only:: subproject
Documentation/driver-api/soundwire/locking.rst new file +106 -0
106 lines not on this page · raw message
Documentation/driver-api/soundwire/stream.rst new file +372 -0
372 lines not on this page · raw message
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 2/13 soundwire: Add support for SoundWire stream management
In reply to Vinod KoulFrom: Sanyog Kale <[email protected]>
This patch adds APIs and relevant stream data structures for initialization and release of stream.
--- drivers/soundwire/Makefile | 2 +- drivers/soundwire/bus.c | 1 + drivers/soundwire/bus.h | 36 +++++ drivers/soundwire/stream.c | 360 ++++++++++++++++++++++++++++++++++++++++++ include/linux/soundwire/sdw.h | 109 +++++++++++++ 5 files changed, 507 insertions(+), 1 deletion(-) create mode 100644 drivers/soundwire/stream.c
drivers/soundwire/Makefile +1 -1
@@ -3,7 +3,7 @@ # #Bus Objs -soundwire-bus-objs := bus_type.o bus.o slave.o mipi_disco.o +soundwire-bus-objs := bus_type.o bus.o slave.o mipi_disco.o stream.o obj-$(CONFIG_SOUNDWIRE_BUS) += soundwire-bus.o #Cadence Objs
drivers/soundwire/bus.c +1 -0
@@ -32,6 +32,7 @@ int sdw_add_bus_master(struct sdw_bus *bus)mutex_init (&bus->msg_lock);mutex_init (&bus->bus_lock);INIT_LIST_HEAD (&bus->slaves); +INIT_LIST_HEAD (&bus->m_rt_list);if (bus->ops->read_prop) { ret = bus->ops->read_prop (bus);
drivers/soundwire/bus.h +36 -0
@@ -45,6 +45,42 @@ struct sdw_msg {bool page; }; +/** +* sdw_slave_runtime: Runtime Stream parameters for Slave +* +* @slave: Slave handle +* @direction: Data direction for Slave +* @ch_count: Number of channels handled by the Slave for +* this stream +* @m_rt_node: sdw_master_runtime list node +*/ +struct sdw_slave_runtime { +struct sdw_slave *slave; +enum sdw_data_direction direction; +unsigned int ch_count; +struct list_head m_rt_node; +}; + +/** +* sdw_master_runtime: Runtime stream parameters for Master +* +* @bus: Bus handle +* @stream: Stream runtime handle +* @direction: Data direction for Master +* @ch_count: Number of channels handled by the Master for +* this stream, can be zero. +* @slave_rt_list: Slave runtime list +* @bus_node: sdw_bus m_rt_list node +*/ +struct sdw_master_runtime { +struct sdw_bus *bus; +struct sdw_stream_runtime *stream; +enum sdw_data_direction direction; +unsigned int ch_count; +struct list_head slave_rt_list; +struct list_head bus_node; +}; +int sdw_transfer (struct sdw_bus *bus,struct sdw_msg *msg);int sdw_transfer_defer (struct sdw_bus *bus,struct sdw_msg *msg,struct sdw_defer *defer);
drivers/soundwire/stream.c new file +360 -0
360 lines not on this page · raw message
include/linux/soundwire/sdw.h +109 -0
133 lines not on this page · raw message
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 3/13 soundwire: Add support for port management
In reply to Vinod KoulFrom: Sanyog Kale <[email protected]>
Add Soundwire port data structures and APIS for initialization and release of ports.
--- drivers/soundwire/bus.h | 25 ++++++++ drivers/soundwire/stream.c | 144 +++++++++++++++++++++++++++++++++++++++++- include/linux/soundwire/sdw.h | 67 ++++++++++++++++++++ 3 files changed, 234 insertions(+), 2 deletions(-)
drivers/soundwire/bus.h +25 -0
@@ -46,6 +46,27 @@ struct sdw_msg { };/** +* sdw_port_runtime: Runtime port parameters for Master or Slave +* +* @num: Port number. For audio streams, valid port number ranges from +* [1,14] +* @ch_mask: Channel mask +* @transport_params: Transport parameters +* @port_params: Port parameters +* @port_node: List node for Master or Slave port_list +* +* SoundWire spec has no mention of ports for Master interface but the +* concept is logically extended. +*/ +struct sdw_port_runtime { +int num; +int ch_mask; +struct sdw_transport_params transport_params; +struct sdw_port_params port_params; +struct list_head port_node; +}; + +/** * sdw_slave_runtime: Runtime Stream parameters for Slave * * @slave: Slave handle
@@ -53,12 +74,14 @@ struct sdw_msg {* @ch_count: Number of channels handled by the Slave for * this stream * @m_rt_node: sdw_master_runtime list node +* @port_list: List of Slave Ports configured for this stream */ struct sdw_slave_runtime {struct sdw_slave *slave;enum sdw_data_direction direction;unsigned int ch_count;struct list_head m_rt_node; +struct list_head port_list; };/**
@@ -70,6 +93,7 @@ struct sdw_slave_runtime {* @ch_count: Number of channels handled by the Master for * this stream, can be zero. * @slave_rt_list: Slave runtime list +* @port_list: List of Master Ports configured for this stream, can be zero. * @bus_node: sdw_bus m_rt_list node */ struct sdw_master_runtime {
@@ -78,6 +102,7 @@ struct sdw_master_runtime {enum sdw_data_direction direction;unsigned int ch_count;struct list_head slave_rt_list; +struct list_head port_list;struct list_head bus_node; };
drivers/soundwire/stream.c +142 -2
222 lines not on this page · raw message
include/linux/soundwire/sdw.h +67 -0
94 lines not on this page · raw message
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 4/13 soundwire: Add Master and Slave port programming
In reply to Vinod KoulFrom: Sanyog Kale <[email protected]>
Master and Slave port registers need to be programmed for each port used in a stream. Add the helpers for port register programming.
--- drivers/soundwire/bus.h | 4 + drivers/soundwire/stream.c | 262 ++++++++++++++++++++++++++++++++++++++++++ include/linux/soundwire/sdw.h | 47 +++++++- 3 files changed, 312 insertions(+), 1 deletion(-)
drivers/soundwire/bus.h +4 -0
@@ -106,6 +106,10 @@ struct sdw_master_runtime {struct list_head bus_node; }; +struct sdw_dpn_prop *sdw_get_slave_dpn_prop (struct sdw_slave *slave, +enum sdw_data_direction direction, +unsigned int port_num); +int sdw_transfer (struct sdw_bus *bus,struct sdw_msg *msg);int sdw_transfer_defer (struct sdw_bus *bus,struct sdw_msg *msg,struct sdw_defer *defer);
drivers/soundwire/stream.c +262 -0
274 lines not on this page · raw message
include/linux/soundwire/sdw.h +46 -1
71 lines not on this page · raw message
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 5/13 soundwire: Add helpers for ports operations
In reply to Vinod KoulFrom: Sanyog Kale <[email protected]>
Add helpers to configure, prepare, enable, disable and de-prepare ports.
--- drivers/soundwire/bus.c | 26 ++++ drivers/soundwire/bus.h | 2 + drivers/soundwire/stream.c | 271 ++++++++++++++++++++++++++++++++++++++++++ include/linux/soundwire/sdw.h | 54 +++++++++ 4 files changed, 353 insertions(+)
drivers/soundwire/bus.c +26 -0
@@ -577,6 +577,32 @@ static void sdw_modify_slave_status(struct sdw_slave *slave,mutex_unlock (&slave->bus->bus_lock); } +int sdw_configure_dpn_intr (struct sdw_slave *slave, +int port,bool enable,int mask) +{ +u32 addr; +int ret; +u8 val =0 ; + + addr =SDW_DPN_INTMASK (port); + +/* Set/Clear port ready interrupt mask */ +if (enable) { + val |= mask; + val |=SDW_DPN_INT_PORT_READY ; + }else { + val &= ~(mask); + val &= ~SDW_DPN_INT_PORT_READY ; + } + + ret =sdw_update (slave, addr, (mask |SDW_DPN_INT_PORT_READY ), val); +if (ret <0 ) +dev_err (slave->bus->dev, +"SDW_DPN_INTMASK write failed:%d" , val); + +return ret; +} +static int sdw_initialize_slave (struct sdw_slave *slave) {struct sdw_slave_prop *prop = &slave->prop;
drivers/soundwire/bus.h +2 -0
@@ -109,6 +109,8 @@ struct sdw_master_runtime {struct sdw_dpn_prop *sdw_get_slave_dpn_prop (struct sdw_slave *slave,enum sdw_data_direction direction,unsigned int port_num); +int sdw_configure_dpn_intr (struct sdw_slave *slave,int port, +bool enable,int mask);int sdw_transfer (struct sdw_bus *bus,struct sdw_msg *msg); int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg,
drivers/soundwire/stream.c +271 -0
277 lines not on this page · raw message
include/linux/soundwire/sdw.h +54 -0
90 lines not on this page · raw message
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 6/13 soundwire: Add bank switch routine
In reply to Vinod KoulFrom: Sanyog Kale <[email protected]>
SoundWire supports two registers banks. So, program the alternate bank with new configuration and then performs bank switch.
--- drivers/soundwire/bus.c | 7 ++ drivers/soundwire/bus.h | 5 ++ drivers/soundwire/stream.c | 202 ++++++++++++++++++++++++++++++++++++++++++ include/linux/soundwire/sdw.h | 48 ++++++++++ 4 files changed, 262 insertions(+)
drivers/soundwire/bus.c +7 -0
@@ -78,6 +78,13 @@ int sdw_add_bus_master(struct sdw_bus *bus)return ret; } +/* +* Default active bank will be 0 as out of reset the Slaves have +* to start with bank 0 (Table 40 of Spec) +*/ + bus->params.curr_bank =SDW_BANK0 ; + bus->params.next_bank =SDW_BANK1 ; +return 0 ; }EXPORT_SYMBOL (sdw_add_bus_master);
drivers/soundwire/bus.h +5 -0
@@ -45,6 +45,11 @@ struct sdw_msg {bool page; }; +#define SDW_DOUBLE_RATE_FACTOR 2 + +extern int rows[SDW_FRAME_ROWS ]; +extern int cols[SDW_FRAME_COLS ]; +/** * sdw_port_runtime: Runtime port parameters for Master or Slave *
drivers/soundwire/stream.c +202 -0
214 lines not on this page · raw message
include/linux/soundwire/sdw.h +48 -0
107 lines not on this page · raw message
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 7/13 soundwire: Add stream configuration APIs
In reply to Vinod KoulFrom: Sanyog Kale <[email protected]>
Add APIs for prepare, enable, disable and de-prepare stream.
--- drivers/soundwire/bus.c | 9 ++ drivers/soundwire/stream.c | 244 ++++++++++++++++++++++++++++++++++++++++++ include/linux/soundwire/sdw.h | 4 + 3 files changed, 257 insertions(+)
drivers/soundwire/bus.c +9 -0
@@ -17,6 +17,7 @@*/ int sdw_add_bus_master (struct sdw_bus *bus) { +struct sdw_master_prop *prop =NULL ;int ret;if (!bus->dev) {
@@ -79,9 +80,17 @@ int sdw_add_bus_master(struct sdw_bus *bus) }/* +* Initialize clock values based on Master properties. The max +* frequency is read from max_freq property. Current assumption +* is that the bus will start at highest clock frequency when +* powered on. +* * Default active bank will be 0 as out of reset the Slaves have * to start with bank 0 (Table 40 of Spec) */ + prop = &bus->prop; + bus->params.max_dr_freq = prop->max_freq *SDW_DOUBLE_RATE_FACTOR ; + bus->params.curr_dr_freq = bus->params.max_dr_freq; bus->params.curr_bank =SDW_BANK0 ; bus->params.next_bank =SDW_BANK1 ;
drivers/soundwire/stream.c +244 -0
247 lines not on this page · raw message
include/linux/soundwire/sdw.h +4 -0
@@ -791,6 +791,10 @@ int sdw_stream_remove_master(struct sdw_bus *bus, struct sdw_stream_runtime *stream);int sdw_stream_remove_slave (struct sdw_slave *slave,struct sdw_stream_runtime *stream); +int sdw_prepare_stream (struct sdw_stream_runtime *stream); +int sdw_enable_stream (struct sdw_stream_runtime *stream); +int sdw_disable_stream (struct sdw_stream_runtime *stream); +int sdw_deprepare_stream (struct sdw_stream_runtime *stream);/* messaging and data APIs */
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 8/13 ASoC: Add SoundWire stream programming interface
In reply to Vinod KoulFrom: Shreyas NC <[email protected]>
SoundWire stream needs to be propagated to all the DAIs(cpu, codec). So, add a snd_soc_dai_set_sdw_stream() API for the same.
--- include/sound/soc-dai.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
include/sound/soc-dai.h +23 -0
@@ -168,6 +168,8 @@ struct snd_soc_dai_ops { unsigned int rx_num, unsigned int *rx_slot);int (*set_tristate)(struct snd_soc_dai *dai,int tristate); +int (*set_sdw_stream)(struct snd_soc_dai *dai, +void *stream,int direction);/* * DAI digital mute - optional. * Called by soc-core to minimise any pops.
@@ -359,4 +361,25 @@ static inline void *snd_soc_dai_get_drvdata(struct snd_soc_dai *dai) return dev_get_drvdata(dai->dev); } +/** +* snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation +* @dai: DAI +* @stream: STREAM +* @direction: Stream direction(Playback/Capture) +* SoundWire subsystem doesn't have a notion of direction and we reuse +* the ASoC stream direction to configure sink/source ports. +* Playback maps to source ports and Capture for sink ports. +* +* This should be invoked with NULL to clear the stream set previously. +* Returns 0 on success, a negative error code otherwise. +*/ +static inline int snd_soc_dai_set_sdw_stream (struct snd_soc_dai *dai, +void *stream,int direction) +{ +if (dai->driver->ops->set_sdw_stream) +return dai->driver->ops->set_sdw_stream (dai, stream, direction); +else +return -ENOTSUPP ; +} +#endif
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 9/13 soundwire: Remove cdns_master_ops
In reply to Vinod KoulFrom: Shreyas NC <[email protected]>
There can be instances where drivers using Cadence IP might want to set sdw_master_ops differently per instance of it's use, so remove the cdns_master_ops and export the APIs.
--- drivers/soundwire/cadence_master.c | 17 ++++++----------- drivers/soundwire/cadence_master.h | 8 ++++++++ drivers/soundwire/intel.c | 11 +++++++++-- 3 files changed, 23 insertions(+), 13 deletions(-)
drivers/soundwire/cadence_master.c +6 -11
@@ -396,7 +396,7 @@ static int cdns_prep_msg(struct sdw_cdns *cdns, struct sdw_msg *msg, int *cmd)return 0 ; } -static enum sdw_command_response +enum sdw_command_response cdns_xfer_msg (struct sdw_bus *bus,struct sdw_msg *msg) {struct sdw_cdns *cdns =bus_to_cdns (bus);
@@ -422,8 +422,9 @@ cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg) exit:return ret; } +EXPORT_SYMBOL (cdns_xfer_msg); -static enum sdw_command_response +enum sdw_command_response cdns_xfer_msg_defer (struct sdw_bus *bus,struct sdw_msg *msg,struct sdw_defer *defer) {
@@ -443,8 +444,9 @@ cdns_xfer_msg_defer(struct sdw_bus *bus,return _cdns_xfer_msg (cdns, msg, cmd,0 , msg->len, true); } +EXPORT_SYMBOL (cdns_xfer_msg_defer); -static enum sdw_command_response +enum sdw_command_response cdns_reset_page_addr (struct sdw_bus *bus,unsigned int dev_num) {struct sdw_cdns *cdns =bus_to_cdns (bus);
@@ -456,6 +458,7 @@ cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num)return cdns_program_scp_addr (cdns, &msg); } +EXPORT_SYMBOL (cdns_reset_page_addr);/* * IRQ handling
@@ -727,14 +730,6 @@ int sdw_cdns_init(struct sdw_cdns *cdns) }EXPORT_SYMBOL (sdw_cdns_init); -struct sdw_master_ops sdw_cdns_master_ops = { - .read_prop = sdw_master_read_prop, - .xfer_msg = cdns_xfer_msg, - .xfer_msg_defer = cdns_xfer_msg_defer, - .reset_page_addr = cdns_reset_page_addr, -}; -EXPORT_SYMBOL (sdw_cdns_master_ops); -/** * sdw_cdns_probe() - Cadence probe routine * @cdns: Cadence instance
drivers/soundwire/cadence_master.h +8 -0
@@ -44,5 +44,13 @@ irqreturn_t sdw_cdns_thread(int irq, void *dev_id);int sdw_cdns_init (struct sdw_cdns *cdns);int sdw_cdns_enable_interrupt (struct sdw_cdns *cdns); +enum sdw_command_response +cdns_xfer_msg (struct sdw_bus *bus,struct sdw_msg *msg); +enum sdw_command_response +cdns_xfer_msg_defer (struct sdw_bus *bus, +struct sdw_msg *msg,struct sdw_defer *defer); + +enum sdw_command_response +cdns_reset_page_addr (struct sdw_bus *bus,unsigned int dev_num);#endif /* __SDW_CADENCE_H */
drivers/soundwire/intel.c +9 -2
@@ -252,6 +252,13 @@ static int intel_prop_read(struct sdw_bus *bus)return 0 ; } +static struct sdw_master_ops sdw_intel_ops = { + .read_prop = sdw_master_read_prop, + .xfer_msg = cdns_xfer_msg, + .xfer_msg_defer = cdns_xfer_msg_defer, + .reset_page_addr = cdns_reset_page_addr, +}; +/* * probe and init */
@@ -276,8 +283,8 @@ static int intel_probe(struct platform_device *pdev)sdw_cdns_probe (&sdw->cdns);/* Set property read ops */ - sdw_cdns_master_ops.read_prop = intel_prop_read; - sdw->cdns.bus.ops = &sdw_cdns_master_ops; + sdw_intel_ops.read_prop = intel_prop_read; + sdw->cdns.bus.ops = &sdw_intel_ops;platform_set_drvdata (pdev, sdw);
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 10/13 soundwire: cdns: Add port routines
In reply to Vinod KoulAdd support for Cadence port management and implement master port ops.
--- drivers/soundwire/cadence_master.c | 243 +++++++++++++++++++++++++++++++++++++ drivers/soundwire/cadence_master.h | 100 +++++++++++++++ drivers/soundwire/intel.c | 1 + 3 files changed, 344 insertions(+)
drivers/soundwire/cadence_master.c +243 -0
@@ -669,6 +669,120 @@ int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns) }EXPORT_SYMBOL (sdw_cdns_enable_interrupt); +static int cdns_allocate_pdi (struct sdw_cdns *cdns, +struct sdw_cdns_pdi **stream, +u32 num,u32 pdi_offset) +{ +struct sdw_cdns_pdi *pdi; +int i; + +if (!num) +return 0 ; + + pdi =devm_kcalloc (cdns->dev, num,sizeof (*pdi),GFP_KERNEL ); +if (!pdi) +return -ENOMEM ; + +for (i =0 ; i < num; i++) { + pdi[i].num = i + pdi_offset; + pdi[i].assigned = false; + } + + *stream = pdi; +return 0 ; +} + +/** +* sdw_cdns_pdi_init() - PDI initialization routine +* +* @cdns: Cadence instance +* @config: Stream configurations +*/ +int sdw_cdns_pdi_init (struct sdw_cdns *cdns, +struct sdw_cdns_stream_config config) +{ +struct sdw_cdns_streams *stream; +int offset, i, ret; + + cdns->pcm.num_bd = config.pcm_bd; + cdns->pcm.num_in = config.pcm_in; + cdns->pcm.num_out = config.pcm_out; + cdns->pdm.num_bd = config.pdm_bd; + cdns->pdm.num_in = config.pdm_in; + cdns->pdm.num_out = config.pdm_out; + +/* Allocate PDIs for PCMs */ + stream = &cdns->pcm; + +/* First two PDIs are reserved for bulk transfers */ + stream->num_bd -=CDNS_PCM_PDI_OFFSET ; + offset =CDNS_PCM_PDI_OFFSET ; + + ret =cdns_allocate_pdi (cdns, &stream->bd, + stream->num_bd, offset); +if (ret) +return ret; + + offset += stream->num_bd; + + ret =cdns_allocate_pdi (cdns, &stream->in, + stream->num_in, offset); +if (ret) +return ret; + + offset += stream->num_in; + + ret =cdns_allocate_pdi (cdns, &stream->out, + stream->num_out, offset); +if (ret) +return ret; + +/* Update total number of PCM PDIs */ + stream->num_pdi = stream->num_bd + stream->num_in + stream->num_out; + cdns->num_ports = stream->num_pdi; + +/* Allocate PDIs for PDMs */ + stream = &cdns->pdm; + offset =CDNS_PDM_PDI_OFFSET ; + ret =cdns_allocate_pdi (cdns, &stream->bd, + stream->num_bd, offset); +if (ret) +return ret; + + offset += stream->num_bd; + + ret =cdns_allocate_pdi (cdns, &stream->in, + stream->num_in, offset); +if (ret) +return ret; + + offset += stream->num_in; + + ret =cdns_allocate_pdi (cdns, &stream->out, + stream->num_out, offset); +if (ret) +return ret; + +/* Update total number of PDM PDIs */ + stream->num_pdi = stream->num_bd + stream->num_in + stream->num_out; + cdns->num_ports += stream->num_pdi; + + cdns->ports =devm_kcalloc (cdns->dev, cdns->num_ports, +sizeof (*cdns->ports),GFP_KERNEL ); +if (!cdns->ports) { + ret = -ENOMEM ; +return ret; + } + +for (i =0 ; i < cdns->num_ports; i++) { + cdns->ports[i].assigned = false; + cdns->ports[i].num = i +1 ;/* Port 0 reserved for bulk */ + } + +return 0 ; +} +EXPORT_SYMBOL (sdw_cdns_pdi_init); +/** * sdw_cdns_init() - Cadence initialization * @cdns: Cadence instance
@@ -730,6 +844,134 @@ int sdw_cdns_init(struct sdw_cdns *cdns) }EXPORT_SYMBOL (sdw_cdns_init); +int cdns_bus_conf (struct sdw_bus *bus,struct sdw_bus_params *params) +{ +struct sdw_cdns *cdns =bus_to_cdns (bus); +int mcp_clkctrl_off, mcp_clkctrl; +int divider; + +if (!params->curr_dr_freq) { +dev_err (cdns->dev,"NULL curr_dr_freq" ); +return -EINVAL ; + } + + divider = (params->max_dr_freq / params->curr_dr_freq) -1 ; + +if (params->next_bank) + mcp_clkctrl_off =CDNS_MCP_CLK_CTRL1 ; +else + mcp_clkctrl_off =CDNS_MCP_CLK_CTRL0 ; + + mcp_clkctrl =cdns_readl (cdns, mcp_clkctrl_off); + mcp_clkctrl |= divider; +cdns_writel (cdns, mcp_clkctrl_off, mcp_clkctrl); + +return 0 ; +} +EXPORT_SYMBOL (cdns_bus_conf); + +static int cdns_port_params (struct sdw_bus *bus, +struct sdw_port_params *p_params,unsigned int bank) +{ +struct sdw_cdns *cdns =bus_to_cdns (bus); +int dpn_config =0 , dpn_config_off; + +if (bank) + dpn_config_off =CDNS_DPN_B1_CONFIG (p_params->num); +else + dpn_config_off =CDNS_DPN_B0_CONFIG (p_params->num); + + dpn_config =cdns_readl (cdns, dpn_config_off); + + dpn_config |= ((p_params->bps -1 ) << +SDW_REG_SHIFT (CDNS_DPN_CONFIG_WL )); + dpn_config |= (p_params->flow_mode << +SDW_REG_SHIFT (CDNS_DPN_CONFIG_PORT_FLOW )); + dpn_config |= (p_params->data_mode << +SDW_REG_SHIFT (CDNS_DPN_CONFIG_PORT_DAT )); + +cdns_writel (cdns, dpn_config_off, dpn_config); + +return 0 ; +} + +static int cdns_transport_params (struct sdw_bus *bus, +struct sdw_transport_params *t_params, +enum sdw_reg_bank bank) +{ +struct sdw_cdns *cdns =bus_to_cdns (bus); +int dpn_offsetctrl =0 , dpn_offsetctrl_off; +int dpn_config =0 , dpn_config_off; +int dpn_hctrl =0 , dpn_hctrl_off; +int num = t_params->port_num; +int dpn_samplectrl_off; + +/* +* Note: Only full data port is supported on the Master side for +* both PCM and PDM ports. +*/ + +if (bank) { + dpn_config_off =CDNS_DPN_B1_CONFIG (num); + dpn_samplectrl_off =CDNS_DPN_B1_SAMPLE_CTRL (num); + dpn_hctrl_off =CDNS_DPN_B1_HCTRL (num); + dpn_offsetctrl_off =CDNS_DPN_B1_OFFSET_CTRL (num); + }else { + dpn_config_off =CDNS_DPN_B0_CONFIG (num); + dpn_samplectrl_off =CDNS_DPN_B0_SAMPLE_CTRL (num); + dpn_hctrl_off =CDNS_DPN_B0_HCTRL (num); + dpn_offsetctrl_off =CDNS_DPN_B0_OFFSET_CTRL (num); + } + + dpn_config =cdns_readl (cdns, dpn_config_off); + + dpn_config |= (t_params->blk_grp_ctrl << +SDW_REG_SHIFT (CDNS_DPN_CONFIG_BGC )); + dpn_config |= (t_params->blk_pkg_mode << +SDW_REG_SHIFT (CDNS_DPN_CONFIG_BPM )); +cdns_writel (cdns, dpn_config_off, dpn_config); + + dpn_offsetctrl |= (t_params->offset1 << +SDW_REG_SHIFT (CDNS_DPN_OFFSET_CTRL_1 )); + dpn_offsetctrl |= (t_params->offset2 << +SDW_REG_SHIFT (CDNS_DPN_OFFSET_CTRL_2 )); +cdns_writel (cdns, dpn_offsetctrl_off, dpn_offsetctrl); + + dpn_hctrl |= (t_params->hstart << +SDW_REG_SHIFT (CDNS_DPN_HCTRL_HSTART )); + dpn_hctrl |= (t_params->hstop <<SDW_REG_SHIFT (CDNS_DPN_HCTRL_HSTOP )); + dpn_hctrl |= (t_params->lane_ctrl << +SDW_REG_SHIFT (CDNS_DPN_HCTRL_LCTRL )); + +cdns_writel (cdns, dpn_hctrl_off, dpn_hctrl); +cdns_writel (cdns, dpn_samplectrl_off, (t_params->sample_interval -1 )); + +return 0 ; +} + +static int cdns_port_enable (struct sdw_bus *bus, +struct sdw_enable_ch *enable_ch,unsigned int bank) +{ +struct sdw_cdns *cdns =bus_to_cdns (bus); +int dpn_chnen_off, ch_mask; + +if (bank) + dpn_chnen_off =CDNS_DPN_B1_CH_EN (enable_ch->port_num); +else + dpn_chnen_off =CDNS_DPN_B0_CH_EN (enable_ch->port_num); + + ch_mask = enable_ch->ch_mask * enable_ch->enable; +cdns_writel (cdns, dpn_chnen_off, ch_mask); + +return 0 ; +} + +static const struct sdw_master_port_ops cdns_port_ops = { + .dpn_set_port_params = cdns_port_params, + .dpn_set_port_transport_params = cdns_transport_params, + .dpn_port_enable_ch = cdns_port_enable, +}; +/** * sdw_cdns_probe() - Cadence probe routine * @cdns: Cadence instance
@@ -737,6 +979,7 @@ EXPORT_SYMBOL(sdw_cdns_init);int sdw_cdns_probe (struct sdw_cdns *cdns) {init_completion (&cdns->tx_complete); + cdns->bus.port_ops = &cdns_port_ops;return 0 ; }
drivers/soundwire/cadence_master.h +100 -0
128 lines not on this page · raw message
drivers/soundwire/intel.c +1 -0
@@ -257,6 +257,7 @@ static struct sdw_master_ops sdw_intel_ops = { .xfer_msg = cdns_xfer_msg, .xfer_msg_defer = cdns_xfer_msg_defer, .reset_page_addr = cdns_reset_page_addr, + .set_bus_conf = cdns_bus_conf, };/*
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 11/13 soundwire: cdns: Add stream routines
In reply to Vinod KoulAdd support for Cadence stream initialization and implement stream APIs.
--- drivers/soundwire/cadence_master.c | 195 +++++++++++++++++++++++++++++++++++++ drivers/soundwire/cadence_master.h | 43 ++++++++ 2 files changed, 238 insertions(+)
drivers/soundwire/cadence_master.c +195 -0
@@ -13,6 +13,8 @@#include <linux/mod_devicetable.h> #include <linux/soundwire/sdw_registers.h> #include <linux/soundwire/sdw.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> #include "bus.h" #include "cadence_master.h"
@@ -985,5 +987,198 @@ int sdw_cdns_probe(struct sdw_cdns *cdns) }EXPORT_SYMBOL (sdw_cdns_probe); +int cdns_set_sdw_stream (struct snd_soc_dai *dai, +void *stream,bool pcm,int direction) +{ +struct sdw_cdns *cdns =snd_soc_dai_get_drvdata (dai); +struct sdw_cdns_dma_data *dma; + + dma =kzalloc (sizeof (*dma),GFP_KERNEL ); +if (!dma) +return -ENOMEM ; + +if (pcm) + dma->stream_type =SDW_STREAM_PCM ; +else + dma->stream_type =SDW_STREAM_PDM ; + + dma->bus = &cdns->bus; + dma->link_id = cdns->instance; + + dma->stream = stream; + +if (direction ==SNDRV_PCM_STREAM_PLAYBACK ) + dai->playback_dma_data = dma; +else + dai->capture_dma_data = dma; + +return 0 ; +} +EXPORT_SYMBOL (cdns_set_sdw_stream); + +/** +* cdns_find_pdi() - Find a free PDI +* +* @cdns: Cadence instance +* @num: Number of PDIs +* @pdi: PDI instances +* +* Find and return a free PDI for a given PDI array +*/ +static struct sdw_cdns_pdi *cdns_find_pdi (struct sdw_cdns *cdns, +unsigned int num,struct sdw_cdns_pdi *pdi) +{ +int i; + +for (i =0 ; i < num; i++) { +if (pdi[i].assigned == true) +continue ; + pdi[i].assigned = true; +return &pdi[i]; + } + +return NULL ; +} + +/** +* sdw_cdns_config_stream: Configure a stream +* +* @cdns: Cadence instance +* @port: Cadence data port +* @ch: Channel count +* @dir: Data direction +* @pdi: PDI to be used +*/ +void sdw_cdns_config_stream (struct sdw_cdns *cdns, +struct sdw_cdns_port *port, +u32 ch,u32 dir,struct sdw_cdns_pdi *pdi) +{ +u32 offset, val =0 ; + +if (dir ==SDW_DATA_DIR_RX ) + val =CDNS_PORTCTRL_DIRN ; + + offset =CDNS_PORTCTRL + port->num *CDNS_PORT_OFFSET ; +cdns_updatel (cdns, offset,CDNS_PORTCTRL_DIRN , val); + + val = port->num; + val |= ((1 << ch) -1 ) <<SDW_REG_SHIFT (CDNS_PDI_CONFIG_CHANNEL ); +cdns_writel (cdns,CDNS_PDI_CONFIG (pdi->num), val); +} +EXPORT_SYMBOL (sdw_cdns_config_stream); + +/** +* cdns_get_num_pdi() - Get number of PDIs required +* +* @cdns: Cadence instance +* @pdi: PDI to be used +* @num: Number of PDIs +* @ch_count: Channel count +*/ +static int cdns_get_num_pdi (struct sdw_cdns *cdns, +struct sdw_cdns_pdi *pdi, +unsigned int num,u32 ch_count) +{ +int i, pdis =0 ; + +for (i =0 ; i < num; i++) { +if (pdi[i].assigned == true) +continue ; + +if (pdi[i].ch_count < ch_count) + ch_count -= pdi[i].ch_count; +else + ch_count =0 ; + + pdis++; + +if (!ch_count) +break ; + } + +if (ch_count) +return 0 ; + +return pdis; +} + +/** +* sdw_cdns_get_stream() - Get stream information +* +* @cdns: Cadence instance +* @stream: Stream to be allocated +* @ch: Channel count +* @dir: Data direction +*/ +int sdw_cdns_get_stream (struct sdw_cdns *cdns, +struct sdw_cdns_streams *stream, +u32 ch,u32 dir) +{ +int pdis =0 ; + +if (dir ==SDW_DATA_DIR_RX ) + pdis =cdns_get_num_pdi (cdns, stream->in, stream->num_in, ch); +else + pdis =cdns_get_num_pdi (cdns, stream->out, stream->num_out, ch); + +/* check if we found PDI, else find in bi-directional */ +if (!pdis) + pdis =cdns_get_num_pdi (cdns, stream->bd, stream->num_bd, ch); + +return pdis; +} +EXPORT_SYMBOL (sdw_cdns_get_stream); + +/** +* sdw_cdns_alloc_stream() - Allocate a stream +* +* @cdns: Cadence instance +* @stream: Stream to be allocated +* @port: Cadence data port +* @ch: Channel count +* @dir: Data direction +*/ +int sdw_cdns_alloc_stream (struct sdw_cdns *cdns, +struct sdw_cdns_streams *stream, +struct sdw_cdns_port *port,u32 ch,u32 dir) +{ +struct sdw_cdns_pdi *pdi =NULL ; + +if (dir ==SDW_DATA_DIR_RX ) + pdi =cdns_find_pdi (cdns, stream->num_in, stream->in); +else + pdi =cdns_find_pdi (cdns, stream->num_out, stream->out); + +/* check if we found a PDI, else find in bi-directional */ +if (!pdi) + pdi =cdns_find_pdi (cdns, stream->num_bd, stream->bd); + +if (!pdi) +return -EIO ; + + port->pdi = pdi; + pdi->l_ch_num =0 ; + pdi->h_ch_num = ch -1 ; + pdi->dir = dir; + pdi->ch_count = ch; + +return 0 ; +} +EXPORT_SYMBOL (sdw_cdns_alloc_stream); + +void sdw_cdns_shutdown (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct sdw_cdns_dma_data *dma; + + dma =snd_soc_dai_get_dma_data (dai, substream); +if (!dma) +return ; + +snd_soc_dai_set_dma_data (dai, substream,NULL ); +kfree (dma); +} +EXPORT_SYMBOL (sdw_cdns_shutdown); +MODULE_LICENSE ("Dual BSD/GPL" );MODULE_DESCRIPTION ("Cadence Soundwire Library" );
drivers/soundwire/cadence_master.h +43 -0
64 lines not on this page · raw message
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 12/13 soundwire: intel: Add stream initialization
In reply to Vinod KoulAdd Intel stream init routines which initialize the Physical Data Interface (PDI), Audio Link Hub (ALH) and Audio shim. Also add bank switch routines.
--- drivers/soundwire/intel.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+)
drivers/soundwire/intel.c +155 -0
@@ -9,6 +9,8 @@#include <linux/delay.h> #include <linux/interrupt.h> #include <linux/platform_device.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> #include <linux/soundwire/sdw_registers.h> #include <linux/soundwire/sdw.h> #include <linux/soundwire/sdw_intel.h>
@@ -234,6 +236,149 @@ static int intel_shim_init(struct sdw_intel *sdw)return ret; } +/* +* PDI routines +*/ +static void intel_pdi_init (struct sdw_intel *sdw, +struct sdw_cdns_stream_config *config) +{ +void __iomem *shim = sdw->res->shim; +unsigned int link_id = sdw->instance; +int pcm_cap, pdm_cap; + +/* PCM Stream Capability */ + pcm_cap =intel_readw (shim,SDW_SHIM_PCMSCAP (link_id)); + + config->pcm_bd = (pcm_cap &SDW_SHIM_PCMSCAP_BSS ) >> +SDW_REG_SHIFT (SDW_SHIM_PCMSCAP_BSS ); + config->pcm_in = (pcm_cap &SDW_SHIM_PCMSCAP_ISS ) >> +SDW_REG_SHIFT (SDW_SHIM_PCMSCAP_ISS ); + config->pcm_out = (pcm_cap &SDW_SHIM_PCMSCAP_OSS ) >> +SDW_REG_SHIFT (SDW_SHIM_PCMSCAP_OSS ); + +/* PDM Stream Capability */ + pdm_cap =intel_readw (shim,SDW_SHIM_PDMSCAP (link_id)); + + config->pdm_bd = (pdm_cap &SDW_SHIM_PDMSCAP_BSS ) >> +SDW_REG_SHIFT (SDW_SHIM_PDMSCAP_BSS ); + config->pdm_in = (pdm_cap &SDW_SHIM_PDMSCAP_ISS ) >> +SDW_REG_SHIFT (SDW_SHIM_PDMSCAP_ISS ); + config->pdm_out = (pdm_cap &SDW_SHIM_PDMSCAP_OSS ) >> +SDW_REG_SHIFT (SDW_SHIM_PDMSCAP_OSS ); +} + +static int +intel_pdi_get_ch_cap (struct sdw_intel *sdw,unsigned int pdi_num,bool pcm) +{ +void __iomem *shim = sdw->res->shim; +unsigned int link_id = sdw->instance; +int count; + +if (pcm) { + count =intel_readw (shim,SDW_SHIM_PCMSYCHC (link_id, pdi_num)); + }else { + count =intel_readw (shim,SDW_SHIM_PDMSCAP (link_id)); + count = ((count &SDW_SHIM_PDMSCAP_CPSS ) >> +SDW_REG_SHIFT (SDW_SHIM_PDMSCAP_CPSS )); + } + +/* zero based values for channel count in register */ + count++; + +return count; +} + +static int intel_pdi_get_ch_update (struct sdw_intel *sdw, +struct sdw_cdns_pdi *pdi, +unsigned int num_pdi, +unsigned int *num_ch,bool pcm) +{ +int i, ch_count =0 ; + +for (i =0 ; i < num_pdi; i++) { + pdi->ch_count =intel_pdi_get_ch_cap (sdw, pdi->num, pcm); + ch_count += pdi->ch_count; + pdi++; + } + + *num_ch = ch_count; +return 0 ; +} + +static int intel_pdi_stream_ch_update (struct sdw_intel *sdw, +struct sdw_cdns_streams *stream,bool pcm) +{ +intel_pdi_get_ch_update (sdw, stream->bd, stream->num_bd, + &stream->num_ch_bd, pcm); + +intel_pdi_get_ch_update (sdw, stream->in, stream->num_in, + &stream->num_ch_in, pcm); + +intel_pdi_get_ch_update (sdw, stream->out, stream->num_out, + &stream->num_ch_out, pcm); + +return 0 ; +} + +static int intel_pdi_ch_update (struct sdw_intel *sdw) +{ +/* First update PCM streams followed by PDM streams */ +intel_pdi_stream_ch_update (sdw, &sdw->cdns.pcm, true); +intel_pdi_stream_ch_update (sdw, &sdw->cdns.pdm, false); + +return 0 ; +} + +static void +intel_pdi_shim_configure (struct sdw_intel *sdw,struct sdw_cdns_pdi *pdi) +{ +void __iomem *shim = sdw->res->shim; +unsigned int link_id = sdw->instance; +int pdi_conf =0 ; + + pdi->intel_alh_id = (link_id *16 ) + pdi->num +5 ; + +/* +* Program stream parameters to stream SHIM register +* This is applicable for PCM stream only. +*/ +if (pdi->type !=SDW_STREAM_PCM ) +return ; + +if (pdi->dir ==SDW_DATA_DIR_RX ) + pdi_conf |=SDW_SHIM_PCMSYCM_DIR ; +else + pdi_conf &= ~(SDW_SHIM_PCMSYCM_DIR ); + + pdi_conf |= (pdi->intel_alh_id << +SDW_REG_SHIFT (SDW_SHIM_PCMSYCM_STREAM )); + pdi_conf |= (pdi->l_ch_num <<SDW_REG_SHIFT (SDW_SHIM_PCMSYCM_LCHN )); + pdi_conf |= (pdi->h_ch_num <<SDW_REG_SHIFT (SDW_SHIM_PCMSYCM_HCHN )); + +intel_writew (shim,SDW_SHIM_PCMSYCHM (link_id, pdi->num), pdi_conf); +} + +static void +intel_pdi_alh_configure (struct sdw_intel *sdw,struct sdw_cdns_pdi *pdi) +{ +void __iomem *alh = sdw->res->alh; +unsigned int link_id = sdw->instance; +unsigned int conf; + + pdi->intel_alh_id = (link_id *16 ) + pdi->num +5 ; + +/* Program Stream config ALH register */ + conf =intel_readl (alh,SDW_ALH_STRMZCFG (pdi->intel_alh_id)); + + conf |= (SDW_ALH_STRMZCFG_DMAT_VAL << +SDW_REG_SHIFT (SDW_ALH_STRMZCFG_DMAT )); + + conf |= ((pdi->ch_count -1 ) << +SDW_REG_SHIFT (SDW_ALH_STRMZCFG_CHN )); + +intel_writel (alh,SDW_ALH_STRMZCFG (pdi->intel_alh_id), conf); +} +static int intel_prop_read (struct sdw_bus *bus) {/* Initialize with default handler to read all DisCo properties */
@@ -265,6 +410,7 @@ static struct sdw_master_ops sdw_intel_ops = {*/ static int intel_probe (struct platform_device *pdev) { +struct sdw_cdns_stream_config config;struct sdw_intel *sdw;int ret;
@@ -287,6 +433,9 @@ static int intel_probe(struct platform_device *pdev) sdw_intel_ops.read_prop = intel_prop_read; sdw->cdns.bus.ops = &sdw_intel_ops; + sdw_intel_ops.read_prop = intel_prop_read; + sdw->cdns.bus.ops = &sdw_intel_ops; +platform_set_drvdata (pdev, sdw); ret =sdw_add_bus_master (&sdw->cdns.bus);
@@ -304,9 +453,15 @@ static int intel_probe(struct platform_device *pdev) goto err_init; ret =sdw_cdns_enable_interrupt (&sdw->cdns); + +/* Read the PDI config and initialize cadence PDI */ +intel_pdi_init (sdw, &config); + ret =sdw_cdns_pdi_init (&sdw->cdns, config);if (ret) goto err_init; +intel_pdi_ch_update (sdw); +/* Acquire IRQ */ ret = request_threaded_irq(sdw->res->irq, sdw_cdns_irq, sdw_cdns_thread, IRQF_SHARED, KBUILD_MODNAME,
Signature · 1 line
2.7.4
Vinod Koul
maintainerPATCH v6 13/13 soundwire: intel: Add audio DAI ops
In reply to Vinod KoulAdd DAI registration and DAI ops for the Intel driver along with callback for topology configuration.
--- drivers/soundwire/Kconfig | 2 +- drivers/soundwire/intel.c | 358 ++++++++++++++++++++++++++++++++++++ drivers/soundwire/intel.h | 4 + drivers/soundwire/intel_init.c | 3 + include/linux/soundwire/sdw.h | 3 + include/linux/soundwire/sdw_intel.h | 14 ++ 6 files changed, 383 insertions(+), 1 deletion(-)
drivers/soundwire/Kconfig +1 -1
@@ -27,7 +27,7 @@ config SOUNDWIRE_INTEL tristate "Intel SoundWire Master driver" select SOUNDWIRE_CADENCE select SOUNDWIRE_BUS - depends on X86 && ACPI + depends on X86 && ACPI && SND_SOC ---help--- SoundWire Intel Master driver. If you have an Intel platform which has a SoundWire Master then
drivers/soundwire/intel.c +358 -0
384 lines not on this page · raw message
drivers/soundwire/intel.h +4 -0
@@ -10,6 +10,8 @@* @shim: Audio shim pointer * @alh: ALH (Audio Link Hub) pointer * @irq: Interrupt line +* @ops: Shim callback ops +* @arg: Shim callback ops argument * * This is set as pdata for each link instance. */
@@ -18,6 +20,8 @@ struct sdw_intel_link_res {void __iomem *shim;void __iomem *alh;int irq; +const struct sdw_intel_ops *ops; + void *arg; };#endif /* __SDW_INTEL_LOCAL_H */
drivers/soundwire/intel_init.c +3 -0
@@ -111,6 +111,9 @@ static struct sdw_intel_ctx link->res.shim = res->mmio_base +SDW_SHIM_BASE ; link->res.alh = res->mmio_base +SDW_ALH_BASE ; + link->res.ops = res->ops; + link->res.arg = res->arg; +memset (&pdevinfo,0 ,sizeof (pdevinfo)); pdevinfo.parent = res->parent;
include/linux/soundwire/sdw.h +3 -0
@@ -38,6 +38,9 @@ struct sdw_slave;#define SDW_VALID_PORT_RANGE (n) (n <= 14 && n >= 1) +#define SDW_DAI_ID_RANGE_START 100 +#define SDW_DAI_ID_RANGE_END 200 +/** * enum sdw_slave_status - Slave status * @SDW_SLAVE_UNATTACHED: Slave is not attached with the bus.
include/linux/soundwire/sdw_intel.h +14 -0
@@ -5,17 +5,31 @@#define __SDW_INTEL_H/** +* struct sdw_intel_ops: Intel audio driver callback ops +* +* @config_stream: configure the stream with the hw_params +*/ +struct sdw_intel_ops { +int (*config_stream)(void *arg,void *substream, +void *dai,void *hw_params,int stream_num); +}; + +/** * struct sdw_intel_res - Soundwire Intel resource structure * @mmio_base: mmio base of SoundWire registers * @irq: interrupt number * @handle: ACPI parent handle * @parent: parent device +* @ops: callback ops +* @arg: callback arg */ struct sdw_intel_res {void __iomem *mmio_base;int irq;acpi_handle handle;struct device *parent; +const struct sdw_intel_ops *ops; +void *arg; };void *sdw_intel_init (acpi_handle *parent_handle,struct sdw_intel_res *res);
Signature · 1 line
2.7.4
Quoted 11 lines · Vinod Koul
This series adds support in SoundWire subsystem for:
- Documentation for stream support
- stream management
- data port management
- DAI ops in cadence and Intel drivers
- ASoC API to propagate SDW streamUpdates in v6:
- Fix return error as pointed by Sanyog
- Update stream state enum documentation as pointed by Pierre and few other nits
I double-checked the v6, all my comments were addressed, so all patches
Thanks Vinod, Shreyas and Sanyog. Enjoy your long week-end. -Pierre
Quoted 67 lines
Updated in v5:
- Add todo for device-device changes in future and some comment updates based on feedback from PierreUpdates in v4:
- Add more comments forsdw_release_master_stream()
- Make sure ports are freed uponsdw_stream_remove_slave()
- Clarifysnd_soc_dai_set_sdw_stream()and setting of NULL upon release.Updates in v3:
- Remove stream state transition checks and redefine stream states
- Update bansk switch routines
- Other nitpicks pointed out by Pierre.Updates in v2:
- Make ASoC API inlined
- Make stream states as states and not action
- Update the direction enum
- Fix some typos and comment updates*** SUBJECT HERE ***
*** BLURB HERE ***
Sanyog Kale (7):
Documentation: soundwire: Add more documentation
soundwire: Add support for SoundWire stream management
soundwire: Add support for port management
soundwire: Add Master and Slave port programming
soundwire: Add helpers for ports operations
soundwire: Add bank switch routine
soundwire: Add stream configuration APIsShreyas NC (2):
ASoC: Add SoundWire stream programming interface
soundwire: Removecdns_master_opsVinod Koul (4):
soundwire: cdns: Add port routines
soundwire: cdns: Add stream routines
soundwire: intel: Add stream initialization
soundwire: intel: Add audio DAI ops.../driver-api/soundwire/error_handling.rst | 65 + Documentation/driver-api/soundwire/index.rst | 3 + Documentation/driver-api/soundwire/locking.rst | 106 ++ Documentation/driver-api/soundwire/stream.rst | 372 +++++ drivers/soundwire/Kconfig | 2 +- drivers/soundwire/Makefile | 2 +- drivers/soundwire/bus.c | 43 + drivers/soundwire/bus.h | 72 + drivers/soundwire/cadence_master.c | 451 +++++- drivers/soundwire/cadence_master.h | 151 ++ drivers/soundwire/intel.c | 525 ++++++- drivers/soundwire/intel.h | 4 + drivers/soundwire/intel_init.c | 3 + drivers/soundwire/stream.c | 1479 ++++++++++++++++++++ include/linux/soundwire/sdw.h | 332 ++++- include/linux/soundwire/sdw_intel.h | 14 + include/sound/soc-dai.h | 23 + 17 files changed, 3633 insertions(+), 14 deletions(-)create mode 100644
Documentation/driver-api/soundwire/error_handling.rstcreate mode 100644Documentation/driver-api/soundwire/locking.rstcreate mode 100644Documentation/driver-api/soundwire/stream.rstcreate mode 100644drivers/soundwire/stream.c
Hi Greg,
Quoted 6 lines · Vinod Koul
This series adds support in SoundWire subsystem for:
- Documentation for stream support
- stream management
- data port management
- DAI ops in cadence and Intel drivers
- ASoC API to propagate SDW stream
Any feedback on this series?
Thanks
Quoted 75 lines
Updates in v6:
- Fix return error as pointed by Sanyog
- Update stream state enum documentation as pointed by Pierre and few other nitsUpdated in v5:
- Add todo for device-device changes in future and some comment updates based on feedback from PierreUpdates in v4:
- Add more comments forsdw_release_master_stream()
- Make sure ports are freed uponsdw_stream_remove_slave()
- Clarifysnd_soc_dai_set_sdw_stream()and setting of NULL upon release.Updates in v3:
- Remove stream state transition checks and redefine stream states
- Update bansk switch routines
- Other nitpicks pointed out by Pierre.Updates in v2:
- Make ASoC API inlined
- Make stream states as states and not action
- Update the direction enum
- Fix some typos and comment updates*** SUBJECT HERE ***
*** BLURB HERE ***
Sanyog Kale (7):
Documentation: soundwire: Add more documentation
soundwire: Add support for SoundWire stream management
soundwire: Add support for port management
soundwire: Add Master and Slave port programming
soundwire: Add helpers for ports operations
soundwire: Add bank switch routine
soundwire: Add stream configuration APIsShreyas NC (2):
ASoC: Add SoundWire stream programming interface
soundwire: Removecdns_master_opsVinod Koul (4):
soundwire: cdns: Add port routines
soundwire: cdns: Add stream routines
soundwire: intel: Add stream initialization
soundwire: intel: Add audio DAI ops.../driver-api/soundwire/error_handling.rst | 65 + Documentation/driver-api/soundwire/index.rst | 3 + Documentation/driver-api/soundwire/locking.rst | 106 ++ Documentation/driver-api/soundwire/stream.rst | 372 +++++ drivers/soundwire/Kconfig | 2 +- drivers/soundwire/Makefile | 2 +- drivers/soundwire/bus.c | 43 + drivers/soundwire/bus.h | 72 + drivers/soundwire/cadence_master.c | 451 +++++- drivers/soundwire/cadence_master.h | 151 ++ drivers/soundwire/intel.c | 525 ++++++- drivers/soundwire/intel.h | 4 + drivers/soundwire/intel_init.c | 3 + drivers/soundwire/stream.c | 1479 ++++++++++++++++++++ include/linux/soundwire/sdw.h | 332 ++++- include/linux/soundwire/sdw_intel.h | 14 + include/sound/soc-dai.h | 23 + 17 files changed, 3633 insertions(+), 14 deletions(-) create mode 100644 Documentation/driver-api/soundwire/error_handling.rst create mode 100644 Documentation/driver-api/soundwire/locking.rst create mode 100644 Documentation/driver-api/soundwire/stream.rst create mode 100644 drivers/soundwire/stream.c--
2.7.4
Re: [PATCH v6 08/13] ASoC: Add SoundWire stream programming interface
In reply to Vinod KoulQuoted 4 lines · Vinod Koul
From: Shreyas NC <[email protected]>
SoundWire stream needs to be propagated to all the
DAIs(cpu, codec). So, add asnd_soc_dai_set_sdw_stream()API for the same.
Vinod Koul
maintainerQuoted 11 lines · Vinod Koul
Hi Greg,
Quoted 6 lines · Vinod Koul
This series adds support in SoundWire subsystem for:
- Documentation for stream support
- stream management
- data port management
- DAI ops in cadence and Intel drivers
- ASoC API to propagate SDW streamAny feedback on this series?
Greg,
Am sure you are busy with lots of stuff, would appreciate if you can help with the series and a tiny patch [1].
Now if you are too busy with things, I am willing to help out.
I can:
a) collate and send you a pull request, or
b) Collect everything and send to Linus as I do with dmaengine, with your blessing of course...
Please do let me know, thanks
Quoted 78 lines
Thanks
Quoted 75 lines
Updates in v6:
- Fix return error as pointed by Sanyog
- Update stream state enum documentation as pointed by Pierre and few other nitsUpdated in v5:
- Add todo for device-device changes in future and some comment updates based on feedback from PierreUpdates in v4:
- Add more comments forsdw_release_master_stream()
- Make sure ports are freed uponsdw_stream_remove_slave()
- Clarifysnd_soc_dai_set_sdw_stream()and setting of NULL upon release.Updates in v3:
- Remove stream state transition checks and redefine stream states
- Update bansk switch routines
- Other nitpicks pointed out by Pierre.Updates in v2:
- Make ASoC API inlined
- Make stream states as states and not action
- Update the direction enum
- Fix some typos and comment updates*** SUBJECT HERE ***
*** BLURB HERE ***
Sanyog Kale (7):
Documentation: soundwire: Add more documentation
soundwire: Add support for SoundWire stream management
soundwire: Add support for port management
soundwire: Add Master and Slave port programming
soundwire: Add helpers for ports operations
soundwire: Add bank switch routine
soundwire: Add stream configuration APIsShreyas NC (2):
ASoC: Add SoundWire stream programming interface
soundwire: Removecdns_master_opsVinod Koul (4):
soundwire: cdns: Add port routines
soundwire: cdns: Add stream routines
soundwire: intel: Add stream initialization
soundwire: intel: Add audio DAI ops.../driver-api/soundwire/error_handling.rst | 65 + Documentation/driver-api/soundwire/index.rst | 3 + Documentation/driver-api/soundwire/locking.rst | 106 ++ Documentation/driver-api/soundwire/stream.rst | 372 +++++ drivers/soundwire/Kconfig | 2 +- drivers/soundwire/Makefile | 2 +- drivers/soundwire/bus.c | 43 + drivers/soundwire/bus.h | 72 + drivers/soundwire/cadence_master.c | 451 +++++- drivers/soundwire/cadence_master.h | 151 ++ drivers/soundwire/intel.c | 525 ++++++- drivers/soundwire/intel.h | 4 + drivers/soundwire/intel_init.c | 3 + drivers/soundwire/stream.c | 1479 ++++++++++++++++++++ include/linux/soundwire/sdw.h | 332 ++++- include/linux/soundwire/sdw_intel.h | 14 + include/sound/soc-dai.h | 23 + 17 files changed, 3633 insertions(+), 14 deletions(-) create mode 100644 Documentation/driver-api/soundwire/error_handling.rst create mode 100644 Documentation/driver-api/soundwire/locking.rst create mode 100644 Documentation/driver-api/soundwire/stream.rst create mode 100644 drivers/soundwire/stream.c--
2.7.4
Signature · 1 line
~Vinod
Quoted 11 lines · Vinod Koul
Quoted 10 lines · Vinod Koul
Hi Greg,
Quoted 6 lines · Vinod Koul
This series adds support in SoundWire subsystem for:
- Documentation for stream support
- stream management
- data port management
- DAI ops in cadence and Intel drivers
- ASoC API to propagate SDW stream
Quoted 6 lines
Quoted 1 line
Any feedback on this series?
Greg,
Am sure you are busy with lots of stuff, would appreciate if you can help with the series and a tiny patch [1].
I don't see [1] anywhere :(
Quoted 8 lines
Now if you are too busy with things, I am willing to help out.
I can:
a) collate and send you a pull request, or
b) Collect everything and send to Linus as I do with dmaengine, with your blessing of course...Please do let me know, thanks
Am I the conduit for this subsystem now? If so, ok, I'll pick it up, I didn't realize I was. But if you could collate and send me a pull request, that would be the easiest.
thanks,
greg k-h
Vinod
maintainerQuoted 12 lines · Greg KH
Quoted 11 lines · Vinod Koul
Quoted 10 lines · Vinod Koul
Hi Greg,
Quoted 6 lines · Vinod Koul
This series adds support in SoundWire subsystem for:
- Documentation for stream support
- stream management
- data port management
- DAI ops in cadence and Intel drivers
- ASoC API to propagate SDW stream
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Any feedback on this series?
Greg,
Am sure you are busy with lots of stuff, would appreciate if you can help with the series and a tiny patch [1].
I don't see [1] anywhere :(
Dont know why, You were in To list!
Quoted 10 lines
Quoted 8 lines
Now if you are too busy with things, I am willing to help out.
I can:
a) collate and send you a pull request, or
b) Collect everything and send to Linus as I do with dmaengine, with your blessing of course...Please do let me know, thanks
Am I the conduit for this subsystem now?
well back in Jan when we merged this subsystem it did go thru your tree so I was assuming that :)
Quoted 3 lines
If so, ok, I'll pick it up, I
didn't realize I was. But if you could collate and send me a pull request, that would be the easiest.
Ok sending in a bit.
Signature · 1 line
~Vinod