Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 2 | /* |
| 3 | * max9850.c -- codec driver for max9850 |
| 4 | * |
| 5 | * Copyright (C) 2011 taskit GmbH |
| 6 | * |
| 7 | * Author: Christian Glindkamp <christian.glindkamp@taskit.de> |
| 8 | * |
| 9 | * Initial development of this code was funded by |
| 10 | * MICRONIC Computer Systeme GmbH, http://www.mcsberlin.de/ |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/i2c.h> |
Mark Brown | 0684166 | 2013-09-23 18:12:51 +0100 | [diff] [blame] | 16 | #include <linux/regmap.h> |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 17 | #include <linux/slab.h> |
| 18 | #include <sound/pcm.h> |
| 19 | #include <sound/pcm_params.h> |
| 20 | #include <sound/soc.h> |
| 21 | #include <sound/tlv.h> |
| 22 | |
| 23 | #include "max9850.h" |
| 24 | |
| 25 | struct max9850_priv { |
Mark Brown | 0684166 | 2013-09-23 18:12:51 +0100 | [diff] [blame] | 26 | struct regmap *regmap; |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 27 | unsigned int sysclk; |
| 28 | }; |
| 29 | |
| 30 | /* max9850 register cache */ |
Mark Brown | 0684166 | 2013-09-23 18:12:51 +0100 | [diff] [blame] | 31 | static const struct reg_default max9850_reg[] = { |
| 32 | { 2, 0x0c }, |
| 33 | { 3, 0x00 }, |
| 34 | { 4, 0x00 }, |
| 35 | { 5, 0x00 }, |
| 36 | { 6, 0x00 }, |
| 37 | { 7, 0x00 }, |
| 38 | { 8, 0x00 }, |
| 39 | { 9, 0x00 }, |
| 40 | { 10, 0x00 }, |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /* these registers are not used at the moment but provided for the sake of |
| 44 | * completeness */ |
Mark Brown | 0684166 | 2013-09-23 18:12:51 +0100 | [diff] [blame] | 45 | static bool max9850_volatile_register(struct device *dev, unsigned int reg) |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 46 | { |
| 47 | switch (reg) { |
| 48 | case MAX9850_STATUSA: |
| 49 | case MAX9850_STATUSB: |
Gustavo A. R. Silva | 038541d | 2018-08-04 16:49:02 -0500 | [diff] [blame] | 50 | return true; |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 51 | default: |
Gustavo A. R. Silva | 038541d | 2018-08-04 16:49:02 -0500 | [diff] [blame] | 52 | return false; |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | |
Mark Brown | 0684166 | 2013-09-23 18:12:51 +0100 | [diff] [blame] | 56 | static const struct regmap_config max9850_regmap = { |
| 57 | .reg_bits = 8, |
| 58 | .val_bits = 8, |
| 59 | |
| 60 | .max_register = MAX9850_DIGITAL_AUDIO, |
| 61 | .volatile_reg = max9850_volatile_register, |
| 62 | .cache_type = REGCACHE_RBTREE, |
| 63 | }; |
| 64 | |
Lars-Peter Clausen | e034098 | 2015-08-02 17:19:45 +0200 | [diff] [blame] | 65 | static const DECLARE_TLV_DB_RANGE(max9850_tlv, |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 66 | 0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0), |
| 67 | 0x20, 0x33, TLV_DB_SCALE_ITEM(-4150, 200, 0), |
| 68 | 0x34, 0x37, TLV_DB_SCALE_ITEM(-150, 100, 0), |
Lars-Peter Clausen | e034098 | 2015-08-02 17:19:45 +0200 | [diff] [blame] | 69 | 0x38, 0x3f, TLV_DB_SCALE_ITEM(250, 50, 0) |
| 70 | ); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 71 | |
| 72 | static const struct snd_kcontrol_new max9850_controls[] = { |
| 73 | SOC_SINGLE_TLV("Headphone Volume", MAX9850_VOLUME, 0, 0x3f, 1, max9850_tlv), |
| 74 | SOC_SINGLE("Headphone Switch", MAX9850_VOLUME, 7, 1, 1), |
| 75 | SOC_SINGLE("Mono Switch", MAX9850_GENERAL_PURPOSE, 2, 1, 0), |
| 76 | }; |
| 77 | |
| 78 | static const struct snd_kcontrol_new max9850_mixer_controls[] = { |
| 79 | SOC_DAPM_SINGLE("Line In Switch", MAX9850_ENABLE, 1, 1, 0), |
| 80 | }; |
| 81 | |
| 82 | static const struct snd_soc_dapm_widget max9850_dapm_widgets[] = { |
| 83 | SND_SOC_DAPM_SUPPLY("Charge Pump 1", MAX9850_ENABLE, 4, 0, NULL, 0), |
| 84 | SND_SOC_DAPM_SUPPLY("Charge Pump 2", MAX9850_ENABLE, 5, 0, NULL, 0), |
| 85 | SND_SOC_DAPM_SUPPLY("MCLK", MAX9850_ENABLE, 6, 0, NULL, 0), |
| 86 | SND_SOC_DAPM_SUPPLY("SHDN", MAX9850_ENABLE, 7, 0, NULL, 0), |
| 87 | SND_SOC_DAPM_MIXER_NAMED_CTL("Output Mixer", MAX9850_ENABLE, 2, 0, |
| 88 | &max9850_mixer_controls[0], |
| 89 | ARRAY_SIZE(max9850_mixer_controls)), |
| 90 | SND_SOC_DAPM_PGA("Headphone Output", MAX9850_ENABLE, 3, 0, NULL, 0), |
| 91 | SND_SOC_DAPM_DAC("DAC", "HiFi Playback", MAX9850_ENABLE, 0, 0), |
| 92 | SND_SOC_DAPM_OUTPUT("OUTL"), |
| 93 | SND_SOC_DAPM_OUTPUT("HPL"), |
| 94 | SND_SOC_DAPM_OUTPUT("OUTR"), |
| 95 | SND_SOC_DAPM_OUTPUT("HPR"), |
| 96 | SND_SOC_DAPM_MIXER("Line Input", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 97 | SND_SOC_DAPM_INPUT("INL"), |
| 98 | SND_SOC_DAPM_INPUT("INR"), |
| 99 | }; |
| 100 | |
Axel Lin | 5ee65ec | 2011-12-19 13:13:31 +0800 | [diff] [blame] | 101 | static const struct snd_soc_dapm_route max9850_dapm_routes[] = { |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 102 | /* output mixer */ |
| 103 | {"Output Mixer", NULL, "DAC"}, |
| 104 | {"Output Mixer", "Line In Switch", "Line Input"}, |
| 105 | |
| 106 | /* outputs */ |
| 107 | {"Headphone Output", NULL, "Output Mixer"}, |
| 108 | {"HPL", NULL, "Headphone Output"}, |
| 109 | {"HPR", NULL, "Headphone Output"}, |
| 110 | {"OUTL", NULL, "Output Mixer"}, |
| 111 | {"OUTR", NULL, "Output Mixer"}, |
| 112 | |
| 113 | /* inputs */ |
| 114 | {"Line Input", NULL, "INL"}, |
| 115 | {"Line Input", NULL, "INR"}, |
| 116 | |
| 117 | /* supplies */ |
| 118 | {"Output Mixer", NULL, "Charge Pump 1"}, |
| 119 | {"Output Mixer", NULL, "Charge Pump 2"}, |
| 120 | {"Output Mixer", NULL, "SHDN"}, |
| 121 | {"DAC", NULL, "MCLK"}, |
| 122 | }; |
| 123 | |
| 124 | static int max9850_hw_params(struct snd_pcm_substream *substream, |
| 125 | struct snd_pcm_hw_params *params, |
| 126 | struct snd_soc_dai *dai) |
| 127 | { |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 128 | struct snd_soc_component *component = dai->component; |
| 129 | struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 130 | u64 lrclk_div; |
| 131 | u8 sf, da; |
| 132 | |
Mark Brown | 27380fb | 2011-03-11 12:07:31 +0000 | [diff] [blame] | 133 | if (!max9850->sysclk) |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 134 | return -EINVAL; |
| 135 | |
| 136 | /* lrclk_div = 2^22 * rate / iclk with iclk = mclk / sf */ |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 137 | sf = (snd_soc_component_read32(component, MAX9850_CLOCK) >> 2) + 1; |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 138 | lrclk_div = (1 << 22); |
| 139 | lrclk_div *= params_rate(params); |
| 140 | lrclk_div *= sf; |
| 141 | do_div(lrclk_div, max9850->sysclk); |
| 142 | |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 143 | snd_soc_component_write(component, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); |
| 144 | snd_soc_component_write(component, MAX9850_LRCLK_LSB, lrclk_div & 0xff); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 145 | |
Mark Brown | 0058e45 | 2014-01-08 20:39:44 +0000 | [diff] [blame] | 146 | switch (params_width(params)) { |
| 147 | case 16: |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 148 | da = 0; |
| 149 | break; |
Mark Brown | 0058e45 | 2014-01-08 20:39:44 +0000 | [diff] [blame] | 150 | case 20: |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 151 | da = 0x2; |
| 152 | break; |
Mark Brown | 0058e45 | 2014-01-08 20:39:44 +0000 | [diff] [blame] | 153 | case 24: |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 154 | da = 0x3; |
| 155 | break; |
| 156 | default: |
| 157 | return -EINVAL; |
| 158 | } |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 159 | snd_soc_component_update_bits(component, MAX9850_DIGITAL_AUDIO, 0x3, da); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
| 165 | int clk_id, unsigned int freq, int dir) |
| 166 | { |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 167 | struct snd_soc_component *component = codec_dai->component; |
| 168 | struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 169 | |
| 170 | /* calculate mclk -> iclk divider */ |
| 171 | if (freq <= 13000000) |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 172 | snd_soc_component_write(component, MAX9850_CLOCK, 0x0); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 173 | else if (freq <= 26000000) |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 174 | snd_soc_component_write(component, MAX9850_CLOCK, 0x4); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 175 | else if (freq <= 40000000) |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 176 | snd_soc_component_write(component, MAX9850_CLOCK, 0x8); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 177 | else |
| 178 | return -EINVAL; |
| 179 | |
| 180 | max9850->sysclk = freq; |
| 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
| 185 | { |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 186 | struct snd_soc_component *component = codec_dai->component; |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 187 | u8 da = 0; |
| 188 | |
| 189 | /* set master/slave audio interface */ |
| 190 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 191 | case SND_SOC_DAIFMT_CBM_CFM: |
| 192 | da |= MAX9850_MASTER; |
| 193 | break; |
| 194 | case SND_SOC_DAIFMT_CBS_CFS: |
| 195 | break; |
| 196 | default: |
| 197 | return -EINVAL; |
| 198 | } |
| 199 | |
| 200 | /* interface format */ |
| 201 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
| 202 | case SND_SOC_DAIFMT_I2S: |
| 203 | da |= MAX9850_DLY; |
| 204 | break; |
| 205 | case SND_SOC_DAIFMT_RIGHT_J: |
| 206 | da |= MAX9850_RTJ; |
| 207 | break; |
| 208 | case SND_SOC_DAIFMT_LEFT_J: |
| 209 | break; |
| 210 | default: |
| 211 | return -EINVAL; |
| 212 | } |
| 213 | |
| 214 | /* clock inversion */ |
| 215 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
| 216 | case SND_SOC_DAIFMT_NB_NF: |
| 217 | break; |
| 218 | case SND_SOC_DAIFMT_IB_IF: |
| 219 | da |= MAX9850_BCINV | MAX9850_INV; |
| 220 | break; |
| 221 | case SND_SOC_DAIFMT_IB_NF: |
| 222 | da |= MAX9850_BCINV; |
| 223 | break; |
| 224 | case SND_SOC_DAIFMT_NB_IF: |
| 225 | da |= MAX9850_INV; |
| 226 | break; |
| 227 | default: |
| 228 | return -EINVAL; |
| 229 | } |
| 230 | |
| 231 | /* set da */ |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 232 | snd_soc_component_write(component, MAX9850_DIGITAL_AUDIO, da); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 233 | |
| 234 | return 0; |
| 235 | } |
| 236 | |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 237 | static int max9850_set_bias_level(struct snd_soc_component *component, |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 238 | enum snd_soc_bias_level level) |
| 239 | { |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 240 | struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 241 | int ret; |
| 242 | |
| 243 | switch (level) { |
| 244 | case SND_SOC_BIAS_ON: |
| 245 | break; |
| 246 | case SND_SOC_BIAS_PREPARE: |
| 247 | break; |
| 248 | case SND_SOC_BIAS_STANDBY: |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 249 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { |
Mark Brown | 0684166 | 2013-09-23 18:12:51 +0100 | [diff] [blame] | 250 | ret = regcache_sync(max9850->regmap); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 251 | if (ret) { |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 252 | dev_err(component->dev, |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 253 | "Failed to sync cache: %d\n", ret); |
| 254 | return ret; |
| 255 | } |
| 256 | } |
| 257 | break; |
| 258 | case SND_SOC_BIAS_OFF: |
| 259 | break; |
| 260 | } |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | #define MAX9850_RATES SNDRV_PCM_RATE_8000_48000 |
| 265 | |
| 266 | #define MAX9850_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ |
| 267 | SNDRV_PCM_FMTBIT_S24_LE) |
| 268 | |
Lars-Peter Clausen | 85e7652 | 2011-11-23 11:40:40 +0100 | [diff] [blame] | 269 | static const struct snd_soc_dai_ops max9850_dai_ops = { |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 270 | .hw_params = max9850_hw_params, |
| 271 | .set_sysclk = max9850_set_dai_sysclk, |
| 272 | .set_fmt = max9850_set_dai_fmt, |
| 273 | }; |
| 274 | |
| 275 | static struct snd_soc_dai_driver max9850_dai = { |
| 276 | .name = "max9850-hifi", |
| 277 | .playback = { |
| 278 | .stream_name = "Playback", |
| 279 | .channels_min = 1, |
| 280 | .channels_max = 2, |
| 281 | .rates = MAX9850_RATES, |
| 282 | .formats = MAX9850_FORMATS |
| 283 | }, |
| 284 | .ops = &max9850_dai_ops, |
| 285 | }; |
| 286 | |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 287 | static int max9850_probe(struct snd_soc_component *component) |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 288 | { |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 289 | /* enable zero-detect */ |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 290 | snd_soc_component_update_bits(component, MAX9850_GENERAL_PURPOSE, 1, 1); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 291 | /* enable slew-rate control */ |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 292 | snd_soc_component_update_bits(component, MAX9850_VOLUME, 0x40, 0x40); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 293 | /* set slew-rate 125ms */ |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 294 | snd_soc_component_update_bits(component, MAX9850_CHARGE_PUMP, 0xff, 0xc0); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 295 | |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 296 | return 0; |
| 297 | } |
| 298 | |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 299 | static const struct snd_soc_component_driver soc_component_dev_max9850 = { |
| 300 | .probe = max9850_probe, |
| 301 | .set_bias_level = max9850_set_bias_level, |
| 302 | .controls = max9850_controls, |
| 303 | .num_controls = ARRAY_SIZE(max9850_controls), |
| 304 | .dapm_widgets = max9850_dapm_widgets, |
| 305 | .num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets), |
| 306 | .dapm_routes = max9850_dapm_routes, |
| 307 | .num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes), |
| 308 | .suspend_bias_off = 1, |
| 309 | .idle_bias_on = 1, |
| 310 | .use_pmdown_time = 1, |
| 311 | .endianness = 1, |
| 312 | .non_legacy_dai_naming = 1, |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 313 | }; |
| 314 | |
Bill Pemberton | 7a79e94 | 2012-12-07 09:26:37 -0500 | [diff] [blame] | 315 | static int max9850_i2c_probe(struct i2c_client *i2c, |
| 316 | const struct i2c_device_id *id) |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 317 | { |
| 318 | struct max9850_priv *max9850; |
| 319 | int ret; |
| 320 | |
Axel Lin | bf791bd | 2011-12-29 12:03:16 +0800 | [diff] [blame] | 321 | max9850 = devm_kzalloc(&i2c->dev, sizeof(struct max9850_priv), |
| 322 | GFP_KERNEL); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 323 | if (max9850 == NULL) |
| 324 | return -ENOMEM; |
| 325 | |
Mark Brown | 0684166 | 2013-09-23 18:12:51 +0100 | [diff] [blame] | 326 | max9850->regmap = devm_regmap_init_i2c(i2c, &max9850_regmap); |
| 327 | if (IS_ERR(max9850->regmap)) |
| 328 | return PTR_ERR(max9850->regmap); |
| 329 | |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 330 | i2c_set_clientdata(i2c, max9850); |
| 331 | |
Kuninori Morimoto | 0b3eda2 | 2018-01-29 04:04:34 +0000 | [diff] [blame] | 332 | ret = devm_snd_soc_register_component(&i2c->dev, |
| 333 | &soc_component_dev_max9850, &max9850_dai, 1); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 334 | return ret; |
| 335 | } |
| 336 | |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 337 | static const struct i2c_device_id max9850_i2c_id[] = { |
| 338 | { "max9850", 0 }, |
| 339 | { } |
| 340 | }; |
| 341 | MODULE_DEVICE_TABLE(i2c, max9850_i2c_id); |
| 342 | |
| 343 | static struct i2c_driver max9850_i2c_driver = { |
| 344 | .driver = { |
| 345 | .name = "max9850", |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 346 | }, |
| 347 | .probe = max9850_i2c_probe, |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 348 | .id_table = max9850_i2c_id, |
| 349 | }; |
| 350 | |
Sachin Kamat | 4abdc8c | 2012-08-06 17:25:46 +0530 | [diff] [blame] | 351 | module_i2c_driver(max9850_i2c_driver); |
Christian Glindkamp | 0e45cab | 2011-03-09 11:20:04 +0100 | [diff] [blame] | 352 | |
| 353 | MODULE_AUTHOR("Christian Glindkamp <christian.glindkamp@taskit.de>"); |
| 354 | MODULE_DESCRIPTION("ASoC MAX9850 codec driver"); |
| 355 | MODULE_LICENSE("GPL"); |