• Home
  • Raw
  • Download

Lines Matching full:wm8994

3  * wm8994-core.c  --  Device access for Wolfson WM8994
24 #include <linux/mfd/wm8994/core.h>
25 #include <linux/mfd/wm8994/pdata.h>
26 #include <linux/mfd/wm8994/registers.h>
28 #include "wm8994.h"
32 .name = "wm8994-ldo",
37 .name = "wm8994-ldo",
61 .name = "wm8994-codec",
67 .name = "wm8994-gpio",
115 struct wm8994 *wm8994 = dev_get_drvdata(dev); in wm8994_suspend() local
120 switch (wm8994->type) { in wm8994_suspend()
123 ret = wm8994_reg_read(wm8994, WM8958_MIC_DETECT_1); in wm8994_suspend()
137 if (!wm8994->ldo_ena_always_driven) in wm8994_suspend()
138 wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, in wm8994_suspend()
145 wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET, in wm8994_suspend()
146 wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET)); in wm8994_suspend()
148 regcache_mark_dirty(wm8994->regmap); in wm8994_suspend()
153 ret = regcache_sync_region(wm8994->regmap, WM8994_GPIO_1, in wm8994_suspend()
159 ret = regcache_sync_region(wm8994->regmap, in wm8994_suspend()
165 regcache_cache_only(wm8994->regmap, true); in wm8994_suspend()
166 wm8994->suspended = true; in wm8994_suspend()
168 ret = regulator_bulk_disable(wm8994->num_supplies, in wm8994_suspend()
169 wm8994->supplies); in wm8994_suspend()
180 struct wm8994 *wm8994 = dev_get_drvdata(dev); in wm8994_resume() local
184 if (!wm8994->suspended) in wm8994_resume()
187 ret = regulator_bulk_enable(wm8994->num_supplies, in wm8994_resume()
188 wm8994->supplies); in wm8994_resume()
194 regcache_cache_only(wm8994->regmap, false); in wm8994_resume()
195 ret = regcache_sync(wm8994->regmap); in wm8994_resume()
202 wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, in wm8994_resume()
206 wm8994->suspended = false; in wm8994_resume()
211 regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); in wm8994_resume()
261 static int wm8994_set_pdata_from_of(struct wm8994 *wm8994) in wm8994_set_pdata_from_of() argument
263 struct device_node *np = wm8994->dev->of_node; in wm8994_set_pdata_from_of()
264 struct wm8994_pdata *pdata = &wm8994->pdata; in wm8994_set_pdata_from_of()
273 if (wm8994->pdata.gpio_defaults[i] == 0) in wm8994_set_pdata_from_of()
295 static int wm8994_set_pdata_from_of(struct wm8994 *wm8994) in wm8994_set_pdata_from_of() argument
304 static int wm8994_device_init(struct wm8994 *wm8994, int irq) in wm8994_device_init() argument
313 if (dev_get_platdata(wm8994->dev)) { in wm8994_device_init()
314 pdata = dev_get_platdata(wm8994->dev); in wm8994_device_init()
315 wm8994->pdata = *pdata; in wm8994_device_init()
317 pdata = &wm8994->pdata; in wm8994_device_init()
319 ret = wm8994_set_pdata_from_of(wm8994); in wm8994_device_init()
324 ret = mfd_add_devices(wm8994->dev, 0, in wm8994_device_init()
329 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); in wm8994_device_init()
333 switch (wm8994->type) { in wm8994_device_init()
335 wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies); in wm8994_device_init()
337 case WM8994: in wm8994_device_init()
338 wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies); in wm8994_device_init()
341 wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies); in wm8994_device_init()
348 wm8994->supplies = devm_kcalloc(wm8994->dev, in wm8994_device_init()
349 wm8994->num_supplies, in wm8994_device_init()
352 if (!wm8994->supplies) { in wm8994_device_init()
357 switch (wm8994->type) { in wm8994_device_init()
360 wm8994->supplies[i].supply = wm1811_main_supplies[i]; in wm8994_device_init()
362 case WM8994: in wm8994_device_init()
364 wm8994->supplies[i].supply = wm8994_main_supplies[i]; in wm8994_device_init()
368 wm8994->supplies[i].supply = wm8958_main_supplies[i]; in wm8994_device_init()
377 * wm8994->dev's children (regulators) and those regulators are in wm8994_device_init()
380 ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, in wm8994_device_init()
381 wm8994->supplies); in wm8994_device_init()
384 dev_err(wm8994->dev, "Failed to get supplies: %d\n", in wm8994_device_init()
389 ret = regulator_bulk_enable(wm8994->num_supplies, wm8994->supplies); in wm8994_device_init()
391 dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); in wm8994_device_init()
395 ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); in wm8994_device_init()
397 dev_err(wm8994->dev, "Failed to read ID register\n"); in wm8994_device_init()
403 if (wm8994->type != WM1811) in wm8994_device_init()
404 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
405 wm8994->type); in wm8994_device_init()
406 wm8994->type = WM1811; in wm8994_device_init()
409 devname = "WM8994"; in wm8994_device_init()
410 if (wm8994->type != WM8994) in wm8994_device_init()
411 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
412 wm8994->type); in wm8994_device_init()
413 wm8994->type = WM8994; in wm8994_device_init()
417 if (wm8994->type != WM8958) in wm8994_device_init()
418 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
419 wm8994->type); in wm8994_device_init()
420 wm8994->type = WM8958; in wm8994_device_init()
423 dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n", in wm8994_device_init()
429 ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION); in wm8994_device_init()
431 dev_err(wm8994->dev, "Failed to read revision register: %d\n", in wm8994_device_init()
435 wm8994->revision = ret & WM8994_CHIP_REV_MASK; in wm8994_device_init()
436 wm8994->cust_id = (ret & WM8994_CUST_ID_MASK) >> WM8994_CUST_ID_SHIFT; in wm8994_device_init()
438 switch (wm8994->type) { in wm8994_device_init()
439 case WM8994: in wm8994_device_init()
440 switch (wm8994->revision) { in wm8994_device_init()
443 dev_warn(wm8994->dev, in wm8994_device_init()
445 'A' + wm8994->revision); in wm8994_device_init()
457 switch (wm8994->revision) { in wm8994_device_init()
469 if (wm8994->revision > 1) in wm8994_device_init()
470 wm8994->revision++; in wm8994_device_init()
480 dev_info(wm8994->dev, "%s revision %c CUST_ID %02x\n", devname, in wm8994_device_init()
481 'A' + wm8994->revision, wm8994->cust_id); in wm8994_device_init()
483 switch (wm8994->type) { in wm8994_device_init()
487 case WM8994: in wm8994_device_init()
494 dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type); in wm8994_device_init()
499 ret = regmap_reinit_cache(wm8994->regmap, regmap_config); in wm8994_device_init()
501 dev_err(wm8994->dev, "Failed to reinit register cache: %d\n", in wm8994_device_init()
510 ret = wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET, in wm8994_device_init()
511 wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET)); in wm8994_device_init()
513 dev_err(wm8994->dev, "Failed to reset device: %d\n", ret); in wm8994_device_init()
518 ret = regmap_register_patch(wm8994->regmap, regmap_patch, in wm8994_device_init()
521 dev_err(wm8994->dev, "Failed to register patch: %d\n", in wm8994_device_init()
527 wm8994->irq_base = pdata->irq_base; in wm8994_device_init()
528 wm8994->gpio_base = pdata->gpio_base; in wm8994_device_init()
533 wm8994_set_bits(wm8994, WM8994_GPIO_1 + i, in wm8994_device_init()
538 wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven; in wm8994_device_init()
546 wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, in wm8994_device_init()
559 wm8994_set_bits(wm8994, WM8994_LDO_1 + i, in wm8994_device_init()
562 wm8994_set_bits(wm8994, WM8994_LDO_1 + i, in wm8994_device_init()
566 wm8994_irq_init(wm8994); in wm8994_device_init()
568 ret = mfd_add_devices(wm8994->dev, -1, in wm8994_device_init()
572 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); in wm8994_device_init()
576 pm_runtime_set_active(wm8994->dev); in wm8994_device_init()
577 pm_runtime_enable(wm8994->dev); in wm8994_device_init()
578 pm_runtime_idle(wm8994->dev); in wm8994_device_init()
583 wm8994_irq_exit(wm8994); in wm8994_device_init()
585 regulator_bulk_disable(wm8994->num_supplies, in wm8994_device_init()
586 wm8994->supplies); in wm8994_device_init()
588 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); in wm8994_device_init()
590 mfd_remove_devices(wm8994->dev); in wm8994_device_init()
594 static void wm8994_device_exit(struct wm8994 *wm8994) in wm8994_device_exit() argument
596 pm_runtime_get_sync(wm8994->dev); in wm8994_device_exit()
597 pm_runtime_disable(wm8994->dev); in wm8994_device_exit()
598 pm_runtime_put_noidle(wm8994->dev); in wm8994_device_exit()
599 wm8994_irq_exit(wm8994); in wm8994_device_exit()
600 regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); in wm8994_device_exit()
601 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); in wm8994_device_exit()
602 mfd_remove_devices(wm8994->dev); in wm8994_device_exit()
607 { .compatible = "wlf,wm8994", .data = (void *)WM8994 },
617 struct wm8994 *wm8994; in wm8994_i2c_probe() local
620 wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL); in wm8994_i2c_probe()
621 if (wm8994 == NULL) in wm8994_i2c_probe()
624 i2c_set_clientdata(i2c, wm8994); in wm8994_i2c_probe()
625 wm8994->dev = &i2c->dev; in wm8994_i2c_probe()
626 wm8994->irq = i2c->irq; in wm8994_i2c_probe()
631 wm8994->type = (uintptr_t)of_id->data; in wm8994_i2c_probe()
633 wm8994->type = id->driver_data; in wm8994_i2c_probe()
636 wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config); in wm8994_i2c_probe()
637 if (IS_ERR(wm8994->regmap)) { in wm8994_i2c_probe()
638 ret = PTR_ERR(wm8994->regmap); in wm8994_i2c_probe()
639 dev_err(wm8994->dev, "Failed to allocate register map: %d\n", in wm8994_i2c_probe()
644 return wm8994_device_init(wm8994, i2c->irq); in wm8994_i2c_probe()
649 struct wm8994 *wm8994 = i2c_get_clientdata(i2c); in wm8994_i2c_remove() local
651 wm8994_device_exit(wm8994); in wm8994_i2c_remove()
657 { "wm8994", WM8994 },
669 .name = "wm8994",
680 MODULE_DESCRIPTION("Core support for the WM8994 audio CODEC");