linux/drivers/iio/adc/axp288_adc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * axp288_adc.c - X-Powers AXP288 PMIC ADC Driver
 *
 * Copyright (C) 2014 Intel Corporation
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#include <linux/dmi.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/regmap.h>
#include <linux/mfd/axp20x.h>
#include <linux/platform_device.h>

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

/*
 * This mask enables all ADCs except for the battery temp-sensor (TS), that is
 * left as-is to avoid breaking charging on devices without a temp-sensor.
 */
#define AXP288_ADC_EN_MASK
#define AXP288_ADC_TS_ENABLE

#define AXP288_ADC_TS_BIAS_MASK
#define AXP288_ADC_TS_BIAS_20UA
#define AXP288_ADC_TS_BIAS_40UA
#define AXP288_ADC_TS_BIAS_60UA
#define AXP288_ADC_TS_BIAS_80UA
#define AXP288_ADC_TS_CURRENT_ON_OFF_MASK
#define AXP288_ADC_TS_CURRENT_OFF
#define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING
#define AXP288_ADC_TS_CURRENT_ON_ONDEMAND
#define AXP288_ADC_TS_CURRENT_ON

enum axp288_adc_id {};

struct axp288_adc_info {};

static const struct iio_chan_spec axp288_adc_channels[] =;

/* for consumer drivers */
static struct iio_map axp288_adc_default_maps[] =;

static int axp288_adc_read_channel(int *val, unsigned long address,
				struct regmap *regmap)
{}

/*
 * The current-source used for the battery temp-sensor (TS) is shared
 * with the GPADC. For proper fuel-gauge and charger operation the TS
 * current-source needs to be permanently on. But to read the GPADC we
 * need to temporary switch the TS current-source to ondemand, so that
 * the GPADC can use it, otherwise we will always read an all 0 value.
 */
static int axp288_adc_set_ts(struct axp288_adc_info *info,
			     unsigned int mode, unsigned long address)
{}

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

/*
 * We rely on the machine's firmware to correctly setup the TS pin bias current
 * at boot. This lists systems with broken fw where we need to set it ourselves.
 */
static const struct dmi_system_id axp288_adc_ts_bias_override[] =;

static int axp288_adc_initialize(struct axp288_adc_info *info)
{}

static const struct iio_info axp288_adc_iio_info =;

static int axp288_adc_probe(struct platform_device *pdev)
{}

static const struct platform_device_id axp288_adc_id_table[] =;

static struct platform_driver axp288_adc_driver =;

MODULE_DEVICE_TABLE(platform, axp288_adc_id_table);

module_platform_driver();

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