blob: 2d239e983a832d081101c25290b856e85f2ea5c7 [file] [log] [blame]
Timur Tabib0c813c2007-07-31 18:18:44 +02001/*
2 * CS4270 ALSA SoC (ASoC) codec driver
3 *
4 * Author: Timur Tabi <timur@freescale.com>
5 *
Timur Tabiff7bf022009-01-30 11:14:49 -06006 * Copyright 2007-2009 Freescale Semiconductor, Inc. This file is licensed
7 * under the terms of the GNU General Public License version 2. This
8 * program is licensed "as is" without any warranty of any kind, whether
9 * express or implied.
Timur Tabib0c813c2007-07-31 18:18:44 +020010 *
11 * This is an ASoC device driver for the Cirrus Logic CS4270 codec.
12 *
13 * Current features/limitations:
14 *
Daniel Mackb191f632009-03-08 17:51:52 +010015 * - Software mode is supported. Stand-alone mode is not supported.
16 * - Only I2C is supported, not SPI
17 * - Support for master and slave mode
18 * - The machine driver's 'startup' function must call
19 * cs4270_set_dai_sysclk() with the value of MCLK.
20 * - Only I2S and left-justified modes are supported
Daniel Mack5e7c0342009-05-06 01:26:01 +020021 * - Power management is supported
Timur Tabib0c813c2007-07-31 18:18:44 +020022 */
23
24#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090025#include <linux/slab.h>
Timur Tabib0c813c2007-07-31 18:18:44 +020026#include <sound/core.h>
27#include <sound/soc.h>
28#include <sound/initval.h>
29#include <linux/i2c.h>
Daniel Mack5e7c0342009-05-06 01:26:01 +020030#include <linux/delay.h>
Daniel Mackffbfd332009-11-30 17:56:11 +010031#include <linux/regulator/consumer.h>
Daniel Mackf98acd82018-12-06 13:24:26 +010032#include <linux/gpio/consumer.h>
Daniel Mack85d07e42012-07-25 15:28:34 +020033#include <linux/of_device.h>
Timur Tabib0c813c2007-07-31 18:18:44 +020034
Timur Tabib0c813c2007-07-31 18:18:44 +020035/*
36 * The codec isn't really big-endian or little-endian, since the I2S
37 * interface requires data to be sent serially with the MSbit first.
38 * However, to support BE and LE I2S devices, we specify both here. That
39 * way, ALSA will always match the bit patterns.
40 */
41#define CS4270_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
42 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \
43 SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE | \
44 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE | \
45 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \
46 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE)
47
Timur Tabib0c813c2007-07-31 18:18:44 +020048/* CS4270 registers addresses */
49#define CS4270_CHIPID 0x01 /* Chip ID */
50#define CS4270_PWRCTL 0x02 /* Power Control */
51#define CS4270_MODE 0x03 /* Mode Control */
52#define CS4270_FORMAT 0x04 /* Serial Format, ADC/DAC Control */
53#define CS4270_TRANS 0x05 /* Transition Control */
54#define CS4270_MUTE 0x06 /* Mute Control */
55#define CS4270_VOLA 0x07 /* DAC Channel A Volume Control */
56#define CS4270_VOLB 0x08 /* DAC Channel B Volume Control */
57
58#define CS4270_FIRSTREG 0x01
59#define CS4270_LASTREG 0x08
60#define CS4270_NUMREGS (CS4270_LASTREG - CS4270_FIRSTREG + 1)
Daniel Mack80ab8812009-05-05 11:25:00 +020061#define CS4270_I2C_INCR 0x80
Timur Tabib0c813c2007-07-31 18:18:44 +020062
63/* Bit masks for the CS4270 registers */
64#define CS4270_CHIPID_ID 0xF0
65#define CS4270_CHIPID_REV 0x0F
66#define CS4270_PWRCTL_FREEZE 0x80
67#define CS4270_PWRCTL_PDN_ADC 0x20
68#define CS4270_PWRCTL_PDN_DAC 0x02
69#define CS4270_PWRCTL_PDN 0x01
Daniel Mack5e7c0342009-05-06 01:26:01 +020070#define CS4270_PWRCTL_PDN_ALL \
71 (CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC | CS4270_PWRCTL_PDN)
Timur Tabib0c813c2007-07-31 18:18:44 +020072#define CS4270_MODE_SPEED_MASK 0x30
73#define CS4270_MODE_1X 0x00
74#define CS4270_MODE_2X 0x10
75#define CS4270_MODE_4X 0x20
76#define CS4270_MODE_SLAVE 0x30
77#define CS4270_MODE_DIV_MASK 0x0E
78#define CS4270_MODE_DIV1 0x00
79#define CS4270_MODE_DIV15 0x02
80#define CS4270_MODE_DIV2 0x04
81#define CS4270_MODE_DIV3 0x06
82#define CS4270_MODE_DIV4 0x08
83#define CS4270_MODE_POPGUARD 0x01
84#define CS4270_FORMAT_FREEZE_A 0x80
85#define CS4270_FORMAT_FREEZE_B 0x40
86#define CS4270_FORMAT_LOOPBACK 0x20
87#define CS4270_FORMAT_DAC_MASK 0x18
88#define CS4270_FORMAT_DAC_LJ 0x00
89#define CS4270_FORMAT_DAC_I2S 0x08
90#define CS4270_FORMAT_DAC_RJ16 0x18
91#define CS4270_FORMAT_DAC_RJ24 0x10
92#define CS4270_FORMAT_ADC_MASK 0x01
93#define CS4270_FORMAT_ADC_LJ 0x00
94#define CS4270_FORMAT_ADC_I2S 0x01
95#define CS4270_TRANS_ONE_VOL 0x80
96#define CS4270_TRANS_SOFT 0x40
97#define CS4270_TRANS_ZERO 0x20
98#define CS4270_TRANS_INV_ADC_A 0x08
99#define CS4270_TRANS_INV_ADC_B 0x10
100#define CS4270_TRANS_INV_DAC_A 0x02
101#define CS4270_TRANS_INV_DAC_B 0x04
102#define CS4270_TRANS_DEEMPH 0x01
103#define CS4270_MUTE_AUTO 0x20
104#define CS4270_MUTE_ADC_A 0x08
105#define CS4270_MUTE_ADC_B 0x10
106#define CS4270_MUTE_POLARITY 0x04
107#define CS4270_MUTE_DAC_A 0x01
108#define CS4270_MUTE_DAC_B 0x02
109
Timur Tabi11b8fca2011-01-10 13:28:32 -0600110/* Power-on default values for the registers
111 *
112 * This array contains the power-on default values of the registers, with the
113 * exception of the "CHIPID" register (01h). The lower four bits of that
114 * register contain the hardware revision, so it is treated as volatile.
Timur Tabi11b8fca2011-01-10 13:28:32 -0600115 */
Mark Brown1ca65172012-09-10 12:57:03 +0800116static const struct reg_default cs4270_reg_defaults[] = {
117 { 2, 0x00 },
118 { 3, 0x30 },
119 { 4, 0x00 },
120 { 5, 0x60 },
121 { 6, 0x20 },
122 { 7, 0x00 },
123 { 8, 0x00 },
Timur Tabi11b8fca2011-01-10 13:28:32 -0600124};
125
Daniel Mackffbfd332009-11-30 17:56:11 +0100126static const char *supply_names[] = {
127 "va", "vd", "vlc"
128};
129
Timur Tabi0db4d072009-01-23 16:31:19 -0600130/* Private data for the CS4270 */
131struct cs4270_private {
Mark Brown1ca65172012-09-10 12:57:03 +0800132 struct regmap *regmap;
Timur Tabi0db4d072009-01-23 16:31:19 -0600133 unsigned int mclk; /* Input frequency of the MCLK pin */
134 unsigned int mode; /* The mode (I2S or left-justified) */
Daniel Mack4eae0802009-02-25 14:37:21 +0100135 unsigned int slave_mode;
Daniel Mack1a4ba052009-04-24 16:37:45 +0200136 unsigned int manual_mute;
Daniel Mackffbfd332009-11-30 17:56:11 +0100137
138 /* power domain regulators */
139 struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
Mike Willardccfc5312020-04-01 20:54:54 +0000140
141 /* reset gpio */
142 struct gpio_desc *reset_gpio;
Timur Tabi0db4d072009-01-23 16:31:19 -0600143};
144
Mark Brown782fbab2013-08-11 12:29:07 +0100145static const struct snd_soc_dapm_widget cs4270_dapm_widgets[] = {
146SND_SOC_DAPM_INPUT("AINL"),
147SND_SOC_DAPM_INPUT("AINR"),
148
149SND_SOC_DAPM_OUTPUT("AOUTL"),
150SND_SOC_DAPM_OUTPUT("AOUTR"),
151};
152
153static const struct snd_soc_dapm_route cs4270_dapm_routes[] = {
murray fosteraa5f9202016-10-09 13:28:45 -0700154 { "Capture", NULL, "AINL" },
155 { "Capture", NULL, "AINR" },
Mark Brown782fbab2013-08-11 12:29:07 +0100156
murray fosteraa5f9202016-10-09 13:28:45 -0700157 { "AOUTL", NULL, "Playback" },
158 { "AOUTR", NULL, "Playback" },
Mark Brown782fbab2013-08-11 12:29:07 +0100159};
160
Timur Tabiff7bf022009-01-30 11:14:49 -0600161/**
162 * struct cs4270_mode_ratios - clock ratio tables
163 * @ratio: the ratio of MCLK to the sample rate
164 * @speed_mode: the Speed Mode bits to set in the Mode Control register for
165 * this ratio
166 * @mclk: the Ratio Select bits to set in the Mode Control register for this
167 * ratio
Timur Tabi84323952007-12-18 15:42:53 +0100168 *
169 * The data for this chart is taken from Table 5 of the CS4270 reference
170 * manual.
171 *
172 * This table is used to determine how to program the Mode Control register.
173 * It is also used by cs4270_set_dai_sysclk() to tell ALSA which sampling
174 * rates the CS4270 currently supports.
175 *
Timur Tabiff7bf022009-01-30 11:14:49 -0600176 * @speed_mode is the corresponding bit pattern to be written to the
Timur Tabi84323952007-12-18 15:42:53 +0100177 * MODE bits of the Mode Control Register
178 *
Timur Tabiff7bf022009-01-30 11:14:49 -0600179 * @mclk is the corresponding bit pattern to be wirten to the MCLK bits of
Timur Tabi84323952007-12-18 15:42:53 +0100180 * the Mode Control Register.
181 *
182 * In situations where a single ratio is represented by multiple speed
183 * modes, we favor the slowest speed. E.g, for a ratio of 128, we pick
184 * double-speed instead of quad-speed. However, the CS4270 errata states
Timur Tabiff7bf022009-01-30 11:14:49 -0600185 * that divide-By-1.5 can cause failures, so we avoid that mode where
Timur Tabi84323952007-12-18 15:42:53 +0100186 * possible.
187 *
Timur Tabiff7bf022009-01-30 11:14:49 -0600188 * Errata: There is an errata for the CS4270 where divide-by-1.5 does not
189 * work if Vd is 3.3V. If this effects you, select the
Timur Tabi84323952007-12-18 15:42:53 +0100190 * CONFIG_SND_SOC_CS4270_VD33_ERRATA Kconfig option, and the driver will
191 * never select any sample rates that require divide-by-1.5.
192 */
Timur Tabiff7bf022009-01-30 11:14:49 -0600193struct cs4270_mode_ratios {
Timur Tabi84323952007-12-18 15:42:53 +0100194 unsigned int ratio;
195 u8 speed_mode;
196 u8 mclk;
Timur Tabiff7bf022009-01-30 11:14:49 -0600197};
198
Timur Tabid9fb7fb2009-02-02 14:50:45 -0600199static struct cs4270_mode_ratios cs4270_mode_ratios[] = {
Timur Tabi84323952007-12-18 15:42:53 +0100200 {64, CS4270_MODE_4X, CS4270_MODE_DIV1},
201#ifndef CONFIG_SND_SOC_CS4270_VD33_ERRATA
202 {96, CS4270_MODE_4X, CS4270_MODE_DIV15},
203#endif
204 {128, CS4270_MODE_2X, CS4270_MODE_DIV1},
205 {192, CS4270_MODE_4X, CS4270_MODE_DIV3},
206 {256, CS4270_MODE_1X, CS4270_MODE_DIV1},
207 {384, CS4270_MODE_2X, CS4270_MODE_DIV3},
208 {512, CS4270_MODE_1X, CS4270_MODE_DIV2},
209 {768, CS4270_MODE_1X, CS4270_MODE_DIV3},
210 {1024, CS4270_MODE_1X, CS4270_MODE_DIV4}
211};
212
213/* The number of MCLK/LRCK ratios supported by the CS4270 */
214#define NUM_MCLK_RATIOS ARRAY_SIZE(cs4270_mode_ratios)
215
Mark Brown1ca65172012-09-10 12:57:03 +0800216static bool cs4270_reg_is_readable(struct device *dev, unsigned int reg)
Timur Tabi11b8fca2011-01-10 13:28:32 -0600217{
218 return (reg >= CS4270_FIRSTREG) && (reg <= CS4270_LASTREG);
219}
220
Mark Brown1ca65172012-09-10 12:57:03 +0800221static bool cs4270_reg_is_volatile(struct device *dev, unsigned int reg)
Timur Tabi11b8fca2011-01-10 13:28:32 -0600222{
223 /* Unreadable registers are considered volatile */
224 if ((reg < CS4270_FIRSTREG) || (reg > CS4270_LASTREG))
Gustavo A. R. Silvac34c4512018-08-04 16:52:01 -0500225 return true;
Timur Tabi11b8fca2011-01-10 13:28:32 -0600226
227 return reg == CS4270_CHIPID;
228}
229
Timur Tabiff7bf022009-01-30 11:14:49 -0600230/**
231 * cs4270_set_dai_sysclk - determine the CS4270 samples rates.
232 * @codec_dai: the codec DAI
233 * @clk_id: the clock ID (ignored)
234 * @freq: the MCLK input frequency
235 * @dir: the clock direction (ignored)
Timur Tabi84323952007-12-18 15:42:53 +0100236 *
Timur Tabiff7bf022009-01-30 11:14:49 -0600237 * This function is used to tell the codec driver what the input MCLK
238 * frequency is.
Timur Tabi84323952007-12-18 15:42:53 +0100239 *
240 * The value of MCLK is used to determine which sample rates are supported
241 * by the CS4270. The ratio of MCLK / Fs must be equal to one of nine
Timur Tabiff7bf022009-01-30 11:14:49 -0600242 * supported values - 64, 96, 128, 192, 256, 384, 512, 768, and 1024.
Timur Tabi84323952007-12-18 15:42:53 +0100243 *
244 * This function calculates the nine ratios and determines which ones match
245 * a standard sample rate. If there's a match, then it is added to the list
Timur Tabiff7bf022009-01-30 11:14:49 -0600246 * of supported sample rates.
Timur Tabi84323952007-12-18 15:42:53 +0100247 *
248 * This function must be called by the machine driver's 'startup' function,
249 * otherwise the list of supported sample rates will not be available in
250 * time for ALSA.
Daniel Mack6aababd2010-01-15 17:36:48 +0100251 *
252 * For setups with variable MCLKs, pass 0 as 'freq' argument. This will cause
253 * theoretically possible sample rates to be enabled. Call it again with a
254 * proper value set one the external clock is set (most probably you would do
255 * that from a machine's driver 'hw_param' hook.
Timur Tabi84323952007-12-18 15:42:53 +0100256 */
Liam Girdwoode550e172008-07-07 16:07:52 +0100257static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai,
Timur Tabi84323952007-12-18 15:42:53 +0100258 int clk_id, unsigned int freq, int dir)
259{
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000260 struct snd_soc_component *component = codec_dai->component;
261 struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component);
Timur Tabi84323952007-12-18 15:42:53 +0100262
263 cs4270->mclk = freq;
Timur Tabi84323952007-12-18 15:42:53 +0100264 return 0;
265}
266
Timur Tabiff7bf022009-01-30 11:14:49 -0600267/**
268 * cs4270_set_dai_fmt - configure the codec for the selected audio format
269 * @codec_dai: the codec DAI
270 * @format: a SND_SOC_DAIFMT_x value indicating the data format
Timur Tabi84323952007-12-18 15:42:53 +0100271 *
272 * This function takes a bitmask of SND_SOC_DAIFMT_x bits and programs the
273 * codec accordingly.
274 *
275 * Currently, this function only supports SND_SOC_DAIFMT_I2S and
276 * SND_SOC_DAIFMT_LEFT_J. The CS4270 codec also supports right-justified
277 * data for playback only, but ASoC currently does not support different
278 * formats for playback vs. record.
279 */
Liam Girdwoode550e172008-07-07 16:07:52 +0100280static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
Timur Tabi84323952007-12-18 15:42:53 +0100281 unsigned int format)
282{
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000283 struct snd_soc_component *component = codec_dai->component;
284 struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component);
Timur Tabi84323952007-12-18 15:42:53 +0100285
Daniel Mack4eae0802009-02-25 14:37:21 +0100286 /* set DAI format */
Timur Tabi84323952007-12-18 15:42:53 +0100287 switch (format & SND_SOC_DAIFMT_FORMAT_MASK) {
288 case SND_SOC_DAIFMT_I2S:
289 case SND_SOC_DAIFMT_LEFT_J:
290 cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
291 break;
292 default:
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000293 dev_err(component->dev, "invalid dai format\n");
Axel Linac601552011-10-06 07:29:56 +0800294 return -EINVAL;
Timur Tabi84323952007-12-18 15:42:53 +0100295 }
296
Daniel Mack4eae0802009-02-25 14:37:21 +0100297 /* set master/slave audio interface */
298 switch (format & SND_SOC_DAIFMT_MASTER_MASK) {
299 case SND_SOC_DAIFMT_CBS_CFS:
300 cs4270->slave_mode = 1;
301 break;
302 case SND_SOC_DAIFMT_CBM_CFM:
303 cs4270->slave_mode = 0;
304 break;
Daniel Mack4eae0802009-02-25 14:37:21 +0100305 default:
Daniel Mackff09d492009-02-28 13:21:03 +0100306 /* all other modes are unsupported by the hardware */
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000307 dev_err(component->dev, "Unknown master/slave configuration\n");
Axel Linac601552011-10-06 07:29:56 +0800308 return -EINVAL;
Daniel Mack4eae0802009-02-25 14:37:21 +0100309 }
310
Axel Linac601552011-10-06 07:29:56 +0800311 return 0;
Timur Tabi84323952007-12-18 15:42:53 +0100312}
313
Timur Tabiff7bf022009-01-30 11:14:49 -0600314/**
Timur Tabiff7bf022009-01-30 11:14:49 -0600315 * cs4270_hw_params - program the CS4270 with the given hardware parameters.
316 * @substream: the audio stream
317 * @params: the hardware parameters to set
318 * @dai: the SOC DAI (ignored)
Timur Tabib0c813c2007-07-31 18:18:44 +0200319 *
Timur Tabiff7bf022009-01-30 11:14:49 -0600320 * This function programs the hardware with the values provided.
321 * Specifically, the sample rate and the data format.
322 *
323 * The .ops functions are used to provide board-specific data, like input
324 * frequencies, to this driver. This function takes that information,
Timur Tabib0c813c2007-07-31 18:18:44 +0200325 * combines it with the hardware parameters provided, and programs the
326 * hardware accordingly.
327 */
328static int cs4270_hw_params(struct snd_pcm_substream *substream,
Mark Browndee89c42008-11-18 22:11:38 +0000329 struct snd_pcm_hw_params *params,
330 struct snd_soc_dai *dai)
Timur Tabib0c813c2007-07-31 18:18:44 +0200331{
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000332 struct snd_soc_component *component = dai->component;
333 struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component);
Roel Kluine34ba212008-04-17 18:58:34 +0200334 int ret;
Timur Tabib0c813c2007-07-31 18:18:44 +0200335 unsigned int i;
336 unsigned int rate;
337 unsigned int ratio;
338 int reg;
339
340 /* Figure out which MCLK/LRCK ratio to use */
341
342 rate = params_rate(params); /* Sampling rate, in Hz */
343 ratio = cs4270->mclk / rate; /* MCLK/LRCK ratio */
344
Timur Tabi9dbd6272007-08-01 12:22:07 +0200345 for (i = 0; i < NUM_MCLK_RATIOS; i++) {
Timur Tabi84323952007-12-18 15:42:53 +0100346 if (cs4270_mode_ratios[i].ratio == ratio)
Timur Tabib0c813c2007-07-31 18:18:44 +0200347 break;
348 }
349
Timur Tabi9dbd6272007-08-01 12:22:07 +0200350 if (i == NUM_MCLK_RATIOS) {
Timur Tabib0c813c2007-07-31 18:18:44 +0200351 /* We did not find a matching ratio */
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000352 dev_err(component->dev, "could not find matching ratio\n");
Timur Tabib0c813c2007-07-31 18:18:44 +0200353 return -EINVAL;
354 }
355
Timur Tabid5e9ba12009-02-03 11:09:32 -0600356 /* Set the sample rate */
Timur Tabib0c813c2007-07-31 18:18:44 +0200357
Kuninori Morimotoa11f8a12020-06-16 14:21:46 +0900358 reg = snd_soc_component_read(component, CS4270_MODE);
Timur Tabib0c813c2007-07-31 18:18:44 +0200359 reg &= ~(CS4270_MODE_SPEED_MASK | CS4270_MODE_DIV_MASK);
Daniel Mack4eae0802009-02-25 14:37:21 +0100360 reg |= cs4270_mode_ratios[i].mclk;
361
362 if (cs4270->slave_mode)
363 reg |= CS4270_MODE_SLAVE;
364 else
365 reg |= cs4270_mode_ratios[i].speed_mode;
Timur Tabib0c813c2007-07-31 18:18:44 +0200366
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000367 ret = snd_soc_component_write(component, CS4270_MODE, reg);
Timur Tabib0c813c2007-07-31 18:18:44 +0200368 if (ret < 0) {
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000369 dev_err(component->dev, "i2c write failed\n");
Timur Tabib0c813c2007-07-31 18:18:44 +0200370 return ret;
371 }
372
Timur Tabid5e9ba12009-02-03 11:09:32 -0600373 /* Set the DAI format */
Timur Tabib0c813c2007-07-31 18:18:44 +0200374
Kuninori Morimotoa11f8a12020-06-16 14:21:46 +0900375 reg = snd_soc_component_read(component, CS4270_FORMAT);
Timur Tabib0c813c2007-07-31 18:18:44 +0200376 reg &= ~(CS4270_FORMAT_DAC_MASK | CS4270_FORMAT_ADC_MASK);
377
378 switch (cs4270->mode) {
379 case SND_SOC_DAIFMT_I2S:
380 reg |= CS4270_FORMAT_DAC_I2S | CS4270_FORMAT_ADC_I2S;
381 break;
382 case SND_SOC_DAIFMT_LEFT_J:
383 reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ;
384 break;
385 default:
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000386 dev_err(component->dev, "unknown dai format\n");
Timur Tabib0c813c2007-07-31 18:18:44 +0200387 return -EINVAL;
388 }
389
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000390 ret = snd_soc_component_write(component, CS4270_FORMAT, reg);
Timur Tabib0c813c2007-07-31 18:18:44 +0200391 if (ret < 0) {
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000392 dev_err(component->dev, "i2c write failed\n");
Timur Tabib0c813c2007-07-31 18:18:44 +0200393 return ret;
394 }
395
Timur Tabib0c813c2007-07-31 18:18:44 +0200396 return ret;
397}
398
Timur Tabiff7bf022009-01-30 11:14:49 -0600399/**
Daniel Mack1a4ba052009-04-24 16:37:45 +0200400 * cs4270_dai_mute - enable/disable the CS4270 external mute
Timur Tabiff7bf022009-01-30 11:14:49 -0600401 * @dai: the SOC DAI
402 * @mute: 0 = disable mute, 1 = enable mute
Pierre-Louis Bossart80cd7302021-03-02 14:59:18 -0600403 * @direction: (ignored)
Timur Tabib0c813c2007-07-31 18:18:44 +0200404 *
405 * This function toggles the mute bits in the MUTE register. The CS4270's
406 * mute capability is intended for external muting circuitry, so if the
407 * board does not have the MUTEA or MUTEB pins connected to such circuitry,
408 * then this function will do nothing.
409 */
Kuninori Morimoto03c0f1b5e2020-07-09 10:57:06 +0900410static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute, int direction)
Timur Tabib0c813c2007-07-31 18:18:44 +0200411{
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000412 struct snd_soc_component *component = dai->component;
413 struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component);
Timur Tabib0c813c2007-07-31 18:18:44 +0200414 int reg6;
415
Kuninori Morimotoa11f8a12020-06-16 14:21:46 +0900416 reg6 = snd_soc_component_read(component, CS4270_MUTE);
Timur Tabib0c813c2007-07-31 18:18:44 +0200417
418 if (mute)
Timur Tabid5e9ba12009-02-03 11:09:32 -0600419 reg6 |= CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B;
Daniel Mack1a4ba052009-04-24 16:37:45 +0200420 else {
Timur Tabid5e9ba12009-02-03 11:09:32 -0600421 reg6 &= ~(CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B);
Daniel Mack1a4ba052009-04-24 16:37:45 +0200422 reg6 |= cs4270->manual_mute;
423 }
Timur Tabib0c813c2007-07-31 18:18:44 +0200424
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000425 return snd_soc_component_write(component, CS4270_MUTE, reg6);
Timur Tabib0c813c2007-07-31 18:18:44 +0200426}
Timur Tabib0c813c2007-07-31 18:18:44 +0200427
Daniel Mack1a4ba052009-04-24 16:37:45 +0200428/**
429 * cs4270_soc_put_mute - put callback for the 'Master Playback switch'
430 * alsa control.
431 * @kcontrol: mixer control
432 * @ucontrol: control element information
433 *
434 * This function basically passes the arguments on to the generic
435 * snd_soc_put_volsw() function and saves the mute information in
436 * our private data structure. This is because we want to prevent
437 * cs4270_dai_mute() neglecting the user's decision to manually
438 * mute the codec's output.
439 *
440 * Returns 0 for success.
441 */
442static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol,
443 struct snd_ctl_elem_value *ucontrol)
444{
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000445 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
446 struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component);
Daniel Mack1a4ba052009-04-24 16:37:45 +0200447 int left = !ucontrol->value.integer.value[0];
448 int right = !ucontrol->value.integer.value[1];
449
450 cs4270->manual_mute = (left ? CS4270_MUTE_DAC_A : 0) |
451 (right ? CS4270_MUTE_DAC_B : 0);
452
453 return snd_soc_put_volsw(kcontrol, ucontrol);
454}
455
Timur Tabib0c813c2007-07-31 18:18:44 +0200456/* A list of non-DAPM controls that the CS4270 supports */
457static const struct snd_kcontrol_new cs4270_snd_controls[] = {
458 SOC_DOUBLE_R("Master Playback Volume",
Timur Tabid5e9ba12009-02-03 11:09:32 -0600459 CS4270_VOLA, CS4270_VOLB, 0, 0xFF, 1),
460 SOC_SINGLE("Digital Sidetone Switch", CS4270_FORMAT, 5, 1, 0),
461 SOC_SINGLE("Soft Ramp Switch", CS4270_TRANS, 6, 1, 0),
462 SOC_SINGLE("Zero Cross Switch", CS4270_TRANS, 5, 1, 0),
Daniel Mack7e1aa1d2009-10-29 02:24:32 +0100463 SOC_SINGLE("De-emphasis filter", CS4270_TRANS, 0, 1, 0),
Timur Tabid5e9ba12009-02-03 11:09:32 -0600464 SOC_SINGLE("Popguard Switch", CS4270_MODE, 0, 1, 1),
465 SOC_SINGLE("Auto-Mute Switch", CS4270_MUTE, 5, 1, 0),
Daniel Mack1a4ba052009-04-24 16:37:45 +0200466 SOC_DOUBLE("Master Capture Switch", CS4270_MUTE, 3, 4, 1, 1),
467 SOC_DOUBLE_EXT("Master Playback Switch", CS4270_MUTE, 0, 1, 1, 1,
468 snd_soc_get_volsw, cs4270_soc_put_mute),
Timur Tabib0c813c2007-07-31 18:18:44 +0200469};
470
Lars-Peter Clausen85e76522011-11-23 11:40:40 +0100471static const struct snd_soc_dai_ops cs4270_dai_ops = {
Eric Miao6335d052009-03-03 09:41:00 +0800472 .hw_params = cs4270_hw_params,
473 .set_sysclk = cs4270_set_dai_sysclk,
474 .set_fmt = cs4270_set_dai_fmt,
Kuninori Morimoto03c0f1b5e2020-07-09 10:57:06 +0900475 .mute_stream = cs4270_dai_mute,
476 .no_capture_mute = 1,
Eric Miao6335d052009-03-03 09:41:00 +0800477};
478
Mark Brown5c758482010-10-06 16:18:17 -0700479static struct snd_soc_dai_driver cs4270_dai = {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000480 .name = "cs4270-hifi",
Timur Tabib0c813c2007-07-31 18:18:44 +0200481 .playback = {
482 .stream_name = "Playback",
Fabio Estevamf76fe0592012-09-18 13:03:54 -0300483 .channels_min = 2,
Timur Tabib0c813c2007-07-31 18:18:44 +0200484 .channels_max = 2,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000485 .rates = SNDRV_PCM_RATE_CONTINUOUS,
486 .rate_min = 4000,
487 .rate_max = 216000,
Timur Tabib0c813c2007-07-31 18:18:44 +0200488 .formats = CS4270_FORMATS,
489 },
490 .capture = {
491 .stream_name = "Capture",
Fabio Estevamf76fe0592012-09-18 13:03:54 -0300492 .channels_min = 2,
Timur Tabib0c813c2007-07-31 18:18:44 +0200493 .channels_max = 2,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000494 .rates = SNDRV_PCM_RATE_CONTINUOUS,
495 .rate_min = 4000,
496 .rate_max = 216000,
Timur Tabib0c813c2007-07-31 18:18:44 +0200497 .formats = CS4270_FORMATS,
498 },
Eric Miao6335d052009-03-03 09:41:00 +0800499 .ops = &cs4270_dai_ops,
Timur Tabib0c813c2007-07-31 18:18:44 +0200500};
Timur Tabib0c813c2007-07-31 18:18:44 +0200501
Timur Tabiff7bf022009-01-30 11:14:49 -0600502/**
503 * cs4270_probe - ASoC probe function
Pierre-Louis Bossart7fdc1512020-07-01 13:13:14 -0500504 * @component: ASoC component
Timur Tabiff7bf022009-01-30 11:14:49 -0600505 *
506 * This function is called when ASoC has all the pieces it needs to
507 * instantiate a sound driver.
Timur Tabi04eb0932009-01-29 14:28:37 -0600508 */
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000509static int cs4270_probe(struct snd_soc_component *component)
Timur Tabi04eb0932009-01-29 14:28:37 -0600510{
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000511 struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component);
Mark Brownb61d6d42012-09-10 12:53:12 +0800512 int ret;
Timur Tabi04eb0932009-01-29 14:28:37 -0600513
Timur Tabid5e9ba12009-02-03 11:09:32 -0600514 /* Disable auto-mute. This feature appears to be buggy. In some
515 * situations, auto-mute will not deactivate when it should, so we want
516 * this feature disabled by default. An application (e.g. alsactl) can
517 * re-enabled it by using the controls.
518 */
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000519 ret = snd_soc_component_update_bits(component, CS4270_MUTE, CS4270_MUTE_AUTO, 0);
Timur Tabid5e9ba12009-02-03 11:09:32 -0600520 if (ret < 0) {
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000521 dev_err(component->dev, "i2c write failed\n");
Timur Tabid5e9ba12009-02-03 11:09:32 -0600522 return ret;
523 }
524
525 /* Disable automatic volume control. The hardware enables, and it
526 * causes volume change commands to be delayed, sometimes until after
527 * playback has started. An application (e.g. alsactl) can
528 * re-enabled it by using the controls.
529 */
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000530 ret = snd_soc_component_update_bits(component, CS4270_TRANS,
Timur Tabi11b8fca2011-01-10 13:28:32 -0600531 CS4270_TRANS_SOFT | CS4270_TRANS_ZERO, 0);
Timur Tabid5e9ba12009-02-03 11:09:32 -0600532 if (ret < 0) {
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000533 dev_err(component->dev, "i2c write failed\n");
Timur Tabid5e9ba12009-02-03 11:09:32 -0600534 return ret;
535 }
536
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000537 ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies),
538 cs4270->supplies);
Jean Delvaree3145df2008-09-30 11:40:37 +0200539
Timur Tabib0c813c2007-07-31 18:18:44 +0200540 return ret;
541}
542
Timur Tabiff7bf022009-01-30 11:14:49 -0600543/**
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000544 * cs4270_remove - ASoC remove function
Pierre-Louis Bossart7fdc1512020-07-01 13:13:14 -0500545 * @component: ASoC component
Timur Tabiff7bf022009-01-30 11:14:49 -0600546 *
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000547 * This function is the counterpart to cs4270_probe().
Timur Tabiff7bf022009-01-30 11:14:49 -0600548 */
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000549static void cs4270_remove(struct snd_soc_component *component)
Timur Tabib0c813c2007-07-31 18:18:44 +0200550{
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000551 struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component);
Timur Tabib0c813c2007-07-31 18:18:44 +0200552
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000553 regulator_bulk_disable(ARRAY_SIZE(cs4270->supplies), cs4270->supplies);
Timur Tabi0db4d072009-01-23 16:31:19 -0600554};
Timur Tabi0db4d072009-01-23 16:31:19 -0600555
Daniel Mack5e7c0342009-05-06 01:26:01 +0200556#ifdef CONFIG_PM
557
558/* This suspend/resume implementation can handle both - a simple standby
559 * where the codec remains powered, and a full suspend, where the voltage
560 * domain the codec is connected to is teared down and/or any other hardware
561 * reset condition is asserted.
562 *
563 * The codec's own power saving features are enabled in the suspend callback,
564 * and all registers are written back to the hardware when resuming.
565 */
566
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000567static int cs4270_soc_suspend(struct snd_soc_component *component)
Daniel Mack15b5bda2009-08-05 20:50:43 +0200568{
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000569 struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component);
Daniel Mackffbfd332009-11-30 17:56:11 +0100570 int reg, ret;
Daniel Mack15b5bda2009-08-05 20:50:43 +0200571
Kuninori Morimotoa11f8a12020-06-16 14:21:46 +0900572 reg = snd_soc_component_read(component, CS4270_PWRCTL) | CS4270_PWRCTL_PDN_ALL;
Daniel Mackffbfd332009-11-30 17:56:11 +0100573 if (reg < 0)
574 return reg;
575
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000576 ret = snd_soc_component_write(component, CS4270_PWRCTL, reg);
Daniel Mackffbfd332009-11-30 17:56:11 +0100577 if (ret < 0)
578 return ret;
579
580 regulator_bulk_disable(ARRAY_SIZE(cs4270->supplies),
581 cs4270->supplies);
582
583 return 0;
Daniel Mack15b5bda2009-08-05 20:50:43 +0200584}
585
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000586static int cs4270_soc_resume(struct snd_soc_component *component)
Daniel Mack15b5bda2009-08-05 20:50:43 +0200587{
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000588 struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component);
Mark Brownab92d092012-03-19 16:15:43 +0000589 int reg, ret;
Daniel Mack5e7c0342009-05-06 01:26:01 +0200590
Mark Brownab92d092012-03-19 16:15:43 +0000591 ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies),
592 cs4270->supplies);
593 if (ret != 0)
594 return ret;
Daniel Mackffbfd332009-11-30 17:56:11 +0100595
Daniel Mack5e7c0342009-05-06 01:26:01 +0200596 /* In case the device was put to hard reset during sleep, we need to
597 * wait 500ns here before any I2C communication. */
598 ndelay(500);
599
600 /* first restore the entire register cache ... */
Mark Brown1ca65172012-09-10 12:57:03 +0800601 regcache_sync(cs4270->regmap);
Daniel Mack5e7c0342009-05-06 01:26:01 +0200602
603 /* ... then disable the power-down bits */
Kuninori Morimotoa11f8a12020-06-16 14:21:46 +0900604 reg = snd_soc_component_read(component, CS4270_PWRCTL);
Daniel Mack5e7c0342009-05-06 01:26:01 +0200605 reg &= ~CS4270_PWRCTL_PDN_ALL;
606
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000607 return snd_soc_component_write(component, CS4270_PWRCTL, reg);
Daniel Mack5e7c0342009-05-06 01:26:01 +0200608}
609#else
Daniel Mack15b5bda2009-08-05 20:50:43 +0200610#define cs4270_soc_suspend NULL
611#define cs4270_soc_resume NULL
Daniel Mack5e7c0342009-05-06 01:26:01 +0200612#endif /* CONFIG_PM */
613
Timur Tabiff7bf022009-01-30 11:14:49 -0600614/*
Daniel Mackb6f7d7c2011-05-25 09:53:12 +0200615 * ASoC codec driver structure
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000616 */
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000617static const struct snd_soc_component_driver soc_component_device_cs4270 = {
618 .probe = cs4270_probe,
619 .remove = cs4270_remove,
620 .suspend = cs4270_soc_suspend,
621 .resume = cs4270_soc_resume,
622 .controls = cs4270_snd_controls,
623 .num_controls = ARRAY_SIZE(cs4270_snd_controls),
624 .dapm_widgets = cs4270_dapm_widgets,
625 .num_dapm_widgets = ARRAY_SIZE(cs4270_dapm_widgets),
626 .dapm_routes = cs4270_dapm_routes,
627 .num_dapm_routes = ARRAY_SIZE(cs4270_dapm_routes),
628 .idle_bias_on = 1,
629 .use_pmdown_time = 1,
630 .endianness = 1,
631 .non_legacy_dai_naming = 1,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000632};
633
Daniel Mack85d07e42012-07-25 15:28:34 +0200634/*
635 * cs4270_of_match - the device tree bindings
636 */
637static const struct of_device_id cs4270_of_match[] = {
638 { .compatible = "cirrus,cs4270", },
639 { }
640};
641MODULE_DEVICE_TABLE(of, cs4270_of_match);
642
Mark Brown1ca65172012-09-10 12:57:03 +0800643static const struct regmap_config cs4270_regmap = {
644 .reg_bits = 8,
645 .val_bits = 8,
646 .max_register = CS4270_LASTREG,
647 .reg_defaults = cs4270_reg_defaults,
648 .num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults),
649 .cache_type = REGCACHE_RBTREE,
Daniel Mackf0f23382019-03-20 22:41:56 +0100650 .write_flag_mask = CS4270_I2C_INCR,
Mark Brown1ca65172012-09-10 12:57:03 +0800651
652 .readable_reg = cs4270_reg_is_readable,
653 .volatile_reg = cs4270_reg_is_volatile,
654};
655
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000656/**
Mike Willardccfc5312020-04-01 20:54:54 +0000657 * cs4270_i2c_remove - deinitialize the I2C interface of the CS4270
658 * @i2c_client: the I2C client object
659 *
660 * This function puts the chip into low power mode when the i2c device
661 * is removed.
662 */
663static int cs4270_i2c_remove(struct i2c_client *i2c_client)
664{
665 struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client);
666
667 gpiod_set_value_cansleep(cs4270->reset_gpio, 0);
668
669 return 0;
670}
671
672/**
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000673 * cs4270_i2c_probe - initialize the I2C interface of the CS4270
674 * @i2c_client: the I2C client object
675 * @id: the I2C device ID (ignored)
676 *
677 * This function is called whenever the I2C subsystem finds a device that
678 * matches the device ID given via a prior call to i2c_add_driver().
679 */
680static int cs4270_i2c_probe(struct i2c_client *i2c_client,
681 const struct i2c_device_id *id)
682{
683 struct cs4270_private *cs4270;
Mark Brown1ca65172012-09-10 12:57:03 +0800684 unsigned int val;
Mark Brownb61d6d42012-09-10 12:53:12 +0800685 int ret, i;
686
687 cs4270 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4270_private),
688 GFP_KERNEL);
Sachin Kamat0e0327f2014-06-20 15:28:57 +0530689 if (!cs4270)
Mark Brownb61d6d42012-09-10 12:53:12 +0800690 return -ENOMEM;
Mark Brownb61d6d42012-09-10 12:53:12 +0800691
692 /* get the power supply regulators */
693 for (i = 0; i < ARRAY_SIZE(supply_names); i++)
694 cs4270->supplies[i].supply = supply_names[i];
695
696 ret = devm_regulator_bulk_get(&i2c_client->dev,
697 ARRAY_SIZE(cs4270->supplies),
698 cs4270->supplies);
699 if (ret < 0)
700 return ret;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000701
Mike Willardccfc5312020-04-01 20:54:54 +0000702 /* reset the device */
703 cs4270->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, "reset",
704 GPIOD_OUT_LOW);
705 if (IS_ERR(cs4270->reset_gpio)) {
706 dev_dbg(&i2c_client->dev, "Error getting CS4270 reset GPIO\n");
707 return PTR_ERR(cs4270->reset_gpio);
708 }
709
710 if (cs4270->reset_gpio) {
711 dev_dbg(&i2c_client->dev, "Found reset GPIO\n");
712 gpiod_set_value_cansleep(cs4270->reset_gpio, 1);
713 }
714
715 /* Sleep 500ns before i2c communications */
716 ndelay(500);
Daniel Mack02286192012-07-25 15:28:35 +0200717
Mark Brown1ca65172012-09-10 12:57:03 +0800718 cs4270->regmap = devm_regmap_init_i2c(i2c_client, &cs4270_regmap);
719 if (IS_ERR(cs4270->regmap))
720 return PTR_ERR(cs4270->regmap);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000721
Mark Brown1ca65172012-09-10 12:57:03 +0800722 /* Verify that we have a CS4270 */
723 ret = regmap_read(cs4270->regmap, CS4270_CHIPID, &val);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000724 if (ret < 0) {
725 dev_err(&i2c_client->dev, "failed to read i2c at addr %X\n",
726 i2c_client->addr);
727 return ret;
728 }
729 /* The top four bits of the chip ID should be 1100. */
Mark Brown1ca65172012-09-10 12:57:03 +0800730 if ((val & 0xF0) != 0xC0) {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000731 dev_err(&i2c_client->dev, "device at addr %X is not a CS4270\n",
732 i2c_client->addr);
733 return -ENODEV;
734 }
735
736 dev_info(&i2c_client->dev, "found device at i2c address %X\n",
737 i2c_client->addr);
Mark Brown1ca65172012-09-10 12:57:03 +0800738 dev_info(&i2c_client->dev, "hardware revision %X\n", val & 0xF);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000739
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000740 i2c_set_clientdata(i2c_client, cs4270);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000741
Kuninori Morimoto70c9a802018-01-29 03:51:09 +0000742 ret = devm_snd_soc_register_component(&i2c_client->dev,
743 &soc_component_device_cs4270, &cs4270_dai, 1);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000744 return ret;
745}
746
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000747/*
748 * cs4270_id - I2C device IDs supported by this driver
749 */
Axel Lin79a54ea2011-03-04 15:22:03 +0800750static const struct i2c_device_id cs4270_id[] = {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000751 {"cs4270", 0},
752 {}
753};
754MODULE_DEVICE_TABLE(i2c, cs4270_id);
755
756/*
Timur Tabiff7bf022009-01-30 11:14:49 -0600757 * cs4270_i2c_driver - I2C device identification
758 *
759 * This structure tells the I2C subsystem how to identify and support a
760 * given I2C device type.
761 */
Timur Tabi0db4d072009-01-23 16:31:19 -0600762static struct i2c_driver cs4270_i2c_driver = {
763 .driver = {
Shawn Guo64902b22012-02-24 22:09:38 +0800764 .name = "cs4270",
Daniel Mack85d07e42012-07-25 15:28:34 +0200765 .of_match_table = cs4270_of_match,
Timur Tabi0db4d072009-01-23 16:31:19 -0600766 },
767 .id_table = cs4270_id,
768 .probe = cs4270_i2c_probe,
Mike Willardccfc5312020-04-01 20:54:54 +0000769 .remove = cs4270_i2c_remove,
Timur Tabi0db4d072009-01-23 16:31:19 -0600770};
771
Sachin Kamat5e383f52012-08-06 17:25:41 +0530772module_i2c_driver(cs4270_i2c_driver);
Mark Brown64089b82008-12-08 19:17:58 +0000773
Timur Tabib0c813c2007-07-31 18:18:44 +0200774MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
775MODULE_DESCRIPTION("Cirrus Logic CS4270 ALSA SoC Codec Driver");
776MODULE_LICENSE("GPL");