diff options
| author | Richard Fitzgerald <rf@opensource.cirrus.com> | 2018-05-21 05:59:56 -0400 |
|---|---|---|
| committer | Lee Jones <lee.jones@linaro.org> | 2018-06-05 06:14:56 -0400 |
| commit | 16b27467f46c1e0dbf093f53971aeb5decbaff4e (patch) | |
| tree | 585644f02c55a33c2c24645f10d8c057c5726369 /include/linux/mfd | |
| parent | 2b49088cdba7dd59693887532e4058ee33b42d87 (diff) | |
mfd: madera: Add common support for Cirrus Logic Madera codecs
This adds the generic core support for Cirrus Logic "Madera" class codecs.
These are complex audio codec SoCs with a variety of digital and analogue
I/O, onboard audio processing and DSPs, and other features.
These codecs are all based off a common set of hardware IP so can be
supported by a core of common code (with a few minor device-to-device
variations).
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Nikesh Oswal <Nikesh.Oswal@cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'include/linux/mfd')
| -rw-r--r-- | include/linux/mfd/madera/core.h | 187 | ||||
| -rw-r--r-- | include/linux/mfd/madera/pdata.h | 59 |
2 files changed, 246 insertions, 0 deletions
diff --git a/include/linux/mfd/madera/core.h b/include/linux/mfd/madera/core.h new file mode 100644 index 000000000000..c332681848ef --- /dev/null +++ b/include/linux/mfd/madera/core.h | |||
| @@ -0,0 +1,187 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* | ||
| 3 | * MFD internals for Cirrus Logic Madera codecs | ||
| 4 | * | ||
| 5 | * Copyright (C) 2015-2018 Cirrus Logic | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by the | ||
| 9 | * Free Software Foundation; version 2. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef MADERA_CORE_H | ||
| 13 | #define MADERA_CORE_H | ||
| 14 | |||
| 15 | #include <linux/gpio/consumer.h> | ||
| 16 | #include <linux/interrupt.h> | ||
| 17 | #include <linux/mfd/madera/pdata.h> | ||
| 18 | #include <linux/notifier.h> | ||
| 19 | #include <linux/regmap.h> | ||
| 20 | #include <linux/regulator/consumer.h> | ||
| 21 | |||
| 22 | enum madera_type { | ||
| 23 | /* 0 is reserved for indicating failure to identify */ | ||
| 24 | CS47L35 = 1, | ||
| 25 | CS47L85 = 2, | ||
| 26 | CS47L90 = 3, | ||
| 27 | CS47L91 = 4, | ||
| 28 | WM1840 = 7, | ||
| 29 | }; | ||
| 30 | |||
| 31 | #define MADERA_MAX_CORE_SUPPLIES 2 | ||
| 32 | #define MADERA_MAX_GPIOS 40 | ||
| 33 | |||
| 34 | #define CS47L35_NUM_GPIOS 16 | ||
| 35 | #define CS47L85_NUM_GPIOS 40 | ||
| 36 | #define CS47L90_NUM_GPIOS 38 | ||
| 37 | |||
| 38 | #define MADERA_MAX_MICBIAS 4 | ||
| 39 | |||
| 40 | /* Notifier events */ | ||
| 41 | #define MADERA_NOTIFY_VOICE_TRIGGER 0x1 | ||
| 42 | #define MADERA_NOTIFY_HPDET 0x2 | ||
| 43 | #define MADERA_NOTIFY_MICDET 0x4 | ||
| 44 | |||
| 45 | /* GPIO Function Definitions */ | ||
| 46 | #define MADERA_GP_FN_ALTERNATE 0x00 | ||
| 47 | #define MADERA_GP_FN_GPIO 0x01 | ||
| 48 | #define MADERA_GP_FN_DSP_GPIO 0x02 | ||
| 49 | #define MADERA_GP_FN_IRQ1 0x03 | ||
| 50 | #define MADERA_GP_FN_IRQ2 0x04 | ||
| 51 | #define MADERA_GP_FN_FLL1_CLOCK 0x10 | ||
| 52 | #define MADERA_GP_FN_FLL2_CLOCK 0x11 | ||
| 53 | #define MADERA_GP_FN_FLL3_CLOCK 0x12 | ||
| 54 | #define MADERA_GP_FN_FLLAO_CLOCK 0x13 | ||
| 55 | #define MADERA_GP_FN_FLL1_LOCK 0x18 | ||
| 56 | #define MADERA_GP_FN_FLL2_LOCK 0x19 | ||
| 57 | #define MADERA_GP_FN_FLL3_LOCK 0x1A | ||
| 58 | #define MADERA_GP_FN_FLLAO_LOCK 0x1B | ||
| 59 | #define MADERA_GP_FN_OPCLK_OUT 0x40 | ||
| 60 | #define MADERA_GP_FN_OPCLK_ASYNC_OUT 0x41 | ||
| 61 | #define MADERA_GP_FN_PWM1 0x48 | ||
| 62 | #define MADERA_GP_FN_PWM2 0x49 | ||
| 63 | #define MADERA_GP_FN_SPDIF_OUT 0x4C | ||
| 64 | #define MADERA_GP_FN_HEADPHONE_DET 0x50 | ||
| 65 | #define MADERA_GP_FN_MIC_DET 0x58 | ||
| 66 | #define MADERA_GP_FN_DRC1_SIGNAL_DETECT 0x80 | ||
| 67 | #define MADERA_GP_FN_DRC2_SIGNAL_DETECT 0x81 | ||
| 68 | #define MADERA_GP_FN_ASRC1_IN1_LOCK 0x88 | ||
| 69 | #define MADERA_GP_FN_ASRC1_IN2_LOCK 0x89 | ||
| 70 | #define MADERA_GP_FN_ASRC2_IN1_LOCK 0x8A | ||
| 71 | #define MADERA_GP_FN_ASRC2_IN2_LOCK 0x8B | ||
| 72 | #define MADERA_GP_FN_DSP_IRQ1 0xA0 | ||
| 73 | #define MADERA_GP_FN_DSP_IRQ2 0xA1 | ||
| 74 | #define MADERA_GP_FN_DSP_IRQ3 0xA2 | ||
| 75 | #define MADERA_GP_FN_DSP_IRQ4 0xA3 | ||
| 76 | #define MADERA_GP_FN_DSP_IRQ5 0xA4 | ||
| 77 | #define MADERA_GP_FN_DSP_IRQ6 0xA5 | ||
| 78 | #define MADERA_GP_FN_DSP_IRQ7 0xA6 | ||
| 79 | #define MADERA_GP_FN_DSP_IRQ8 0xA7 | ||
| 80 | #define MADERA_GP_FN_DSP_IRQ9 0xA8 | ||
| 81 | #define MADERA_GP_FN_DSP_IRQ10 0xA9 | ||
| 82 | #define MADERA_GP_FN_DSP_IRQ11 0xAA | ||
| 83 | #define MADERA_GP_FN_DSP_IRQ12 0xAB | ||
| 84 | #define MADERA_GP_FN_DSP_IRQ13 0xAC | ||
| 85 | #define MADERA_GP_FN_DSP_IRQ14 0xAD | ||
| 86 | #define MADERA_GP_FN_DSP_IRQ15 0xAE | ||
| 87 | #define MADERA_GP_FN_DSP_IRQ16 0xAF | ||
| 88 | #define MADERA_GP_FN_HPOUT1L_SC 0xB0 | ||
| 89 | #define MADERA_GP_FN_HPOUT1R_SC 0xB1 | ||
| 90 | #define MADERA_GP_FN_HPOUT2L_SC 0xB2 | ||
| 91 | #define MADERA_GP_FN_HPOUT2R_SC 0xB3 | ||
| 92 | #define MADERA_GP_FN_HPOUT3L_SC 0xB4 | ||
| 93 | #define MADERA_GP_FN_HPOUT4R_SC 0xB5 | ||
| 94 | #define MADERA_GP_FN_SPKOUTL_SC 0xB6 | ||
| 95 | #define MADERA_GP_FN_SPKOUTR_SC 0xB7 | ||
| 96 | #define MADERA_GP_FN_HPOUT1L_ENA 0xC0 | ||
| 97 | #define MADERA_GP_FN_HPOUT1R_ENA 0xC1 | ||
| 98 | #define MADERA_GP_FN_HPOUT2L_ENA 0xC2 | ||
| 99 | #define MADERA_GP_FN_HPOUT2R_ENA 0xC3 | ||
| 100 | #define MADERA_GP_FN_HPOUT3L_ENA 0xC4 | ||
| 101 | #define MADERA_GP_FN_HPOUT4R_ENA 0xC5 | ||
| 102 | #define MADERA_GP_FN_SPKOUTL_ENA 0xC6 | ||
| 103 | #define MADERA_GP_FN_SPKOUTR_ENA 0xC7 | ||
| 104 | #define MADERA_GP_FN_HPOUT1L_DIS 0xD0 | ||
| 105 | #define MADERA_GP_FN_HPOUT1R_DIS 0xD1 | ||
| 106 | #define MADERA_GP_FN_HPOUT2L_DIS 0xD2 | ||
| 107 | #define MADERA_GP_FN_HPOUT2R_DIS 0xD3 | ||
| 108 | #define MADERA_GP_FN_HPOUT3L_DIS 0xD4 | ||
| 109 | #define MADERA_GP_FN_HPOUT4R_DIS 0xD5 | ||
| 110 | #define MADERA_GP_FN_SPKOUTL_DIS 0xD6 | ||
| 111 | #define MADERA_GP_FN_SPKOUTR_DIS 0xD7 | ||
| 112 | #define MADERA_GP_FN_SPK_SHUTDOWN 0xE0 | ||
| 113 | #define MADERA_GP_FN_SPK_OVH_SHUTDOWN 0xE1 | ||
| 114 | #define MADERA_GP_FN_SPK_OVH_WARN 0xE2 | ||
| 115 | #define MADERA_GP_FN_TIMER1_STATUS 0x140 | ||
| 116 | #define MADERA_GP_FN_TIMER2_STATUS 0x141 | ||
| 117 | #define MADERA_GP_FN_TIMER3_STATUS 0x142 | ||
| 118 | #define MADERA_GP_FN_TIMER4_STATUS 0x143 | ||
| 119 | #define MADERA_GP_FN_TIMER5_STATUS 0x144 | ||
| 120 | #define MADERA_GP_FN_TIMER6_STATUS 0x145 | ||
| 121 | #define MADERA_GP_FN_TIMER7_STATUS 0x146 | ||
| 122 | #define MADERA_GP_FN_TIMER8_STATUS 0x147 | ||
| 123 | #define MADERA_GP_FN_EVENTLOG1_FIFO_STS 0x150 | ||
| 124 | #define MADERA_GP_FN_EVENTLOG2_FIFO_STS 0x151 | ||
| 125 | #define MADERA_GP_FN_EVENTLOG3_FIFO_STS 0x152 | ||
| 126 | #define MADERA_GP_FN_EVENTLOG4_FIFO_STS 0x153 | ||
| 127 | #define MADERA_GP_FN_EVENTLOG5_FIFO_STS 0x154 | ||
| 128 | #define MADERA_GP_FN_EVENTLOG6_FIFO_STS 0x155 | ||
| 129 | #define MADERA_GP_FN_EVENTLOG7_FIFO_STS 0x156 | ||
| 130 | #define MADERA_GP_FN_EVENTLOG8_FIFO_STS 0x157 | ||
| 131 | |||
| 132 | struct snd_soc_dapm_context; | ||
| 133 | |||
| 134 | /* | ||
| 135 | * struct madera - internal data shared by the set of Madera drivers | ||
| 136 | * | ||
| 137 | * This should not be used by anything except child drivers of the Madera MFD | ||
| 138 | * | ||
| 139 | * @regmap: pointer to the regmap instance for 16-bit registers | ||
| 140 | * @regmap_32bit: pointer to the regmap instance for 32-bit registers | ||
| 141 | * @dev: pointer to the MFD device | ||
| 142 | * @type: type of codec | ||
| 143 | * @rev: silicon revision | ||
| 144 | * @type_name: display name of this codec | ||
| 145 | * @num_core_supplies: number of core supply regulators | ||
| 146 | * @core_supplies: list of core supplies that are always required | ||
| 147 | * @dcvdd: pointer to DCVDD regulator | ||
| 148 | * @internal_dcvdd: true if DCVDD is supplied from the internal LDO1 | ||
| 149 | * @pdata: our pdata | ||
| 150 | * @irq_dev: the irqchip child driver device | ||
| 151 | * @irq: host irq number from SPI or I2C configuration | ||
| 152 | * @out_clamp: indicates output clamp state for each analogue output | ||
| 153 | * @out_shorted: indicates short circuit state for each analogue output | ||
| 154 | * @hp_ena: bitflags of enable state for the headphone outputs | ||
| 155 | * @num_micbias: number of MICBIAS outputs | ||
| 156 | * @num_childbias: number of child biases for each MICBIAS | ||
| 157 | * @dapm: pointer to codec driver DAPM context | ||
| 158 | * @notifier: notifier for signalling events to ASoC machine driver | ||
| 159 | */ | ||
| 160 | struct madera { | ||
| 161 | struct regmap *regmap; | ||
| 162 | struct regmap *regmap_32bit; | ||
| 163 | |||
| 164 | struct device *dev; | ||
| 165 | |||
| 166 | enum madera_type type; | ||
| 167 | unsigned int rev; | ||
| 168 | const char *type_name; | ||
| 169 | |||
| 170 | int num_core_supplies; | ||
| 171 | struct regulator_bulk_data core_supplies[MADERA_MAX_CORE_SUPPLIES]; | ||
| 172 | struct regulator *dcvdd; | ||
| 173 | bool internal_dcvdd; | ||
| 174 | |||
| 175 | struct madera_pdata pdata; | ||
| 176 | |||
| 177 | struct device *irq_dev; | ||
| 178 | int irq; | ||
| 179 | |||
| 180 | unsigned int num_micbias; | ||
| 181 | unsigned int num_childbias[MADERA_MAX_MICBIAS]; | ||
| 182 | |||
| 183 | struct snd_soc_dapm_context *dapm; | ||
| 184 | |||
| 185 | struct blocking_notifier_head notifier; | ||
| 186 | }; | ||
| 187 | #endif | ||
diff --git a/include/linux/mfd/madera/pdata.h b/include/linux/mfd/madera/pdata.h new file mode 100644 index 000000000000..0b311f39c8f4 --- /dev/null +++ b/include/linux/mfd/madera/pdata.h | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* | ||
| 3 | * Platform data for Cirrus Logic Madera codecs | ||
| 4 | * | ||
| 5 | * Copyright (C) 2015-2018 Cirrus Logic | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by the | ||
| 9 | * Free Software Foundation; version 2. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef MADERA_PDATA_H | ||
| 13 | #define MADERA_PDATA_H | ||
| 14 | |||
| 15 | #include <linux/kernel.h> | ||
| 16 | #include <linux/regulator/arizona-ldo1.h> | ||
| 17 | #include <linux/regulator/arizona-micsupp.h> | ||
| 18 | #include <linux/regulator/machine.h> | ||
| 19 | |||
| 20 | #define MADERA_MAX_MICBIAS 4 | ||
| 21 | #define MADERA_MAX_CHILD_MICBIAS 4 | ||
| 22 | |||
| 23 | #define MADERA_MAX_GPSW 2 | ||
| 24 | |||
| 25 | struct gpio_desc; | ||
| 26 | struct pinctrl_map; | ||
| 27 | struct madera_irqchip_pdata; | ||
| 28 | struct madera_codec_pdata; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * struct madera_pdata - Configuration data for Madera devices | ||
| 32 | * | ||
| 33 | * @reset: GPIO controlling /RESET (NULL = none) | ||
| 34 | * @ldo1: Substruct of pdata for the LDO1 regulator | ||
| 35 | * @micvdd: Substruct of pdata for the MICVDD regulator | ||
| 36 | * @irq_flags: Mode for primary IRQ (defaults to active low) | ||
| 37 | * @gpio_base: Base GPIO number | ||
| 38 | * @gpio_configs: Array of GPIO configurations (See Documentation/pinctrl.txt) | ||
| 39 | * @n_gpio_configs: Number of entries in gpio_configs | ||
| 40 | * @gpsw: General purpose switch mode setting. Depends on the external | ||
| 41 | * hardware connected to the switch. (See the SW1_MODE field | ||
| 42 | * in the datasheet for the available values for your codec) | ||
| 43 | */ | ||
| 44 | struct madera_pdata { | ||
| 45 | struct gpio_desc *reset; | ||
| 46 | |||
| 47 | struct arizona_ldo1_pdata ldo1; | ||
| 48 | struct arizona_micsupp_pdata micvdd; | ||
| 49 | |||
| 50 | unsigned int irq_flags; | ||
| 51 | int gpio_base; | ||
| 52 | |||
| 53 | const struct pinctrl_map *gpio_configs; | ||
| 54 | int n_gpio_configs; | ||
| 55 | |||
| 56 | u32 gpsw[MADERA_MAX_GPSW]; | ||
| 57 | }; | ||
| 58 | |||
| 59 | #endif | ||
