Lines Matching +full:stm32 +full:- +full:dac
1 // SPDX-License-Identifier: GPL-2.0
3 * This file is part of STM32 DAC driver
5 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
21 #include "stm32-dac-core.h"
24 * struct stm32_dac_priv - stm32 DAC core private data
27 * @common: Common data for all DAC instances
36 * struct stm32_dac_cfg - DAC configuration
37 * @has_hfsel: DAC has high frequency control
61 ret = regulator_enable(priv->vref); in stm32_dac_core_hw_start()
67 ret = clk_prepare_enable(priv->pclk); in stm32_dac_core_hw_start()
76 regulator_disable(priv->vref); in stm32_dac_core_hw_start()
86 clk_disable_unprepare(priv->pclk); in stm32_dac_core_hw_stop()
87 regulator_disable(priv->vref); in stm32_dac_core_hw_stop()
92 struct device *dev = &pdev->dev; in stm32_dac_probe()
102 return -ENOMEM; in stm32_dac_probe()
103 platform_set_drvdata(pdev, &priv->common); in stm32_dac_probe()
115 priv->common.regmap = regmap; in stm32_dac_probe()
117 priv->pclk = devm_clk_get(dev, "pclk"); in stm32_dac_probe()
118 if (IS_ERR(priv->pclk)) in stm32_dac_probe()
119 return dev_err_probe(dev, PTR_ERR(priv->pclk), "pclk get failed\n"); in stm32_dac_probe()
121 priv->vref = devm_regulator_get(dev, "vref"); in stm32_dac_probe()
122 if (IS_ERR(priv->vref)) in stm32_dac_probe()
123 return dev_err_probe(dev, PTR_ERR(priv->vref), "vref get failed\n"); in stm32_dac_probe()
133 ret = regulator_get_voltage(priv->vref); in stm32_dac_probe()
138 priv->common.vref_mv = ret / 1000; in stm32_dac_probe()
139 dev_dbg(dev, "vref+=%dmV\n", priv->common.vref_mv); in stm32_dac_probe()
153 if (cfg && cfg->has_hfsel) { in stm32_dac_probe()
155 priv->common.hfsel = (clk_get_rate(priv->pclk) > 80000000UL); in stm32_dac_probe()
158 priv->common.hfsel ? in stm32_dac_probe()
165 ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, dev); in stm32_dac_probe()
187 pm_runtime_get_sync(&pdev->dev); in stm32_dac_remove()
188 of_platform_depopulate(&pdev->dev); in stm32_dac_remove()
189 stm32_dac_core_hw_stop(&pdev->dev); in stm32_dac_remove()
190 pm_runtime_disable(&pdev->dev); in stm32_dac_remove()
191 pm_runtime_set_suspended(&pdev->dev); in stm32_dac_remove()
192 pm_runtime_put_noidle(&pdev->dev); in stm32_dac_remove()
201 if (priv->common.hfsel) { in stm32_dac_core_resume()
203 ret = regmap_set_bits(priv->common.regmap, STM32_DAC_CR, in stm32_dac_core_resume()
237 .compatible = "st,stm32f4-dac-core",
239 .compatible = "st,stm32h7-dac-core",
250 .name = "stm32-dac-core",
258 MODULE_DESCRIPTION("STMicroelectronics STM32 DAC core driver");
260 MODULE_ALIAS("platform:stm32-dac-core");