1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2021 Intel Corporation. All rights reserved.
4  */
5 
6 /*
7  * This file contains structures that are exact copies of an existing ABI used
8  * by IOT middleware. They are Intel specific and will be used by one middleware.
9  *
10  * Some of the structures may contain programming implementations that makes them
11  * unsuitable for generic use and general usage.
12  */
13 
14 /**
15  * \file include/ipc4/ssp.h
16  * \brief IPC4 global definitions.
17  * NOTE: This ABI uses bit fields and is non portable.
18  */
19 
20 #ifndef __SOF_IPC4_SSP_H__
21 #define __SOF_IPC4_SSP_H__
22 
23 #include <stdint.h>
24 #include <ipc4/gateway.h>
25 
26 #define I2S_TDM_INVALID_SLOT_MAP1 0xF
27 #define I2S_TDM_MAX_CHANNEL_COUNT 8
28 #define I2S_TDM_MAX_SLOT_MAP_COUNT 8
29 
30 /* i2s Configuration BLOB building blocks */
31 
32 /* i2s registers for i2s Configuration */
33 struct ipc4_ssp_config {
34 	uint32_t ssc0;
35 	uint32_t ssc1;
36 	uint32_t sscto;
37 	uint32_t sspsp;
38 	uint32_t sstsa;
39 	uint32_t ssrsa;
40 	uint32_t ssc2;
41 	uint32_t sspsp2;
42 	uint32_t ssc3;
43 	uint32_t ssioc;
44 } __attribute__((packed, aligned(4)));
45 
46 struct ipc4_ssp_mclk_config {
47 	/* master clock divider control register */
48 	uint32_t mdivc;
49 
50 	/* master clock divider ratio register */
51 	uint32_t mdivr;
52 } __attribute__((packed, aligned(4)));
53 
54 struct ipc4_ssp_driver_config {
55 	struct ipc4_ssp_config i2s_config;
56 	struct ipc4_ssp_mclk_config mclk_config;
57 } __attribute__((packed, aligned(4)));
58 
59 struct ipc4_ssp_start_control {
60 	/* delay in msec between enabling interface (moment when
61 	 * Copier instance is being attached to the interface) and actual
62 	 * interface start. Value of 0 means no delay.
63 	 */
64 	uint32_t clock_warm_up    : 16;
65 
66 	/* specifies if parameters target MCLK (1) or SCLK (0) */
67 	uint32_t mclk             : 1;
68 
69 	/* value of 1 means that clock should be started immediately
70 	 * even if no Copier instance is currently attached to the interface.
71 	 */
72 	uint32_t warm_up_ovr      : 1;
73 	uint32_t rsvd0            : 14;
74 } __attribute__((packed, aligned(4)));
75 
76 struct ipc4_ssp_stop_control {
77 	/* delay in msec between stopping the interface
78 	 * (moment when Copier instance is being detached from the interface)
79 	 * and interface clock stop. Value of 0 means no delay.
80 	 */
81 	uint32_t clock_stop_delay : 16;
82 
83 	/* value of 1 means that clock should be kept running (infinite
84 	 * stop delay) after Copier instance detaches from the interface.
85 	 */
86 	uint32_t keep_running     : 1;
87 
88 	/* value of 1 means that clock should be stopped immediately */
89 	uint32_t clock_stop_ovr   : 1;
90 	uint32_t rsvd1            : 14;
91 } __attribute__((packed, aligned(4)));
92 
93 union ipc4_ssp_dma_control {
94 	struct ipc4_ssp_control {
95 		struct ipc4_ssp_start_control start_control;
96 		struct ipc4_ssp_stop_control stop_control;
97 	} control_data;
98 
99 	struct ipc4_mn_div_config {
100 		uint32_t mval;
101 		uint32_t nval;
102 	} mndiv_control_data;
103 } __attribute__((packed, aligned(4)));
104 
105 struct ipc4_ssp_configuration_blob {
106 	union ipc4_gateway_attributes gw_attr;
107 
108 	/* TDM time slot mappings */
109 	uint32_t tdm_ts_group[I2S_TDM_MAX_SLOT_MAP_COUNT];
110 
111 	/* i2s port configuration */
112 	struct ipc4_ssp_driver_config i2s_driver_config;
113 
114 	/* optional configuration parameters */
115 	union ipc4_ssp_dma_control i2s_dma_control[];
116 } __attribute__((packed, aligned(4)));
117 
118 #endif
119