Lines Matching +full:codec +full:- +full:mclk1

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2015-2018 Cirrus Logic
50 .name = "madera-ldo1",
62 { .name = "madera-pinctrl", },
63 { .name = "madera-irq", },
64 { .name = "madera-gpio", },
66 .name = "madera-extcon",
71 .name = "cs47l15-codec",
86 { .name = "madera-pinctrl", },
87 { .name = "madera-irq", },
88 { .name = "madera-micsupp", },
89 { .name = "madera-gpio", },
91 .name = "madera-extcon",
96 .name = "cs47l35-codec",
114 { .name = "madera-pinctrl", },
115 { .name = "madera-irq", },
116 { .name = "madera-micsupp", },
117 { .name = "madera-gpio", },
119 .name = "madera-extcon",
124 .name = "cs47l85-codec",
140 { .name = "madera-pinctrl", },
141 { .name = "madera-irq", },
142 { .name = "madera-micsupp", },
143 { .name = "madera-gpio", },
145 .name = "madera-extcon",
150 .name = "cs47l90-codec",
163 { .name = "madera-pinctrl", },
164 { .name = "madera-irq", },
165 { .name = "madera-micsupp", },
166 { .name = "madera-gpio", },
168 .name = "madera-extcon",
173 .name = "cs47l92-codec",
179 /* Used by madera-i2c and madera-spi drivers */
224 regmap_read(madera->regmap, MADERA_IRQ1_RAW_STATUS_1, &val); in madera_wait_for_boot_noack()
229 regmap_read(madera->regmap, MADERA_IRQ1_RAW_STATUS_1, &val); in madera_wait_for_boot_noack()
233 dev_err(madera->dev, "Polling BOOT_DONE_STS timed out\n"); in madera_wait_for_boot_noack()
234 ret = -ETIMEDOUT; in madera_wait_for_boot_noack()
248 regmap_write(madera->regmap, MADERA_IRQ1_STATUS_1, in madera_wait_for_boot()
251 pm_runtime_mark_last_busy(madera->dev); in madera_wait_for_boot()
260 ret = regmap_write(madera->regmap, MADERA_SOFTWARE_RESET, 0); in madera_soft_reset()
262 dev_err(madera->dev, "Failed to soft reset device: %d\n", ret); in madera_soft_reset()
275 * There are many existing out-of-tree users of these codecs that we in madera_enable_hard_reset()
279 gpiod_set_raw_value_cansleep(madera->pdata.reset, 0); in madera_enable_hard_reset()
284 gpiod_set_raw_value_cansleep(madera->pdata.reset, 1); in madera_disable_hard_reset()
296 if (!madera->reset_errata) in madera_runtime_resume()
299 ret = regulator_enable(madera->dcvdd); in madera_runtime_resume()
305 regcache_cache_only(madera->regmap, false); in madera_runtime_resume()
306 regcache_cache_only(madera->regmap_32bit, false); in madera_runtime_resume()
308 if (madera->reset_errata) in madera_runtime_resume()
313 if (!madera->pdata.reset || madera->reset_errata) { in madera_runtime_resume()
329 ret = regcache_sync(madera->regmap); in madera_runtime_resume()
331 dev_err(dev, "Failed to restore 16-bit register cache\n"); in madera_runtime_resume()
335 ret = regcache_sync(madera->regmap_32bit); in madera_runtime_resume()
337 dev_err(dev, "Failed to restore 32-bit register cache\n"); in madera_runtime_resume()
344 regcache_cache_only(madera->regmap_32bit, true); in madera_runtime_resume()
345 regcache_cache_only(madera->regmap, true); in madera_runtime_resume()
346 regulator_disable(madera->dcvdd); in madera_runtime_resume()
355 dev_dbg(madera->dev, "Entering sleep mode\n"); in madera_runtime_suspend()
357 regcache_cache_only(madera->regmap, true); in madera_runtime_suspend()
358 regcache_mark_dirty(madera->regmap); in madera_runtime_suspend()
359 regcache_cache_only(madera->regmap_32bit, true); in madera_runtime_suspend()
360 regcache_mark_dirty(madera->regmap_32bit); in madera_runtime_suspend()
362 regulator_disable(madera->dcvdd); in madera_runtime_suspend()
393 if (madera->pdata.reset) in madera_get_reset_gpio()
396 reset = devm_gpiod_get_optional(madera->dev, "reset", GPIOD_OUT_LOW); in madera_get_reset_gpio()
398 return dev_err_probe(madera->dev, PTR_ERR(reset), in madera_get_reset_gpio()
407 dev_warn(madera->dev, in madera_get_reset_gpio()
410 madera->pdata.reset = reset; in madera_get_reset_gpio()
421 switch (madera->type) { in madera_set_micbias_info()
423 madera->num_micbias = 1; in madera_set_micbias_info()
424 madera->num_childbias[0] = 3; in madera_set_micbias_info()
427 madera->num_micbias = 2; in madera_set_micbias_info()
428 madera->num_childbias[0] = 2; in madera_set_micbias_info()
429 madera->num_childbias[1] = 2; in madera_set_micbias_info()
433 madera->num_micbias = 4; in madera_set_micbias_info()
438 madera->num_micbias = 2; in madera_set_micbias_info()
439 madera->num_childbias[0] = 4; in madera_set_micbias_info()
440 madera->num_childbias[1] = 4; in madera_set_micbias_info()
445 madera->num_micbias = 2; in madera_set_micbias_info()
446 madera->num_childbias[0] = 4; in madera_set_micbias_info()
447 madera->num_childbias[1] = 2; in madera_set_micbias_info()
456 struct device *dev = madera->dev; in madera_dev_init()
463 dev_set_drvdata(madera->dev, madera); in madera_dev_init()
464 BLOCKING_INIT_NOTIFIER_HEAD(&madera->notifier); in madera_dev_init()
465 mutex_init(&madera->dapm_ptr_lock); in madera_dev_init()
473 if (dev_get_platdata(madera->dev)) { in madera_dev_init()
474 memcpy(&madera->pdata, dev_get_platdata(madera->dev), in madera_dev_init()
475 sizeof(madera->pdata)); in madera_dev_init()
478 madera->mclk[MADERA_MCLK1].id = "mclk1"; in madera_dev_init()
479 madera->mclk[MADERA_MCLK2].id = "mclk2"; in madera_dev_init()
480 madera->mclk[MADERA_MCLK3].id = "mclk3"; in madera_dev_init()
482 ret = devm_clk_bulk_get_optional(madera->dev, ARRAY_SIZE(madera->mclk), in madera_dev_init()
483 madera->mclk); in madera_dev_init()
485 dev_err(madera->dev, "Failed to get clocks: %d\n", ret); in madera_dev_init()
490 if (!madera->mclk[MADERA_MCLK2].clk) in madera_dev_init()
491 dev_warn(madera->dev, "Missing MCLK2, requires 32kHz clock\n"); in madera_dev_init()
497 regcache_cache_only(madera->regmap, true); in madera_dev_init()
498 regcache_cache_only(madera->regmap_32bit, true); in madera_dev_init()
501 madera->core_supplies[i].supply = madera_core_supplies[i]; in madera_dev_init()
503 madera->num_core_supplies = ARRAY_SIZE(madera_core_supplies); in madera_dev_init()
510 switch (madera->type) { in madera_dev_init()
512 madera->reset_errata = true; in madera_dev_init()
523 ret = mfd_add_devices(madera->dev, PLATFORM_DEVID_NONE, in madera_dev_init()
534 dev_err(madera->dev, "Unknown device type %d\n", madera->type); in madera_dev_init()
535 return -ENODEV; in madera_dev_init()
538 ret = devm_regulator_bulk_get(dev, madera->num_core_supplies, in madera_dev_init()
539 madera->core_supplies); in madera_dev_init()
550 madera->dcvdd = regulator_get(madera->dev, "DCVDD"); in madera_dev_init()
551 if (IS_ERR(madera->dcvdd)) { in madera_dev_init()
552 ret = PTR_ERR(madera->dcvdd); in madera_dev_init()
557 ret = regulator_bulk_enable(madera->num_core_supplies, in madera_dev_init()
558 madera->core_supplies); in madera_dev_init()
564 if (madera->reset_errata) in madera_dev_init()
567 ret = regulator_enable(madera->dcvdd); in madera_dev_init()
573 if (madera->reset_errata) in madera_dev_init()
578 regcache_cache_only(madera->regmap, false); in madera_dev_init()
579 regcache_cache_only(madera->regmap_32bit, false); in madera_dev_init()
583 dev_err(madera->dev, "Device failed initial boot: %d\n", ret); in madera_dev_init()
591 ret = regmap_read(madera->regmap, MADERA_SOFTWARE_RESET, &hwid); in madera_dev_init()
600 switch (madera->type) { in madera_dev_init()
613 switch (madera->type) { in madera_dev_init()
626 switch (madera->type) { in madera_dev_init()
640 switch (madera->type) { in madera_dev_init()
654 switch (madera->type) { in madera_dev_init()
668 dev_err(madera->dev, "Unknown device ID: %x\n", hwid); in madera_dev_init()
669 ret = -EINVAL; in madera_dev_init()
674 dev_err(madera->dev, "Device ID 0x%x not a %s\n", hwid, in madera_dev_init()
675 madera->type_name); in madera_dev_init()
676 ret = -ENODEV; in madera_dev_init()
684 if (!madera->pdata.reset || madera->reset_errata) { in madera_dev_init()
692 dev_err(madera->dev, "Failed to clear boot done: %d\n", ret); in madera_dev_init()
696 ret = regmap_read(madera->regmap, MADERA_HARDWARE_REVISION, in madera_dev_init()
697 &madera->rev); in madera_dev_init()
702 madera->rev &= MADERA_HW_REVISION_MASK; in madera_dev_init()
704 dev_info(dev, "%s silicon revision %d\n", madera->type_name, in madera_dev_init()
705 madera->rev); in madera_dev_init()
711 dev_err(madera->dev, "Failed to apply patch %d\n", ret); in madera_dev_init()
717 ret = clk_prepare_enable(madera->mclk[MADERA_MCLK2].clk); in madera_dev_init()
719 dev_err(madera->dev, "Failed to enable 32k clock: %d\n", ret); in madera_dev_init()
723 ret = regmap_update_bits(madera->regmap, in madera_dev_init()
728 dev_err(madera->dev, "Failed to init 32k clock: %d\n", ret); in madera_dev_init()
732 pm_runtime_set_active(madera->dev); in madera_dev_init()
733 pm_runtime_enable(madera->dev); in madera_dev_init()
734 pm_runtime_set_autosuspend_delay(madera->dev, 100); in madera_dev_init()
735 pm_runtime_use_autosuspend(madera->dev); in madera_dev_init()
738 ret = mfd_add_devices(madera->dev, PLATFORM_DEVID_NONE, in madera_dev_init()
742 dev_err(madera->dev, "Failed to add subdevices: %d\n", ret); in madera_dev_init()
749 pm_runtime_disable(madera->dev); in madera_dev_init()
751 clk_disable_unprepare(madera->mclk[MADERA_MCLK2].clk); in madera_dev_init()
754 regulator_disable(madera->dcvdd); in madera_dev_init()
756 regulator_bulk_disable(madera->num_core_supplies, in madera_dev_init()
757 madera->core_supplies); in madera_dev_init()
759 regulator_put(madera->dcvdd); in madera_dev_init()
770 disable_irq(madera->irq); in madera_dev_exit()
772 pm_runtime_get_sync(madera->dev); in madera_dev_exit()
774 mfd_remove_devices(madera->dev); in madera_dev_exit()
776 pm_runtime_disable(madera->dev); in madera_dev_exit()
778 regulator_disable(madera->dcvdd); in madera_dev_exit()
779 regulator_put(madera->dcvdd); in madera_dev_exit()
781 mfd_remove_devices_late(madera->dev); in madera_dev_exit()
783 pm_runtime_set_suspended(madera->dev); in madera_dev_exit()
784 pm_runtime_put_noidle(madera->dev); in madera_dev_exit()
786 clk_disable_unprepare(madera->mclk[MADERA_MCLK2].clk); in madera_dev_exit()
790 regulator_bulk_disable(madera->num_core_supplies, in madera_dev_exit()
791 madera->core_supplies); in madera_dev_exit()