Lines Matching +full:cpvdd +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm8994-core.c -- Device access for Wolfson WM8994
32 .name = "wm8994-ldo",
37 .name = "wm8994-ldo",
61 .name = "wm8994-codec",
67 .name = "wm8994-gpio",
76 * and should be handled via the standard regulator API supply
86 "CPVDD",
96 "CPVDD",
108 "CPVDD",
120 switch (wm8994->type) { in wm8994_suspend()
137 if (!wm8994->ldo_ena_always_driven) 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()
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()
206 wm8994->suspended = false; in wm8994_resume()
211 regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); in wm8994_resume()
224 ldo_pdata = &pdata->ldo[ldo]; in wm8994_ldo_in_use()
226 if (!ldo_pdata->init_data) in wm8994_ldo_in_use()
229 return ldo_pdata->init_data->num_consumer_supplies != 0; in wm8994_ldo_in_use()
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()
270 if (of_property_read_u32_array(np, "wlf,gpio-cfg", pdata->gpio_defaults, in wm8994_set_pdata_from_of()
271 ARRAY_SIZE(pdata->gpio_defaults)) >= 0) { in wm8994_set_pdata_from_of()
272 for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { in wm8994_set_pdata_from_of()
273 if (wm8994->pdata.gpio_defaults[i] == 0) in wm8994_set_pdata_from_of()
274 pdata->gpio_defaults[i] in wm8994_set_pdata_from_of()
279 of_property_read_u32_array(np, "wlf,micbias-cfg", pdata->micbias, in wm8994_set_pdata_from_of()
280 ARRAY_SIZE(pdata->micbias)); in wm8994_set_pdata_from_of()
282 pdata->lineout1_diff = !of_property_read_bool(np, "wlf,lineout1-se"); in wm8994_set_pdata_from_of()
283 pdata->lineout2_diff = !of_property_read_bool(np, "wlf,lineout2-se"); in wm8994_set_pdata_from_of()
284 pdata->lineout1fb = of_property_read_bool(np, "wlf,lineout1-feedback"); in wm8994_set_pdata_from_of()
285 pdata->lineout2fb = of_property_read_bool(np, "wlf,lineout2-feedback") || in wm8994_set_pdata_from_of()
286 of_property_read_bool(np, "wlf,ldoena-always-driven"); in wm8994_set_pdata_from_of()
288 pdata->spkmode_pu = of_property_read_bool(np, "wlf,spkmode-pu"); in wm8994_set_pdata_from_of()
290 pdata->csnaddr_pd = of_property_read_bool(np, "wlf,csnaddr-pd"); in wm8994_set_pdata_from_of()
302 * Instantiate the generic non-control parts of the device.
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()
323 /* Add the on-chip regulators first for bootstrapping */ 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()
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()
353 ret = -ENOMEM; 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()
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()
383 if (ret != -EPROBE_DEFER) 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()
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()
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()
425 ret = -EINVAL; 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()
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()
494 dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type); in wm8994_device_init()
495 ret = -EINVAL; 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()
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()
530 /* GPIO configuration is only applied if it's non-zero */ in wm8994_device_init()
531 for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { in wm8994_device_init()
532 if (pdata->gpio_defaults[i]) { in wm8994_device_init()
534 0xffff, pdata->gpio_defaults[i]); in wm8994_device_init()
538 wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven; in wm8994_device_init()
540 if (pdata->spkmode_pu) in wm8994_device_init()
542 if (pdata->csnaddr_pd) 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()
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()
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()
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()
620 wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL); in wm8994_i2c_probe()
622 return -ENOMEM; in wm8994_i2c_probe()
625 wm8994->dev = &i2c->dev; in wm8994_i2c_probe()
626 wm8994->irq = i2c->irq; in wm8994_i2c_probe()
628 if (i2c->dev.of_node) { in wm8994_i2c_probe()
629 of_id = of_match_device(wm8994_of_match, &i2c->dev); 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()