xref: /openbmc/linux/sound/soc/codecs/cs4349.c (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2e40da86aSTim Howe /*
3e40da86aSTim Howe  * cs4349.c  --  CS4349 ALSA Soc Audio driver
4e40da86aSTim Howe  *
5e40da86aSTim Howe  * Copyright 2015 Cirrus Logic, Inc.
6e40da86aSTim Howe  *
7e40da86aSTim Howe  * Authors: Tim Howe <Tim.Howe@cirrus.com>
8e40da86aSTim Howe  */
9e40da86aSTim Howe 
10e40da86aSTim Howe #include <linux/module.h>
11e40da86aSTim Howe #include <linux/moduleparam.h>
12e40da86aSTim Howe #include <linux/kernel.h>
13e40da86aSTim Howe #include <linux/init.h>
14e40da86aSTim Howe #include <linux/delay.h>
15e40da86aSTim Howe #include <linux/gpio.h>
16091571d0Sakpm@linux-foundation.org #include <linux/gpio/consumer.h>
17e40da86aSTim Howe #include <linux/platform_device.h>
18e40da86aSTim Howe #include <linux/pm.h>
19e40da86aSTim Howe #include <linux/i2c.h>
20e40da86aSTim Howe #include <linux/of_device.h>
21e40da86aSTim Howe #include <linux/regmap.h>
22e40da86aSTim Howe #include <linux/slab.h>
23e40da86aSTim Howe #include <sound/core.h>
24e40da86aSTim Howe #include <sound/pcm.h>
25e40da86aSTim Howe #include <sound/pcm_params.h>
26e40da86aSTim Howe #include <sound/soc.h>
27e40da86aSTim Howe #include <sound/soc-dapm.h>
28e40da86aSTim Howe #include <sound/initval.h>
29e40da86aSTim Howe #include <sound/tlv.h>
30e40da86aSTim Howe #include "cs4349.h"
31e40da86aSTim Howe 
32e40da86aSTim Howe 
33e40da86aSTim Howe static const struct reg_default cs4349_reg_defaults[] = {
34e40da86aSTim Howe 	{ 2, 0x00 },	/* r02	- Mode Control */
35e40da86aSTim Howe 	{ 3, 0x09 },	/* r03	- Volume, Mixing and Inversion Control */
36e40da86aSTim Howe 	{ 4, 0x81 },	/* r04	- Mute Control */
37e40da86aSTim Howe 	{ 5, 0x00 },	/* r05	- Channel A Volume Control */
38e40da86aSTim Howe 	{ 6, 0x00 },	/* r06	- Channel B Volume Control */
39e40da86aSTim Howe 	{ 7, 0xB1 },	/* r07	- Ramp and Filter Control */
40e40da86aSTim Howe 	{ 8, 0x1C },	/* r08	- Misc. Control */
41e40da86aSTim Howe };
42e40da86aSTim Howe 
43e40da86aSTim Howe /* Private data for the CS4349 */
44e40da86aSTim Howe struct  cs4349_private {
45e40da86aSTim Howe 	struct regmap			*regmap;
46e40da86aSTim Howe 	struct gpio_desc		*reset_gpio;
47e40da86aSTim Howe 	unsigned int			mode;
48e40da86aSTim Howe 	int				rate;
49e40da86aSTim Howe };
50e40da86aSTim Howe 
cs4349_readable_register(struct device * dev,unsigned int reg)51e40da86aSTim Howe static bool cs4349_readable_register(struct device *dev, unsigned int reg)
52e40da86aSTim Howe {
53e40da86aSTim Howe 	switch (reg) {
540443de7eSAxel Lin 	case CS4349_CHIPID ... CS4349_MISC:
550443de7eSAxel Lin 		return true;
560443de7eSAxel Lin 	default:
570443de7eSAxel Lin 		return false;
580443de7eSAxel Lin 	}
590443de7eSAxel Lin }
600443de7eSAxel Lin 
cs4349_writeable_register(struct device * dev,unsigned int reg)610443de7eSAxel Lin static bool cs4349_writeable_register(struct device *dev, unsigned int reg)
620443de7eSAxel Lin {
630443de7eSAxel Lin 	switch (reg) {
640443de7eSAxel Lin 	case CS4349_MODE ...  CS4349_MISC:
65e40da86aSTim Howe 		return true;
66e40da86aSTim Howe 	default:
67e40da86aSTim Howe 		return false;
68e40da86aSTim Howe 	}
69e40da86aSTim Howe }
70e40da86aSTim Howe 
cs4349_set_dai_fmt(struct snd_soc_dai * codec_dai,unsigned int format)71e40da86aSTim Howe static int cs4349_set_dai_fmt(struct snd_soc_dai *codec_dai,
72e40da86aSTim Howe 			      unsigned int format)
73e40da86aSTim Howe {
740ec65b67SKuninori Morimoto 	struct snd_soc_component *component = codec_dai->component;
750ec65b67SKuninori Morimoto 	struct cs4349_private *cs4349 = snd_soc_component_get_drvdata(component);
76e40da86aSTim Howe 	unsigned int fmt;
77e40da86aSTim Howe 
78e40da86aSTim Howe 	fmt = format & SND_SOC_DAIFMT_FORMAT_MASK;
79e40da86aSTim Howe 
80e40da86aSTim Howe 	switch (fmt) {
81e40da86aSTim Howe 	case SND_SOC_DAIFMT_I2S:
82e40da86aSTim Howe 	case SND_SOC_DAIFMT_LEFT_J:
83e40da86aSTim Howe 	case SND_SOC_DAIFMT_RIGHT_J:
84e40da86aSTim Howe 		cs4349->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
85e40da86aSTim Howe 		break;
86e40da86aSTim Howe 	default:
87e40da86aSTim Howe 		return -EINVAL;
88e40da86aSTim Howe 	}
89e40da86aSTim Howe 
90e40da86aSTim Howe 	return 0;
91e40da86aSTim Howe }
92e40da86aSTim Howe 
cs4349_pcm_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params,struct snd_soc_dai * dai)93e40da86aSTim Howe static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream,
94e40da86aSTim Howe 			    struct snd_pcm_hw_params *params,
95e40da86aSTim Howe 			    struct snd_soc_dai *dai)
96e40da86aSTim Howe {
970ec65b67SKuninori Morimoto 	struct snd_soc_component *component = dai->component;
980ec65b67SKuninori Morimoto 	struct cs4349_private *cs4349 = snd_soc_component_get_drvdata(component);
99da304ac3SAxel Lin 	int fmt, ret;
100e40da86aSTim Howe 
101e40da86aSTim Howe 	cs4349->rate = params_rate(params);
102e40da86aSTim Howe 
103e40da86aSTim Howe 	switch (cs4349->mode) {
104e40da86aSTim Howe 	case SND_SOC_DAIFMT_I2S:
105da304ac3SAxel Lin 		fmt = DIF_I2S;
106e40da86aSTim Howe 		break;
107e40da86aSTim Howe 	case SND_SOC_DAIFMT_LEFT_J:
108da304ac3SAxel Lin 		fmt = DIF_LEFT_JST;
109e40da86aSTim Howe 		break;
110e40da86aSTim Howe 	case SND_SOC_DAIFMT_RIGHT_J:
111e40da86aSTim Howe 		switch (params_width(params)) {
112e40da86aSTim Howe 		case 16:
113e40da86aSTim Howe 			fmt = DIF_RGHT_JST16;
114e40da86aSTim Howe 			break;
115e40da86aSTim Howe 		case 24:
116e40da86aSTim Howe 			fmt = DIF_RGHT_JST24;
117e40da86aSTim Howe 			break;
118e40da86aSTim Howe 		default:
119e40da86aSTim Howe 			return -EINVAL;
120e40da86aSTim Howe 		}
121e40da86aSTim Howe 		break;
122e40da86aSTim Howe 	default:
123e40da86aSTim Howe 		return -EINVAL;
124e40da86aSTim Howe 	}
125e40da86aSTim Howe 
1260ec65b67SKuninori Morimoto 	ret = snd_soc_component_update_bits(component, CS4349_MODE, DIF_MASK,
127da304ac3SAxel Lin 				  MODE_FORMAT(fmt));
128e40da86aSTim Howe 	if (ret < 0)
129e40da86aSTim Howe 		return ret;
130e40da86aSTim Howe 
131e40da86aSTim Howe 	return 0;
132e40da86aSTim Howe }
133e40da86aSTim Howe 
cs4349_mute(struct snd_soc_dai * dai,int mute,int direction)13403c0f1b5SKuninori Morimoto static int cs4349_mute(struct snd_soc_dai *dai, int mute, int direction)
135e40da86aSTim Howe {
1360ec65b67SKuninori Morimoto 	struct snd_soc_component *component = dai->component;
137e40da86aSTim Howe 	int reg;
138e40da86aSTim Howe 
139e40da86aSTim Howe 	reg = 0;
140e40da86aSTim Howe 	if (mute)
141e40da86aSTim Howe 		reg = MUTE_AB_MASK;
142e40da86aSTim Howe 
1430ec65b67SKuninori Morimoto 	return snd_soc_component_update_bits(component, CS4349_MUTE, MUTE_AB_MASK, reg);
144e40da86aSTim Howe }
145e40da86aSTim Howe 
146e40da86aSTim Howe static DECLARE_TLV_DB_SCALE(dig_tlv, -12750, 50, 0);
147e40da86aSTim Howe 
148e40da86aSTim Howe static const char * const chan_mix_texts[] = {
149e40da86aSTim Howe 	"Mute", "MuteA", "MuteA SwapB", "MuteA MonoB", "SwapA MuteB",
150e40da86aSTim Howe 	"BothR", "Swap", "SwapA MonoB", "MuteB", "Normal", "BothL",
151e40da86aSTim Howe 	"MonoB", "MonoA MuteB", "MonoA", "MonoA SwapB", "Mono",
152e40da86aSTim Howe 	/*Normal == Channel A = Left, Channel B = Right*/
153e40da86aSTim Howe };
154e40da86aSTim Howe 
155e40da86aSTim Howe static const char * const fm_texts[] = {
156e40da86aSTim Howe 	"Auto", "Single", "Double", "Quad",
157e40da86aSTim Howe };
158e40da86aSTim Howe 
159e40da86aSTim Howe static const char * const deemph_texts[] = {
160e40da86aSTim Howe 	"None", "44.1k", "48k", "32k",
161e40da86aSTim Howe };
162e40da86aSTim Howe 
163e40da86aSTim Howe static const char * const softr_zeroc_texts[] = {
164e40da86aSTim Howe 	"Immediate", "Zero Cross", "Soft Ramp", "SR on ZC",
165e40da86aSTim Howe };
166e40da86aSTim Howe 
167e40da86aSTim Howe static int deemph_values[] = {
168e40da86aSTim Howe 	0, 4, 8, 12,
169e40da86aSTim Howe };
170e40da86aSTim Howe 
171e40da86aSTim Howe static int softr_zeroc_values[] = {
172e40da86aSTim Howe 	0, 64, 128, 192,
173e40da86aSTim Howe };
174e40da86aSTim Howe 
175e40da86aSTim Howe static const struct soc_enum chan_mix_enum =
176e40da86aSTim Howe 	SOC_ENUM_SINGLE(CS4349_VMI, 0,
177e40da86aSTim Howe 			ARRAY_SIZE(chan_mix_texts),
178e40da86aSTim Howe 			chan_mix_texts);
179e40da86aSTim Howe 
180e40da86aSTim Howe static const struct soc_enum fm_mode_enum =
181e40da86aSTim Howe 	SOC_ENUM_SINGLE(CS4349_MODE, 0,
182e40da86aSTim Howe 			ARRAY_SIZE(fm_texts),
183e40da86aSTim Howe 			fm_texts);
184e40da86aSTim Howe 
185e40da86aSTim Howe static SOC_VALUE_ENUM_SINGLE_DECL(deemph_enum, CS4349_MODE, 0, DEM_MASK,
186e40da86aSTim Howe 				deemph_texts, deemph_values);
187e40da86aSTim Howe 
188e40da86aSTim Howe static SOC_VALUE_ENUM_SINGLE_DECL(softr_zeroc_enum, CS4349_RMPFLT, 0,
189e40da86aSTim Howe 				SR_ZC_MASK, softr_zeroc_texts,
190e40da86aSTim Howe 				softr_zeroc_values);
191e40da86aSTim Howe 
192e40da86aSTim Howe static const struct snd_kcontrol_new cs4349_snd_controls[] = {
193e40da86aSTim Howe 	SOC_DOUBLE_R_TLV("Master Playback Volume",
194e40da86aSTim Howe 			 CS4349_VOLA, CS4349_VOLB, 0, 0xFF, 1, dig_tlv),
195e40da86aSTim Howe 	SOC_ENUM("Functional Mode", fm_mode_enum),
196e40da86aSTim Howe 	SOC_ENUM("De-Emphasis Control", deemph_enum),
197e40da86aSTim Howe 	SOC_ENUM("Soft Ramp Zero Cross Control", softr_zeroc_enum),
198e40da86aSTim Howe 	SOC_ENUM("Channel Mixer", chan_mix_enum),
199e40da86aSTim Howe 	SOC_SINGLE("VolA = VolB Switch", CS4349_VMI, 7, 1, 0),
200e40da86aSTim Howe 	SOC_SINGLE("InvertA Switch", CS4349_VMI, 6, 1, 0),
201e40da86aSTim Howe 	SOC_SINGLE("InvertB Switch", CS4349_VMI, 5, 1, 0),
202e40da86aSTim Howe 	SOC_SINGLE("Auto-Mute Switch", CS4349_MUTE, 7, 1, 0),
203e40da86aSTim Howe 	SOC_SINGLE("MUTEC A = B Switch", CS4349_MUTE, 5, 1, 0),
204e40da86aSTim Howe 	SOC_SINGLE("Soft Ramp Up Switch", CS4349_RMPFLT, 5, 1, 0),
205e40da86aSTim Howe 	SOC_SINGLE("Soft Ramp Down Switch", CS4349_RMPFLT, 4, 1, 0),
206e40da86aSTim Howe 	SOC_SINGLE("Slow Roll Off Filter Switch", CS4349_RMPFLT, 2, 1, 0),
207e40da86aSTim Howe 	SOC_SINGLE("Freeze Switch", CS4349_MISC, 5, 1, 0),
208e40da86aSTim Howe 	SOC_SINGLE("Popguard Switch", CS4349_MISC, 4, 1, 0),
209e40da86aSTim Howe };
210e40da86aSTim Howe 
211e40da86aSTim Howe static const struct snd_soc_dapm_widget cs4349_dapm_widgets[] = {
212e40da86aSTim Howe 	SND_SOC_DAPM_DAC("HiFi DAC", NULL, SND_SOC_NOPM, 0, 0),
213e40da86aSTim Howe 
214e40da86aSTim Howe 	SND_SOC_DAPM_OUTPUT("OutputA"),
215e40da86aSTim Howe 	SND_SOC_DAPM_OUTPUT("OutputB"),
216e40da86aSTim Howe };
217e40da86aSTim Howe 
218e40da86aSTim Howe static const struct snd_soc_dapm_route cs4349_routes[] = {
219e40da86aSTim Howe 	{"DAC Playback", NULL, "OutputA"},
220e40da86aSTim Howe 	{"DAC Playback", NULL, "OutputB"},
221e40da86aSTim Howe 
222e40da86aSTim Howe 	{"OutputA", NULL, "HiFi DAC"},
223e40da86aSTim Howe 	{"OutputB", NULL, "HiFi DAC"},
224e40da86aSTim Howe };
225e40da86aSTim Howe 
2268a85e2fcSCharles Keepax #define CS4349_PCM_FORMATS (SNDRV_PCM_FMTBIT_S8  | SNDRV_PCM_FMTBIT_S16_LE  | \
2278a85e2fcSCharles Keepax 			SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S20_3LE | \
2288a85e2fcSCharles Keepax 			SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE  | \
229e40da86aSTim Howe 			SNDRV_PCM_FMTBIT_S32_LE)
230e40da86aSTim Howe 
231e40da86aSTim Howe #define CS4349_PCM_RATES SNDRV_PCM_RATE_8000_192000
232e40da86aSTim Howe 
233e40da86aSTim Howe static const struct snd_soc_dai_ops cs4349_dai_ops = {
234e40da86aSTim Howe 	.hw_params	= cs4349_pcm_hw_params,
235e40da86aSTim Howe 	.set_fmt	= cs4349_set_dai_fmt,
23603c0f1b5SKuninori Morimoto 	.mute_stream	= cs4349_mute,
23703c0f1b5SKuninori Morimoto 	.no_capture_mute = 1,
238e40da86aSTim Howe };
239e40da86aSTim Howe 
240e40da86aSTim Howe static struct snd_soc_dai_driver cs4349_dai = {
241e40da86aSTim Howe 	.name = "cs4349_hifi",
242e40da86aSTim Howe 	.playback = {
243e40da86aSTim Howe 		.stream_name	= "DAC Playback",
244e40da86aSTim Howe 		.channels_min	= 1,
245e40da86aSTim Howe 		.channels_max	= 2,
246e40da86aSTim Howe 		.rates		= CS4349_PCM_RATES,
247e40da86aSTim Howe 		.formats	= CS4349_PCM_FORMATS,
248e40da86aSTim Howe 	},
249e40da86aSTim Howe 	.ops = &cs4349_dai_ops,
250260b668cSKuninori Morimoto 	.symmetric_rate = 1,
251e40da86aSTim Howe };
252e40da86aSTim Howe 
2530ec65b67SKuninori Morimoto static const struct snd_soc_component_driver soc_component_dev_cs4349 = {
254e40da86aSTim Howe 	.controls		= cs4349_snd_controls,
255e40da86aSTim Howe 	.num_controls		= ARRAY_SIZE(cs4349_snd_controls),
256e40da86aSTim Howe 	.dapm_widgets		= cs4349_dapm_widgets,
257e40da86aSTim Howe 	.num_dapm_widgets	= ARRAY_SIZE(cs4349_dapm_widgets),
258e40da86aSTim Howe 	.dapm_routes		= cs4349_routes,
259e40da86aSTim Howe 	.num_dapm_routes	= ARRAY_SIZE(cs4349_routes),
2600ec65b67SKuninori Morimoto 	.idle_bias_on		= 1,
2610ec65b67SKuninori Morimoto 	.use_pmdown_time	= 1,
2620ec65b67SKuninori Morimoto 	.endianness		= 1,
263e40da86aSTim Howe };
264e40da86aSTim Howe 
265b08b3382SAxel Lin static const struct regmap_config cs4349_regmap = {
266e40da86aSTim Howe 	.reg_bits		= 8,
267e40da86aSTim Howe 	.val_bits		= 8,
268e40da86aSTim Howe 
269dd9283e2SAxel Lin 	.max_register		= CS4349_MISC,
270e40da86aSTim Howe 	.reg_defaults		= cs4349_reg_defaults,
271e40da86aSTim Howe 	.num_reg_defaults	= ARRAY_SIZE(cs4349_reg_defaults),
272e40da86aSTim Howe 	.readable_reg		= cs4349_readable_register,
2730443de7eSAxel Lin 	.writeable_reg		= cs4349_writeable_register,
274*a4ccfe88SMark Brown 	.cache_type		= REGCACHE_MAPLE,
275e40da86aSTim Howe };
276e40da86aSTim Howe 
cs4349_i2c_probe(struct i2c_client * client)2774a404345SStephen Kitt static int cs4349_i2c_probe(struct i2c_client *client)
278e40da86aSTim Howe {
279e40da86aSTim Howe 	struct cs4349_private *cs4349;
28044251551SAxel Lin 	int ret;
281e40da86aSTim Howe 
282e40da86aSTim Howe 	cs4349 = devm_kzalloc(&client->dev, sizeof(*cs4349), GFP_KERNEL);
283e40da86aSTim Howe 	if (!cs4349)
284e40da86aSTim Howe 		return -ENOMEM;
285e40da86aSTim Howe 
286e40da86aSTim Howe 	cs4349->regmap = devm_regmap_init_i2c(client, &cs4349_regmap);
287e40da86aSTim Howe 	if (IS_ERR(cs4349->regmap)) {
288e40da86aSTim Howe 		ret = PTR_ERR(cs4349->regmap);
289e40da86aSTim Howe 		dev_err(&client->dev, "regmap_init() failed: %d\n", ret);
290e40da86aSTim Howe 		return ret;
291e40da86aSTim Howe 	}
292e40da86aSTim Howe 
293e40da86aSTim Howe 	/* Reset the Device */
294e40da86aSTim Howe 	cs4349->reset_gpio = devm_gpiod_get_optional(&client->dev,
295e40da86aSTim Howe 		"reset", GPIOD_OUT_LOW);
296e40da86aSTim Howe 	if (IS_ERR(cs4349->reset_gpio))
297e40da86aSTim Howe 		return PTR_ERR(cs4349->reset_gpio);
298e40da86aSTim Howe 
299e40da86aSTim Howe 	gpiod_set_value_cansleep(cs4349->reset_gpio, 1);
300e40da86aSTim Howe 
301e40da86aSTim Howe 	i2c_set_clientdata(client, cs4349);
302e40da86aSTim Howe 
3030ec65b67SKuninori Morimoto 	return devm_snd_soc_register_component(&client->dev,
3040ec65b67SKuninori Morimoto 		&soc_component_dev_cs4349,
305e40da86aSTim Howe 		&cs4349_dai, 1);
306e40da86aSTim Howe }
307e40da86aSTim Howe 
cs4349_i2c_remove(struct i2c_client * client)308ed5c2f5fSUwe Kleine-König static void cs4349_i2c_remove(struct i2c_client *client)
309e40da86aSTim Howe {
310e40da86aSTim Howe 	struct cs4349_private *cs4349 = i2c_get_clientdata(client);
311e40da86aSTim Howe 
312e40da86aSTim Howe 	/* Hold down reset */
313e40da86aSTim Howe 	gpiod_set_value_cansleep(cs4349->reset_gpio, 0);
314e40da86aSTim Howe }
315e40da86aSTim Howe 
316e40da86aSTim Howe #ifdef CONFIG_PM
cs4349_runtime_suspend(struct device * dev)317e40da86aSTim Howe static int cs4349_runtime_suspend(struct device *dev)
318e40da86aSTim Howe {
319e40da86aSTim Howe 	struct cs4349_private *cs4349 = dev_get_drvdata(dev);
320e40da86aSTim Howe 	int ret;
321e40da86aSTim Howe 
322ec12693eSAxel Lin 	ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, PWR_DWN);
323e40da86aSTim Howe 	if (ret < 0)
324e40da86aSTim Howe 		return ret;
325e40da86aSTim Howe 
326e40da86aSTim Howe 	regcache_cache_only(cs4349->regmap, true);
327e40da86aSTim Howe 
328e40da86aSTim Howe 	/* Hold down reset */
329e40da86aSTim Howe 	gpiod_set_value_cansleep(cs4349->reset_gpio, 0);
330e40da86aSTim Howe 
331e40da86aSTim Howe 	return 0;
332e40da86aSTim Howe }
333e40da86aSTim Howe 
cs4349_runtime_resume(struct device * dev)334e40da86aSTim Howe static int cs4349_runtime_resume(struct device *dev)
335e40da86aSTim Howe {
336e40da86aSTim Howe 	struct cs4349_private *cs4349 = dev_get_drvdata(dev);
337e40da86aSTim Howe 	int ret;
338e40da86aSTim Howe 
339cb2510daSLars-Peter Clausen 	ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, 0);
340e40da86aSTim Howe 	if (ret < 0)
341e40da86aSTim Howe 		return ret;
342e40da86aSTim Howe 
343e40da86aSTim Howe 	gpiod_set_value_cansleep(cs4349->reset_gpio, 1);
344e40da86aSTim Howe 
345e40da86aSTim Howe 	regcache_cache_only(cs4349->regmap, false);
346e40da86aSTim Howe 	regcache_sync(cs4349->regmap);
347e40da86aSTim Howe 
348e40da86aSTim Howe 	return 0;
349e40da86aSTim Howe }
350e40da86aSTim Howe #endif
351e40da86aSTim Howe 
352e40da86aSTim Howe static const struct dev_pm_ops cs4349_runtime_pm = {
353e40da86aSTim Howe 	SET_RUNTIME_PM_OPS(cs4349_runtime_suspend, cs4349_runtime_resume,
354e40da86aSTim Howe 			   NULL)
355e40da86aSTim Howe };
356e40da86aSTim Howe 
357e40da86aSTim Howe static const struct of_device_id cs4349_of_match[] = {
358e40da86aSTim Howe 	{ .compatible = "cirrus,cs4349", },
359e40da86aSTim Howe 	{},
360e40da86aSTim Howe };
361e40da86aSTim Howe 
362e40da86aSTim Howe MODULE_DEVICE_TABLE(of, cs4349_of_match);
363e40da86aSTim Howe 
364e40da86aSTim Howe static const struct i2c_device_id cs4349_i2c_id[] = {
365e40da86aSTim Howe 	{"cs4349", 0},
366e40da86aSTim Howe 	{}
367e40da86aSTim Howe };
368e40da86aSTim Howe 
369e40da86aSTim Howe MODULE_DEVICE_TABLE(i2c, cs4349_i2c_id);
370e40da86aSTim Howe 
371e40da86aSTim Howe static struct i2c_driver cs4349_i2c_driver = {
372e40da86aSTim Howe 	.driver = {
373e40da86aSTim Howe 		.name		= "cs4349",
374e40da86aSTim Howe 		.of_match_table	= cs4349_of_match,
3759b4275c4SYueHaibing 		.pm = &cs4349_runtime_pm,
376e40da86aSTim Howe 	},
377e40da86aSTim Howe 	.id_table	= cs4349_i2c_id,
3789abcd240SUwe Kleine-König 	.probe		= cs4349_i2c_probe,
379e40da86aSTim Howe 	.remove		= cs4349_i2c_remove,
380e40da86aSTim Howe };
381e40da86aSTim Howe 
382e40da86aSTim Howe module_i2c_driver(cs4349_i2c_driver);
383e40da86aSTim Howe 
384e40da86aSTim Howe MODULE_AUTHOR("Tim Howe <tim.howe@cirrus.com>");
385e40da86aSTim Howe MODULE_DESCRIPTION("Cirrus Logic CS4349 ALSA SoC Codec Driver");
386e40da86aSTim Howe MODULE_LICENSE("GPL");
387