Lines Matching refs:wm831x
31 static int wm831x_auxadc_read_irq(struct wm831x *wm831x, in wm831x_auxadc_read_irq() argument
46 mutex_lock(&wm831x->auxadc_lock); in wm831x_auxadc_read_irq()
49 list_add(&req->list, &wm831x->auxadc_pending); in wm831x_auxadc_read_irq()
51 ena = !wm831x->auxadc_active; in wm831x_auxadc_read_irq()
54 ret = wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL, in wm831x_auxadc_read_irq()
57 dev_err(wm831x->dev, "Failed to enable AUXADC: %d\n", in wm831x_auxadc_read_irq()
64 if (!(wm831x->auxadc_active & (1 << input))) { in wm831x_auxadc_read_irq()
65 ret = wm831x_set_bits(wm831x, WM831X_AUXADC_SOURCE, in wm831x_auxadc_read_irq()
68 dev_err(wm831x->dev, in wm831x_auxadc_read_irq()
73 wm831x->auxadc_active |= 1 << input; in wm831x_auxadc_read_irq()
78 ret = wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL, in wm831x_auxadc_read_irq()
84 dev_err(wm831x->dev, "Failed to start AUXADC: %d\n", in wm831x_auxadc_read_irq()
90 mutex_unlock(&wm831x->auxadc_lock); in wm831x_auxadc_read_irq()
95 mutex_lock(&wm831x->auxadc_lock); in wm831x_auxadc_read_irq()
100 mutex_unlock(&wm831x->auxadc_lock); in wm831x_auxadc_read_irq()
109 struct wm831x *wm831x = irq_data; in wm831x_auxadc_irq() local
113 ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA); in wm831x_auxadc_irq()
115 dev_err(wm831x->dev, in wm831x_auxadc_irq()
128 mutex_lock(&wm831x->auxadc_lock); in wm831x_auxadc_irq()
131 wm831x_set_bits(wm831x, WM831X_AUXADC_SOURCE, in wm831x_auxadc_irq()
133 wm831x->auxadc_active &= ~(1 << input); in wm831x_auxadc_irq()
136 if (!wm831x->auxadc_active) in wm831x_auxadc_irq()
137 wm831x_reg_write(wm831x, WM831X_AUXADC_CONTROL, 0); in wm831x_auxadc_irq()
140 list_for_each_entry(req, &wm831x->auxadc_pending, list) { in wm831x_auxadc_irq()
147 mutex_unlock(&wm831x->auxadc_lock); in wm831x_auxadc_irq()
152 static int wm831x_auxadc_read_polled(struct wm831x *wm831x, in wm831x_auxadc_read_polled() argument
157 mutex_lock(&wm831x->auxadc_lock); in wm831x_auxadc_read_polled()
159 ret = wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL, in wm831x_auxadc_read_polled()
162 dev_err(wm831x->dev, "Failed to enable AUXADC: %d\n", ret); in wm831x_auxadc_read_polled()
168 ret = wm831x_reg_write(wm831x, WM831X_AUXADC_SOURCE, in wm831x_auxadc_read_polled()
171 dev_err(wm831x->dev, "Failed to set AUXADC source: %d\n", ret); in wm831x_auxadc_read_polled()
175 ret = wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL, in wm831x_auxadc_read_polled()
178 dev_err(wm831x->dev, "Failed to start AUXADC: %d\n", ret); in wm831x_auxadc_read_polled()
188 ret = wm831x_reg_read(wm831x, in wm831x_auxadc_read_polled()
191 dev_err(wm831x->dev, in wm831x_auxadc_read_polled()
198 wm831x_reg_write(wm831x, in wm831x_auxadc_read_polled()
203 dev_err(wm831x->dev, in wm831x_auxadc_read_polled()
210 ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA); in wm831x_auxadc_read_polled()
212 dev_err(wm831x->dev, in wm831x_auxadc_read_polled()
224 dev_err(wm831x->dev, "Data from source %d not %d\n", in wm831x_auxadc_read_polled()
232 wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL, WM831X_AUX_ENA, 0); in wm831x_auxadc_read_polled()
234 mutex_unlock(&wm831x->auxadc_lock); in wm831x_auxadc_read_polled()
244 int wm831x_auxadc_read(struct wm831x *wm831x, enum wm831x_auxadc input) in wm831x_auxadc_read() argument
246 return wm831x->auxadc_read(wm831x, input); in wm831x_auxadc_read()
256 int wm831x_auxadc_read_uv(struct wm831x *wm831x, enum wm831x_auxadc input) in wm831x_auxadc_read_uv() argument
260 ret = wm831x_auxadc_read(wm831x, input); in wm831x_auxadc_read_uv()
270 void wm831x_auxadc_init(struct wm831x *wm831x) in wm831x_auxadc_init() argument
274 mutex_init(&wm831x->auxadc_lock); in wm831x_auxadc_init()
275 INIT_LIST_HEAD(&wm831x->auxadc_pending); in wm831x_auxadc_init()
277 if (wm831x->irq) { in wm831x_auxadc_init()
278 wm831x->auxadc_read = wm831x_auxadc_read_irq; in wm831x_auxadc_init()
280 ret = request_threaded_irq(wm831x_irq(wm831x, in wm831x_auxadc_init()
284 "auxadc", wm831x); in wm831x_auxadc_init()
286 dev_err(wm831x->dev, "AUXADC IRQ request failed: %d\n", in wm831x_auxadc_init()
288 wm831x->auxadc_read = NULL; in wm831x_auxadc_init()
292 if (!wm831x->auxadc_read) in wm831x_auxadc_init()
293 wm831x->auxadc_read = wm831x_auxadc_read_polled; in wm831x_auxadc_init()