Lines Matching +full:micvdd +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2015-2018 Cirrus Logic
51 .name = "madera-ldo1",
57 "MICVDD",
63 { .name = "madera-pinctrl", },
64 { .name = "madera-irq", },
65 { .name = "madera-gpio", },
67 .name = "madera-extcon",
69 .num_parent_supplies = 1, /* We only need MICVDD */
72 .name = "cs47l15-codec",
79 "MICVDD",
87 { .name = "madera-pinctrl", },
88 { .name = "madera-irq", },
89 { .name = "madera-micsupp", },
90 { .name = "madera-gpio", },
92 .name = "madera-extcon",
94 .num_parent_supplies = 1, /* We only need MICVDD */
97 .name = "cs47l35-codec",
104 "MICVDD",
115 { .name = "madera-pinctrl", },
116 { .name = "madera-irq", },
117 { .name = "madera-micsupp", },
118 { .name = "madera-gpio", },
120 .name = "madera-extcon",
122 .num_parent_supplies = 1, /* We only need MICVDD */
125 .name = "cs47l85-codec",
132 "MICVDD",
141 { .name = "madera-pinctrl", },
142 { .name = "madera-irq", },
143 { .name = "madera-micsupp", },
144 { .name = "madera-gpio", },
146 .name = "madera-extcon",
148 .num_parent_supplies = 1, /* We only need MICVDD */
151 .name = "cs47l90-codec",
158 "MICVDD",
164 { .name = "madera-pinctrl", },
165 { .name = "madera-irq", },
166 { .name = "madera-micsupp", },
167 { .name = "madera-gpio", },
169 .name = "madera-extcon",
171 .num_parent_supplies = 1, /* We only need MICVDD */
174 .name = "cs47l92-codec",
180 /* Used by madera-i2c and madera-spi drivers */
225 regmap_read(madera->regmap, MADERA_IRQ1_RAW_STATUS_1, &val); in madera_wait_for_boot_noack()
230 regmap_read(madera->regmap, MADERA_IRQ1_RAW_STATUS_1, &val); in madera_wait_for_boot_noack()
234 dev_err(madera->dev, "Polling BOOT_DONE_STS timed out\n"); in madera_wait_for_boot_noack()
235 ret = -ETIMEDOUT; in madera_wait_for_boot_noack()
249 regmap_write(madera->regmap, MADERA_IRQ1_STATUS_1, in madera_wait_for_boot()
252 pm_runtime_mark_last_busy(madera->dev); in madera_wait_for_boot()
261 ret = regmap_write(madera->regmap, MADERA_SOFTWARE_RESET, 0); in madera_soft_reset()
263 dev_err(madera->dev, "Failed to soft reset device: %d\n", ret); in madera_soft_reset()
276 * There are many existing out-of-tree users of these codecs that we in madera_enable_hard_reset()
280 gpiod_set_raw_value_cansleep(madera->pdata.reset, 0); in madera_enable_hard_reset()
285 gpiod_set_raw_value_cansleep(madera->pdata.reset, 1); in madera_disable_hard_reset()
297 if (!madera->reset_errata) in madera_runtime_resume()
300 ret = regulator_enable(madera->dcvdd); in madera_runtime_resume()
306 regcache_cache_only(madera->regmap, false); in madera_runtime_resume()
307 regcache_cache_only(madera->regmap_32bit, false); in madera_runtime_resume()
309 if (madera->reset_errata) in madera_runtime_resume()
314 if (!madera->pdata.reset || madera->reset_errata) { in madera_runtime_resume()
330 ret = regcache_sync(madera->regmap); in madera_runtime_resume()
332 dev_err(dev, "Failed to restore 16-bit register cache\n"); in madera_runtime_resume()
336 ret = regcache_sync(madera->regmap_32bit); in madera_runtime_resume()
338 dev_err(dev, "Failed to restore 32-bit register cache\n"); in madera_runtime_resume()
345 regcache_cache_only(madera->regmap_32bit, true); in madera_runtime_resume()
346 regcache_cache_only(madera->regmap, true); in madera_runtime_resume()
347 regulator_disable(madera->dcvdd); in madera_runtime_resume()
356 dev_dbg(madera->dev, "Entering sleep mode\n"); in madera_runtime_suspend()
358 regcache_cache_only(madera->regmap, true); in madera_runtime_suspend()
359 regcache_mark_dirty(madera->regmap); in madera_runtime_suspend()
360 regcache_cache_only(madera->regmap_32bit, true); in madera_runtime_suspend()
361 regcache_mark_dirty(madera->regmap_32bit); in madera_runtime_suspend()
363 regulator_disable(madera->dcvdd); in madera_runtime_suspend()
394 if (madera->pdata.reset) in madera_get_reset_gpio()
397 reset = devm_gpiod_get_optional(madera->dev, "reset", GPIOD_OUT_LOW); in madera_get_reset_gpio()
399 return dev_err_probe(madera->dev, PTR_ERR(reset), in madera_get_reset_gpio()
408 dev_warn(madera->dev, in madera_get_reset_gpio()
411 madera->pdata.reset = reset; in madera_get_reset_gpio()
422 switch (madera->type) { in madera_set_micbias_info()
424 madera->num_micbias = 1; in madera_set_micbias_info()
425 madera->num_childbias[0] = 3; in madera_set_micbias_info()
428 madera->num_micbias = 2; in madera_set_micbias_info()
429 madera->num_childbias[0] = 2; in madera_set_micbias_info()
430 madera->num_childbias[1] = 2; in madera_set_micbias_info()
434 madera->num_micbias = 4; in madera_set_micbias_info()
439 madera->num_micbias = 2; in madera_set_micbias_info()
440 madera->num_childbias[0] = 4; in madera_set_micbias_info()
441 madera->num_childbias[1] = 4; in madera_set_micbias_info()
446 madera->num_micbias = 2; in madera_set_micbias_info()
447 madera->num_childbias[0] = 4; in madera_set_micbias_info()
448 madera->num_childbias[1] = 2; in madera_set_micbias_info()
457 struct device *dev = madera->dev; in madera_dev_init()
464 dev_set_drvdata(madera->dev, madera); in madera_dev_init()
465 BLOCKING_INIT_NOTIFIER_HEAD(&madera->notifier); in madera_dev_init()
466 mutex_init(&madera->dapm_ptr_lock); in madera_dev_init()
474 if (dev_get_platdata(madera->dev)) { in madera_dev_init()
475 memcpy(&madera->pdata, dev_get_platdata(madera->dev), in madera_dev_init()
476 sizeof(madera->pdata)); in madera_dev_init()
479 madera->mclk[MADERA_MCLK1].id = "mclk1"; in madera_dev_init()
480 madera->mclk[MADERA_MCLK2].id = "mclk2"; in madera_dev_init()
481 madera->mclk[MADERA_MCLK3].id = "mclk3"; in madera_dev_init()
483 ret = devm_clk_bulk_get_optional(madera->dev, ARRAY_SIZE(madera->mclk), in madera_dev_init()
484 madera->mclk); in madera_dev_init()
486 dev_err(madera->dev, "Failed to get clocks: %d\n", ret); in madera_dev_init()
491 if (!madera->mclk[MADERA_MCLK2].clk) in madera_dev_init()
492 dev_warn(madera->dev, "Missing MCLK2, requires 32kHz clock\n"); in madera_dev_init()
498 regcache_cache_only(madera->regmap, true); in madera_dev_init()
499 regcache_cache_only(madera->regmap_32bit, true); in madera_dev_init()
502 madera->core_supplies[i].supply = madera_core_supplies[i]; in madera_dev_init()
504 madera->num_core_supplies = ARRAY_SIZE(madera_core_supplies); in madera_dev_init()
511 switch (madera->type) { in madera_dev_init()
513 madera->reset_errata = true; in madera_dev_init()
524 ret = mfd_add_devices(madera->dev, PLATFORM_DEVID_NONE, in madera_dev_init()
535 dev_err(madera->dev, "Unknown device type %d\n", madera->type); in madera_dev_init()
536 return -ENODEV; in madera_dev_init()
539 ret = devm_regulator_bulk_get(dev, madera->num_core_supplies, in madera_dev_init()
540 madera->core_supplies); in madera_dev_init()
551 madera->dcvdd = regulator_get(madera->dev, "DCVDD"); in madera_dev_init()
552 if (IS_ERR(madera->dcvdd)) { in madera_dev_init()
553 ret = PTR_ERR(madera->dcvdd); in madera_dev_init()
558 ret = regulator_bulk_enable(madera->num_core_supplies, in madera_dev_init()
559 madera->core_supplies); in madera_dev_init()
565 if (madera->reset_errata) in madera_dev_init()
568 ret = regulator_enable(madera->dcvdd); in madera_dev_init()
574 if (madera->reset_errata) in madera_dev_init()
579 regcache_cache_only(madera->regmap, false); in madera_dev_init()
580 regcache_cache_only(madera->regmap_32bit, false); in madera_dev_init()
584 dev_err(madera->dev, "Device failed initial boot: %d\n", ret); in madera_dev_init()
592 ret = regmap_read(madera->regmap, MADERA_SOFTWARE_RESET, &hwid); in madera_dev_init()
601 switch (madera->type) { in madera_dev_init()
614 switch (madera->type) { in madera_dev_init()
627 switch (madera->type) { in madera_dev_init()
641 switch (madera->type) { in madera_dev_init()
655 switch (madera->type) { in madera_dev_init()
669 dev_err(madera->dev, "Unknown device ID: %x\n", hwid); in madera_dev_init()
670 ret = -EINVAL; in madera_dev_init()
675 dev_err(madera->dev, "Device ID 0x%x not a %s\n", hwid, in madera_dev_init()
676 madera->type_name); in madera_dev_init()
677 ret = -ENODEV; in madera_dev_init()
685 if (!madera->pdata.reset || madera->reset_errata) { in madera_dev_init()
693 dev_err(madera->dev, "Failed to clear boot done: %d\n", ret); in madera_dev_init()
697 ret = regmap_read(madera->regmap, MADERA_HARDWARE_REVISION, in madera_dev_init()
698 &madera->rev); in madera_dev_init()
703 madera->rev &= MADERA_HW_REVISION_MASK; in madera_dev_init()
705 dev_info(dev, "%s silicon revision %d\n", madera->type_name, in madera_dev_init()
706 madera->rev); in madera_dev_init()
712 dev_err(madera->dev, "Failed to apply patch %d\n", ret); in madera_dev_init()
718 ret = clk_prepare_enable(madera->mclk[MADERA_MCLK2].clk); in madera_dev_init()
720 dev_err(madera->dev, "Failed to enable 32k clock: %d\n", ret); in madera_dev_init()
724 ret = regmap_update_bits(madera->regmap, in madera_dev_init()
729 dev_err(madera->dev, "Failed to init 32k clock: %d\n", ret); in madera_dev_init()
733 pm_runtime_set_active(madera->dev); in madera_dev_init()
734 pm_runtime_enable(madera->dev); in madera_dev_init()
735 pm_runtime_set_autosuspend_delay(madera->dev, 100); in madera_dev_init()
736 pm_runtime_use_autosuspend(madera->dev); in madera_dev_init()
739 ret = mfd_add_devices(madera->dev, PLATFORM_DEVID_NONE, in madera_dev_init()
743 dev_err(madera->dev, "Failed to add subdevices: %d\n", ret); in madera_dev_init()
750 pm_runtime_disable(madera->dev); in madera_dev_init()
752 clk_disable_unprepare(madera->mclk[MADERA_MCLK2].clk); in madera_dev_init()
755 regulator_disable(madera->dcvdd); in madera_dev_init()
757 regulator_bulk_disable(madera->num_core_supplies, in madera_dev_init()
758 madera->core_supplies); in madera_dev_init()
760 regulator_put(madera->dcvdd); in madera_dev_init()
771 disable_irq(madera->irq); in madera_dev_exit()
773 pm_runtime_get_sync(madera->dev); in madera_dev_exit()
775 mfd_remove_devices(madera->dev); in madera_dev_exit()
777 pm_runtime_disable(madera->dev); in madera_dev_exit()
779 regulator_disable(madera->dcvdd); in madera_dev_exit()
780 regulator_put(madera->dcvdd); in madera_dev_exit()
782 mfd_remove_devices_late(madera->dev); in madera_dev_exit()
784 pm_runtime_set_suspended(madera->dev); in madera_dev_exit()
785 pm_runtime_put_noidle(madera->dev); in madera_dev_exit()
787 clk_disable_unprepare(madera->mclk[MADERA_MCLK2].clk); in madera_dev_exit()
791 regulator_bulk_disable(madera->num_core_supplies, in madera_dev_exit()
792 madera->core_supplies); in madera_dev_exit()