• Home
  • Raw
  • Download

Lines Matching refs:wm8994

42 int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg)  in wm8994_reg_read()  argument
47 ret = regmap_read(wm8994->regmap, reg, &val); in wm8994_reg_read()
64 int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg, in wm8994_bulk_read() argument
67 return regmap_bulk_read(wm8994->regmap, reg, buf, count); in wm8994_bulk_read()
77 int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg, in wm8994_reg_write() argument
80 return regmap_write(wm8994->regmap, reg, val); in wm8994_reg_write()
92 int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg, in wm8994_bulk_write() argument
95 return regmap_raw_write(wm8994->regmap, reg, buf, count * sizeof(u16)); in wm8994_bulk_write()
107 int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg, in wm8994_set_bits() argument
110 return regmap_update_bits(wm8994->regmap, reg, mask, val); in wm8994_set_bits()
200 struct wm8994 *wm8994 = dev_get_drvdata(dev); in wm8994_suspend() local
205 ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_1); in wm8994_suspend()
213 ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_4); in wm8994_suspend()
223 ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_5); in wm8994_suspend()
233 switch (wm8994->type) { in wm8994_suspend()
236 ret = wm8994_reg_read(wm8994, WM8958_MIC_DETECT_1); in wm8994_suspend()
248 switch (wm8994->type) { in wm8994_suspend()
250 ret = wm8994_reg_read(wm8994, WM8994_ANTIPOP_2); in wm8994_suspend()
262 switch (wm8994->type) { in wm8994_suspend()
264 ret = wm8994_reg_read(wm8994, WM8994_ANTIPOP_2); in wm8994_suspend()
278 if (!wm8994->ldo_ena_always_driven) in wm8994_suspend()
279 wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, in wm8994_suspend()
286 wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET, in wm8994_suspend()
287 wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET)); in wm8994_suspend()
289 regcache_mark_dirty(wm8994->regmap); in wm8994_suspend()
294 ret = regcache_sync_region(wm8994->regmap, WM8994_GPIO_1, in wm8994_suspend()
300 ret = regcache_sync_region(wm8994->regmap, in wm8994_suspend()
306 regcache_cache_only(wm8994->regmap, true); in wm8994_suspend()
307 wm8994->suspended = true; in wm8994_suspend()
309 ret = regulator_bulk_disable(wm8994->num_supplies, in wm8994_suspend()
310 wm8994->supplies); in wm8994_suspend()
321 struct wm8994 *wm8994 = dev_get_drvdata(dev); in wm8994_resume() local
325 if (!wm8994->suspended) in wm8994_resume()
328 ret = regulator_bulk_enable(wm8994->num_supplies, in wm8994_resume()
329 wm8994->supplies); in wm8994_resume()
335 regcache_cache_only(wm8994->regmap, false); in wm8994_resume()
336 ret = regcache_sync(wm8994->regmap); in wm8994_resume()
343 wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, in wm8994_resume()
347 wm8994->suspended = false; in wm8994_resume()
352 regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); in wm8994_resume()
403 static int wm8994_set_pdata_from_of(struct wm8994 *wm8994) in wm8994_set_pdata_from_of() argument
405 struct device_node *np = wm8994->dev->of_node; in wm8994_set_pdata_from_of()
406 struct wm8994_pdata *pdata = &wm8994->pdata; in wm8994_set_pdata_from_of()
415 if (wm8994->pdata.gpio_defaults[i] == 0) in wm8994_set_pdata_from_of()
450 static int wm8994_set_pdata_from_of(struct wm8994 *wm8994) in wm8994_set_pdata_from_of() argument
459 static int wm8994_device_init(struct wm8994 *wm8994, int irq) in wm8994_device_init() argument
468 if (dev_get_platdata(wm8994->dev)) { in wm8994_device_init()
469 pdata = dev_get_platdata(wm8994->dev); in wm8994_device_init()
470 wm8994->pdata = *pdata; in wm8994_device_init()
472 pdata = &wm8994->pdata; in wm8994_device_init()
474 ret = wm8994_set_pdata_from_of(wm8994); in wm8994_device_init()
478 dev_set_drvdata(wm8994->dev, wm8994); in wm8994_device_init()
481 ret = mfd_add_devices(wm8994->dev, -1, in wm8994_device_init()
486 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); in wm8994_device_init()
490 switch (wm8994->type) { in wm8994_device_init()
492 wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies); in wm8994_device_init()
495 wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies); in wm8994_device_init()
498 wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies); in wm8994_device_init()
505 wm8994->supplies = devm_kzalloc(wm8994->dev, in wm8994_device_init()
507 wm8994->num_supplies, GFP_KERNEL); in wm8994_device_init()
508 if (!wm8994->supplies) { in wm8994_device_init()
513 switch (wm8994->type) { in wm8994_device_init()
516 wm8994->supplies[i].supply = wm1811_main_supplies[i]; in wm8994_device_init()
520 wm8994->supplies[i].supply = wm8994_main_supplies[i]; in wm8994_device_init()
524 wm8994->supplies[i].supply = wm8958_main_supplies[i]; in wm8994_device_init()
531 ret = devm_regulator_bulk_get(wm8994->dev, wm8994->num_supplies, in wm8994_device_init()
532 wm8994->supplies); in wm8994_device_init()
534 dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); in wm8994_device_init()
538 ret = regulator_bulk_enable(wm8994->num_supplies, in wm8994_device_init()
539 wm8994->supplies); in wm8994_device_init()
541 dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); in wm8994_device_init()
545 ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); in wm8994_device_init()
547 dev_err(wm8994->dev, "Failed to read ID register\n"); in wm8994_device_init()
553 if (wm8994->type != WM1811) in wm8994_device_init()
554 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
555 wm8994->type); in wm8994_device_init()
556 wm8994->type = WM1811; in wm8994_device_init()
560 if (wm8994->type != WM8994) in wm8994_device_init()
561 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
562 wm8994->type); in wm8994_device_init()
563 wm8994->type = WM8994; in wm8994_device_init()
567 if (wm8994->type != WM8958) in wm8994_device_init()
568 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
569 wm8994->type); in wm8994_device_init()
570 wm8994->type = WM8958; in wm8994_device_init()
573 dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n", in wm8994_device_init()
579 ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION); in wm8994_device_init()
581 dev_err(wm8994->dev, "Failed to read revision register: %d\n", in wm8994_device_init()
585 wm8994->revision = ret & WM8994_CHIP_REV_MASK; in wm8994_device_init()
586 wm8994->cust_id = (ret & WM8994_CUST_ID_MASK) >> WM8994_CUST_ID_SHIFT; in wm8994_device_init()
588 switch (wm8994->type) { in wm8994_device_init()
590 switch (wm8994->revision) { in wm8994_device_init()
593 dev_warn(wm8994->dev, in wm8994_device_init()
595 'A' + wm8994->revision); in wm8994_device_init()
607 switch (wm8994->revision) { in wm8994_device_init()
619 if (wm8994->revision > 1) in wm8994_device_init()
620 wm8994->revision++; in wm8994_device_init()
630 dev_info(wm8994->dev, "%s revision %c CUST_ID %02x\n", devname, in wm8994_device_init()
631 'A' + wm8994->revision, wm8994->cust_id); in wm8994_device_init()
633 switch (wm8994->type) { in wm8994_device_init()
644 dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type); in wm8994_device_init()
648 ret = regmap_reinit_cache(wm8994->regmap, regmap_config); in wm8994_device_init()
650 dev_err(wm8994->dev, "Failed to reinit register cache: %d\n", in wm8994_device_init()
656 ret = regmap_register_patch(wm8994->regmap, regmap_patch, in wm8994_device_init()
659 dev_err(wm8994->dev, "Failed to register patch: %d\n", in wm8994_device_init()
665 wm8994->irq_base = pdata->irq_base; in wm8994_device_init()
666 wm8994->gpio_base = pdata->gpio_base; in wm8994_device_init()
671 wm8994_set_bits(wm8994, WM8994_GPIO_1 + i, in wm8994_device_init()
676 wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven; in wm8994_device_init()
682 wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, in wm8994_device_init()
695 wm8994_set_bits(wm8994, WM8994_LDO_1 + i, in wm8994_device_init()
698 wm8994_set_bits(wm8994, WM8994_LDO_1 + i, in wm8994_device_init()
702 wm8994_irq_init(wm8994); in wm8994_device_init()
704 ret = mfd_add_devices(wm8994->dev, -1, in wm8994_device_init()
708 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); in wm8994_device_init()
712 pm_runtime_enable(wm8994->dev); in wm8994_device_init()
713 pm_runtime_idle(wm8994->dev); in wm8994_device_init()
718 wm8994_irq_exit(wm8994); in wm8994_device_init()
720 regulator_bulk_disable(wm8994->num_supplies, in wm8994_device_init()
721 wm8994->supplies); in wm8994_device_init()
723 mfd_remove_devices(wm8994->dev); in wm8994_device_init()
727 static void wm8994_device_exit(struct wm8994 *wm8994) in wm8994_device_exit() argument
729 pm_runtime_disable(wm8994->dev); in wm8994_device_exit()
730 mfd_remove_devices(wm8994->dev); in wm8994_device_exit()
731 wm8994_irq_exit(wm8994); in wm8994_device_exit()
732 regulator_bulk_disable(wm8994->num_supplies, in wm8994_device_exit()
733 wm8994->supplies); in wm8994_device_exit()
748 struct wm8994 *wm8994; in wm8994_i2c_probe() local
751 wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL); in wm8994_i2c_probe()
752 if (wm8994 == NULL) in wm8994_i2c_probe()
755 i2c_set_clientdata(i2c, wm8994); in wm8994_i2c_probe()
756 wm8994->dev = &i2c->dev; in wm8994_i2c_probe()
757 wm8994->irq = i2c->irq; in wm8994_i2c_probe()
762 wm8994->type = (int)of_id->data; in wm8994_i2c_probe()
764 wm8994->type = id->driver_data; in wm8994_i2c_probe()
767 wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config); in wm8994_i2c_probe()
768 if (IS_ERR(wm8994->regmap)) { in wm8994_i2c_probe()
769 ret = PTR_ERR(wm8994->regmap); in wm8994_i2c_probe()
770 dev_err(wm8994->dev, "Failed to allocate register map: %d\n", in wm8994_i2c_probe()
775 return wm8994_device_init(wm8994, i2c->irq); in wm8994_i2c_probe()
780 struct wm8994 *wm8994 = i2c_get_clientdata(i2c); in wm8994_i2c_remove() local
782 wm8994_device_exit(wm8994); in wm8994_i2c_remove()