Lines Matching full:dfsdm

3  * This file is part the core part STM32 DFSDM driver
23 #include "stm32-dfsdm.h"
26 * struct stm32_dfsdm_dev_data - DFSDM compatible configuration data
27 * @ipid: DFSDM identification number. Used only if hardware provides identification registers
28 * @num_filters: DFSDM number of filters. Unused if identification registers are available
29 * @num_channels: DFSDM number of channels. Unused if identification registers are available
94 struct stm32_dfsdm dfsdm; /* common data exported for all instances */ member
99 struct clk *clk; /* DFSDM clock */
103 static inline struct dfsdm_priv *to_stm32_dfsdm_priv(struct stm32_dfsdm *dfsdm) in to_stm32_dfsdm_priv() argument
105 return container_of(dfsdm, struct dfsdm_priv, dfsdm); in to_stm32_dfsdm_priv()
108 static int stm32_dfsdm_clk_prepare_enable(struct stm32_dfsdm *dfsdm) in stm32_dfsdm_clk_prepare_enable() argument
110 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_clk_prepare_enable()
124 static void stm32_dfsdm_clk_disable_unprepare(struct stm32_dfsdm *dfsdm) in stm32_dfsdm_clk_disable_unprepare() argument
126 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_clk_disable_unprepare()
133 * stm32_dfsdm_start_dfsdm - start global dfsdm interface.
136 * @dfsdm: Handle used to retrieve dfsdm context.
138 int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm) in stm32_dfsdm_start_dfsdm() argument
140 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_start_dfsdm()
150 /* select clock source, e.g. 0 for "dfsdm" or 1 for "audio" */ in stm32_dfsdm_start_dfsdm()
152 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_start_dfsdm()
159 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_start_dfsdm()
165 /* Global enable of DFSDM interface */ in stm32_dfsdm_start_dfsdm()
166 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_start_dfsdm()
188 * stm32_dfsdm_stop_dfsdm - stop global DFSDM interface.
191 * @dfsdm: Handle used to retrieve dfsdm context.
193 int stm32_dfsdm_stop_dfsdm(struct stm32_dfsdm *dfsdm) in stm32_dfsdm_stop_dfsdm() argument
195 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_stop_dfsdm()
199 /* Global disable of DFSDM interface */ in stm32_dfsdm_stop_dfsdm()
200 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_stop_dfsdm()
207 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), in stm32_dfsdm_stop_dfsdm()
234 priv->dfsdm.base = devm_platform_get_and_ioremap_resource(pdev, 0, in stm32_dfsdm_parse_of()
236 if (IS_ERR(priv->dfsdm.base)) in stm32_dfsdm_parse_of()
237 return PTR_ERR(priv->dfsdm.base); in stm32_dfsdm_parse_of()
239 priv->dfsdm.phys_base = res->start; in stm32_dfsdm_parse_of()
242 * "dfsdm" clock is mandatory for DFSDM peripheral clocking. in stm32_dfsdm_parse_of()
243 * "dfsdm" or "audio" clocks can be used as source clock for in stm32_dfsdm_parse_of()
247 priv->clk = devm_clk_get(&pdev->dev, "dfsdm"); in stm32_dfsdm_parse_of()
282 priv->dfsdm.spi_master_freq = clk_freq / (priv->spi_clk_out_div + 1); in stm32_dfsdm_parse_of()
295 .compatible = "st,stm32h7-dfsdm",
299 .compatible = "st,stm32mp1-dfsdm",
312 struct stm32_dfsdm *dfsdm = &priv->dfsdm; in stm32_dfsdm_probe_identification() local
318 dfsdm->num_fls = dev_data->num_filters; in stm32_dfsdm_probe_identification()
319 dfsdm->num_chs = dev_data->num_channels; in stm32_dfsdm_probe_identification()
323 ret = regmap_read(dfsdm->regmap, DFSDM_IPIDR, &id); in stm32_dfsdm_probe_identification()
336 /* Count only child nodes with dfsdm compatible */ in stm32_dfsdm_probe_identification()
337 if (strstr(compat, "dfsdm")) in stm32_dfsdm_probe_identification()
341 ret = regmap_read(dfsdm->regmap, DFSDM_HWCFGR, &val); in stm32_dfsdm_probe_identification()
345 dfsdm->num_fls = FIELD_GET(DFSDM_HWCFGR_NBF_MASK, val); in stm32_dfsdm_probe_identification()
346 dfsdm->num_chs = FIELD_GET(DFSDM_HWCFGR_NBT_MASK, val); in stm32_dfsdm_probe_identification()
348 if (count > dfsdm->num_fls) { in stm32_dfsdm_probe_identification()
353 ret = regmap_read(dfsdm->regmap, DFSDM_VERR, &val); in stm32_dfsdm_probe_identification()
357 dev_dbg(&pdev->dev, "DFSDM version: %lu.%lu. %d channels/%d filters\n", in stm32_dfsdm_probe_identification()
360 dfsdm->num_chs, dfsdm->num_fls); in stm32_dfsdm_probe_identification()
369 struct stm32_dfsdm *dfsdm; in stm32_dfsdm_probe() local
380 dfsdm = &priv->dfsdm; in stm32_dfsdm_probe()
386 dfsdm->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "dfsdm", in stm32_dfsdm_probe()
387 dfsdm->base, in stm32_dfsdm_probe()
389 if (IS_ERR(dfsdm->regmap)) { in stm32_dfsdm_probe()
390 ret = PTR_ERR(dfsdm->regmap); in stm32_dfsdm_probe()
400 dfsdm->fl_list = devm_kcalloc(&pdev->dev, dfsdm->num_fls, in stm32_dfsdm_probe()
401 sizeof(*dfsdm->fl_list), GFP_KERNEL); in stm32_dfsdm_probe()
402 if (!dfsdm->fl_list) in stm32_dfsdm_probe()
405 dfsdm->ch_list = devm_kcalloc(&pdev->dev, dfsdm->num_chs, in stm32_dfsdm_probe()
406 sizeof(*dfsdm->ch_list), GFP_KERNEL); in stm32_dfsdm_probe()
407 if (!dfsdm->ch_list) in stm32_dfsdm_probe()
410 platform_set_drvdata(pdev, dfsdm); in stm32_dfsdm_probe()
412 ret = stm32_dfsdm_clk_prepare_enable(dfsdm); in stm32_dfsdm_probe()
434 stm32_dfsdm_clk_disable_unprepare(dfsdm); in stm32_dfsdm_probe()
441 struct stm32_dfsdm *dfsdm = platform_get_drvdata(pdev); in stm32_dfsdm_core_remove() local
448 stm32_dfsdm_clk_disable_unprepare(dfsdm); in stm32_dfsdm_core_remove()
453 struct stm32_dfsdm *dfsdm = dev_get_drvdata(dev); in stm32_dfsdm_core_suspend() local
454 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_core_suspend()
469 struct stm32_dfsdm *dfsdm = dev_get_drvdata(dev); in stm32_dfsdm_core_resume() local
470 struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm); in stm32_dfsdm_core_resume()
486 struct stm32_dfsdm *dfsdm = dev_get_drvdata(dev); in stm32_dfsdm_core_runtime_suspend() local
488 stm32_dfsdm_clk_disable_unprepare(dfsdm); in stm32_dfsdm_core_runtime_suspend()
495 struct stm32_dfsdm *dfsdm = dev_get_drvdata(dev); in stm32_dfsdm_core_runtime_resume() local
497 return stm32_dfsdm_clk_prepare_enable(dfsdm); in stm32_dfsdm_core_runtime_resume()
511 .name = "stm32-dfsdm",
520 MODULE_DESCRIPTION("STMicroelectronics STM32 dfsdm driver");