Lines Matching refs:wm8994
116 struct wm8994 *wm8994 = dev_get_drvdata(dev); in wm8994_suspend() local
121 switch (wm8994->type) { in wm8994_suspend()
124 ret = wm8994_reg_read(wm8994, WM8958_MIC_DETECT_1); in wm8994_suspend()
138 if (!wm8994->ldo_ena_always_driven) in wm8994_suspend()
139 wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, in wm8994_suspend()
146 wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET, in wm8994_suspend()
147 wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET)); in wm8994_suspend()
149 regcache_mark_dirty(wm8994->regmap); in wm8994_suspend()
154 ret = regcache_sync_region(wm8994->regmap, WM8994_GPIO_1, in wm8994_suspend()
160 ret = regcache_sync_region(wm8994->regmap, in wm8994_suspend()
166 regcache_cache_only(wm8994->regmap, true); in wm8994_suspend()
167 wm8994->suspended = true; in wm8994_suspend()
169 ret = regulator_bulk_disable(wm8994->num_supplies, in wm8994_suspend()
170 wm8994->supplies); in wm8994_suspend()
181 struct wm8994 *wm8994 = dev_get_drvdata(dev); in wm8994_resume() local
185 if (!wm8994->suspended) in wm8994_resume()
188 ret = regulator_bulk_enable(wm8994->num_supplies, in wm8994_resume()
189 wm8994->supplies); in wm8994_resume()
195 regcache_cache_only(wm8994->regmap, false); in wm8994_resume()
196 ret = regcache_sync(wm8994->regmap); in wm8994_resume()
203 wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, in wm8994_resume()
207 wm8994->suspended = false; in wm8994_resume()
212 regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); in wm8994_resume()
263 static int wm8994_set_pdata_from_of(struct wm8994 *wm8994) in wm8994_set_pdata_from_of() argument
265 struct device_node *np = wm8994->dev->of_node; in wm8994_set_pdata_from_of()
266 struct wm8994_pdata *pdata = &wm8994->pdata; in wm8994_set_pdata_from_of()
275 if (wm8994->pdata.gpio_defaults[i] == 0) in wm8994_set_pdata_from_of()
306 static int wm8994_set_pdata_from_of(struct wm8994 *wm8994) in wm8994_set_pdata_from_of() argument
315 static int wm8994_device_init(struct wm8994 *wm8994, int irq) in wm8994_device_init() argument
324 if (dev_get_platdata(wm8994->dev)) { in wm8994_device_init()
325 pdata = dev_get_platdata(wm8994->dev); in wm8994_device_init()
326 wm8994->pdata = *pdata; in wm8994_device_init()
328 pdata = &wm8994->pdata; in wm8994_device_init()
330 ret = wm8994_set_pdata_from_of(wm8994); in wm8994_device_init()
334 dev_set_drvdata(wm8994->dev, wm8994); in wm8994_device_init()
337 ret = mfd_add_devices(wm8994->dev, 0, in wm8994_device_init()
342 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); in wm8994_device_init()
346 switch (wm8994->type) { in wm8994_device_init()
348 wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies); in wm8994_device_init()
351 wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies); in wm8994_device_init()
354 wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies); in wm8994_device_init()
361 wm8994->supplies = devm_kcalloc(wm8994->dev, in wm8994_device_init()
362 wm8994->num_supplies, in wm8994_device_init()
365 if (!wm8994->supplies) { in wm8994_device_init()
370 switch (wm8994->type) { in wm8994_device_init()
373 wm8994->supplies[i].supply = wm1811_main_supplies[i]; in wm8994_device_init()
377 wm8994->supplies[i].supply = wm8994_main_supplies[i]; in wm8994_device_init()
381 wm8994->supplies[i].supply = wm8958_main_supplies[i]; in wm8994_device_init()
393 ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, in wm8994_device_init()
394 wm8994->supplies); in wm8994_device_init()
396 dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); in wm8994_device_init()
400 ret = regulator_bulk_enable(wm8994->num_supplies, wm8994->supplies); in wm8994_device_init()
402 dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); in wm8994_device_init()
406 ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); in wm8994_device_init()
408 dev_err(wm8994->dev, "Failed to read ID register\n"); in wm8994_device_init()
414 if (wm8994->type != WM1811) in wm8994_device_init()
415 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
416 wm8994->type); in wm8994_device_init()
417 wm8994->type = WM1811; in wm8994_device_init()
421 if (wm8994->type != WM8994) in wm8994_device_init()
422 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
423 wm8994->type); in wm8994_device_init()
424 wm8994->type = WM8994; in wm8994_device_init()
428 if (wm8994->type != WM8958) in wm8994_device_init()
429 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
430 wm8994->type); in wm8994_device_init()
431 wm8994->type = WM8958; in wm8994_device_init()
434 dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n", in wm8994_device_init()
440 ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION); in wm8994_device_init()
442 dev_err(wm8994->dev, "Failed to read revision register: %d\n", in wm8994_device_init()
446 wm8994->revision = ret & WM8994_CHIP_REV_MASK; in wm8994_device_init()
447 wm8994->cust_id = (ret & WM8994_CUST_ID_MASK) >> WM8994_CUST_ID_SHIFT; in wm8994_device_init()
449 switch (wm8994->type) { in wm8994_device_init()
451 switch (wm8994->revision) { in wm8994_device_init()
454 dev_warn(wm8994->dev, in wm8994_device_init()
456 'A' + wm8994->revision); in wm8994_device_init()
468 switch (wm8994->revision) { in wm8994_device_init()
480 if (wm8994->revision > 1) in wm8994_device_init()
481 wm8994->revision++; in wm8994_device_init()
491 dev_info(wm8994->dev, "%s revision %c CUST_ID %02x\n", devname, in wm8994_device_init()
492 'A' + wm8994->revision, wm8994->cust_id); in wm8994_device_init()
494 switch (wm8994->type) { in wm8994_device_init()
505 dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type); in wm8994_device_init()
510 ret = regmap_reinit_cache(wm8994->regmap, regmap_config); in wm8994_device_init()
512 dev_err(wm8994->dev, "Failed to reinit register cache: %d\n", in wm8994_device_init()
521 ret = wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET, in wm8994_device_init()
522 wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET)); in wm8994_device_init()
524 dev_err(wm8994->dev, "Failed to reset device: %d\n", ret); in wm8994_device_init()
529 ret = regmap_register_patch(wm8994->regmap, regmap_patch, in wm8994_device_init()
532 dev_err(wm8994->dev, "Failed to register patch: %d\n", in wm8994_device_init()
538 wm8994->irq_base = pdata->irq_base; in wm8994_device_init()
539 wm8994->gpio_base = pdata->gpio_base; in wm8994_device_init()
544 wm8994_set_bits(wm8994, WM8994_GPIO_1 + i, in wm8994_device_init()
549 wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven; in wm8994_device_init()
557 wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, in wm8994_device_init()
570 wm8994_set_bits(wm8994, WM8994_LDO_1 + i, in wm8994_device_init()
573 wm8994_set_bits(wm8994, WM8994_LDO_1 + i, in wm8994_device_init()
577 wm8994_irq_init(wm8994); in wm8994_device_init()
579 ret = mfd_add_devices(wm8994->dev, -1, in wm8994_device_init()
583 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); in wm8994_device_init()
587 pm_runtime_enable(wm8994->dev); in wm8994_device_init()
588 pm_runtime_idle(wm8994->dev); in wm8994_device_init()
593 wm8994_irq_exit(wm8994); in wm8994_device_init()
595 regulator_bulk_disable(wm8994->num_supplies, in wm8994_device_init()
596 wm8994->supplies); in wm8994_device_init()
598 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); in wm8994_device_init()
600 mfd_remove_devices(wm8994->dev); in wm8994_device_init()
604 static void wm8994_device_exit(struct wm8994 *wm8994) in wm8994_device_exit() argument
606 pm_runtime_disable(wm8994->dev); in wm8994_device_exit()
607 wm8994_irq_exit(wm8994); in wm8994_device_exit()
608 regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); in wm8994_device_exit()
609 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); in wm8994_device_exit()
610 mfd_remove_devices(wm8994->dev); in wm8994_device_exit()
625 struct wm8994 *wm8994; in wm8994_i2c_probe() local
628 wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL); in wm8994_i2c_probe()
629 if (wm8994 == NULL) in wm8994_i2c_probe()
632 i2c_set_clientdata(i2c, wm8994); in wm8994_i2c_probe()
633 wm8994->dev = &i2c->dev; in wm8994_i2c_probe()
634 wm8994->irq = i2c->irq; in wm8994_i2c_probe()
639 wm8994->type = (enum wm8994_type)of_id->data; in wm8994_i2c_probe()
641 wm8994->type = id->driver_data; in wm8994_i2c_probe()
644 wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config); in wm8994_i2c_probe()
645 if (IS_ERR(wm8994->regmap)) { in wm8994_i2c_probe()
646 ret = PTR_ERR(wm8994->regmap); in wm8994_i2c_probe()
647 dev_err(wm8994->dev, "Failed to allocate register map: %d\n", in wm8994_i2c_probe()
652 return wm8994_device_init(wm8994, i2c->irq); in wm8994_i2c_probe()
657 struct wm8994 *wm8994 = i2c_get_clientdata(i2c); in wm8994_i2c_remove() local
659 wm8994_device_exit(wm8994); in wm8994_i2c_remove()