|
| 1 | +/* |
| 2 | + Copyright(c) 2021 Intel Corporation |
| 3 | + All rights reserved. |
| 4 | +
|
| 5 | + This program is free software; you can redistribute it and/or modify |
| 6 | + it under the terms of version 2 of the GNU General Public License as |
| 7 | + published by the Free Software Foundation. |
| 8 | +
|
| 9 | + This program is distributed in the hope that it will be useful, but |
| 10 | + WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | + General Public License for more details. |
| 13 | +
|
| 14 | + You should have received a copy of the GNU General Public License |
| 15 | + along with this program; if not, write to the Free Software |
| 16 | + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | + The full GNU General Public License is included in this distribution |
| 18 | + in the file called LICENSE.GPL. |
| 19 | +*/ |
| 20 | + |
| 21 | +#ifndef __SSP_MACROS_H |
| 22 | +#define __SSP_MACROS_H |
| 23 | + |
| 24 | +#define MIN(a, b) ({ \ |
| 25 | + typeof(a) __a = (a); \ |
| 26 | + typeof(b) __b = (b); \ |
| 27 | + __a > __b ? __b : __a; \ |
| 28 | +}) |
| 29 | +#define MAX(a, b) ({ \ |
| 30 | + typeof(a) __a = (a); \ |
| 31 | + typeof(b) __b = (b); \ |
| 32 | + __a < __b ? __b : __a; \ |
| 33 | +}) |
| 34 | + |
| 35 | +#define BIT(b) (1UL << (b)) |
| 36 | +#define MASK(b_hi, b_lo) (((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL) << (b_lo)) |
| 37 | +#define SET_BIT(b, x) (((x) & 1) << (b)) |
| 38 | +#define SET_BITS(b_hi, b_lo, x) (((x) & ((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL)) << (b_lo)) |
| 39 | + |
| 40 | +#define SSP_FMT_I2S 1 /**< I2S mode */ |
| 41 | +#define SSP_FMT_RIGHT_J 2 /**< Right Justified mode */ |
| 42 | +#define SSP_FMT_LEFT_J 3 /**< Left Justified mode */ |
| 43 | +#define SSP_FMT_DSP_A 4 /**< L data MSB after FRM LRC */ |
| 44 | +#define SSP_FMT_DSP_B 5 /**< L data MSB during FRM LRC */ |
| 45 | +#define SSP_FMT_PDM 6 /**< Pulse density modulation */ |
| 46 | + |
| 47 | +#define SSP_FMT_CONT (1 << 4) /**< continuous clock */ |
| 48 | +#define SSP_FMT_GATED (0 << 4) /**< clock is gated */ |
| 49 | + |
| 50 | +#define SSP_FMT_NB_NF (0 << 8) /**< normal bit clock + frame */ |
| 51 | +#define SSP_FMT_NB_IF (2 << 8) /**< normal BCLK + inv FRM */ |
| 52 | +#define SSP_FMT_IB_NF (3 << 8) /**< invert BCLK + nor FRM */ |
| 53 | +#define SSP_FMT_IB_IF (4 << 8) /**< invert BCLK + FRM */ |
| 54 | + |
| 55 | +#define SSP_FMT_CBP_CFP (0 << 12) /**< codec bclk provider & frame provider */ |
| 56 | +#define SSP_FMT_CBC_CFP (2 << 12) /**< codec bclk consumer & frame provider */ |
| 57 | +#define SSP_FMT_CBP_CFC (3 << 12) /**< codec bclk provider & frame consumer */ |
| 58 | +#define SSP_FMT_CBC_CFC (4 << 12) /**< codec bclk consumer & frame consumer */ |
| 59 | + |
| 60 | +#define SSP_FMT_FORMAT_MASK 0x000f |
| 61 | +#define SSP_FMT_CLOCK_MASK 0x00f0 |
| 62 | +#define SSP_FMT_INV_MASK 0x0f00 |
| 63 | +#define SSP_FMT_CLOCK_PROVIDER_MASK 0xf000 |
| 64 | + |
| 65 | +/* SSCR0 bits */ |
| 66 | +#define SSCR0_DSIZE(x) SET_BITS(3, 0, (x) - 1) |
| 67 | +#define SSCR0_FRF MASK(5, 4) |
| 68 | +#define SSCR0_MOT SET_BITS(5, 4, 0) |
| 69 | +#define SSCR0_TI SET_BITS(5, 4, 1) |
| 70 | +#define SSCR0_NAT SET_BITS(5, 4, 2) |
| 71 | +#define SSCR0_PSP SET_BITS(5, 4, 3) |
| 72 | +#define SSCR0_ECS BIT(6) |
| 73 | +#define SSCR0_SSE BIT(7) |
| 74 | +#define SSCR0_SCR_MASK MASK(19, 8) |
| 75 | +#define SSCR0_SCR(x) SET_BITS(19, 8, x) |
| 76 | +#define SSCR0_EDSS BIT(20) |
| 77 | +#define SSCR0_NCS BIT(21) |
| 78 | +#define SSCR0_RIM BIT(22) |
| 79 | +#define SSCR0_TIM BIT(23) |
| 80 | +#define SSCR0_FRDC(x) SET_BITS(26, 24, (x) - 1) |
| 81 | +#define SSCR0_ACS BIT(30) |
| 82 | +#define SSCR0_MOD BIT(31) |
| 83 | + |
| 84 | +/* SSCR1 bits */ |
| 85 | +#define SSCR1_RIE BIT(0) |
| 86 | +#define SSCR1_TIE BIT(1) |
| 87 | +#define SSCR1_LBM BIT(2) |
| 88 | +#define SSCR1_SPO BIT(3) |
| 89 | +#define SSCR1_SPH BIT(4) |
| 90 | +#define SSCR1_MWDS BIT(5) |
| 91 | +#define SSCR1_TFT_MASK MASK(9, 6) |
| 92 | +#define SSCR1_TFT(x) SET_BITS(9, 6, (x) - 1) |
| 93 | +#define SSCR1_RFT_MASK MASK(13, 10) |
| 94 | +#define SSCR1_RFT(x) SET_BITS(13, 10, (x) - 1) |
| 95 | +#define SSCR1_EFWR BIT(14) |
| 96 | +#define SSCR1_STRF BIT(15) |
| 97 | +#define SSCR1_IFS BIT(16) |
| 98 | +#define SSCR1_PINTE BIT(18) |
| 99 | +#define SSCR1_TINTE BIT(19) |
| 100 | +#define SSCR1_RSRE BIT(20) |
| 101 | +#define SSCR1_TSRE BIT(21) |
| 102 | +#define SSCR1_TRAIL BIT(22) |
| 103 | +#define SSCR1_RWOT BIT(23) |
| 104 | +#define SSCR1_SFRMDIR BIT(24) |
| 105 | +#define SSCR1_SCLKDIR BIT(25) |
| 106 | +#define SSCR1_ECRB BIT(26) |
| 107 | +#define SSCR1_ECRA BIT(27) |
| 108 | +#define SSCR1_SCFR BIT(28) |
| 109 | +#define SSCR1_EBCEI BIT(29) |
| 110 | +#define SSCR1_TTE BIT(30) |
| 111 | +#define SSCR1_TTELP BIT(31) |
| 112 | + |
| 113 | +/* SSCR2 bits */ |
| 114 | +#define SSCR2_URUN_FIX0 BIT(0) |
| 115 | +#define SSCR2_URUN_FIX1 BIT(1) |
| 116 | +#define SSCR2_SLV_EXT_CLK_RUN_EN BIT(2) |
| 117 | +#define SSCR2_CLK_DEL_EN BIT(3) |
| 118 | +#define SSCR2_UNDRN_FIX_EN BIT(6) |
| 119 | +#define SSCR2_FIFO_EMPTY_FIX_EN BIT(7) |
| 120 | +#define SSCR2_ASRC_CNTR_EN BIT(8) |
| 121 | +#define SSCR2_ASRC_CNTR_CLR BIT(9) |
| 122 | +#define SSCR2_ASRC_FRM_CNRT_EN BIT(10) |
| 123 | +#define SSCR2_ASRC_INTR_MASK BIT(11) |
| 124 | +#define SSCR2_TURM1 BIT(1) |
| 125 | +#define SSCR2_PSPSRWFDFD BIT(3) |
| 126 | +#define SSCR2_PSPSTWFDFD BIT(4) |
| 127 | +#define SSCR2_SDFD BIT(14) |
| 128 | +#define SSCR2_SDPM BIT(16) |
| 129 | +#define SSCR2_LJDFD BIT(17) |
| 130 | +#define SSCR2_MMRATF BIT(18) |
| 131 | +#define SSCR2_SMTATF BIT(19) |
| 132 | + |
| 133 | +/* SSR bits */ |
| 134 | +#define SSSR_TNF BIT(2) |
| 135 | +#define SSSR_RNE BIT(3) |
| 136 | +#define SSSR_BSY BIT(4) |
| 137 | +#define SSSR_TFS BIT(5) |
| 138 | +#define SSSR_RFS BIT(6) |
| 139 | +#define SSSR_ROR BIT(7) |
| 140 | +#define SSSR_TUR BIT(21) |
| 141 | + |
| 142 | +/* SSPSP bits */ |
| 143 | +#define SSPSP_SCMODE(x) SET_BITS(1, 0, x) |
| 144 | +#define SSPSP_SFRMP(x) SET_BIT(2, x) |
| 145 | +#define SSPSP_ETDS BIT(3) |
| 146 | +#define SSPSP_STRTDLY(x) SET_BITS(6, 4, x) |
| 147 | +#define SSPSP_DMYSTRT(x) SET_BITS(8, 7, x) |
| 148 | +#define SSPSP_SFRMDLY(x) SET_BITS(15, 9, x) |
| 149 | +#define SSPSP_SFRMWDTH(x) SET_BITS(21, 16, x) |
| 150 | +#define SSPSP_DMYSTOP(x) SET_BITS(24, 23, x) |
| 151 | +#define SSPSP_DMYSTOP_BITS 2 |
| 152 | +#define SSPSP_DMYSTOP_MASK MASK(SSPSP_DMYSTOP_BITS - 1, 0) |
| 153 | +#define SSPSP_FSRT BIT(25) |
| 154 | +#define SSPSP_EDMYSTOP(x) SET_BITS(28, 26, x) |
| 155 | + |
| 156 | +#define SSPSP2 0x44 |
| 157 | +#define SSPSP2_FEP_MASK 0xff |
| 158 | + |
| 159 | +#define SSCR3 0x48 |
| 160 | +#define SSIOC 0x4C |
| 161 | +#define SSP_REG_MAX SSIOC |
| 162 | + |
| 163 | +/* SSTSA bits */ |
| 164 | +#define SSTSA_SSTSA(x) SET_BITS(7, 0, x) |
| 165 | +#define SSTSA_TXEN BIT(8) |
| 166 | + |
| 167 | +/* SSRSA bits */ |
| 168 | +#define SSRSA_SSRSA(x) SET_BITS(7, 0, x) |
| 169 | +#define SSRSA_RXEN BIT(8) |
| 170 | + |
| 171 | +/* SSCR3 bits */ |
| 172 | +#define SSCR3_FRM_MST_EN BIT(0) |
| 173 | +#define SSCR3_I2S_MODE_EN BIT(1) |
| 174 | +#define SSCR3_I2S_FRM_POL(x) SET_BIT(2, x) |
| 175 | +#define SSCR3_I2S_TX_SS_FIX_EN BIT(3) |
| 176 | +#define SSCR3_I2S_RX_SS_FIX_EN BIT(4) |
| 177 | +#define SSCR3_I2S_TX_EN BIT(9) |
| 178 | +#define SSCR3_I2S_RX_EN BIT(10) |
| 179 | +#define SSCR3_CLK_EDGE_SEL BIT(12) |
| 180 | +#define SSCR3_STRETCH_TX BIT(14) |
| 181 | +#define SSCR3_STRETCH_RX BIT(15) |
| 182 | +#define SSCR3_MST_CLK_EN BIT(16) |
| 183 | +#define SSCR3_SYN_FIX_EN BIT(17) |
| 184 | + |
| 185 | +/* SSCR4 bits */ |
| 186 | +#define SSCR4_TOT_FRM_PRD(x) ((x) << 7) |
| 187 | + |
| 188 | +/* SSCR5 bits */ |
| 189 | +#define SSCR5_FRM_ASRT_CLOCKS(x) (((x) - 1) << 1) |
| 190 | +#define SSCR5_FRM_POLARITY(x) SET_BIT(0, x) |
| 191 | + |
| 192 | +/* SFIFOTT bits */ |
| 193 | +#define SFIFOTT_TX(x) ((x) - 1) |
| 194 | +#define SFIFOTT_RX(x) (((x) - 1) << 16) |
| 195 | + |
| 196 | +/* SFIFOL bits */ |
| 197 | +#define SFIFOL_TFL(x) ((x) & 0xFFFF) |
| 198 | +#define SFIFOL_RFL(x) ((x) >> 16) |
| 199 | + |
| 200 | +#define SSTSA_TSEN BIT(8) |
| 201 | +#define SSRSA_RSEN BIT(8) |
| 202 | + |
| 203 | +#define SSCR3_TFL_MASK MASK(5, 0) |
| 204 | +#define SSCR3_RFL_MASK MASK(13, 8) |
| 205 | +#define SSCR3_TFL_VAL(scr3_val) (((scr3_val) >> 0) & MASK(5, 0)) |
| 206 | +#define SSCR3_RFL_VAL(scr3_val) (((scr3_val) >> 8) & MASK(5, 0)) |
| 207 | +#define SSCR3_TX(x) SET_BITS(21, 16, (x) - 1) |
| 208 | +#define SSCR3_RX(x) SET_BITS(29, 24, (x) - 1) |
| 209 | + |
| 210 | +#define SSIOC_TXDPDEB BIT(1) |
| 211 | +#define SSIOC_SFCR BIT(4) |
| 212 | +#define SSIOC_SCOE BIT(5) |
| 213 | + |
| 214 | +#define MAX_SSP_COUNT 8 |
| 215 | +#define SSP_FIFO_DEPTH 16 |
| 216 | +#define SSP_FIFO_WATERMARK 8 |
| 217 | + |
| 218 | +#define SSP_INTEL_QUIRK_TINTE (1 << 0) |
| 219 | +#define SSP_INTEL_QUIRK_PINTE (1 << 1) |
| 220 | +#define SSP_INTEL_QUIRK_SMTATF (1 << 2) |
| 221 | +#define SSP_INTEL_QUIRK_MMRATF (1 << 3) |
| 222 | +#define SSP_INTEL_QUIRK_PSPSTWFDFD (1 << 4) |
| 223 | +#define SSP_INTEL_QUIRK_PSPSRWFDFD (1 << 5) |
| 224 | +#define SSP_INTEL_QUIRK_LBM (1 << 6) |
| 225 | + |
| 226 | +#define SSP_INTEL_FRAME_PULSE_WIDTH_MAX 38 |
| 227 | +#define SSP_INTEL_SLOT_PADDING_MAX 31 |
| 228 | + |
| 229 | +/* SSP clocks control settings */ |
| 230 | +#define SSP_INTEL_MCLK_0_DISABLE BIT(0) |
| 231 | +#define SSP_INTEL_MCLK_1_DISABLE BIT(1) |
| 232 | +#define SSP_INTEL_CLKCTRL_MCLK_KA BIT(2) |
| 233 | +#define SSP_INTEL_CLKCTRL_BCLK_KA BIT(3) |
| 234 | +#define SSP_INTEL_CLKCTRL_FS_KA BIT(4) |
| 235 | +#define SSP_INTEL_CLKCTRL_BCLK_IDLE_HIGH BIT(5) |
| 236 | + |
| 237 | +#endif /* __SSP_MACROS_H */ |
0 commit comments