#include <linux/clk.h>
#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
#include <linux/iio/timer/stm32-lptim-trigger.h>
#include <linux/iio/timer/stm32-timer-trigger.h>
#include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/nvmem-consumer.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include "stm32-adc-core.h"
#define STM32H7_LINCALFACT_NUM …
#define STM32H7_BOOST_CLKRATE …
#define STM32_ADC_CH_MAX …
#define STM32_ADC_CH_SZ …
#define STM32_ADC_MAX_SQ …
#define STM32_ADC_MAX_SMP …
#define STM32_ADC_TIMEOUT_US …
#define STM32_ADC_TIMEOUT …
#define STM32_ADC_HW_STOP_DELAY_MS …
#define STM32_ADC_VREFINT_VOLTAGE …
#define STM32_DMA_BUFFER_SIZE …
enum stm32_adc_exten { … };
enum stm32_adc_extsel { … };
enum stm32_adc_int_ch { … };
struct stm32_adc_ic { … };
static const struct stm32_adc_ic stm32_adc_ic[STM32_ADC_INT_CH_NB] = …;
struct stm32_adc_trig_info { … };
struct stm32_adc_calib { … };
struct stm32_adc_regs { … };
struct stm32_adc_vrefint { … };
struct stm32_adc_regspec { … };
struct stm32_adc;
struct stm32_adc_cfg { … };
struct stm32_adc { … };
struct stm32_adc_diff_channel { … };
struct stm32_adc_info { … };
static const unsigned int stm32f4_adc_resolutions[] = …;
static const struct stm32_adc_info stm32f4_adc_info = …;
static const unsigned int stm32h7_adc_resolutions[] = …;
static const struct stm32_adc_info stm32h7_adc_info = …;
static const struct stm32_adc_info stm32mp13_adc_info = …;
static const struct stm32_adc_regs stm32f4_sq[STM32_ADC_MAX_SQ + 1] = …;
static struct stm32_adc_trig_info stm32f4_adc_trigs[] = …;
static const struct stm32_adc_regs stm32f4_smp_bits[] = …;
static const unsigned int stm32f4_adc_smp_cycles[STM32_ADC_MAX_SMP + 1] = …;
static const struct stm32_adc_regspec stm32f4_adc_regspec = …;
static const struct stm32_adc_regs stm32h7_sq[STM32_ADC_MAX_SQ + 1] = …;
static struct stm32_adc_trig_info stm32h7_adc_trigs[] = …;
static const struct stm32_adc_regs stm32h7_smp_bits[] = …;
static const unsigned int stm32h7_adc_smp_cycles[STM32_ADC_MAX_SMP + 1] = …;
static const struct stm32_adc_regspec stm32h7_adc_regspec = …;
static const unsigned int stm32mp13_adc_smp_cycles[STM32_ADC_MAX_SMP + 1] = …;
static const struct stm32_adc_regspec stm32mp13_adc_regspec = …;
static const struct stm32_adc_regspec stm32mp1_adc_regspec = …;
static u32 stm32_adc_readl(struct stm32_adc *adc, u32 reg)
{ … }
#define stm32_adc_readl_addr(addr) …
#define stm32_adc_readl_poll_timeout(reg, val, cond, sleep_us, timeout_us) …
static u16 stm32_adc_readw(struct stm32_adc *adc, u32 reg)
{ … }
static void stm32_adc_writel(struct stm32_adc *adc, u32 reg, u32 val)
{ … }
static void stm32_adc_set_bits(struct stm32_adc *adc, u32 reg, u32 bits)
{ … }
static void stm32_adc_set_bits_common(struct stm32_adc *adc, u32 reg, u32 bits)
{ … }
static void stm32_adc_clr_bits(struct stm32_adc *adc, u32 reg, u32 bits)
{ … }
static void stm32_adc_clr_bits_common(struct stm32_adc *adc, u32 reg, u32 bits)
{ … }
static void stm32_adc_conv_irq_enable(struct stm32_adc *adc)
{
stm32_adc_set_bits(adc, adc->cfg->regs->ier_eoc.reg,
adc->cfg->regs->ier_eoc.mask);
};
static void stm32_adc_conv_irq_disable(struct stm32_adc *adc)
{ … }
static void stm32_adc_ovr_irq_enable(struct stm32_adc *adc)
{ … }
static void stm32_adc_ovr_irq_disable(struct stm32_adc *adc)
{ … }
static void stm32_adc_set_res(struct stm32_adc *adc)
{ … }
static int stm32_adc_hw_stop(struct device *dev)
{ … }
static int stm32_adc_hw_start(struct device *dev)
{ … }
static void stm32_adc_int_ch_enable(struct iio_dev *indio_dev)
{ … }
static void stm32_adc_int_ch_disable(struct stm32_adc *adc)
{ … }
static void stm32f4_adc_start_conv(struct iio_dev *indio_dev, bool dma)
{ … }
static void stm32f4_adc_stop_conv(struct iio_dev *indio_dev)
{ … }
static void stm32f4_adc_irq_clear(struct iio_dev *indio_dev, u32 msk)
{ … }
static void stm32h7_adc_start_conv(struct iio_dev *indio_dev, bool dma)
{ … }
static void stm32h7_adc_stop_conv(struct iio_dev *indio_dev)
{ … }
static void stm32h7_adc_irq_clear(struct iio_dev *indio_dev, u32 msk)
{ … }
static void stm32mp13_adc_start_conv(struct iio_dev *indio_dev, bool dma)
{ … }
static int stm32h7_adc_exit_pwr_down(struct iio_dev *indio_dev)
{ … }
static void stm32h7_adc_enter_pwr_down(struct stm32_adc *adc)
{ … }
static int stm32h7_adc_enable(struct iio_dev *indio_dev)
{ … }
static void stm32h7_adc_disable(struct iio_dev *indio_dev)
{ … }
static int stm32h7_adc_read_selfcalib(struct iio_dev *indio_dev)
{ … }
static int stm32h7_adc_restore_selfcalib(struct iio_dev *indio_dev)
{ … }
#define STM32H7_ADC_CALIB_TIMEOUT_US …
static int stm32h7_adc_selfcalib(struct iio_dev *indio_dev, int do_lincal)
{ … }
static int stm32h7_adc_check_selfcalib(struct iio_dev *indio_dev)
{ … }
static int stm32h7_adc_prepare(struct iio_dev *indio_dev)
{ … }
static void stm32h7_adc_unprepare(struct iio_dev *indio_dev)
{ … }
static int stm32_adc_conf_scan_seq(struct iio_dev *indio_dev,
const unsigned long *scan_mask)
{ … }
static int stm32_adc_get_trig_extsel(struct iio_dev *indio_dev,
struct iio_trigger *trig)
{ … }
static int stm32_adc_set_trig(struct iio_dev *indio_dev,
struct iio_trigger *trig)
{ … }
static int stm32_adc_set_trig_pol(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
unsigned int type)
{ … }
static int stm32_adc_get_trig_pol(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
{ … }
static const char * const stm32_trig_pol_items[] = …;
static const struct iio_enum stm32_adc_trig_pol = …;
static int stm32_adc_single_conv(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
int *res)
{ … }
static int stm32_adc_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{ … }
static void stm32_adc_irq_clear(struct iio_dev *indio_dev, u32 msk)
{ … }
static irqreturn_t stm32_adc_threaded_isr(int irq, void *data)
{ … }
static irqreturn_t stm32_adc_isr(int irq, void *data)
{ … }
static int stm32_adc_validate_trigger(struct iio_dev *indio_dev,
struct iio_trigger *trig)
{ … }
static int stm32_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
{ … }
static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
const unsigned long *scan_mask)
{ … }
static int stm32_adc_fwnode_xlate(struct iio_dev *indio_dev,
const struct fwnode_reference_args *iiospec)
{ … }
static int stm32_adc_debugfs_reg_access(struct iio_dev *indio_dev,
unsigned reg, unsigned writeval,
unsigned *readval)
{ … }
static const struct iio_info stm32_adc_iio_info = …;
static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
{ … }
static void stm32_adc_dma_buffer_done(void *data)
{ … }
static int stm32_adc_dma_start(struct iio_dev *indio_dev)
{ … }
static int stm32_adc_buffer_postenable(struct iio_dev *indio_dev)
{ … }
static int stm32_adc_buffer_predisable(struct iio_dev *indio_dev)
{ … }
static const struct iio_buffer_setup_ops stm32_adc_buffer_setup_ops = …;
static irqreturn_t stm32_adc_trigger_handler(int irq, void *p)
{ … }
static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = …;
static void stm32_adc_debugfs_init(struct iio_dev *indio_dev)
{ … }
static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev)
{ … }
static void stm32_adc_smpr_init(struct stm32_adc *adc, int channel, u32 smp_ns)
{ … }
static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
struct iio_chan_spec *chan, u32 vinp,
u32 vinn, int scan_index, bool differential)
{ … }
static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm32_adc *adc)
{ … }
static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
struct stm32_adc *adc,
struct iio_chan_spec *channels,
int nchans)
{ … }
static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_name,
int chan)
{ … }
static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
struct stm32_adc *adc,
struct iio_chan_spec *channels)
{ … }
static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
{ … }
static int stm32_adc_dma_request(struct device *dev, struct iio_dev *indio_dev)
{ … }
static int stm32_adc_probe(struct platform_device *pdev)
{ … }
static void stm32_adc_remove(struct platform_device *pdev)
{ … }
static int stm32_adc_suspend(struct device *dev)
{ … }
static int stm32_adc_resume(struct device *dev)
{ … }
static int stm32_adc_runtime_suspend(struct device *dev)
{ … }
static int stm32_adc_runtime_resume(struct device *dev)
{ … }
static const struct dev_pm_ops stm32_adc_pm_ops = …;
static const struct stm32_adc_cfg stm32f4_adc_cfg = …;
static const unsigned int stm32_adc_min_ts_h7[] = …;
static_assert(…);
static const struct stm32_adc_cfg stm32h7_adc_cfg = …;
static const unsigned int stm32_adc_min_ts_mp1[] = …;
static_assert(…);
static const struct stm32_adc_cfg stm32mp1_adc_cfg = …;
static const unsigned int stm32_adc_min_ts_mp13[] = …;
static_assert(…);
static const struct stm32_adc_cfg stm32mp13_adc_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(…) …;