Lines Matching +full:i2c +full:- +full:gpio

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for the 1250-EV1 audio I/O module
11 #include <linux/i2c.h>
12 #include <linux/gpio.h>
15 #include <sound/soc-dapm.h>
16 #include <sound/wm1250-ev1.h>
27 struct gpio gpios[WM1250_EV1_NUM_GPIOS];
33 struct wm1250_priv *wm1250 = dev_get_drvdata(component->dev); in wm1250_ev1_set_bias_level()
37 ena = wm1250->gpios[WM1250_EV1_GPIO_CLK_ENA].gpio; in wm1250_ev1_set_bias_level()
39 ena = -1; in wm1250_ev1_set_bias_level()
63 SND_SOC_DAPM_ADC("ADC", "wm1250-ev1 Capture", SND_SOC_NOPM, 0, 0),
64 SND_SOC_DAPM_DAC("DAC", "wm1250-ev1 Playback", SND_SOC_NOPM, 0, 0),
79 struct wm1250_priv *wm1250 = snd_soc_component_get_drvdata(dai->component); in wm1250_ev1_hw_params()
83 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL0].gpio, in wm1250_ev1_hw_params()
85 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL1].gpio, in wm1250_ev1_hw_params()
89 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL0].gpio, in wm1250_ev1_hw_params()
91 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL1].gpio, in wm1250_ev1_hw_params()
95 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL0].gpio, in wm1250_ev1_hw_params()
97 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL1].gpio, in wm1250_ev1_hw_params()
101 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL0].gpio, in wm1250_ev1_hw_params()
103 gpio_set_value(wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL1].gpio, in wm1250_ev1_hw_params()
107 return -EINVAL; in wm1250_ev1_hw_params()
121 .name = "wm1250-ev1",
149 static int wm1250_ev1_pdata(struct i2c_client *i2c) in wm1250_ev1_pdata() argument
151 struct wm1250_ev1_pdata *pdata = dev_get_platdata(&i2c->dev); in wm1250_ev1_pdata()
158 wm1250 = devm_kzalloc(&i2c->dev, sizeof(*wm1250), GFP_KERNEL); in wm1250_ev1_pdata()
160 ret = -ENOMEM; in wm1250_ev1_pdata()
164 for (i = 0; i < ARRAY_SIZE(wm1250->gpios); i++) { in wm1250_ev1_pdata()
165 wm1250->gpios[i].gpio = pdata->gpios[i]; in wm1250_ev1_pdata()
166 wm1250->gpios[i].label = wm1250_gpio_names[i]; in wm1250_ev1_pdata()
167 wm1250->gpios[i].flags = GPIOF_OUT_INIT_LOW; in wm1250_ev1_pdata()
169 wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL0].flags = GPIOF_OUT_INIT_HIGH; in wm1250_ev1_pdata()
170 wm1250->gpios[WM1250_EV1_GPIO_CLK_SEL1].flags = GPIOF_OUT_INIT_HIGH; in wm1250_ev1_pdata()
172 ret = gpio_request_array(wm1250->gpios, ARRAY_SIZE(wm1250->gpios)); in wm1250_ev1_pdata()
174 dev_err(&i2c->dev, "Failed to get GPIOs: %d\n", ret); in wm1250_ev1_pdata()
178 dev_set_drvdata(&i2c->dev, wm1250); in wm1250_ev1_pdata()
186 static void wm1250_ev1_free(struct i2c_client *i2c) in wm1250_ev1_free() argument
188 struct wm1250_priv *wm1250 = dev_get_drvdata(&i2c->dev); in wm1250_ev1_free()
191 gpio_free_array(wm1250->gpios, ARRAY_SIZE(wm1250->gpios)); in wm1250_ev1_free()
194 static int wm1250_ev1_probe(struct i2c_client *i2c) in wm1250_ev1_probe() argument
198 dev_set_drvdata(&i2c->dev, NULL); in wm1250_ev1_probe()
200 board = i2c_smbus_read_byte_data(i2c, 0); in wm1250_ev1_probe()
202 dev_err(&i2c->dev, "Failed to read ID: %d\n", board); in wm1250_ev1_probe()
210 dev_err(&i2c->dev, "Unknown board ID %d\n", id); in wm1250_ev1_probe()
211 return -ENODEV; in wm1250_ev1_probe()
214 dev_info(&i2c->dev, "revision %d\n", rev + 1); in wm1250_ev1_probe()
216 ret = wm1250_ev1_pdata(i2c); in wm1250_ev1_probe()
220 ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm1250_ev1, in wm1250_ev1_probe()
223 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); in wm1250_ev1_probe()
224 wm1250_ev1_free(i2c); in wm1250_ev1_probe()
231 static void wm1250_ev1_remove(struct i2c_client *i2c) in wm1250_ev1_remove() argument
233 wm1250_ev1_free(i2c); in wm1250_ev1_remove()
237 { "wm1250-ev1", 0 },
240 MODULE_DEVICE_TABLE(i2c, wm1250_ev1_i2c_id);
244 .name = "wm1250-ev1",
254 MODULE_DESCRIPTION("WM1250-EV1 audio I/O module driver");