Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * MFD internals for Cirrus Logic Madera codecs
0004  *
0005  * Copyright (C) 2015-2018 Cirrus Logic
0006  */
0007 
0008 #ifndef MADERA_CORE_H
0009 #define MADERA_CORE_H
0010 
0011 #include <linux/clk.h>
0012 #include <linux/gpio/consumer.h>
0013 #include <linux/interrupt.h>
0014 #include <linux/mfd/madera/pdata.h>
0015 #include <linux/mutex.h>
0016 #include <linux/notifier.h>
0017 #include <linux/regmap.h>
0018 #include <linux/regulator/consumer.h>
0019 
0020 enum madera_type {
0021     /* 0 is reserved for indicating failure to identify */
0022     CS47L35 = 1,
0023     CS47L85 = 2,
0024     CS47L90 = 3,
0025     CS47L91 = 4,
0026     CS47L92 = 5,
0027     CS47L93 = 6,
0028     WM1840 = 7,
0029     CS47L15 = 8,
0030     CS42L92 = 9,
0031 };
0032 
0033 enum {
0034     MADERA_MCLK1,
0035     MADERA_MCLK2,
0036     MADERA_MCLK3,
0037     MADERA_NUM_MCLK
0038 };
0039 
0040 #define MADERA_MAX_CORE_SUPPLIES    2
0041 #define MADERA_MAX_GPIOS        40
0042 
0043 #define CS47L15_NUM_GPIOS       15
0044 #define CS47L35_NUM_GPIOS       16
0045 #define CS47L85_NUM_GPIOS       40
0046 #define CS47L90_NUM_GPIOS       38
0047 #define CS47L92_NUM_GPIOS       16
0048 
0049 #define MADERA_MAX_MICBIAS      4
0050 
0051 #define MADERA_MAX_HP_OUTPUT        3
0052 
0053 /* Notifier events */
0054 #define MADERA_NOTIFY_VOICE_TRIGGER 0x1
0055 #define MADERA_NOTIFY_HPDET     0x2
0056 #define MADERA_NOTIFY_MICDET        0x4
0057 
0058 /* GPIO Function Definitions */
0059 #define MADERA_GP_FN_ALTERNATE      0x00
0060 #define MADERA_GP_FN_GPIO       0x01
0061 #define MADERA_GP_FN_DSP_GPIO       0x02
0062 #define MADERA_GP_FN_IRQ1       0x03
0063 #define MADERA_GP_FN_IRQ2       0x04
0064 #define MADERA_GP_FN_FLL1_CLOCK     0x10
0065 #define MADERA_GP_FN_FLL2_CLOCK     0x11
0066 #define MADERA_GP_FN_FLL3_CLOCK     0x12
0067 #define MADERA_GP_FN_FLLAO_CLOCK    0x13
0068 #define MADERA_GP_FN_FLL1_LOCK      0x18
0069 #define MADERA_GP_FN_FLL2_LOCK      0x19
0070 #define MADERA_GP_FN_FLL3_LOCK      0x1A
0071 #define MADERA_GP_FN_FLLAO_LOCK     0x1B
0072 #define MADERA_GP_FN_OPCLK_OUT      0x40
0073 #define MADERA_GP_FN_OPCLK_ASYNC_OUT    0x41
0074 #define MADERA_GP_FN_PWM1       0x48
0075 #define MADERA_GP_FN_PWM2       0x49
0076 #define MADERA_GP_FN_SPDIF_OUT      0x4C
0077 #define MADERA_GP_FN_HEADPHONE_DET  0x50
0078 #define MADERA_GP_FN_MIC_DET        0x58
0079 #define MADERA_GP_FN_DRC1_SIGNAL_DETECT 0x80
0080 #define MADERA_GP_FN_DRC2_SIGNAL_DETECT 0x81
0081 #define MADERA_GP_FN_ASRC1_IN1_LOCK 0x88
0082 #define MADERA_GP_FN_ASRC1_IN2_LOCK 0x89
0083 #define MADERA_GP_FN_ASRC2_IN1_LOCK 0x8A
0084 #define MADERA_GP_FN_ASRC2_IN2_LOCK 0x8B
0085 #define MADERA_GP_FN_DSP_IRQ1       0xA0
0086 #define MADERA_GP_FN_DSP_IRQ2       0xA1
0087 #define MADERA_GP_FN_DSP_IRQ3       0xA2
0088 #define MADERA_GP_FN_DSP_IRQ4       0xA3
0089 #define MADERA_GP_FN_DSP_IRQ5       0xA4
0090 #define MADERA_GP_FN_DSP_IRQ6       0xA5
0091 #define MADERA_GP_FN_DSP_IRQ7       0xA6
0092 #define MADERA_GP_FN_DSP_IRQ8       0xA7
0093 #define MADERA_GP_FN_DSP_IRQ9       0xA8
0094 #define MADERA_GP_FN_DSP_IRQ10      0xA9
0095 #define MADERA_GP_FN_DSP_IRQ11      0xAA
0096 #define MADERA_GP_FN_DSP_IRQ12      0xAB
0097 #define MADERA_GP_FN_DSP_IRQ13      0xAC
0098 #define MADERA_GP_FN_DSP_IRQ14      0xAD
0099 #define MADERA_GP_FN_DSP_IRQ15      0xAE
0100 #define MADERA_GP_FN_DSP_IRQ16      0xAF
0101 #define MADERA_GP_FN_HPOUT1L_SC     0xB0
0102 #define MADERA_GP_FN_HPOUT1R_SC     0xB1
0103 #define MADERA_GP_FN_HPOUT2L_SC     0xB2
0104 #define MADERA_GP_FN_HPOUT2R_SC     0xB3
0105 #define MADERA_GP_FN_HPOUT3L_SC     0xB4
0106 #define MADERA_GP_FN_HPOUT4R_SC     0xB5
0107 #define MADERA_GP_FN_SPKOUTL_SC     0xB6
0108 #define MADERA_GP_FN_SPKOUTR_SC     0xB7
0109 #define MADERA_GP_FN_HPOUT1L_ENA    0xC0
0110 #define MADERA_GP_FN_HPOUT1R_ENA    0xC1
0111 #define MADERA_GP_FN_HPOUT2L_ENA    0xC2
0112 #define MADERA_GP_FN_HPOUT2R_ENA    0xC3
0113 #define MADERA_GP_FN_HPOUT3L_ENA    0xC4
0114 #define MADERA_GP_FN_HPOUT4R_ENA    0xC5
0115 #define MADERA_GP_FN_SPKOUTL_ENA    0xC6
0116 #define MADERA_GP_FN_SPKOUTR_ENA    0xC7
0117 #define MADERA_GP_FN_HPOUT1L_DIS    0xD0
0118 #define MADERA_GP_FN_HPOUT1R_DIS    0xD1
0119 #define MADERA_GP_FN_HPOUT2L_DIS    0xD2
0120 #define MADERA_GP_FN_HPOUT2R_DIS    0xD3
0121 #define MADERA_GP_FN_HPOUT3L_DIS    0xD4
0122 #define MADERA_GP_FN_HPOUT4R_DIS    0xD5
0123 #define MADERA_GP_FN_SPKOUTL_DIS    0xD6
0124 #define MADERA_GP_FN_SPKOUTR_DIS    0xD7
0125 #define MADERA_GP_FN_SPK_SHUTDOWN   0xE0
0126 #define MADERA_GP_FN_SPK_OVH_SHUTDOWN   0xE1
0127 #define MADERA_GP_FN_SPK_OVH_WARN   0xE2
0128 #define MADERA_GP_FN_TIMER1_STATUS  0x140
0129 #define MADERA_GP_FN_TIMER2_STATUS  0x141
0130 #define MADERA_GP_FN_TIMER3_STATUS  0x142
0131 #define MADERA_GP_FN_TIMER4_STATUS  0x143
0132 #define MADERA_GP_FN_TIMER5_STATUS  0x144
0133 #define MADERA_GP_FN_TIMER6_STATUS  0x145
0134 #define MADERA_GP_FN_TIMER7_STATUS  0x146
0135 #define MADERA_GP_FN_TIMER8_STATUS  0x147
0136 #define MADERA_GP_FN_EVENTLOG1_FIFO_STS 0x150
0137 #define MADERA_GP_FN_EVENTLOG2_FIFO_STS 0x151
0138 #define MADERA_GP_FN_EVENTLOG3_FIFO_STS 0x152
0139 #define MADERA_GP_FN_EVENTLOG4_FIFO_STS 0x153
0140 #define MADERA_GP_FN_EVENTLOG5_FIFO_STS 0x154
0141 #define MADERA_GP_FN_EVENTLOG6_FIFO_STS 0x155
0142 #define MADERA_GP_FN_EVENTLOG7_FIFO_STS 0x156
0143 #define MADERA_GP_FN_EVENTLOG8_FIFO_STS 0x157
0144 
0145 struct snd_soc_dapm_context;
0146 
0147 /*
0148  * struct madera - internal data shared by the set of Madera drivers
0149  *
0150  * This should not be used by anything except child drivers of the Madera MFD
0151  *
0152  * @regmap:     pointer to the regmap instance for 16-bit registers
0153  * @regmap_32bit:   pointer to the regmap instance for 32-bit registers
0154  * @dev:        pointer to the MFD device
0155  * @type:       type of codec
0156  * @rev:        silicon revision
0157  * @type_name:      display name of this codec
0158  * @num_core_supplies:  number of core supply regulators
0159  * @core_supplies:  list of core supplies that are always required
0160  * @dcvdd:      pointer to DCVDD regulator
0161  * @internal_dcvdd: true if DCVDD is supplied from the internal LDO1
0162  * @pdata:      our pdata
0163  * @irq_dev:        the irqchip child driver device
0164  * @irq_data:       pointer to irqchip data for the child irqchip driver
0165  * @irq:        host irq number from SPI or I2C configuration
0166  * @mclk:       Structure holding clock supplies
0167  * @out_clamp:      indicates output clamp state for each analogue output
0168  * @out_shorted:    indicates short circuit state for each analogue output
0169  * @hp_ena:     bitflags of enable state for the headphone outputs
0170  * @num_micbias:    number of MICBIAS outputs
0171  * @num_childbias:  number of child biases for each MICBIAS
0172  * @dapm:       pointer to codec driver DAPM context
0173  * @notifier:       notifier for signalling events to ASoC machine driver
0174  */
0175 struct madera {
0176     struct regmap *regmap;
0177     struct regmap *regmap_32bit;
0178 
0179     struct device *dev;
0180 
0181     enum madera_type type;
0182     unsigned int rev;
0183     const char *type_name;
0184 
0185     int num_core_supplies;
0186     struct regulator_bulk_data core_supplies[MADERA_MAX_CORE_SUPPLIES];
0187     struct regulator *dcvdd;
0188     bool internal_dcvdd;
0189     bool reset_errata;
0190 
0191     struct madera_pdata pdata;
0192 
0193     struct device *irq_dev;
0194     struct regmap_irq_chip_data *irq_data;
0195     int irq;
0196 
0197     struct clk_bulk_data mclk[MADERA_NUM_MCLK];
0198 
0199     unsigned int num_micbias;
0200     unsigned int num_childbias[MADERA_MAX_MICBIAS];
0201 
0202     struct snd_soc_dapm_context *dapm;
0203     struct mutex dapm_ptr_lock;
0204     unsigned int hp_ena;
0205     bool out_clamp[MADERA_MAX_HP_OUTPUT];
0206     bool out_shorted[MADERA_MAX_HP_OUTPUT];
0207 
0208     struct blocking_notifier_head notifier;
0209 };
0210 #endif