Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * NAU8810 ALSA SoC audio driver
0004  *
0005  * Copyright 2016 Nuvoton Technology Corp.
0006  * Author: David Lin <ctlin0@nuvoton.com>
0007  */
0008 
0009 #ifndef __NAU8810_H__
0010 #define __NAU8810_H__
0011 
0012 #define NAU8810_REG_RESET       0x00
0013 #define NAU8810_REG_POWER1      0x01
0014 #define NAU8810_REG_POWER2      0x02
0015 #define NAU8810_REG_POWER3      0x03
0016 #define NAU8810_REG_IFACE       0x04
0017 #define NAU8810_REG_COMP        0x05
0018 #define NAU8810_REG_CLOCK       0x06
0019 #define NAU8810_REG_SMPLR       0x07
0020 #define NAU8810_REG_DAC     0x0A
0021 #define NAU8810_REG_DACGAIN     0x0B
0022 #define NAU8810_REG_ADC     0x0E
0023 #define NAU8810_REG_ADCGAIN     0x0F
0024 #define NAU8810_REG_EQ1     0x12
0025 #define NAU8810_REG_EQ2     0x13
0026 #define NAU8810_REG_EQ3     0x14
0027 #define NAU8810_REG_EQ4     0x15
0028 #define NAU8810_REG_EQ5     0x16
0029 #define NAU8810_REG_DACLIM1     0x18
0030 #define NAU8810_REG_DACLIM2     0x19
0031 #define NAU8810_REG_NOTCH1      0x1B
0032 #define NAU8810_REG_NOTCH2      0x1C
0033 #define NAU8810_REG_NOTCH3      0x1D
0034 #define NAU8810_REG_NOTCH4      0x1E
0035 #define NAU8810_REG_ALC1        0x20
0036 #define NAU8810_REG_ALC2        0x21
0037 #define NAU8810_REG_ALC3        0x22
0038 #define NAU8810_REG_NOISEGATE       0x23
0039 #define NAU8810_REG_PLLN        0x24
0040 #define NAU8810_REG_PLLK1       0x25
0041 #define NAU8810_REG_PLLK2       0x26
0042 #define NAU8810_REG_PLLK3       0x27
0043 #define NAU8810_REG_ATTEN       0x28
0044 #define NAU8810_REG_INPUT_SIGNAL    0x2C
0045 #define NAU8810_REG_PGAGAIN     0x2D
0046 #define NAU8810_REG_ADCBOOST        0x2F
0047 #define NAU8810_REG_OUTPUT      0x31
0048 #define NAU8810_REG_SPKMIX      0x32
0049 #define NAU8810_REG_SPKGAIN     0x36
0050 #define NAU8810_REG_MONOMIX     0x38
0051 #define NAU8810_REG_POWER4      0x3A
0052 #define NAU8810_REG_TSLOTCTL1       0x3B
0053 #define NAU8810_REG_TSLOTCTL2       0x3C
0054 #define NAU8810_REG_DEVICE_REVID    0x3E
0055 #define NAU8810_REG_I2C_DEVICEID    0x3F
0056 #define NAU8810_REG_ADDITIONID  0x40
0057 #define NAU8810_REG_RESERVE     0x41
0058 #define NAU8810_REG_OUTCTL      0x45
0059 #define NAU8810_REG_ALC1ENHAN1  0x46
0060 #define NAU8810_REG_ALC1ENHAN2  0x47
0061 #define NAU8810_REG_MISCCTL     0x49
0062 #define NAU8810_REG_OUTTIEOFF       0x4B
0063 #define NAU8810_REG_AGCP2POUT   0x4C
0064 #define NAU8810_REG_AGCPOUT     0x4D
0065 #define NAU8810_REG_AMTCTL      0x4E
0066 #define NAU8810_REG_OUTTIEOFFMAN    0x4F
0067 #define NAU8810_REG_MAX     NAU8810_REG_OUTTIEOFFMAN
0068 
0069 
0070 /* NAU8810_REG_POWER1 (0x1) */
0071 #define NAU8810_DCBUF_EN        (0x1 << 8)
0072 #define NAU8810_AUX_EN_SFT      6
0073 #define NAU8810_PLL_EN_SFT      5
0074 #define NAU8810_MICBIAS_EN_SFT  4
0075 #define NAU8810_ABIAS_EN        (0x1 << 3)
0076 #define NAU8810_IOBUF_EN        (0x1 << 2)
0077 #define NAU8810_REFIMP_MASK     0x3
0078 #define NAU8810_REFIMP_DIS      0x0
0079 #define NAU8810_REFIMP_80K      0x1
0080 #define NAU8810_REFIMP_300K     0x2
0081 #define NAU8810_REFIMP_3K       0x3
0082 
0083 /* NAU8810_REG_POWER2 (0x2) */
0084 #define NAU8810_BST_EN_SFT      4
0085 #define NAU8810_PGA_EN_SFT      2
0086 #define NAU8810_ADC_EN_SFT      0
0087 
0088 /* NAU8810_REG_POWER3 (0x3) */
0089 #define NAU8810_DAC_EN_SFT      0
0090 #define NAU8810_SPKMX_EN_SFT        2
0091 #define NAU8810_MOUTMX_EN_SFT   3
0092 #define NAU8810_PSPK_EN_SFT     5
0093 #define NAU8810_NSPK_EN_SFT     6
0094 #define NAU8810_MOUT_EN_SFT     7
0095 
0096 /* NAU8810_REG_IFACE (0x4) */
0097 #define NAU8810_AIFMT_SFT       3
0098 #define NAU8810_AIFMT_MASK      (0x3 << NAU8810_AIFMT_SFT)
0099 #define NAU8810_AIFMT_RIGHT     (0x0 << NAU8810_AIFMT_SFT)
0100 #define NAU8810_AIFMT_LEFT      (0x1 << NAU8810_AIFMT_SFT)
0101 #define NAU8810_AIFMT_I2S       (0x2 << NAU8810_AIFMT_SFT)
0102 #define NAU8810_AIFMT_PCM_A     (0x3 << NAU8810_AIFMT_SFT)
0103 #define NAU8810_WLEN_SFT        5
0104 #define NAU8810_WLEN_MASK       (0x3 << NAU8810_WLEN_SFT)
0105 #define NAU8810_WLEN_16     (0x0 << NAU8810_WLEN_SFT)
0106 #define NAU8810_WLEN_20     (0x1 << NAU8810_WLEN_SFT)
0107 #define NAU8810_WLEN_24     (0x2 << NAU8810_WLEN_SFT)
0108 #define NAU8810_WLEN_32     (0x3 << NAU8810_WLEN_SFT)
0109 #define NAU8810_FSP_IF          (0x1 << 7)
0110 #define NAU8810_BCLKP_IB        (0x1 << 8)
0111 
0112 /* NAU8810_REG_COMP (0x5) */
0113 #define NAU8810_ADDAP_SFT       0
0114 #define NAU8810_ADCCM_SFT       1
0115 #define NAU8810_DACCM_SFT       3
0116 
0117 /* NAU8810_REG_CLOCK (0x6) */
0118 #define NAU8810_CLKIO_MASK      0x1
0119 #define NAU8810_CLKIO_SLAVE     0x0
0120 #define NAU8810_CLKIO_MASTER        0x1
0121 #define NAU8810_BCLKSEL_SFT     2
0122 #define NAU8810_BCLKSEL_MASK        (0x7 << NAU8810_BCLKSEL_SFT)
0123 #define NAU8810_BCLKDIV_1       (0x0 << NAU8810_BCLKSEL_SFT)
0124 #define NAU8810_BCLKDIV_2       (0x1 << NAU8810_BCLKSEL_SFT)
0125 #define NAU8810_BCLKDIV_4       (0x2 << NAU8810_BCLKSEL_SFT)
0126 #define NAU8810_BCLKDIV_8       (0x3 << NAU8810_BCLKSEL_SFT)
0127 #define NAU8810_BCLKDIV_16      (0x4 << NAU8810_BCLKSEL_SFT)
0128 #define NAU8810_BCLKDIV_32      (0x5 << NAU8810_BCLKSEL_SFT)
0129 #define NAU8810_MCLKSEL_SFT     5
0130 #define NAU8810_MCLKSEL_MASK        (0x7 << NAU8810_MCLKSEL_SFT)
0131 #define NAU8810_CLKM_SFT        8
0132 #define NAU8810_CLKM_MASK       (0x1 << NAU8810_CLKM_SFT)
0133 #define NAU8810_CLKM_MCLK       (0x0 << NAU8810_CLKM_SFT)
0134 #define NAU8810_CLKM_PLL        (0x1 << NAU8810_CLKM_SFT)
0135 
0136 /* NAU8810_REG_SMPLR (0x7) */
0137 #define NAU8810_SMPLR_SFT       1
0138 #define NAU8810_SMPLR_MASK      (0x7 << NAU8810_SMPLR_SFT)
0139 #define NAU8810_SMPLR_48K       (0x0 << NAU8810_SMPLR_SFT)
0140 #define NAU8810_SMPLR_32K       (0x1 << NAU8810_SMPLR_SFT)
0141 #define NAU8810_SMPLR_24K       (0x2 << NAU8810_SMPLR_SFT)
0142 #define NAU8810_SMPLR_16K       (0x3 << NAU8810_SMPLR_SFT)
0143 #define NAU8810_SMPLR_12K       (0x4 << NAU8810_SMPLR_SFT)
0144 #define NAU8810_SMPLR_8K        (0x5 << NAU8810_SMPLR_SFT)
0145 
0146 /* NAU8810_REG_DAC (0xA) */
0147 #define NAU8810_DACPL_SFT       0
0148 #define NAU8810_DACOS_SFT       3
0149 #define NAU8810_DEEMP_SFT       4
0150 
0151 /* NAU8810_REG_DACGAIN (0xB) */
0152 #define NAU8810_DACGAIN_SFT     0
0153 
0154 /* NAU8810_REG_ADC (0xE) */
0155 #define NAU8810_ADCPL_SFT       0
0156 #define NAU8810_ADCOS_SFT       3
0157 #define NAU8810_HPF_SFT     4
0158 #define NAU8810_HPFEN_SFT       8
0159 
0160 /* NAU8810_REG_ADCGAIN (0xF) */
0161 #define NAU8810_ADCGAIN_SFT     0
0162 
0163 /* NAU8810_REG_EQ1 (0x12) */
0164 #define NAU8810_EQ1GC_SFT       0
0165 #define NAU8810_EQ1CF_SFT       5
0166 #define NAU8810_EQM_SFT     8
0167 
0168 /* NAU8810_REG_EQ2 (0x13) */
0169 #define NAU8810_EQ2GC_SFT       0
0170 #define NAU8810_EQ2CF_SFT       5
0171 #define NAU8810_EQ2BW_SFT       8
0172 
0173 /* NAU8810_REG_EQ3 (0x14) */
0174 #define NAU8810_EQ3GC_SFT       0
0175 #define NAU8810_EQ3CF_SFT       5
0176 #define NAU8810_EQ3BW_SFT       8
0177 
0178 /* NAU8810_REG_EQ4 (0x15) */
0179 #define NAU8810_EQ4GC_SFT       0
0180 #define NAU8810_EQ4CF_SFT       5
0181 #define NAU8810_EQ4BW_SFT       8
0182 
0183 /* NAU8810_REG_EQ5 (0x16) */
0184 #define NAU8810_EQ5GC_SFT       0
0185 #define NAU8810_EQ5CF_SFT       5
0186 
0187 /* NAU8810_REG_DACLIM1 (0x18) */
0188 #define NAU8810_DACLIMATK_SFT       0
0189 #define NAU8810_DACLIMDCY_SFT       4
0190 #define NAU8810_DACLIMEN_SFT        8
0191 
0192 /* NAU8810_REG_DACLIM2 (0x19) */
0193 #define NAU8810_DACLIMBST_SFT       0
0194 #define NAU8810_DACLIMTHL_SFT       4
0195 
0196 /* NAU8810_REG_ALC1 (0x20) */
0197 #define NAU8810_ALCMINGAIN_SFT  0
0198 #define NAU8810_ALCMXGAIN_SFT       3
0199 #define NAU8810_ALCEN_SFT       8
0200 
0201 /* NAU8810_REG_ALC2 (0x21) */
0202 #define NAU8810_ALCSL_SFT       0
0203 #define NAU8810_ALCHT_SFT       4
0204 #define NAU8810_ALCZC_SFT       8
0205 
0206 /* NAU8810_REG_ALC3 (0x22) */
0207 #define NAU8810_ALCATK_SFT      0
0208 #define NAU8810_ALCDCY_SFT      4
0209 #define NAU8810_ALCM_SFT        8
0210 
0211 /* NAU8810_REG_NOISEGATE (0x23) */
0212 #define NAU8810_ALCNTH_SFT      0
0213 #define NAU8810_ALCNEN_SFT      3
0214 
0215 /* NAU8810_REG_PLLN (0x24) */
0216 #define NAU8810_PLLN_MASK       0xF
0217 #define NAU8810_PLLMCLK_DIV2        (0x1 << 4)
0218 
0219 /* NAU8810_REG_PLLK1 (0x25) */
0220 #define NAU8810_PLLK1_SFT       18
0221 #define NAU8810_PLLK1_MASK      0x3F
0222 
0223 /* NAU8810_REG_PLLK2 (0x26) */
0224 #define NAU8810_PLLK2_SFT       9
0225 #define NAU8810_PLLK2_MASK      0x1FF
0226 
0227 /* NAU8810_REG_PLLK3 (0x27) */
0228 #define NAU8810_PLLK3_MASK      0x1FF
0229 
0230 /* NAU8810_REG_INPUT_SIGNAL (0x2C) */
0231 #define NAU8810_PMICPGA_SFT     0
0232 #define NAU8810_PMICPGA_EN      (0x1 << NAU8810_PMICPGA_SFT)
0233 #define NAU8810_NMICPGA_SFT     1
0234 #define NAU8810_NMICPGA_EN      (0x1 << NAU8810_NMICPGA_SFT)
0235 #define NAU8810_AUXPGA_SFT      2
0236 
0237 /* NAU8810_REG_PGAGAIN (0x2D) */
0238 #define NAU8810_PGAGAIN_SFT     0
0239 #define NAU8810_PGAMT_SFT       6
0240 #define NAU8810_PGAZC_SFT       7
0241 
0242 /* NAU8810_REG_ADCBOOST (0x2F) */
0243 #define NAU8810_AUXBSTGAIN_SFT  0
0244 #define NAU8810_PMICBSTGAIN_SFT 4
0245 #define NAU8810_PMICBSTGAIN_MASK    (0x7 << NAU8810_PMICBSTGAIN_SFT)
0246 #define NAU8810_PGABST_SFT      8
0247 
0248 /* NAU8810_REG_SPKMIX (0x32) */
0249 #define NAU8810_DACSPK_SFT      0
0250 #define NAU8810_BYPSPK_SFT      1
0251 #define NAU8810_AUXSPK_SFT      5
0252 
0253 /* NAU8810_REG_SPKGAIN (0x36) */
0254 #define NAU8810_SPKGAIN_SFT     0
0255 #define NAU8810_SPKMT_SFT       6
0256 #define NAU8810_SPKZC_SFT       7
0257 
0258 /* NAU8810_REG_MONOMIX (0x38) */
0259 #define NAU8810_DACMOUT_SFT     0
0260 #define NAU8810_BYPMOUT_SFT     1
0261 #define NAU8810_AUXMOUT_SFT     2
0262 #define NAU8810_MOUTMXMT_SFT        6
0263 
0264 
0265 /* System Clock Source */
0266 enum {
0267     NAU8810_SCLK_MCLK,
0268     NAU8810_SCLK_PLL,
0269 };
0270 
0271 struct nau8810_pll {
0272     int pre_factor;
0273     int mclk_scaler;
0274     int pll_frac;
0275     int pll_int;
0276 };
0277 
0278 struct nau8810 {
0279     struct device *dev;
0280     struct regmap *regmap;
0281     struct nau8810_pll pll;
0282     int sysclk;
0283     int clk_id;
0284 };
0285 
0286 #endif