1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * MFD internals for Cirrus Logic Madera codecs 4 * 5 * Copyright (C) 2015-2018 Cirrus Logic 6 */ 7 8 #ifndef MADERA_CORE_H 9 #define MADERA_CORE_H 10 11 #include <linux/clk.h> 12 #include <linux/gpio/consumer.h> 13 #include <linux/interrupt.h> 14 #include <linux/mfd/madera/pdata.h> 15 #include <linux/mutex.h> 16 #include <linux/notifier.h> 17 #include <linux/regmap.h> 18 #include <linux/regulator/consumer.h> 19 20 enum madera_type { 21 /* 0 is reserved for indicating failure to identify */ 22 CS47L35 = 1, 23 CS47L85 = 2, 24 CS47L90 = 3, 25 CS47L91 = 4, 26 CS47L92 = 5, 27 CS47L93 = 6, 28 WM1840 = 7, 29 CS47L15 = 8, 30 CS42L92 = 9, 31 }; 32 33 enum { 34 MADERA_MCLK1, 35 MADERA_MCLK2, 36 MADERA_MCLK3, 37 MADERA_NUM_MCLK 38 }; 39 40 #define MADERA_MAX_CORE_SUPPLIES 2 41 #define MADERA_MAX_GPIOS 40 42 43 #define CS47L15_NUM_GPIOS 15 44 #define CS47L35_NUM_GPIOS 16 45 #define CS47L85_NUM_GPIOS 40 46 #define CS47L90_NUM_GPIOS 38 47 #define CS47L92_NUM_GPIOS 16 48 49 #define MADERA_MAX_MICBIAS 4 50 51 #define MADERA_MAX_HP_OUTPUT 3 52 53 /* Notifier events */ 54 #define MADERA_NOTIFY_VOICE_TRIGGER 0x1 55 #define MADERA_NOTIFY_HPDET 0x2 56 #define MADERA_NOTIFY_MICDET 0x4 57 58 /* GPIO Function Definitions */ 59 #define MADERA_GP_FN_ALTERNATE 0x00 60 #define MADERA_GP_FN_GPIO 0x01 61 #define MADERA_GP_FN_DSP_GPIO 0x02 62 #define MADERA_GP_FN_IRQ1 0x03 63 #define MADERA_GP_FN_IRQ2 0x04 64 #define MADERA_GP_FN_FLL1_CLOCK 0x10 65 #define MADERA_GP_FN_FLL2_CLOCK 0x11 66 #define MADERA_GP_FN_FLL3_CLOCK 0x12 67 #define MADERA_GP_FN_FLLAO_CLOCK 0x13 68 #define MADERA_GP_FN_FLL1_LOCK 0x18 69 #define MADERA_GP_FN_FLL2_LOCK 0x19 70 #define MADERA_GP_FN_FLL3_LOCK 0x1A 71 #define MADERA_GP_FN_FLLAO_LOCK 0x1B 72 #define MADERA_GP_FN_OPCLK_OUT 0x40 73 #define MADERA_GP_FN_OPCLK_ASYNC_OUT 0x41 74 #define MADERA_GP_FN_PWM1 0x48 75 #define MADERA_GP_FN_PWM2 0x49 76 #define MADERA_GP_FN_SPDIF_OUT 0x4C 77 #define MADERA_GP_FN_HEADPHONE_DET 0x50 78 #define MADERA_GP_FN_MIC_DET 0x58 79 #define MADERA_GP_FN_DRC1_SIGNAL_DETECT 0x80 80 #define MADERA_GP_FN_DRC2_SIGNAL_DETECT 0x81 81 #define MADERA_GP_FN_ASRC1_IN1_LOCK 0x88 82 #define MADERA_GP_FN_ASRC1_IN2_LOCK 0x89 83 #define MADERA_GP_FN_ASRC2_IN1_LOCK 0x8A 84 #define MADERA_GP_FN_ASRC2_IN2_LOCK 0x8B 85 #define MADERA_GP_FN_DSP_IRQ1 0xA0 86 #define MADERA_GP_FN_DSP_IRQ2 0xA1 87 #define MADERA_GP_FN_DSP_IRQ3 0xA2 88 #define MADERA_GP_FN_DSP_IRQ4 0xA3 89 #define MADERA_GP_FN_DSP_IRQ5 0xA4 90 #define MADERA_GP_FN_DSP_IRQ6 0xA5 91 #define MADERA_GP_FN_DSP_IRQ7 0xA6 92 #define MADERA_GP_FN_DSP_IRQ8 0xA7 93 #define MADERA_GP_FN_DSP_IRQ9 0xA8 94 #define MADERA_GP_FN_DSP_IRQ10 0xA9 95 #define MADERA_GP_FN_DSP_IRQ11 0xAA 96 #define MADERA_GP_FN_DSP_IRQ12 0xAB 97 #define MADERA_GP_FN_DSP_IRQ13 0xAC 98 #define MADERA_GP_FN_DSP_IRQ14 0xAD 99 #define MADERA_GP_FN_DSP_IRQ15 0xAE 100 #define MADERA_GP_FN_DSP_IRQ16 0xAF 101 #define MADERA_GP_FN_HPOUT1L_SC 0xB0 102 #define MADERA_GP_FN_HPOUT1R_SC 0xB1 103 #define MADERA_GP_FN_HPOUT2L_SC 0xB2 104 #define MADERA_GP_FN_HPOUT2R_SC 0xB3 105 #define MADERA_GP_FN_HPOUT3L_SC 0xB4 106 #define MADERA_GP_FN_HPOUT4R_SC 0xB5 107 #define MADERA_GP_FN_SPKOUTL_SC 0xB6 108 #define MADERA_GP_FN_SPKOUTR_SC 0xB7 109 #define MADERA_GP_FN_HPOUT1L_ENA 0xC0 110 #define MADERA_GP_FN_HPOUT1R_ENA 0xC1 111 #define MADERA_GP_FN_HPOUT2L_ENA 0xC2 112 #define MADERA_GP_FN_HPOUT2R_ENA 0xC3 113 #define MADERA_GP_FN_HPOUT3L_ENA 0xC4 114 #define MADERA_GP_FN_HPOUT4R_ENA 0xC5 115 #define MADERA_GP_FN_SPKOUTL_ENA 0xC6 116 #define MADERA_GP_FN_SPKOUTR_ENA 0xC7 117 #define MADERA_GP_FN_HPOUT1L_DIS 0xD0 118 #define MADERA_GP_FN_HPOUT1R_DIS 0xD1 119 #define MADERA_GP_FN_HPOUT2L_DIS 0xD2 120 #define MADERA_GP_FN_HPOUT2R_DIS 0xD3 121 #define MADERA_GP_FN_HPOUT3L_DIS 0xD4 122 #define MADERA_GP_FN_HPOUT4R_DIS 0xD5 123 #define MADERA_GP_FN_SPKOUTL_DIS 0xD6 124 #define MADERA_GP_FN_SPKOUTR_DIS 0xD7 125 #define MADERA_GP_FN_SPK_SHUTDOWN 0xE0 126 #define MADERA_GP_FN_SPK_OVH_SHUTDOWN 0xE1 127 #define MADERA_GP_FN_SPK_OVH_WARN 0xE2 128 #define MADERA_GP_FN_TIMER1_STATUS 0x140 129 #define MADERA_GP_FN_TIMER2_STATUS 0x141 130 #define MADERA_GP_FN_TIMER3_STATUS 0x142 131 #define MADERA_GP_FN_TIMER4_STATUS 0x143 132 #define MADERA_GP_FN_TIMER5_STATUS 0x144 133 #define MADERA_GP_FN_TIMER6_STATUS 0x145 134 #define MADERA_GP_FN_TIMER7_STATUS 0x146 135 #define MADERA_GP_FN_TIMER8_STATUS 0x147 136 #define MADERA_GP_FN_EVENTLOG1_FIFO_STS 0x150 137 #define MADERA_GP_FN_EVENTLOG2_FIFO_STS 0x151 138 #define MADERA_GP_FN_EVENTLOG3_FIFO_STS 0x152 139 #define MADERA_GP_FN_EVENTLOG4_FIFO_STS 0x153 140 #define MADERA_GP_FN_EVENTLOG5_FIFO_STS 0x154 141 #define MADERA_GP_FN_EVENTLOG6_FIFO_STS 0x155 142 #define MADERA_GP_FN_EVENTLOG7_FIFO_STS 0x156 143 #define MADERA_GP_FN_EVENTLOG8_FIFO_STS 0x157 144 145 struct snd_soc_dapm_context; 146 147 /* 148 * struct madera - internal data shared by the set of Madera drivers 149 * 150 * This should not be used by anything except child drivers of the Madera MFD 151 * 152 * @regmap: pointer to the regmap instance for 16-bit registers 153 * @regmap_32bit: pointer to the regmap instance for 32-bit registers 154 * @dev: pointer to the MFD device 155 * @type: type of codec 156 * @rev: silicon revision 157 * @type_name: display name of this codec 158 * @num_core_supplies: number of core supply regulators 159 * @core_supplies: list of core supplies that are always required 160 * @dcvdd: pointer to DCVDD regulator 161 * @internal_dcvdd: true if DCVDD is supplied from the internal LDO1 162 * @pdata: our pdata 163 * @irq_dev: the irqchip child driver device 164 * @irq_data: pointer to irqchip data for the child irqchip driver 165 * @irq: host irq number from SPI or I2C configuration 166 * @mclk: Structure holding clock supplies 167 * @out_clamp: indicates output clamp state for each analogue output 168 * @out_shorted: indicates short circuit state for each analogue output 169 * @hp_ena: bitflags of enable state for the headphone outputs 170 * @num_micbias: number of MICBIAS outputs 171 * @num_childbias: number of child biases for each MICBIAS 172 * @dapm: pointer to codec driver DAPM context 173 * @notifier: notifier for signalling events to ASoC machine driver 174 */ 175 struct madera { 176 struct regmap *regmap; 177 struct regmap *regmap_32bit; 178 179 struct device *dev; 180 181 enum madera_type type; 182 unsigned int rev; 183 const char *type_name; 184 185 int num_core_supplies; 186 struct regulator_bulk_data core_supplies[MADERA_MAX_CORE_SUPPLIES]; 187 struct regulator *dcvdd; 188 bool internal_dcvdd; 189 190 struct madera_pdata pdata; 191 192 struct device *irq_dev; 193 struct regmap_irq_chip_data *irq_data; 194 int irq; 195 196 struct clk_bulk_data mclk[MADERA_NUM_MCLK]; 197 198 unsigned int num_micbias; 199 unsigned int num_childbias[MADERA_MAX_MICBIAS]; 200 201 struct snd_soc_dapm_context *dapm; 202 struct mutex dapm_ptr_lock; 203 unsigned int hp_ena; 204 bool out_clamp[MADERA_MAX_HP_OUTPUT]; 205 bool out_shorted[MADERA_MAX_HP_OUTPUT]; 206 207 struct blocking_notifier_head notifier; 208 }; 209 #endif 210