1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2 /* Copyright(c) 2015-17 Intel Corporation. */
7 #include <linux/mod_devicetable.h>
12 /* SDW spec defines and enums, as defined by MIPI 1.1. Spec */
14 /* SDW Broadcast Device Number */
15 #define SDW_BROADCAST_DEV_NUM 15
17 /* SDW Enumeration Device Number */
18 #define SDW_ENUM_DEV_NUM 0
20 /* SDW Group Device Numbers */
21 #define SDW_GROUP12_DEV_NUM 12
22 #define SDW_GROUP13_DEV_NUM 13
24 /* SDW Master Device Number, not supported yet */
25 #define SDW_MASTER_DEV_NUM 14
27 #define SDW_NUM_DEV_ID_REGISTERS 6
28 /* frame shape defines */
31 * Note: The maximum row define in SoundWire spec 1.1 is 23. In order to
32 * fill hole with 0, one more dummy entry is added
34 #define SDW_FRAME_ROWS 24
35 #define SDW_FRAME_COLS 8
36 #define SDW_FRAME_ROW_COLS (SDW_FRAME_ROWS * SDW_FRAME_COLS)
38 #define SDW_FRAME_CTRL_BITS 48
39 #define SDW_MAX_DEVICES 11
41 #define SDW_VALID_PORT_RANGE(n) ((n) <= 14 && (n) >= 1)
44 SDW_PORT_DIRN_SINK = 0,
50 * constants for flow control, ports and transport
52 * these are bit masks as devices can have multiple capabilities
56 * flow modes for SDW port. These can be isochronous, tx controlled,
57 * rx controlled or async
59 #define SDW_PORT_FLOW_MODE_ISOCH 0
60 #define SDW_PORT_FLOW_MODE_TX_CNTRL BIT(0)
61 #define SDW_PORT_FLOW_MODE_RX_CNTRL BIT(1)
62 #define SDW_PORT_FLOW_MODE_ASYNC GENMASK(1, 0)
64 /* sample packaging for block. It can be per port or per channel */
65 #define SDW_BLOCK_PACKG_PER_PORT BIT(0)
66 #define SDW_BLOCK_PACKG_PER_CH BIT(1)
69 * enum sdw_slave_status - Slave status
70 * @SDW_SLAVE_UNATTACHED: Slave is not attached with the bus.
71 * @SDW_SLAVE_ATTACHED: Slave is attached with bus.
72 * @SDW_SLAVE_ALERT: Some alert condition on the Slave
73 * @SDW_SLAVE_RESERVED: Reserved for future use
75 enum sdw_slave_status {
76 SDW_SLAVE_UNATTACHED = 0,
77 SDW_SLAVE_ATTACHED = 1,
79 SDW_SLAVE_RESERVED = 3,
83 * enum sdw_command_response - Command response as defined by SDW spec
84 * @SDW_CMD_OK: cmd was successful
85 * @SDW_CMD_IGNORED: cmd was ignored
86 * @SDW_CMD_FAIL: cmd was NACKed
87 * @SDW_CMD_TIMEOUT: cmd timedout
88 * @SDW_CMD_FAIL_OTHER: cmd failed due to other reason than above
90 * NOTE: The enum is different than actual Spec as response in the Spec is
91 * combination of ACK/NAK bits
93 * SDW_CMD_TIMEOUT/FAIL_OTHER is defined for SW use, not in spec
95 enum sdw_command_response {
100 SDW_CMD_FAIL_OTHER = 4,
103 /* block group count enum */
104 enum sdw_dpn_grouping {
105 SDW_BLK_GRP_CNT_1 = 0,
106 SDW_BLK_GRP_CNT_2 = 1,
107 SDW_BLK_GRP_CNT_3 = 2,
108 SDW_BLK_GRP_CNT_4 = 3,
112 * enum sdw_stream_type: data stream type
114 * @SDW_STREAM_PCM: PCM data stream
115 * @SDW_STREAM_PDM: PDM data stream
117 * spec doesn't define this, but is used in implementation
119 enum sdw_stream_type {
125 * enum sdw_data_direction: Data direction
127 * @SDW_DATA_DIR_RX: Data into Port
128 * @SDW_DATA_DIR_TX: Data out of Port
130 enum sdw_data_direction {
136 * enum sdw_port_data_mode: Data Port mode
138 * @SDW_PORT_DATA_MODE_NORMAL: Normal data mode where audio data is received
140 * @SDW_PORT_DATA_MODE_STATIC_1: Simple test mode which uses static value of
141 * logic 1. The encoding will result in signal transitions at every bitslot
143 * @SDW_PORT_DATA_MODE_STATIC_0: Simple test mode which uses static value of
144 * logic 0. The encoding will result in no signal transitions
145 * @SDW_PORT_DATA_MODE_PRBS: Test mode which uses a PRBS generator to produce
146 * a pseudo random data pattern that is transferred
148 enum sdw_port_data_mode {
149 SDW_PORT_DATA_MODE_NORMAL = 0,
150 SDW_PORT_DATA_MODE_STATIC_1 = 1,
151 SDW_PORT_DATA_MODE_STATIC_0 = 2,
152 SDW_PORT_DATA_MODE_PRBS = 3,
156 * SDW properties, defined in MIPI DisCo spec v1.0
158 enum sdw_clk_stop_reset_behave {
159 SDW_CLK_STOP_KEEP_STATUS = 1,
163 * enum sdw_p15_behave - Slave Port 15 behaviour when the Master attempts a
165 * @SDW_P15_READ_IGNORED: Read is ignored
166 * @SDW_P15_CMD_OK: Command is ok
168 enum sdw_p15_behave {
169 SDW_P15_READ_IGNORED = 0,
174 * enum sdw_dpn_type - Data port types
175 * @SDW_DPN_FULL: Full Data Port is supported
176 * @SDW_DPN_SIMPLE: Simplified Data Port as defined in spec.
177 * DPN_SampleCtrl2, DPN_OffsetCtrl2, DPN_HCtrl and DPN_BlockCtrl3
178 * are not implemented.
179 * @SDW_DPN_REDUCED: Reduced Data Port as defined in spec.
180 * DPN_SampleCtrl2, DPN_HCtrl are not implemented.
189 * enum sdw_clk_stop_mode - Clock Stop modes
190 * @SDW_CLK_STOP_MODE0: Slave can continue operation seamlessly on clock
192 * @SDW_CLK_STOP_MODE1: Slave may have entered a deeper power-saving mode,
193 * not capable of continuing operation seamlessly when the clock restarts
195 enum sdw_clk_stop_mode {
196 SDW_CLK_STOP_MODE0 = 0,
197 SDW_CLK_STOP_MODE1 = 1,
201 * struct sdw_dp0_prop - DP0 properties
202 * @max_word: Maximum number of bits in a Payload Channel Sample, 1 to 64
204 * @min_word: Minimum number of bits in a Payload Channel Sample, 1 to 64
206 * @num_words: number of wordlengths supported
207 * @words: wordlengths supported
208 * @BRA_flow_controlled: Slave implementation results in an OK_NotReady
210 * @simple_ch_prep_sm: If channel prepare sequence is required
211 * @imp_def_interrupts: If set, each bit corresponds to support for
212 * implementation-defined interrupts
214 * The wordlengths are specified by Spec as max, min AND number of
215 * discrete values, implementation can define based on the wordlengths they
218 struct sdw_dp0_prop {
223 bool BRA_flow_controlled;
224 bool simple_ch_prep_sm;
225 bool imp_def_interrupts;
229 * struct sdw_dpn_audio_mode - Audio mode properties for DPn
230 * @bus_min_freq: Minimum bus frequency, in Hz
231 * @bus_max_freq: Maximum bus frequency, in Hz
232 * @bus_num_freq: Number of discrete frequencies supported
233 * @bus_freq: Discrete bus frequencies, in Hz
234 * @min_freq: Minimum sampling frequency, in Hz
235 * @max_freq: Maximum sampling bus frequency, in Hz
236 * @num_freq: Number of discrete sampling frequency supported
237 * @freq: Discrete sampling frequencies, in Hz
238 * @prep_ch_behave: Specifies the dependencies between Channel Prepare
239 * sequence and bus clock configuration
240 * If 0, Channel Prepare can happen at any Bus clock rate
241 * If 1, Channel Prepare sequence shall happen only after Bus clock is
242 * changed to a frequency supported by this mode or compatible modes
243 * described by the next field
244 * @glitchless: Bitmap describing possible glitchless transitions from this
245 * Audio Mode to other Audio Modes
247 struct sdw_dpn_audio_mode {
261 * struct sdw_dpn_prop - Data Port DPn properties
263 * @max_word: Maximum number of bits in a Payload Channel Sample, 1 to 64
265 * @min_word: Minimum number of bits in a Payload Channel Sample, 1 to 64
267 * @num_words: Number of discrete supported wordlengths
268 * @words: Discrete supported wordlength
269 * @type: Data port type. Full, Simplified or Reduced
270 * @max_grouping: Maximum number of samples that can be grouped together for
272 * @simple_ch_prep_sm: If the port supports simplified channel prepare state
274 * @ch_prep_timeout: Port-specific timeout value, in milliseconds
275 * @imp_def_interrupts: If set, each bit corresponds to support for
276 * implementation-defined interrupts
277 * @max_ch: Maximum channels supported
278 * @min_ch: Minimum channels supported
279 * @num_ch: Number of discrete channels supported
280 * @ch: Discrete channels supported
281 * @num_ch_combinations: Number of channel combinations supported
282 * @ch_combinations: Channel combinations supported
283 * @modes: SDW mode supported
284 * @max_async_buffer: Number of samples that this port can buffer in
286 * @block_pack_mode: Type of block port mode supported
287 * @port_encoding: Payload Channel Sample encoding schemes supported
288 * @audio_modes: Audio modes supported
290 struct sdw_dpn_prop {
296 enum sdw_dpn_type type;
298 bool simple_ch_prep_sm;
300 u32 imp_def_interrupts;
305 u32 num_ch_combinations;
306 u32 *ch_combinations;
308 u32 max_async_buffer;
309 bool block_pack_mode;
311 struct sdw_dpn_audio_mode *audio_modes;
315 * struct sdw_slave_prop - SoundWire Slave properties
316 * @mipi_revision: Spec version of the implementation
317 * @wake_capable: Wake-up events are supported
318 * @test_mode_capable: If test mode is supported
319 * @clk_stop_mode1: Clock-Stop Mode 1 is supported
320 * @simple_clk_stop_capable: Simple clock mode is supported
321 * @clk_stop_timeout: Worst-case latency of the Clock Stop Prepare State
322 * Machine transitions, in milliseconds
323 * @ch_prep_timeout: Worst-case latency of the Channel Prepare State Machine
324 * transitions, in milliseconds
325 * @reset_behave: Slave keeps the status of the SlaveStopClockPrepare
326 * state machine (P=1 SCSP_SM) after exit from clock-stop mode1
327 * @high_PHY_capable: Slave is HighPHY capable
328 * @paging_support: Slave implements paging registers SCP_AddrPage1 and
330 * @bank_delay_support: Slave implements bank delay/bridge support registers
331 * SCP_BankDelay and SCP_NextFrame
332 * @p15_behave: Slave behavior when the Master attempts a read to the Port15
334 * @lane_control_support: Slave supports lane control
335 * @master_count: Number of Masters present on this Slave
336 * @source_ports: Bitmap identifying source ports
337 * @sink_ports: Bitmap identifying sink ports
338 * @dp0_prop: Data Port 0 properties
339 * @src_dpn_prop: Source Data Port N properties
340 * @sink_dpn_prop: Sink Data Port N properties
342 struct sdw_slave_prop {
345 bool test_mode_capable;
347 bool simple_clk_stop_capable;
348 u32 clk_stop_timeout;
350 enum sdw_clk_stop_reset_behave reset_behave;
351 bool high_PHY_capable;
353 bool bank_delay_support;
354 enum sdw_p15_behave p15_behave;
355 bool lane_control_support;
359 struct sdw_dp0_prop *dp0_prop;
360 struct sdw_dpn_prop *src_dpn_prop;
361 struct sdw_dpn_prop *sink_dpn_prop;
365 * struct sdw_master_prop - Master properties
366 * @revision: MIPI spec version of the implementation
367 * @clk_stop_modes: Bitmap, bit N set when clock-stop-modeN supported
368 * @max_clk_freq: Maximum Bus clock frequency, in Hz
369 * @num_clk_gears: Number of clock gears supported
370 * @clk_gears: Clock gears supported
371 * @num_clk_freq: Number of clock frequencies supported, in Hz
372 * @clk_freq: Clock frequencies supported, in Hz
373 * @default_frame_rate: Controller default Frame rate, in Hz
374 * @default_row: Number of rows
375 * @default_col: Number of columns
376 * @dynamic_frame: Dynamic frame shape supported
377 * @err_threshold: Number of times that software may retry sending a single
379 * @mclk_freq: clock reference passed to SoundWire Master, in Hz.
380 * @hw_disabled: if true, the Master is not functional, typically due to pin-mux
382 struct sdw_master_prop {
390 u32 default_frame_rate;
399 int sdw_master_read_prop(struct sdw_bus *bus);
400 int sdw_slave_read_prop(struct sdw_slave *slave);
403 * SDW Slave Structures and APIs
406 #define SDW_IGNORED_UNIQUE_ID 0xFF
409 * struct sdw_slave_id - Slave ID
410 * @mfg_id: MIPI Manufacturer ID
411 * @part_id: Device Part ID
412 * @class_id: MIPI Class ID, unused now.
413 * Currently a placeholder in MIPI SoundWire Spec
414 * @unique_id: Device unique ID
415 * @sdw_version: SDW version implemented
417 * The order of the IDs here does not follow the DisCo spec definitions
419 struct sdw_slave_id {
428 * struct sdw_slave_intr_status - Slave interrupt status
429 * @control_port: control port status
430 * @port: data port status
432 struct sdw_slave_intr_status {
438 * sdw_reg_bank - SoundWire register banks
439 * @SDW_BANK0: Soundwire register bank 0
440 * @SDW_BANK1: Soundwire register bank 1
448 * struct sdw_bus_conf: Bus configuration
450 * @clk_freq: Clock frequency, in Hz
451 * @num_rows: Number of rows in frame
452 * @num_cols: Number of columns in frame
453 * @bank: Next register bank
455 struct sdw_bus_conf {
456 unsigned int clk_freq;
457 unsigned int num_rows;
458 unsigned int num_cols;
463 * struct sdw_prepare_ch: Prepare/De-prepare Data Port channel
466 * @ch_mask: Active channel mask
467 * @prepare: Prepare (true) /de-prepare (false) channel
468 * @bank: Register bank, which bank Slave/Master driver should program for
469 * implementation defined registers. This is always updated to next_bank
470 * value read from bus params.
473 struct sdw_prepare_ch {
475 unsigned int ch_mask;
481 * enum sdw_port_prep_ops: Prepare operations for Data Port
483 * @SDW_OPS_PORT_PRE_PREP: Pre prepare operation for the Port
484 * @SDW_OPS_PORT_PREP: Prepare operation for the Port
485 * @SDW_OPS_PORT_POST_PREP: Post prepare operation for the Port
487 enum sdw_port_prep_ops {
488 SDW_OPS_PORT_PRE_PREP = 0,
489 SDW_OPS_PORT_PREP = 1,
490 SDW_OPS_PORT_POST_PREP = 2,
494 * struct sdw_bus_params: Structure holding bus configuration
496 * @curr_bank: Current bank in use (BANK0/BANK1)
497 * @next_bank: Next bank to use (BANK0/BANK1). next_bank will always be
499 * @max_dr_freq: Maximum double rate clock frequency supported, in Hz
500 * @curr_dr_freq: Current double rate clock frequency, in Hz
501 * @bandwidth: Current bandwidth
502 * @col: Active columns
505 struct sdw_bus_params {
506 enum sdw_reg_bank curr_bank;
507 enum sdw_reg_bank next_bank;
508 unsigned int max_dr_freq;
509 unsigned int curr_dr_freq;
510 unsigned int bandwidth;
516 * struct sdw_slave_ops: Slave driver callback ops
518 * @read_prop: Read Slave properties
519 * @interrupt_callback: Device interrupt notification (invoked in thread
521 * @update_status: Update Slave status
522 * @bus_config: Update the bus config for Slave
523 * @port_prep: Prepare the port with parameters
525 struct sdw_slave_ops {
526 int (*read_prop)(struct sdw_slave *sdw);
527 int (*interrupt_callback)(struct sdw_slave *slave,
528 struct sdw_slave_intr_status *status);
529 int (*update_status)(struct sdw_slave *slave,
530 enum sdw_slave_status status);
531 int (*bus_config)(struct sdw_slave *slave,
532 struct sdw_bus_params *params);
533 int (*port_prep)(struct sdw_slave *slave,
534 struct sdw_prepare_ch *prepare_ch,
535 enum sdw_port_prep_ops pre_ops);
539 * struct sdw_slave - SoundWire Slave
540 * @id: MIPI device ID
542 * @status: Status reported by the Slave
544 * @ops: Slave callback ops
545 * @prop: Slave properties
546 * @debugfs: Slave debugfs
547 * @node: node for bus list
548 * @port_ready: Port ready completion flag for each Slave port
549 * @dev_num: Current Device Number, values can be 0 or dev_num_sticky
550 * @dev_num_sticky: one-time static Device Number assigned by Bus
551 * @probed: boolean tracking driver state
552 * @probe_complete: completion utility to control potential races
553 * on startup between driver probe/initialization and SoundWire
554 * Slave state changes/implementation-defined interrupts
555 * @enumeration_complete: completion utility to control potential races
556 * on startup between device enumeration and read/write access to the
558 * @initialization_complete: completion utility to control potential races
559 * on startup between device enumeration and settings being restored
560 * @unattach_request: mask field to keep track why the Slave re-attached and
561 * was re-initialized. This is useful to deal with potential race conditions
562 * between the Master suspending and the codec resuming, and make sure that
563 * when the Master triggered a reset the Slave is properly enumerated and
567 struct sdw_slave_id id;
569 enum sdw_slave_status status;
571 const struct sdw_slave_ops *ops;
572 struct sdw_slave_prop prop;
573 #ifdef CONFIG_DEBUG_FS
574 struct dentry *debugfs;
576 struct list_head node;
577 struct completion *port_ready;
581 struct completion probe_complete;
582 struct completion enumeration_complete;
583 struct completion initialization_complete;
584 u32 unattach_request;
587 #define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev)
592 int (*probe)(struct sdw_slave *sdw,
593 const struct sdw_device_id *id);
594 int (*remove)(struct sdw_slave *sdw);
595 void (*shutdown)(struct sdw_slave *sdw);
597 const struct sdw_device_id *id_table;
598 const struct sdw_slave_ops *ops;
600 struct device_driver driver;
603 #define SDW_SLAVE_ENTRY(_mfg_id, _part_id, _drv_data) \
604 { .mfg_id = (_mfg_id), .part_id = (_part_id), \
605 .driver_data = (unsigned long)(_drv_data) }
607 int sdw_handle_slave_status(struct sdw_bus *bus,
608 enum sdw_slave_status status[]);
611 * SDW master structures and APIs
615 * struct sdw_port_params: Data Port parameters
618 * @bps: Word length of the Port
619 * @flow_mode: Port Data flow mode
620 * @data_mode: Test modes or normal mode
622 * This is used to program the Data Port based on Data Port stream
625 struct sdw_port_params {
628 unsigned int flow_mode;
629 unsigned int data_mode;
633 * struct sdw_transport_params: Data Port Transport Parameters
635 * @blk_grp_ctrl_valid: Port implements block group control
637 * @blk_grp_ctrl: Block group control value
638 * @sample_interval: Sample interval
639 * @offset1: Blockoffset of the payload data
640 * @offset2: Blockoffset of the payload data
641 * @hstart: Horizontal start of the payload data
642 * @hstop: Horizontal stop of the payload data
643 * @blk_pkg_mode: Block per channel or block per port
644 * @lane_ctrl: Data lane Port uses for Data transfer. Currently only single
645 * data lane is supported in bus
647 * This is used to program the Data Port based on Data Port transport
648 * parameters. All these parameters are banked and can be modified
649 * during a bank switch without any artifacts in audio stream.
651 struct sdw_transport_params {
652 bool blk_grp_ctrl_valid;
653 unsigned int port_num;
654 unsigned int blk_grp_ctrl;
655 unsigned int sample_interval;
656 unsigned int offset1;
657 unsigned int offset2;
660 unsigned int blk_pkg_mode;
661 unsigned int lane_ctrl;
665 * struct sdw_enable_ch: Enable/disable Data Port channel
668 * @ch_mask: Active channel mask
669 * @enable: Enable (true) /disable (false) channel
671 struct sdw_enable_ch {
672 unsigned int port_num;
673 unsigned int ch_mask;
678 * struct sdw_master_port_ops: Callback functions from bus to Master
679 * driver to set Master Data ports.
681 * @dpn_set_port_params: Set the Port parameters for the Master Port.
683 * @dpn_set_port_transport_params: Set transport parameters for the Master
684 * Port. Mandatory callback
685 * @dpn_port_prep: Port prepare operations for the Master Data Port.
686 * @dpn_port_enable_ch: Enable the channels of Master Port.
688 struct sdw_master_port_ops {
689 int (*dpn_set_port_params)(struct sdw_bus *bus,
690 struct sdw_port_params *port_params,
692 int (*dpn_set_port_transport_params)(struct sdw_bus *bus,
693 struct sdw_transport_params *transport_params,
694 enum sdw_reg_bank bank);
695 int (*dpn_port_prep)(struct sdw_bus *bus,
696 struct sdw_prepare_ch *prepare_ch);
697 int (*dpn_port_enable_ch)(struct sdw_bus *bus,
698 struct sdw_enable_ch *enable_ch, unsigned int bank);
704 * struct sdw_defer - SDW deffered message
705 * @length: message length
706 * @complete: message completion
711 struct completion complete;
716 * struct sdw_master_ops - Master driver ops
717 * @read_prop: Read Master properties
718 * @xfer_msg: Transfer message callback
719 * @xfer_msg_defer: Defer version of transfer message callback
720 * @reset_page_addr: Reset the SCP page address registers
721 * @set_bus_conf: Set the bus configuration
722 * @pre_bank_switch: Callback for pre bank switch
723 * @post_bank_switch: Callback for post bank switch
725 struct sdw_master_ops {
726 int (*read_prop)(struct sdw_bus *bus);
728 enum sdw_command_response (*xfer_msg)
729 (struct sdw_bus *bus, struct sdw_msg *msg);
730 enum sdw_command_response (*xfer_msg_defer)
731 (struct sdw_bus *bus, struct sdw_msg *msg,
732 struct sdw_defer *defer);
733 enum sdw_command_response (*reset_page_addr)
734 (struct sdw_bus *bus, unsigned int dev_num);
735 int (*set_bus_conf)(struct sdw_bus *bus,
736 struct sdw_bus_params *params);
737 int (*pre_bank_switch)(struct sdw_bus *bus);
738 int (*post_bank_switch)(struct sdw_bus *bus);
743 * struct sdw_bus - SoundWire bus
744 * @dev: Master linux device
745 * @link_id: Link id number, can be 0 to N, unique for each Master
746 * @slaves: list of Slaves on this bus
747 * @assigned: Bitmap for Slave device numbers.
748 * Bit set implies used number, bit clear implies unused number.
749 * @bus_lock: bus lock
750 * @msg_lock: message lock
751 * @compute_params: points to Bus resource management implementation
752 * @ops: Master callback ops
753 * @port_ops: Master port callback ops
754 * @params: Current bus parameters
755 * @prop: Master properties
756 * @m_rt_list: List of Master instance of all stream(s) running on Bus. This
757 * is used to compute and program bus bandwidth, clock, frame shape,
758 * transport and port parameters
759 * @debugfs: Bus debugfs
760 * @defer_msg: Defer message
761 * @clk_stop_timeout: Clock stop timeout computed
762 * @bank_switch_timeout: Bank switch timeout computed
763 * @multi_link: Store bus property that indicates if multi links
764 * are supported. This flag is populated by drivers after reading
765 * appropriate firmware (ACPI/DT).
769 unsigned int link_id;
770 struct list_head slaves;
771 DECLARE_BITMAP(assigned, SDW_MAX_DEVICES);
772 struct mutex bus_lock;
773 struct mutex msg_lock;
774 int (*compute_params)(struct sdw_bus *bus);
775 const struct sdw_master_ops *ops;
776 const struct sdw_master_port_ops *port_ops;
777 struct sdw_bus_params params;
778 struct sdw_master_prop prop;
779 struct list_head m_rt_list;
780 #ifdef CONFIG_DEBUG_FS
781 struct dentry *debugfs;
783 struct sdw_defer defer_msg;
784 unsigned int clk_stop_timeout;
785 u32 bank_switch_timeout;
789 int sdw_add_bus_master(struct sdw_bus *bus);
790 void sdw_delete_bus_master(struct sdw_bus *bus);
793 * sdw_port_config: Master or Slave Port configuration
796 * @ch_mask: channels mask for port
798 struct sdw_port_config {
800 unsigned int ch_mask;
804 * sdw_stream_config: Master or Slave stream configuration
806 * @frame_rate: Audio frame rate of the stream, in Hz
807 * @ch_count: Channel count of the stream
808 * @bps: Number of bits per audio sample
809 * @direction: Data direction
810 * @type: Stream type PCM or PDM
812 struct sdw_stream_config {
813 unsigned int frame_rate;
814 unsigned int ch_count;
816 enum sdw_data_direction direction;
817 enum sdw_stream_type type;
821 * sdw_stream_state: Stream states
823 * @SDW_STREAM_ALLOCATED: New stream allocated.
824 * @SDW_STREAM_CONFIGURED: Stream configured
825 * @SDW_STREAM_PREPARED: Stream prepared
826 * @SDW_STREAM_ENABLED: Stream enabled
827 * @SDW_STREAM_DISABLED: Stream disabled
828 * @SDW_STREAM_DEPREPARED: Stream de-prepared
829 * @SDW_STREAM_RELEASED: Stream released
831 enum sdw_stream_state {
832 SDW_STREAM_ALLOCATED = 0,
833 SDW_STREAM_CONFIGURED = 1,
834 SDW_STREAM_PREPARED = 2,
835 SDW_STREAM_ENABLED = 3,
836 SDW_STREAM_DISABLED = 4,
837 SDW_STREAM_DEPREPARED = 5,
838 SDW_STREAM_RELEASED = 6,
842 * sdw_stream_params: Stream parameters
844 * @rate: Sampling frequency, in Hz
845 * @ch_count: Number of channels
846 * @bps: bits per channel sample
848 struct sdw_stream_params {
850 unsigned int ch_count;
855 * sdw_stream_runtime: Runtime stream parameters
857 * @name: SoundWire stream name
858 * @params: Stream parameters
859 * @state: Current state of the stream
860 * @type: Stream type PCM or PDM
861 * @master_list: List of Master runtime(s) in this stream.
862 * master_list can contain only one m_rt per Master instance
864 * @m_rt_count: Count of Master runtime(s) in this stream
866 struct sdw_stream_runtime {
868 struct sdw_stream_params params;
869 enum sdw_stream_state state;
870 enum sdw_stream_type type;
871 struct list_head master_list;
875 struct sdw_stream_runtime *sdw_alloc_stream(const char *stream_name);
876 void sdw_release_stream(struct sdw_stream_runtime *stream);
877 int sdw_stream_add_master(struct sdw_bus *bus,
878 struct sdw_stream_config *stream_config,
879 struct sdw_port_config *port_config,
880 unsigned int num_ports,
881 struct sdw_stream_runtime *stream);
882 int sdw_stream_add_slave(struct sdw_slave *slave,
883 struct sdw_stream_config *stream_config,
884 struct sdw_port_config *port_config,
885 unsigned int num_ports,
886 struct sdw_stream_runtime *stream);
887 int sdw_stream_remove_master(struct sdw_bus *bus,
888 struct sdw_stream_runtime *stream);
889 int sdw_stream_remove_slave(struct sdw_slave *slave,
890 struct sdw_stream_runtime *stream);
891 int sdw_prepare_stream(struct sdw_stream_runtime *stream);
892 int sdw_enable_stream(struct sdw_stream_runtime *stream);
893 int sdw_disable_stream(struct sdw_stream_runtime *stream);
894 int sdw_deprepare_stream(struct sdw_stream_runtime *stream);
896 /* messaging and data APIs */
898 int sdw_read(struct sdw_slave *slave, u32 addr);
899 int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
900 int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
901 int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
903 #endif /* __SOUNDWIRE_H */