Lines Matching refs:wm8350
63 int wm8350_clear_bits(struct wm8350 *wm8350, u16 reg, u16 mask) in wm8350_clear_bits() argument
65 return regmap_update_bits(wm8350->regmap, reg, mask, 0); in wm8350_clear_bits()
69 int wm8350_set_bits(struct wm8350 *wm8350, u16 reg, u16 mask) in wm8350_set_bits() argument
71 return regmap_update_bits(wm8350->regmap, reg, mask, mask); in wm8350_set_bits()
75 u16 wm8350_reg_read(struct wm8350 *wm8350, int reg) in wm8350_reg_read() argument
80 err = regmap_read(wm8350->regmap, reg, &data); in wm8350_reg_read()
82 dev_err(wm8350->dev, "read from reg R%d failed\n", reg); in wm8350_reg_read()
88 int wm8350_reg_write(struct wm8350 *wm8350, int reg, u16 val) in wm8350_reg_write() argument
92 ret = regmap_write(wm8350->regmap, reg, val); in wm8350_reg_write()
95 dev_err(wm8350->dev, "write to reg R%d failed\n", reg); in wm8350_reg_write()
100 int wm8350_block_read(struct wm8350 *wm8350, int start_reg, int regs, in wm8350_block_read() argument
105 err = regmap_bulk_read(wm8350->regmap, start_reg, dest, regs); in wm8350_block_read()
107 dev_err(wm8350->dev, "block read starting from R%d failed\n", in wm8350_block_read()
114 int wm8350_block_write(struct wm8350 *wm8350, int start_reg, int regs, in wm8350_block_write() argument
119 ret = regmap_bulk_write(wm8350->regmap, start_reg, src, regs); in wm8350_block_write()
121 dev_err(wm8350->dev, "block write starting at R%d failed\n", in wm8350_block_write()
135 int wm8350_reg_lock(struct wm8350 *wm8350) in wm8350_reg_lock() argument
143 ret = wm8350_reg_write(wm8350, WM8350_SECURITY, WM8350_LOCK_KEY); in wm8350_reg_lock()
145 dev_err(wm8350->dev, "lock failed\n"); in wm8350_reg_lock()
147 wm8350->unlocked = false; in wm8350_reg_lock()
164 int wm8350_reg_unlock(struct wm8350 *wm8350) in wm8350_reg_unlock() argument
172 ret = wm8350_reg_write(wm8350, WM8350_SECURITY, WM8350_UNLOCK_KEY); in wm8350_reg_unlock()
174 dev_err(wm8350->dev, "unlock failed\n"); in wm8350_reg_unlock()
176 wm8350->unlocked = true; in wm8350_reg_unlock()
184 int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale, int vref) in wm8350_read_auxadc() argument
194 mutex_lock(&wm8350->auxadc_mutex); in wm8350_read_auxadc()
197 reg = wm8350_reg_read(wm8350, WM8350_POWER_MGMT_5); in wm8350_read_auxadc()
198 wm8350_reg_write(wm8350, WM8350_POWER_MGMT_5, reg | WM8350_AUXADC_ENA); in wm8350_read_auxadc()
203 wm8350_reg_write(wm8350, WM8350_AUX1_READBACK + channel, reg); in wm8350_read_auxadc()
206 reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1); in wm8350_read_auxadc()
208 wm8350_reg_write(wm8350, WM8350_DIGITISER_CONTROL_1, reg); in wm8350_read_auxadc()
212 try_wait_for_completion(&wm8350->auxadc_done); in wm8350_read_auxadc()
217 wait_for_completion_timeout(&wm8350->auxadc_done, msecs_to_jiffies(5)); in wm8350_read_auxadc()
219 reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1); in wm8350_read_auxadc()
221 dev_err(wm8350->dev, "adc chn %d read timeout\n", channel); in wm8350_read_auxadc()
223 result = wm8350_reg_read(wm8350, in wm8350_read_auxadc()
227 reg = wm8350_reg_read(wm8350, WM8350_POWER_MGMT_5); in wm8350_read_auxadc()
228 wm8350_reg_write(wm8350, WM8350_POWER_MGMT_5, in wm8350_read_auxadc()
231 mutex_unlock(&wm8350->auxadc_mutex); in wm8350_read_auxadc()
239 struct wm8350 *wm8350 = irq_data; in wm8350_auxadc_irq() local
241 complete(&wm8350->auxadc_done); in wm8350_auxadc_irq()
250 static void wm8350_client_dev_register(struct wm8350 *wm8350, in wm8350_client_dev_register() argument
258 dev_err(wm8350->dev, "Failed to allocate %s\n", name); in wm8350_client_dev_register()
262 (*pdev)->dev.parent = wm8350->dev; in wm8350_client_dev_register()
263 platform_set_drvdata(*pdev, wm8350); in wm8350_client_dev_register()
266 dev_err(wm8350->dev, "Failed to register %s: %d\n", name, ret); in wm8350_client_dev_register()
272 int wm8350_device_init(struct wm8350 *wm8350, int irq, in wm8350_device_init() argument
279 dev_set_drvdata(wm8350->dev, wm8350); in wm8350_device_init()
282 ret = regmap_read(wm8350->regmap, WM8350_RESET_ID, &id1); in wm8350_device_init()
284 dev_err(wm8350->dev, "Failed to read ID: %d\n", ret); in wm8350_device_init()
288 ret = regmap_read(wm8350->regmap, WM8350_ID, &id2); in wm8350_device_init()
290 dev_err(wm8350->dev, "Failed to read ID: %d\n", ret); in wm8350_device_init()
294 ret = regmap_read(wm8350->regmap, WM8350_REVISION, &mask_rev); in wm8350_device_init()
296 dev_err(wm8350->dev, "Failed to read revision: %d\n", ret); in wm8350_device_init()
301 dev_err(wm8350->dev, in wm8350_device_init()
310 dev_info(wm8350->dev, in wm8350_device_init()
315 dev_err(wm8350->dev, "Unsupported CUST_ID\n"); in wm8350_device_init()
322 wm8350->pmic.max_dcdc = WM8350_DCDC_6; in wm8350_device_init()
323 wm8350->pmic.max_isink = WM8350_ISINK_B; in wm8350_device_init()
327 dev_info(wm8350->dev, "WM8350 Rev E\n"); in wm8350_device_init()
330 dev_info(wm8350->dev, "WM8350 Rev F\n"); in wm8350_device_init()
333 dev_info(wm8350->dev, "WM8350 Rev G\n"); in wm8350_device_init()
334 wm8350->power.rev_g_coeff = 1; in wm8350_device_init()
337 dev_info(wm8350->dev, "WM8350 Rev H\n"); in wm8350_device_init()
338 wm8350->power.rev_g_coeff = 1; in wm8350_device_init()
342 dev_err(wm8350->dev, "Unknown WM8350 CHIP_REV\n"); in wm8350_device_init()
349 wm8350->pmic.max_dcdc = WM8350_DCDC_4; in wm8350_device_init()
350 wm8350->pmic.max_isink = WM8350_ISINK_A; in wm8350_device_init()
354 dev_info(wm8350->dev, "WM8351 Rev A\n"); in wm8350_device_init()
355 wm8350->power.rev_g_coeff = 1; in wm8350_device_init()
359 dev_info(wm8350->dev, "WM8351 Rev B\n"); in wm8350_device_init()
360 wm8350->power.rev_g_coeff = 1; in wm8350_device_init()
364 dev_err(wm8350->dev, "Unknown WM8351 CHIP_REV\n"); in wm8350_device_init()
371 wm8350->pmic.max_dcdc = WM8350_DCDC_6; in wm8350_device_init()
372 wm8350->pmic.max_isink = WM8350_ISINK_B; in wm8350_device_init()
376 dev_info(wm8350->dev, "WM8352 Rev A\n"); in wm8350_device_init()
377 wm8350->power.rev_g_coeff = 1; in wm8350_device_init()
381 dev_err(wm8350->dev, "Unknown WM8352 CHIP_REV\n"); in wm8350_device_init()
388 dev_err(wm8350->dev, "Unknown MASK_REV\n"); in wm8350_device_init()
393 mutex_init(&wm8350->auxadc_mutex); in wm8350_device_init()
394 init_completion(&wm8350->auxadc_done); in wm8350_device_init()
396 ret = wm8350_irq_init(wm8350, irq, pdata); in wm8350_device_init()
400 if (wm8350->irq_base) { in wm8350_device_init()
401 ret = request_threaded_irq(wm8350->irq_base + in wm8350_device_init()
405 "auxadc", wm8350); in wm8350_device_init()
407 dev_warn(wm8350->dev, in wm8350_device_init()
412 ret = pdata->init(wm8350); in wm8350_device_init()
414 dev_err(wm8350->dev, "Platform init() failed: %d\n", in wm8350_device_init()
420 wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0x0); in wm8350_device_init()
422 wm8350_client_dev_register(wm8350, "wm8350-codec", in wm8350_device_init()
423 &(wm8350->codec.pdev)); in wm8350_device_init()
424 wm8350_client_dev_register(wm8350, "wm8350-gpio", in wm8350_device_init()
425 &(wm8350->gpio.pdev)); in wm8350_device_init()
426 wm8350_client_dev_register(wm8350, "wm8350-hwmon", in wm8350_device_init()
427 &(wm8350->hwmon.pdev)); in wm8350_device_init()
428 wm8350_client_dev_register(wm8350, "wm8350-power", in wm8350_device_init()
429 &(wm8350->power.pdev)); in wm8350_device_init()
430 wm8350_client_dev_register(wm8350, "wm8350-rtc", &(wm8350->rtc.pdev)); in wm8350_device_init()
431 wm8350_client_dev_register(wm8350, "wm8350-wdt", &(wm8350->wdt.pdev)); in wm8350_device_init()
436 wm8350_irq_exit(wm8350); in wm8350_device_init()