linux/drivers/iio/adc/aspeed_adc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Aspeed AST2400/2500/2600 ADC
 *
 * Copyright (C) 2017 Google, Inc.
 * Copyright (C) 2021 Aspeed Technology Inc.
 *
 * ADC clock formula:
 * Ast2400/Ast2500:
 * clock period = period of PCLK * 2 * (ADC0C[31:17] + 1) * (ADC0C[9:0] + 1)
 * Ast2600:
 * clock period = period of PCLK * 2 * (ADC0C[15:0] + 1)
 */

#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
#include <linux/reset.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/bitfield.h>
#include <linux/regmap.h>
#include <linux/mfd/syscon.h>

#include <linux/iio/iio.h>
#include <linux/iio/driver.h>
#include <linux/iopoll.h>

#define ASPEED_RESOLUTION_BITS
#define ASPEED_CLOCKS_PER_SAMPLE

#define ASPEED_REG_ENGINE_CONTROL
#define ASPEED_REG_INTERRUPT_CONTROL
#define ASPEED_REG_VGA_DETECT_CONTROL
#define ASPEED_REG_CLOCK_CONTROL
#define ASPEED_REG_COMPENSATION_TRIM
/*
 * The register offset between 0xC8~0xCC can be read and won't affect the
 * hardware logic in each version of ADC.
 */
#define ASPEED_REG_MAX

#define ASPEED_ADC_ENGINE_ENABLE
#define ASPEED_ADC_OP_MODE
#define ASPEED_ADC_OP_MODE_PWR_DOWN
#define ASPEED_ADC_OP_MODE_STANDBY
#define ASPEED_ADC_OP_MODE_NORMAL
#define ASPEED_ADC_CTRL_COMPENSATION
#define ASPEED_ADC_AUTO_COMPENSATION
/*
 * Bit 6 determines not only the reference voltage range but also the dividing
 * circuit for battery sensing.
 */
#define ASPEED_ADC_REF_VOLTAGE
#define ASPEED_ADC_REF_VOLTAGE_2500mV
#define ASPEED_ADC_REF_VOLTAGE_1200mV
#define ASPEED_ADC_REF_VOLTAGE_EXT_HIGH
#define ASPEED_ADC_REF_VOLTAGE_EXT_LOW
#define ASPEED_ADC_BAT_SENSING_DIV
#define ASPEED_ADC_BAT_SENSING_DIV_2_3
#define ASPEED_ADC_BAT_SENSING_DIV_1_3
#define ASPEED_ADC_CTRL_INIT_RDY
#define ASPEED_ADC_CH7_MODE
#define ASPEED_ADC_CH7_NORMAL
#define ASPEED_ADC_CH7_BAT
#define ASPEED_ADC_BAT_SENSING_ENABLE
#define ASPEED_ADC_CTRL_CHANNEL
#define ASPEED_ADC_CTRL_CHANNEL_ENABLE(ch)

#define ASPEED_ADC_INIT_POLLING_TIME
#define ASPEED_ADC_INIT_TIMEOUT
/*
 * When the sampling rate is too high, the ADC may not have enough charging
 * time, resulting in a low voltage value. Thus, the default uses a slow
 * sampling rate for most use cases.
 */
#define ASPEED_ADC_DEF_SAMPLING_RATE

struct aspeed_adc_trim_locate {};

struct aspeed_adc_model_data {};

struct adc_gain {};

struct aspeed_adc_data {};

#define ASPEED_CHAN(_idx, _data_reg_addr)

static const struct iio_chan_spec aspeed_adc_iio_channels[] =;

#define ASPEED_BAT_CHAN(_idx, _data_reg_addr)
static const struct iio_chan_spec aspeed_adc_iio_bat_channels[] =;

static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev)
{}

static int aspeed_adc_compensation(struct iio_dev *indio_dev)
{}

static int aspeed_adc_set_sampling_rate(struct iio_dev *indio_dev, u32 rate)
{}

static int aspeed_adc_read_raw(struct iio_dev *indio_dev,
			       struct iio_chan_spec const *chan,
			       int *val, int *val2, long mask)
{}

static int aspeed_adc_write_raw(struct iio_dev *indio_dev,
				struct iio_chan_spec const *chan,
				int val, int val2, long mask)
{}

static int aspeed_adc_reg_access(struct iio_dev *indio_dev,
				 unsigned int reg, unsigned int writeval,
				 unsigned int *readval)
{}

static const struct iio_info aspeed_adc_iio_info =;

static void aspeed_adc_unregister_fixed_divider(void *data)
{}

static void aspeed_adc_reset_assert(void *data)
{}

static void aspeed_adc_clk_disable_unprepare(void *data)
{}

static void aspeed_adc_power_down(void *data)
{}

static int aspeed_adc_vref_config(struct iio_dev *indio_dev)
{}

static int aspeed_adc_probe(struct platform_device *pdev)
{}

static const struct aspeed_adc_trim_locate ast2500_adc_trim =;

static const struct aspeed_adc_trim_locate ast2600_adc0_trim =;

static const struct aspeed_adc_trim_locate ast2600_adc1_trim =;

static const struct aspeed_adc_model_data ast2400_model_data =;

static const struct aspeed_adc_model_data ast2500_model_data =;

static const struct aspeed_adc_model_data ast2600_adc0_model_data =;

static const struct aspeed_adc_model_data ast2600_adc1_model_data =;

static const struct of_device_id aspeed_adc_matches[] =;
MODULE_DEVICE_TABLE(of, aspeed_adc_matches);

static struct platform_driver aspeed_adc_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();