Lines Matching +full:lineout2 +full:- +full:feedback
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm8994-core.c -- Device access for Wolfson WM8994
31 .name = "wm8994-ldo",
36 .name = "wm8994-ldo",
60 .name = "wm8994-codec",
66 .name = "wm8994-gpio",
119 switch (wm8994->type) { in wm8994_suspend()
136 if (!wm8994->ldo_ena_always_driven) in wm8994_suspend()
147 regcache_mark_dirty(wm8994->regmap); in wm8994_suspend()
152 ret = regcache_sync_region(wm8994->regmap, WM8994_GPIO_1, in wm8994_suspend()
158 ret = regcache_sync_region(wm8994->regmap, in wm8994_suspend()
164 regcache_cache_only(wm8994->regmap, true); in wm8994_suspend()
165 wm8994->suspended = true; in wm8994_suspend()
167 ret = regulator_bulk_disable(wm8994->num_supplies, in wm8994_suspend()
168 wm8994->supplies); in wm8994_suspend()
183 if (!wm8994->suspended) in wm8994_resume()
186 ret = regulator_bulk_enable(wm8994->num_supplies, in wm8994_resume()
187 wm8994->supplies); in wm8994_resume()
193 regcache_cache_only(wm8994->regmap, false); in wm8994_resume()
194 ret = regcache_sync(wm8994->regmap); in wm8994_resume()
205 wm8994->suspended = false; in wm8994_resume()
210 regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); in wm8994_resume()
223 ldo_pdata = &pdata->ldo[ldo]; in wm8994_ldo_in_use()
225 if (!ldo_pdata->init_data) in wm8994_ldo_in_use()
228 return ldo_pdata->init_data->num_consumer_supplies != 0; in wm8994_ldo_in_use()
262 struct device_node *np = wm8994->dev->of_node; in wm8994_set_pdata_from_of()
263 struct wm8994_pdata *pdata = &wm8994->pdata; in wm8994_set_pdata_from_of()
269 if (of_property_read_u32_array(np, "wlf,gpio-cfg", pdata->gpio_defaults, in wm8994_set_pdata_from_of()
270 ARRAY_SIZE(pdata->gpio_defaults)) >= 0) { in wm8994_set_pdata_from_of()
271 for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { in wm8994_set_pdata_from_of()
272 if (wm8994->pdata.gpio_defaults[i] == 0) in wm8994_set_pdata_from_of()
273 pdata->gpio_defaults[i] in wm8994_set_pdata_from_of()
278 of_property_read_u32_array(np, "wlf,micbias-cfg", pdata->micbias, in wm8994_set_pdata_from_of()
279 ARRAY_SIZE(pdata->micbias)); in wm8994_set_pdata_from_of()
281 pdata->lineout1_diff = !of_property_read_bool(np, "wlf,lineout1-se"); in wm8994_set_pdata_from_of()
282 pdata->lineout2_diff = !of_property_read_bool(np, "wlf,lineout2-se"); in wm8994_set_pdata_from_of()
283 pdata->lineout1fb = of_property_read_bool(np, "wlf,lineout1-feedback"); in wm8994_set_pdata_from_of()
284 pdata->lineout2fb = of_property_read_bool(np, "wlf,lineout2-feedback") || in wm8994_set_pdata_from_of()
285 of_property_read_bool(np, "wlf,ldoena-always-driven"); in wm8994_set_pdata_from_of()
287 pdata->spkmode_pu = of_property_read_bool(np, "wlf,spkmode-pu"); in wm8994_set_pdata_from_of()
289 pdata->csnaddr_pd = of_property_read_bool(np, "wlf,csnaddr-pd"); in wm8994_set_pdata_from_of()
301 * Instantiate the generic non-control parts of the device.
312 if (dev_get_platdata(wm8994->dev)) { in wm8994_device_init()
313 pdata = dev_get_platdata(wm8994->dev); in wm8994_device_init()
314 wm8994->pdata = *pdata; in wm8994_device_init()
316 pdata = &wm8994->pdata; in wm8994_device_init()
322 /* Add the on-chip regulators first for bootstrapping */ in wm8994_device_init()
323 ret = mfd_add_devices(wm8994->dev, 0, in wm8994_device_init()
328 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); in wm8994_device_init()
332 switch (wm8994->type) { in wm8994_device_init()
334 wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies); in wm8994_device_init()
337 wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies); in wm8994_device_init()
340 wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies); in wm8994_device_init()
347 wm8994->supplies = devm_kcalloc(wm8994->dev, in wm8994_device_init()
348 wm8994->num_supplies, in wm8994_device_init()
351 if (!wm8994->supplies) { in wm8994_device_init()
352 ret = -ENOMEM; in wm8994_device_init()
356 switch (wm8994->type) { in wm8994_device_init()
359 wm8994->supplies[i].supply = wm1811_main_supplies[i]; in wm8994_device_init()
363 wm8994->supplies[i].supply = wm8994_main_supplies[i]; in wm8994_device_init()
367 wm8994->supplies[i].supply = wm8958_main_supplies[i]; in wm8994_device_init()
376 * wm8994->dev's children (regulators) and those regulators are in wm8994_device_init()
379 ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, in wm8994_device_init()
380 wm8994->supplies); in wm8994_device_init()
382 if (ret != -EPROBE_DEFER) in wm8994_device_init()
383 dev_err(wm8994->dev, "Failed to get supplies: %d\n", in wm8994_device_init()
388 ret = regulator_bulk_enable(wm8994->num_supplies, wm8994->supplies); in wm8994_device_init()
390 dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); in wm8994_device_init()
396 dev_err(wm8994->dev, "Failed to read ID register\n"); in wm8994_device_init()
402 if (wm8994->type != WM1811) in wm8994_device_init()
403 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
404 wm8994->type); in wm8994_device_init()
405 wm8994->type = WM1811; in wm8994_device_init()
409 if (wm8994->type != WM8994) in wm8994_device_init()
410 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
411 wm8994->type); in wm8994_device_init()
412 wm8994->type = WM8994; in wm8994_device_init()
416 if (wm8994->type != WM8958) in wm8994_device_init()
417 dev_warn(wm8994->dev, "Device registered as type %d\n", in wm8994_device_init()
418 wm8994->type); in wm8994_device_init()
419 wm8994->type = WM8958; in wm8994_device_init()
422 dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n", in wm8994_device_init()
424 ret = -EINVAL; in wm8994_device_init()
430 dev_err(wm8994->dev, "Failed to read revision register: %d\n", in wm8994_device_init()
434 wm8994->revision = ret & WM8994_CHIP_REV_MASK; in wm8994_device_init()
435 wm8994->cust_id = (ret & WM8994_CUST_ID_MASK) >> WM8994_CUST_ID_SHIFT; in wm8994_device_init()
437 switch (wm8994->type) { in wm8994_device_init()
439 switch (wm8994->revision) { in wm8994_device_init()
442 dev_warn(wm8994->dev, in wm8994_device_init()
444 'A' + wm8994->revision); in wm8994_device_init()
456 switch (wm8994->revision) { in wm8994_device_init()
468 if (wm8994->revision > 1) in wm8994_device_init()
469 wm8994->revision++; in wm8994_device_init()
479 dev_info(wm8994->dev, "%s revision %c CUST_ID %02x\n", devname, in wm8994_device_init()
480 'A' + wm8994->revision, wm8994->cust_id); in wm8994_device_init()
482 switch (wm8994->type) { in wm8994_device_init()
493 dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type); in wm8994_device_init()
494 ret = -EINVAL; in wm8994_device_init()
498 ret = regmap_reinit_cache(wm8994->regmap, regmap_config); in wm8994_device_init()
500 dev_err(wm8994->dev, "Failed to reinit register cache: %d\n", in wm8994_device_init()
512 dev_err(wm8994->dev, "Failed to reset device: %d\n", ret); in wm8994_device_init()
517 ret = regmap_register_patch(wm8994->regmap, regmap_patch, in wm8994_device_init()
520 dev_err(wm8994->dev, "Failed to register patch: %d\n", in wm8994_device_init()
526 wm8994->irq_base = pdata->irq_base; in wm8994_device_init()
527 wm8994->gpio_base = pdata->gpio_base; in wm8994_device_init()
529 /* GPIO configuration is only applied if it's non-zero */ in wm8994_device_init()
530 for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { in wm8994_device_init()
531 if (pdata->gpio_defaults[i]) { in wm8994_device_init()
533 0xffff, pdata->gpio_defaults[i]); in wm8994_device_init()
537 wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven; in wm8994_device_init()
539 if (pdata->spkmode_pu) in wm8994_device_init()
541 if (pdata->csnaddr_pd) in wm8994_device_init()
567 ret = mfd_add_devices(wm8994->dev, -1, in wm8994_device_init()
571 dev_err(wm8994->dev, "Failed to add children: %d\n", ret); in wm8994_device_init()
575 pm_runtime_set_active(wm8994->dev); in wm8994_device_init()
576 pm_runtime_enable(wm8994->dev); in wm8994_device_init()
577 pm_runtime_idle(wm8994->dev); in wm8994_device_init()
584 regulator_bulk_disable(wm8994->num_supplies, in wm8994_device_init()
585 wm8994->supplies); in wm8994_device_init()
587 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); in wm8994_device_init()
589 mfd_remove_devices(wm8994->dev); in wm8994_device_init()
595 pm_runtime_get_sync(wm8994->dev); in wm8994_device_exit()
596 pm_runtime_disable(wm8994->dev); in wm8994_device_exit()
597 pm_runtime_put_noidle(wm8994->dev); in wm8994_device_exit()
599 regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); in wm8994_device_exit()
600 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); in wm8994_device_exit()
601 mfd_remove_devices(wm8994->dev); in wm8994_device_exit()
617 wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL); in wm8994_i2c_probe()
619 return -ENOMEM; in wm8994_i2c_probe()
622 wm8994->dev = &i2c->dev; in wm8994_i2c_probe()
623 wm8994->irq = i2c->irq; in wm8994_i2c_probe()
625 wm8994->type = (kernel_ulong_t)i2c_get_match_data(i2c); in wm8994_i2c_probe()
627 wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config); in wm8994_i2c_probe()
628 if (IS_ERR(wm8994->regmap)) { in wm8994_i2c_probe()
629 ret = PTR_ERR(wm8994->regmap); in wm8994_i2c_probe()
630 dev_err(wm8994->dev, "Failed to allocate register map: %d\n", in wm8994_i2c_probe()
635 return wm8994_device_init(wm8994, i2c->irq); in wm8994_i2c_probe()