Lines Matching full:dfsdm
3 * This file is part the core part STM32 DFSDM driver
20 #include "stm32-dfsdm.h"
86 struct stm32_dfsdm dfsdm; /* common data exported for all instances */ member
91 struct clk *clk; /* DFSDM clock */
95 static inline struct dfsdm_priv *to_stm32_dfsdm_priv(struct stm32_dfsdm *dfsdm) in to_stm32_dfsdm_priv() argument
97 return container_of(dfsdm, struct dfsdm_priv, dfsdm); in to_stm32_dfsdm_priv()
100 static int stm32_dfsdm_clk_prepare_enable(struct stm32_dfsdm *dfsdm) in stm32_dfsdm_clk_prepare_enable() argument
102 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_clk_prepare_enable()
116 static void stm32_dfsdm_clk_disable_unprepare(struct stm32_dfsdm *dfsdm) in stm32_dfsdm_clk_disable_unprepare() argument
118 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_clk_disable_unprepare()
126 * stm32_dfsdm_start_dfsdm - start global dfsdm interface.
129 * @dfsdm: Handle used to retrieve dfsdm context.
131 int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm) in stm32_dfsdm_start_dfsdm() argument
133 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_start_dfsdm()
145 /* select clock source, e.g. 0 for "dfsdm" or 1 for "audio" */ in stm32_dfsdm_start_dfsdm()
147 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_start_dfsdm()
154 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_start_dfsdm()
160 /* Global enable of DFSDM interface */ in stm32_dfsdm_start_dfsdm()
161 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_start_dfsdm()
183 * stm32_dfsdm_stop_dfsdm - stop global DFSDM interface.
186 * @dfsdm: Handle used to retrieve dfsdm context.
188 int stm32_dfsdm_stop_dfsdm(struct stm32_dfsdm *dfsdm) in stm32_dfsdm_stop_dfsdm() argument
190 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_stop_dfsdm()
194 /* Global disable of DFSDM interface */ in stm32_dfsdm_stop_dfsdm()
195 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_stop_dfsdm()
202 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_stop_dfsdm()
229 priv->dfsdm.base = devm_platform_get_and_ioremap_resource(pdev, 0, in stm32_dfsdm_parse_of()
231 if (IS_ERR(priv->dfsdm.base)) in stm32_dfsdm_parse_of()
232 return PTR_ERR(priv->dfsdm.base); in stm32_dfsdm_parse_of()
234 priv->dfsdm.phys_base = res->start; in stm32_dfsdm_parse_of()
237 * "dfsdm" clock is mandatory for DFSDM peripheral clocking. in stm32_dfsdm_parse_of()
238 * "dfsdm" or "audio" clocks can be used as source clock for in stm32_dfsdm_parse_of()
242 priv->clk = devm_clk_get(&pdev->dev, "dfsdm"); in stm32_dfsdm_parse_of()
277 priv->dfsdm.spi_master_freq = clk_freq / (priv->spi_clk_out_div + 1); in stm32_dfsdm_parse_of()
290 .compatible = "st,stm32h7-dfsdm",
294 .compatible = "st,stm32mp1-dfsdm",
305 struct stm32_dfsdm *dfsdm; in stm32_dfsdm_probe() local
316 dfsdm = &priv->dfsdm; in stm32_dfsdm_probe()
317 dfsdm->fl_list = devm_kcalloc(&pdev->dev, dev_data->num_filters, in stm32_dfsdm_probe()
318 sizeof(*dfsdm->fl_list), GFP_KERNEL); in stm32_dfsdm_probe()
319 if (!dfsdm->fl_list) in stm32_dfsdm_probe()
322 dfsdm->num_fls = dev_data->num_filters; in stm32_dfsdm_probe()
323 dfsdm->ch_list = devm_kcalloc(&pdev->dev, dev_data->num_channels, in stm32_dfsdm_probe()
324 sizeof(*dfsdm->ch_list), in stm32_dfsdm_probe()
326 if (!dfsdm->ch_list) in stm32_dfsdm_probe()
328 dfsdm->num_chs = dev_data->num_channels; in stm32_dfsdm_probe()
334 dfsdm->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "dfsdm", in stm32_dfsdm_probe()
335 dfsdm->base, in stm32_dfsdm_probe()
337 if (IS_ERR(dfsdm->regmap)) { in stm32_dfsdm_probe()
338 ret = PTR_ERR(dfsdm->regmap); in stm32_dfsdm_probe()
344 platform_set_drvdata(pdev, dfsdm); in stm32_dfsdm_probe()
346 ret = stm32_dfsdm_clk_prepare_enable(dfsdm); in stm32_dfsdm_probe()
368 stm32_dfsdm_clk_disable_unprepare(dfsdm); in stm32_dfsdm_probe()
375 struct stm32_dfsdm *dfsdm = platform_get_drvdata(pdev); in stm32_dfsdm_core_remove() local
382 stm32_dfsdm_clk_disable_unprepare(dfsdm); in stm32_dfsdm_core_remove()
389 struct stm32_dfsdm *dfsdm = dev_get_drvdata(dev); in stm32_dfsdm_core_suspend() local
390 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_core_suspend()
405 struct stm32_dfsdm *dfsdm = dev_get_drvdata(dev); in stm32_dfsdm_core_resume() local
406 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_core_resume()
422 struct stm32_dfsdm *dfsdm = dev_get_drvdata(dev); in stm32_dfsdm_core_runtime_suspend() local
424 stm32_dfsdm_clk_disable_unprepare(dfsdm); in stm32_dfsdm_core_runtime_suspend()
431 struct stm32_dfsdm *dfsdm = dev_get_drvdata(dev); in stm32_dfsdm_core_runtime_resume() local
433 return stm32_dfsdm_clk_prepare_enable(dfsdm); in stm32_dfsdm_core_runtime_resume()
448 .name = "stm32-dfsdm",
457 MODULE_DESCRIPTION("STMicroelectronics STM32 dfsdm driver");