wm1250-ev1.c (0cce284537fb42d9c28b9b31038ffc9b464555f5) wm1250-ev1.c (39506cf83bb1b4df80dee1492f8cebc26cec355e)
1/*
2 * Driver for the 1250-EV1 audio I/O module
3 *
4 * Copyright 2011 Wolfson Microelectronics plc
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your

--- 18 unchanged lines hidden (view full) ---

27 "WM1250 OSR",
28 "WM1250 MASTER",
29};
30
31struct wm1250_priv {
32 struct gpio gpios[WM1250_EV1_NUM_GPIOS];
33};
34
1/*
2 * Driver for the 1250-EV1 audio I/O module
3 *
4 * Copyright 2011 Wolfson Microelectronics plc
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your

--- 18 unchanged lines hidden (view full) ---

27 "WM1250 OSR",
28 "WM1250 MASTER",
29};
30
31struct wm1250_priv {
32 struct gpio gpios[WM1250_EV1_NUM_GPIOS];
33};
34
35static int wm1250_ev1_set_bias_level(struct snd_soc_codec *codec,
35static int wm1250_ev1_set_bias_level(struct snd_soc_component *component,
36 enum snd_soc_bias_level level)
37{
36 enum snd_soc_bias_level level)
37{
38 struct wm1250_priv *wm1250 = dev_get_drvdata(codec->dev);
38 struct wm1250_priv *wm1250 = dev_get_drvdata(component->dev);
39 int ena;
40
41 if (wm1250)
42 ena = wm1250->gpios[WM1250_EV1_GPIO_CLK_ENA].gpio;
43 else
44 ena = -1;
45
46 switch (level) {

--- 29 unchanged lines hidden (view full) ---

76 { "ADC", NULL, "WM1250 Input" },
77 { "WM1250 Output", NULL, "DAC" },
78};
79
80static int wm1250_ev1_hw_params(struct snd_pcm_substream *substream,
81 struct snd_pcm_hw_params *params,
82 struct snd_soc_dai *dai)
83{
39 int ena;
40
41 if (wm1250)
42 ena = wm1250->gpios[WM1250_EV1_GPIO_CLK_ENA].gpio;
43 else
44 ena = -1;
45
46 switch (level) {

--- 29 unchanged lines hidden (view full) ---

76 { "ADC", NULL, "WM1250 Input" },
77 { "WM1250 Output", NULL, "DAC" },
78};
79
80static int wm1250_ev1_hw_params(struct snd_pcm_substream *substream,
81 struct snd_pcm_hw_params *params,
82 struct snd_soc_dai *dai)
83{
84 struct wm1250_priv *wm1250 = snd_soc_codec_get_drvdata(dai->codec);
84 struct wm1250_priv *wm1250 = snd_soc_component_get_drvdata(dai->component);
85
86 switch (params_rate(params)) {
87 case 8000:
88 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL0].gpio,
89 1);
90 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL1].gpio,
91 1);
92 break;

--- 43 unchanged lines hidden (view full) ---

136 .channels_min = 1,
137 .channels_max = 2,
138 .rates = WM1250_EV1_RATES,
139 .formats = SNDRV_PCM_FMTBIT_S16_LE,
140 },
141 .ops = &wm1250_ev1_ops,
142};
143
85
86 switch (params_rate(params)) {
87 case 8000:
88 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL0].gpio,
89 1);
90 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL1].gpio,
91 1);
92 break;

--- 43 unchanged lines hidden (view full) ---

136 .channels_min = 1,
137 .channels_max = 2,
138 .rates = WM1250_EV1_RATES,
139 .formats = SNDRV_PCM_FMTBIT_S16_LE,
140 },
141 .ops = &wm1250_ev1_ops,
142};
143
144static const struct snd_soc_codec_driver soc_codec_dev_wm1250_ev1 = {
145 .component_driver = {
146 .dapm_widgets = wm1250_ev1_dapm_widgets,
147 .num_dapm_widgets = ARRAY_SIZE(wm1250_ev1_dapm_widgets),
148 .dapm_routes = wm1250_ev1_dapm_routes,
149 .num_dapm_routes = ARRAY_SIZE(wm1250_ev1_dapm_routes),
150 },
151 .set_bias_level = wm1250_ev1_set_bias_level,
152 .idle_bias_off = true,
144static const struct snd_soc_component_driver soc_component_dev_wm1250_ev1 = {
145 .dapm_widgets = wm1250_ev1_dapm_widgets,
146 .num_dapm_widgets = ARRAY_SIZE(wm1250_ev1_dapm_widgets),
147 .dapm_routes = wm1250_ev1_dapm_routes,
148 .num_dapm_routes = ARRAY_SIZE(wm1250_ev1_dapm_routes),
149 .set_bias_level = wm1250_ev1_set_bias_level,
150 .use_pmdown_time = 1,
151 .endianness = 1,
152 .non_legacy_dai_naming = 1,
153};
154
155static int wm1250_ev1_pdata(struct i2c_client *i2c)
156{
157 struct wm1250_ev1_pdata *pdata = dev_get_platdata(&i2c->dev);
158 struct wm1250_priv *wm1250;
159 int i, ret;
160

--- 58 unchanged lines hidden (view full) ---

219 }
220
221 dev_info(&i2c->dev, "revision %d\n", rev + 1);
222
223 ret = wm1250_ev1_pdata(i2c);
224 if (ret != 0)
225 return ret;
226
153};
154
155static int wm1250_ev1_pdata(struct i2c_client *i2c)
156{
157 struct wm1250_ev1_pdata *pdata = dev_get_platdata(&i2c->dev);
158 struct wm1250_priv *wm1250;
159 int i, ret;
160

--- 58 unchanged lines hidden (view full) ---

219 }
220
221 dev_info(&i2c->dev, "revision %d\n", rev + 1);
222
223 ret = wm1250_ev1_pdata(i2c);
224 if (ret != 0)
225 return ret;
226
227 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm1250_ev1,
227 ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm1250_ev1,
228 &wm1250_ev1_dai, 1);
229 if (ret != 0) {
230 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
231 wm1250_ev1_free(i2c);
232 return ret;
233 }
234
235 return 0;
236}
237
238static int wm1250_ev1_remove(struct i2c_client *i2c)
239{
228 &wm1250_ev1_dai, 1);
229 if (ret != 0) {
230 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
231 wm1250_ev1_free(i2c);
232 return ret;
233 }
234
235 return 0;
236}
237
238static int wm1250_ev1_remove(struct i2c_client *i2c)
239{
240 snd_soc_unregister_codec(&i2c->dev);
241 wm1250_ev1_free(i2c);
242
243 return 0;
244}
245
246static const struct i2c_device_id wm1250_ev1_i2c_id[] = {
247 { "wm1250-ev1", 0 },
248 { }

--- 17 unchanged lines hidden ---
240 wm1250_ev1_free(i2c);
241
242 return 0;
243}
244
245static const struct i2c_device_id wm1250_ev1_i2c_id[] = {
246 { "wm1250-ev1", 0 },
247 { }

--- 17 unchanged lines hidden ---