#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/irqdesc.h>
#include <linux/irqdomain.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/units.h>
#include "stm32-adc-core.h"
#define STM32_ADC_CORE_SLEEP_DELAY_MS …
#define STM32MP1_SYSCFG_PMCSETR …
#define STM32MP1_SYSCFG_PMCCLRR …
#define STM32MP1_SYSCFG_ANASWVDD_MASK …
#define HAS_VBOOSTER …
#define HAS_ANASWVDD …
struct stm32_adc_common_regs { … };
struct stm32_adc_priv;
struct stm32_adc_priv_cfg { … };
struct stm32_adc_priv { … };
static struct stm32_adc_priv *to_stm32_adc_priv(struct stm32_adc_common *com)
{ … }
static int stm32f4_pclk_div[] = …;
static int stm32f4_adc_clk_sel(struct platform_device *pdev,
struct stm32_adc_priv *priv)
{ … }
struct stm32h7_adc_ck_spec { … };
static const struct stm32h7_adc_ck_spec stm32h7_adc_ckmodes_spec[] = …;
static int stm32h7_adc_clk_sel(struct platform_device *pdev,
struct stm32_adc_priv *priv)
{ … }
static const struct stm32_adc_common_regs stm32f4_adc_common_regs = …;
static const struct stm32_adc_common_regs stm32h7_adc_common_regs = …;
static const struct stm32_adc_common_regs stm32mp13_adc_common_regs = …;
static const unsigned int stm32_adc_offset[STM32_ADC_MAX_ADCS] = …;
static unsigned int stm32_adc_eoc_enabled(struct stm32_adc_priv *priv,
unsigned int adc)
{ … }
static void stm32_adc_irq_handler(struct irq_desc *desc)
{
struct stm32_adc_priv *priv = irq_desc_get_handler_data(desc);
struct irq_chip *chip = irq_desc_get_chip(desc);
int i;
u32 status;
chained_irq_enter(chip, desc);
status = readl_relaxed(priv->common.base + priv->cfg->regs->csr);
for (i = 0; i < priv->nb_adc_max; i++) {
if ((status & priv->cfg->regs->eoc_msk[i] &&
stm32_adc_eoc_enabled(priv, i)) ||
(status & priv->cfg->regs->ovr_msk[i]))
generic_handle_domain_irq(priv->domain, i);
}
chained_irq_exit(chip, desc);
};
static int stm32_adc_domain_map(struct irq_domain *d, unsigned int irq,
irq_hw_number_t hwirq)
{ … }
static void stm32_adc_domain_unmap(struct irq_domain *d, unsigned int irq)
{ … }
static const struct irq_domain_ops stm32_adc_domain_ops = …;
static int stm32_adc_irq_probe(struct platform_device *pdev,
struct stm32_adc_priv *priv)
{ … }
static void stm32_adc_irq_remove(struct platform_device *pdev,
struct stm32_adc_priv *priv)
{ … }
static int stm32_adc_core_switches_supply_en(struct stm32_adc_priv *priv,
struct device *dev)
{ … }
static void stm32_adc_core_switches_supply_dis(struct stm32_adc_priv *priv)
{ … }
static int stm32_adc_core_hw_start(struct device *dev)
{ … }
static void stm32_adc_core_hw_stop(struct device *dev)
{ … }
static int stm32_adc_core_switches_probe(struct device *dev,
struct stm32_adc_priv *priv)
{ … }
static int stm32_adc_probe_identification(struct platform_device *pdev,
struct stm32_adc_priv *priv)
{ … }
static int stm32_adc_probe(struct platform_device *pdev)
{ … }
static void stm32_adc_remove(struct platform_device *pdev)
{ … }
static int stm32_adc_core_runtime_suspend(struct device *dev)
{ … }
static int stm32_adc_core_runtime_resume(struct device *dev)
{ … }
static int stm32_adc_core_runtime_idle(struct device *dev)
{ … }
static DEFINE_RUNTIME_DEV_PM_OPS(stm32_adc_core_pm_ops,
stm32_adc_core_runtime_suspend,
stm32_adc_core_runtime_resume,
stm32_adc_core_runtime_idle);
static const struct stm32_adc_priv_cfg stm32f4_adc_priv_cfg = …;
static const struct stm32_adc_priv_cfg stm32h7_adc_priv_cfg = …;
static const struct stm32_adc_priv_cfg stm32mp1_adc_priv_cfg = …;
static const struct stm32_adc_priv_cfg stm32mp13_adc_priv_cfg = …;
static const struct of_device_id stm32_adc_of_match[] = …;
MODULE_DEVICE_TABLE(of, stm32_adc_of_match);
static struct platform_driver stm32_adc_driver = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_ALIAS(…) …;