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
18 #include "stm32-dac-core.h"
21 * struct stm32_dac_priv - stm32 DAC core private data
24 * @common: Common data for all DAC instances
33 * struct stm32_dac_cfg - DAC configuration
34 * @has_hfsel: DAC has high frequency control
58 ret = regulator_enable(priv->vref); in stm32_dac_core_hw_start()
64 ret = clk_prepare_enable(priv->pclk); in stm32_dac_core_hw_start()
73 regulator_disable(priv->vref); in stm32_dac_core_hw_start()
83 clk_disable_unprepare(priv->pclk); in stm32_dac_core_hw_stop()
84 regulator_disable(priv->vref); in stm32_dac_core_hw_stop()
89 struct device *dev = &pdev->dev; in stm32_dac_probe()
98 if (!dev->of_node) in stm32_dac_probe()
99 return -ENODEV; in stm32_dac_probe()
103 return -ENOMEM; in stm32_dac_probe()
104 platform_set_drvdata(pdev, &priv->common); in stm32_dac_probe()
107 of_match_device(dev->driver->of_match_table, dev)->data; in stm32_dac_probe()
118 priv->common.regmap = regmap; in stm32_dac_probe()
120 priv->pclk = devm_clk_get(dev, "pclk"); in stm32_dac_probe()
121 if (IS_ERR(priv->pclk)) { in stm32_dac_probe()
122 ret = PTR_ERR(priv->pclk); in stm32_dac_probe()
127 priv->vref = devm_regulator_get(dev, "vref"); in stm32_dac_probe()
128 if (IS_ERR(priv->vref)) { in stm32_dac_probe()
129 ret = PTR_ERR(priv->vref); in stm32_dac_probe()
142 ret = regulator_get_voltage(priv->vref); in stm32_dac_probe()
147 priv->common.vref_mv = ret / 1000; in stm32_dac_probe()
148 dev_dbg(dev, "vref+=%dmV\n", priv->common.vref_mv); in stm32_dac_probe()
162 if (cfg && cfg->has_hfsel) { in stm32_dac_probe()
164 priv->common.hfsel = (clk_get_rate(priv->pclk) > 80000000UL); in stm32_dac_probe()
167 priv->common.hfsel ? in stm32_dac_probe()
174 ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, dev); in stm32_dac_probe()
196 pm_runtime_get_sync(&pdev->dev); in stm32_dac_remove()
197 of_platform_depopulate(&pdev->dev); in stm32_dac_remove()
198 stm32_dac_core_hw_stop(&pdev->dev); in stm32_dac_remove()
199 pm_runtime_disable(&pdev->dev); in stm32_dac_remove()
200 pm_runtime_set_suspended(&pdev->dev); in stm32_dac_remove()
201 pm_runtime_put_noidle(&pdev->dev); in stm32_dac_remove()
212 if (priv->common.hfsel) { in stm32_dac_core_resume()
214 ret = regmap_update_bits(priv->common.regmap, STM32_DAC_CR, in stm32_dac_core_resume()
249 .compatible = "st,stm32f4-dac-core",
251 .compatible = "st,stm32h7-dac-core",
262 .name = "stm32-dac-core",
270 MODULE_DESCRIPTION("STMicroelectronics STM32 DAC core driver");
272 MODULE_ALIAS("platform:stm32-dac-core");