Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 1 | /* |
| 2 | * tlv320aic32x4.h |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | #ifndef _TLV320AIC32X4_H |
| 11 | #define _TLV320AIC32X4_H |
| 12 | |
Jeremy McDermond | 3bcfd22 | 2016-04-18 17:24:05 -0700 | [diff] [blame] | 13 | struct device; |
| 14 | struct regmap_config; |
| 15 | |
| 16 | extern const struct regmap_config aic32x4_regmap_config; |
| 17 | int aic32x4_probe(struct device *dev, struct regmap *regmap); |
| 18 | int aic32x4_remove(struct device *dev); |
Annaliese McDermond | 514b044 | 2019-03-21 17:58:45 -0700 | [diff] [blame] | 19 | int aic32x4_register_clocks(struct device *dev, const char *mclk_name); |
Jeremy McDermond | 3bcfd22 | 2016-04-18 17:24:05 -0700 | [diff] [blame] | 20 | |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 21 | /* tlv320aic32x4 register space (in decimal to match datasheet) */ |
| 22 | |
Andrew F. Davis | 1714196 | 2017-12-12 16:43:03 -0600 | [diff] [blame] | 23 | #define AIC32X4_REG(page, reg) ((page * 128) + reg) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 24 | |
Andrew F. Davis | 1714196 | 2017-12-12 16:43:03 -0600 | [diff] [blame] | 25 | #define AIC32X4_PSEL AIC32X4_REG(0, 0) |
| 26 | |
| 27 | #define AIC32X4_RESET AIC32X4_REG(0, 1) |
| 28 | #define AIC32X4_CLKMUX AIC32X4_REG(0, 4) |
| 29 | #define AIC32X4_PLLPR AIC32X4_REG(0, 5) |
| 30 | #define AIC32X4_PLLJ AIC32X4_REG(0, 6) |
| 31 | #define AIC32X4_PLLDMSB AIC32X4_REG(0, 7) |
| 32 | #define AIC32X4_PLLDLSB AIC32X4_REG(0, 8) |
| 33 | #define AIC32X4_NDAC AIC32X4_REG(0, 11) |
| 34 | #define AIC32X4_MDAC AIC32X4_REG(0, 12) |
| 35 | #define AIC32X4_DOSRMSB AIC32X4_REG(0, 13) |
| 36 | #define AIC32X4_DOSRLSB AIC32X4_REG(0, 14) |
| 37 | #define AIC32X4_NADC AIC32X4_REG(0, 18) |
| 38 | #define AIC32X4_MADC AIC32X4_REG(0, 19) |
| 39 | #define AIC32X4_AOSR AIC32X4_REG(0, 20) |
| 40 | #define AIC32X4_CLKMUX2 AIC32X4_REG(0, 25) |
| 41 | #define AIC32X4_CLKOUTM AIC32X4_REG(0, 26) |
| 42 | #define AIC32X4_IFACE1 AIC32X4_REG(0, 27) |
| 43 | #define AIC32X4_IFACE2 AIC32X4_REG(0, 28) |
| 44 | #define AIC32X4_IFACE3 AIC32X4_REG(0, 29) |
| 45 | #define AIC32X4_BCLKN AIC32X4_REG(0, 30) |
| 46 | #define AIC32X4_IFACE4 AIC32X4_REG(0, 31) |
| 47 | #define AIC32X4_IFACE5 AIC32X4_REG(0, 32) |
| 48 | #define AIC32X4_IFACE6 AIC32X4_REG(0, 33) |
| 49 | #define AIC32X4_GPIOCTL AIC32X4_REG(0, 52) |
| 50 | #define AIC32X4_DOUTCTL AIC32X4_REG(0, 53) |
| 51 | #define AIC32X4_DINCTL AIC32X4_REG(0, 54) |
| 52 | #define AIC32X4_MISOCTL AIC32X4_REG(0, 55) |
| 53 | #define AIC32X4_SCLKCTL AIC32X4_REG(0, 56) |
| 54 | #define AIC32X4_DACSPB AIC32X4_REG(0, 60) |
| 55 | #define AIC32X4_ADCSPB AIC32X4_REG(0, 61) |
| 56 | #define AIC32X4_DACSETUP AIC32X4_REG(0, 63) |
| 57 | #define AIC32X4_DACMUTE AIC32X4_REG(0, 64) |
| 58 | #define AIC32X4_LDACVOL AIC32X4_REG(0, 65) |
| 59 | #define AIC32X4_RDACVOL AIC32X4_REG(0, 66) |
| 60 | #define AIC32X4_ADCSETUP AIC32X4_REG(0, 81) |
| 61 | #define AIC32X4_ADCFGA AIC32X4_REG(0, 82) |
| 62 | #define AIC32X4_LADCVOL AIC32X4_REG(0, 83) |
| 63 | #define AIC32X4_RADCVOL AIC32X4_REG(0, 84) |
| 64 | #define AIC32X4_LAGC1 AIC32X4_REG(0, 86) |
| 65 | #define AIC32X4_LAGC2 AIC32X4_REG(0, 87) |
| 66 | #define AIC32X4_LAGC3 AIC32X4_REG(0, 88) |
| 67 | #define AIC32X4_LAGC4 AIC32X4_REG(0, 89) |
| 68 | #define AIC32X4_LAGC5 AIC32X4_REG(0, 90) |
| 69 | #define AIC32X4_LAGC6 AIC32X4_REG(0, 91) |
| 70 | #define AIC32X4_LAGC7 AIC32X4_REG(0, 92) |
| 71 | #define AIC32X4_RAGC1 AIC32X4_REG(0, 94) |
| 72 | #define AIC32X4_RAGC2 AIC32X4_REG(0, 95) |
| 73 | #define AIC32X4_RAGC3 AIC32X4_REG(0, 96) |
| 74 | #define AIC32X4_RAGC4 AIC32X4_REG(0, 97) |
| 75 | #define AIC32X4_RAGC5 AIC32X4_REG(0, 98) |
| 76 | #define AIC32X4_RAGC6 AIC32X4_REG(0, 99) |
| 77 | #define AIC32X4_RAGC7 AIC32X4_REG(0, 100) |
| 78 | |
| 79 | #define AIC32X4_PWRCFG AIC32X4_REG(1, 1) |
| 80 | #define AIC32X4_LDOCTL AIC32X4_REG(1, 2) |
Annaliese McDermond | d3e6e37 | 2019-04-03 21:01:55 -0700 | [diff] [blame] | 81 | #define AIC32X4_LPLAYBACK AIC32X4_REG(1, 3) |
| 82 | #define AIC32X4_RPLAYBACK AIC32X4_REG(1, 4) |
Andrew F. Davis | 1714196 | 2017-12-12 16:43:03 -0600 | [diff] [blame] | 83 | #define AIC32X4_OUTPWRCTL AIC32X4_REG(1, 9) |
| 84 | #define AIC32X4_CMMODE AIC32X4_REG(1, 10) |
| 85 | #define AIC32X4_HPLROUTE AIC32X4_REG(1, 12) |
| 86 | #define AIC32X4_HPRROUTE AIC32X4_REG(1, 13) |
| 87 | #define AIC32X4_LOLROUTE AIC32X4_REG(1, 14) |
| 88 | #define AIC32X4_LORROUTE AIC32X4_REG(1, 15) |
| 89 | #define AIC32X4_HPLGAIN AIC32X4_REG(1, 16) |
| 90 | #define AIC32X4_HPRGAIN AIC32X4_REG(1, 17) |
| 91 | #define AIC32X4_LOLGAIN AIC32X4_REG(1, 18) |
| 92 | #define AIC32X4_LORGAIN AIC32X4_REG(1, 19) |
| 93 | #define AIC32X4_HEADSTART AIC32X4_REG(1, 20) |
| 94 | #define AIC32X4_MICBIAS AIC32X4_REG(1, 51) |
| 95 | #define AIC32X4_LMICPGAPIN AIC32X4_REG(1, 52) |
| 96 | #define AIC32X4_LMICPGANIN AIC32X4_REG(1, 54) |
| 97 | #define AIC32X4_RMICPGAPIN AIC32X4_REG(1, 55) |
| 98 | #define AIC32X4_RMICPGANIN AIC32X4_REG(1, 57) |
| 99 | #define AIC32X4_FLOATINGINPUT AIC32X4_REG(1, 58) |
| 100 | #define AIC32X4_LMICPGAVOL AIC32X4_REG(1, 59) |
| 101 | #define AIC32X4_RMICPGAVOL AIC32X4_REG(1, 60) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 102 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 103 | /* Bits, masks, and shifts */ |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 104 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 105 | /* AIC32X4_CLKMUX */ |
| 106 | #define AIC32X4_PLL_CLKIN_MASK GENMASK(3, 2) |
| 107 | #define AIC32X4_PLL_CLKIN_SHIFT (2) |
| 108 | #define AIC32X4_PLL_CLKIN_MCLK (0x00) |
| 109 | #define AIC32X4_PLL_CLKIN_BCKL (0x01) |
| 110 | #define AIC32X4_PLL_CLKIN_GPIO1 (0x02) |
| 111 | #define AIC32X4_PLL_CLKIN_DIN (0x03) |
| 112 | #define AIC32X4_CODEC_CLKIN_MASK GENMASK(1, 0) |
| 113 | #define AIC32X4_CODEC_CLKIN_SHIFT (0) |
| 114 | #define AIC32X4_CODEC_CLKIN_MCLK (0x00) |
| 115 | #define AIC32X4_CODEC_CLKIN_BCLK (0x01) |
| 116 | #define AIC32X4_CODEC_CLKIN_GPIO1 (0x02) |
| 117 | #define AIC32X4_CODEC_CLKIN_PLL (0x03) |
Javier Martin | a405387 | 2012-10-31 11:53:33 +0100 | [diff] [blame] | 118 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 119 | /* AIC32X4_PLLPR */ |
| 120 | #define AIC32X4_PLLEN BIT(7) |
Andrew F. Davis | 64aab89 | 2017-12-12 16:43:09 -0600 | [diff] [blame] | 121 | #define AIC32X4_PLL_P_MASK GENMASK(6, 4) |
| 122 | #define AIC32X4_PLL_P_SHIFT (4) |
| 123 | #define AIC32X4_PLL_R_MASK GENMASK(3, 0) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 124 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 125 | /* AIC32X4_NDAC */ |
| 126 | #define AIC32X4_NDACEN BIT(7) |
Andrew F. Davis | 64aab89 | 2017-12-12 16:43:09 -0600 | [diff] [blame] | 127 | #define AIC32X4_NDAC_MASK GENMASK(6, 0) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 128 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 129 | /* AIC32X4_MDAC */ |
| 130 | #define AIC32X4_MDACEN BIT(7) |
Andrew F. Davis | 64aab89 | 2017-12-12 16:43:09 -0600 | [diff] [blame] | 131 | #define AIC32X4_MDAC_MASK GENMASK(6, 0) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 132 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 133 | /* AIC32X4_NADC */ |
| 134 | #define AIC32X4_NADCEN BIT(7) |
Andrew F. Davis | 64aab89 | 2017-12-12 16:43:09 -0600 | [diff] [blame] | 135 | #define AIC32X4_NADC_MASK GENMASK(6, 0) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 136 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 137 | /* AIC32X4_MADC */ |
| 138 | #define AIC32X4_MADCEN BIT(7) |
Andrew F. Davis | 64aab89 | 2017-12-12 16:43:09 -0600 | [diff] [blame] | 139 | #define AIC32X4_MADC_MASK GENMASK(6, 0) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 140 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 141 | /* AIC32X4_BCLKN */ |
| 142 | #define AIC32X4_BCLKEN BIT(7) |
Andrew F. Davis | 64aab89 | 2017-12-12 16:43:09 -0600 | [diff] [blame] | 143 | #define AIC32X4_BCLK_MASK GENMASK(6, 0) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 144 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 145 | /* AIC32X4_IFACE1 */ |
| 146 | #define AIC32X4_IFACE1_DATATYPE_MASK GENMASK(7, 6) |
| 147 | #define AIC32X4_IFACE1_DATATYPE_SHIFT (6) |
| 148 | #define AIC32X4_I2S_MODE (0x00) |
| 149 | #define AIC32X4_DSP_MODE (0x01) |
| 150 | #define AIC32X4_RIGHT_JUSTIFIED_MODE (0x02) |
| 151 | #define AIC32X4_LEFT_JUSTIFIED_MODE (0x03) |
| 152 | #define AIC32X4_IFACE1_DATALEN_MASK GENMASK(5, 4) |
| 153 | #define AIC32X4_IFACE1_DATALEN_SHIFT (4) |
| 154 | #define AIC32X4_WORD_LEN_16BITS (0x00) |
| 155 | #define AIC32X4_WORD_LEN_20BITS (0x01) |
| 156 | #define AIC32X4_WORD_LEN_24BITS (0x02) |
| 157 | #define AIC32X4_WORD_LEN_32BITS (0x03) |
| 158 | #define AIC32X4_IFACE1_MASTER_MASK GENMASK(3, 2) |
| 159 | #define AIC32X4_BCLKMASTER BIT(2) |
| 160 | #define AIC32X4_WCLKMASTER BIT(3) |
| 161 | |
| 162 | /* AIC32X4_IFACE2 */ |
| 163 | #define AIC32X4_DATA_OFFSET_MASK GENMASK(7, 0) |
| 164 | |
| 165 | /* AIC32X4_IFACE3 */ |
| 166 | #define AIC32X4_BCLKINV_MASK BIT(3) |
| 167 | #define AIC32X4_BDIVCLK_MASK GENMASK(1, 0) |
| 168 | #define AIC32X4_BDIVCLK_SHIFT (0) |
| 169 | #define AIC32X4_DAC2BCLK (0x00) |
| 170 | #define AIC32X4_DACMOD2BCLK (0x01) |
| 171 | #define AIC32X4_ADC2BCLK (0x02) |
| 172 | #define AIC32X4_ADCMOD2BCLK (0x03) |
| 173 | |
| 174 | /* AIC32X4_DACSETUP */ |
| 175 | #define AIC32X4_DAC_CHAN_MASK GENMASK(5, 2) |
| 176 | #define AIC32X4_LDAC2RCHN BIT(5) |
| 177 | #define AIC32X4_LDAC2LCHN BIT(4) |
| 178 | #define AIC32X4_RDAC2LCHN BIT(3) |
| 179 | #define AIC32X4_RDAC2RCHN BIT(2) |
| 180 | |
| 181 | /* AIC32X4_DACMUTE */ |
| 182 | #define AIC32X4_MUTEON 0x0C |
| 183 | |
| 184 | /* AIC32X4_ADCSETUP */ |
| 185 | #define AIC32X4_LADC_EN BIT(7) |
| 186 | #define AIC32X4_RADC_EN BIT(6) |
| 187 | |
| 188 | /* AIC32X4_PWRCFG */ |
| 189 | #define AIC32X4_AVDDWEAKDISABLE BIT(3) |
| 190 | |
| 191 | /* AIC32X4_LDOCTL */ |
| 192 | #define AIC32X4_LDOCTLEN BIT(0) |
| 193 | |
| 194 | /* AIC32X4_CMMODE */ |
| 195 | #define AIC32X4_LDOIN_18_36 BIT(0) |
| 196 | #define AIC32X4_LDOIN2HP BIT(1) |
| 197 | |
| 198 | /* AIC32X4_MICBIAS */ |
| 199 | #define AIC32X4_MICBIAS_LDOIN BIT(3) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 200 | #define AIC32X4_MICBIAS_2075V 0x60 |
b-ak | 04d979d | 2019-01-09 22:41:21 +0530 | [diff] [blame] | 201 | #define AIC32x4_MICBIAS_MASK GENMASK(6, 3) |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 202 | |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 203 | /* AIC32X4_LMICPGANIN */ |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 204 | #define AIC32X4_LMICPGANIN_IN2R_10K 0x10 |
Markus Pargmann | 609e602 | 2014-01-27 13:03:06 +0100 | [diff] [blame] | 205 | #define AIC32X4_LMICPGANIN_CM1L_10K 0x40 |
Andrew F. Davis | 0fe7aa3 | 2017-12-12 16:43:07 -0600 | [diff] [blame] | 206 | |
| 207 | /* AIC32X4_RMICPGANIN */ |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 208 | #define AIC32X4_RMICPGANIN_IN1L_10K 0x10 |
Markus Pargmann | 609e602 | 2014-01-27 13:03:06 +0100 | [diff] [blame] | 209 | #define AIC32X4_RMICPGANIN_CM1R_10K 0x40 |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 210 | |
Annaliese McDermond | a51b500 | 2019-03-21 17:58:47 -0700 | [diff] [blame] | 211 | /* Common mask and enable for all of the dividers */ |
| 212 | #define AIC32X4_DIVEN BIT(7) |
| 213 | #define AIC32X4_DIV_MASK GENMASK(6, 0) |
| 214 | |
Annaliese McDermond | 514b044 | 2019-03-21 17:58:45 -0700 | [diff] [blame] | 215 | /* Clock Limits */ |
Annaliese McDermond | 96c3bb0 | 2019-03-21 17:58:51 -0700 | [diff] [blame] | 216 | #define AIC32X4_MAX_DOSR_FREQ 6200000 |
| 217 | #define AIC32X4_MIN_DOSR_FREQ 2800000 |
| 218 | #define AIC32X4_MAX_CODEC_CLKIN_FREQ 110000000 |
Annaliese McDermond | 514b044 | 2019-03-21 17:58:45 -0700 | [diff] [blame] | 219 | #define AIC32X4_MAX_PLL_CLKIN 20000000 |
| 220 | |
Javier Martin | 1d471cd | 2011-03-02 14:52:32 +0100 | [diff] [blame] | 221 | #endif /* _TLV320AIC32X4_H */ |