linux/drivers/iio/adc/mt6359-auxadc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * MediaTek MT6359 PMIC AUXADC IIO driver
 *
 * Copyright (c) 2021 MediaTek Inc.
 * Copyright (c) 2024 Collabora Ltd
 * Author: AngeloGioacchino Del Regno <[email protected]>
 */

#include <linux/bits.h>
#include <linux/cleanup.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/types.h>

#include <linux/iio/iio.h>

#include <linux/mfd/mt6397/core.h>

#include <dt-bindings/iio/adc/mediatek,mt6357-auxadc.h>
#include <dt-bindings/iio/adc/mediatek,mt6358-auxadc.h>
#include <dt-bindings/iio/adc/mediatek,mt6359-auxadc.h>

#define AUXADC_AVG_TIME_US
#define AUXADC_POLL_DELAY_US
#define AUXADC_TIMEOUT_US
#define AUXADC_VOLT_FULL
#define IMP_STOP_DELAY_US
#define IMP_POLL_DELAY_US

/* For PMIC_RG_RESET_VAL and MT6358_IMP0_CLEAR, the bits specific purpose is unknown. */
#define PMIC_RG_RESET_VAL
#define PMIC_AUXADC_RDY_BIT
#define MT6357_IMP_ADC_NUM
#define MT6358_IMP_ADC_NUM

#define MT6358_DCM_CK_SW_EN
#define MT6358_IMP0_CLEAR
#define MT6358_IMP0_IRQ_RDY
#define MT6358_IMP1_AUTOREPEAT_EN

#define MT6359_IMP0_CONV_EN
#define MT6359_IMP1_IRQ_RDY

enum mtk_pmic_auxadc_regs {};

enum mtk_pmic_auxadc_channels {};

/**
 * struct mt6359_auxadc - Main driver structure
 * @dev:           Device pointer
 * @regmap:        Regmap from SoC PMIC Wrapper
 * @chip_info:     PMIC specific chip info
 * @lock:          Mutex to serialize AUXADC reading vs configuration
 * @timed_out:     Signals whether the last read timed out
 */
struct mt6359_auxadc {};

/**
 * struct mtk_pmic_auxadc_chan - PMIC AUXADC channel data
 * @req_idx:       Request register number
 * @req_mask:      Bitmask to activate a channel
 * @num_samples:   Number of AUXADC samples for averaging
 * @r_ratio:       Resistance ratio fractional
 */
struct mtk_pmic_auxadc_chan {};

/**
 * struct mtk_pmic_auxadc_info - PMIC specific chip info
 * @model_name:     PMIC model name
 * @channels:       IIO specification of ADC channels
 * @num_channels:   Number of ADC channels
 * @desc:           PMIC AUXADC channel data
 * @regs:           List of PMIC specific registers
 * @sec_unlock_key: Security unlock key for HK_TOP writes
 * @imp_adc_num:    ADC channel for battery impedance readings
 * @read_imp:       Callback to read impedance channels
 */
struct mtk_pmic_auxadc_info {};

#define MTK_PMIC_ADC_CHAN(_ch_idx, _req_idx, _req_bit, _samples, _rnum, _rdiv)

#define MTK_PMIC_IIO_CHAN(_model, _name, _ch_idx, _adc_idx, _nbits, _ch_type)

static const struct iio_chan_spec mt6357_auxadc_channels[] =;

static const struct mtk_pmic_auxadc_chan mt6357_auxadc_ch_desc[] =;

static const u16 mt6357_auxadc_regs[] =;

static const struct iio_chan_spec mt6358_auxadc_channels[] =;

static const struct mtk_pmic_auxadc_chan mt6358_auxadc_ch_desc[] =;

static const u16 mt6358_auxadc_regs[] =;

static const struct iio_chan_spec mt6359_auxadc_channels[] =;

static const struct mtk_pmic_auxadc_chan mt6359_auxadc_ch_desc[] =;

static const u16 mt6359_auxadc_regs[] =;

static void mt6358_stop_imp_conv(struct mt6359_auxadc *adc_dev)
{}

static int mt6358_start_imp_conv(struct mt6359_auxadc *adc_dev)
{}

static int mt6358_read_imp(struct mt6359_auxadc *adc_dev, int *vbat, int *ibat)
{}

static int mt6359_read_imp(struct mt6359_auxadc *adc_dev, int *vbat, int *ibat)
{}

static const struct mtk_pmic_auxadc_info mt6357_chip_info =;

static const struct mtk_pmic_auxadc_info mt6358_chip_info =;

static const struct mtk_pmic_auxadc_info mt6359_chip_info =;

static void mt6359_auxadc_reset(struct mt6359_auxadc *adc_dev)
{}

static int mt6359_auxadc_read_adc(struct mt6359_auxadc *adc_dev,
				  const struct iio_chan_spec *chan, int *out)
{}

static int mt6359_auxadc_read_label(struct iio_dev *indio_dev,
				    const struct iio_chan_spec *chan, char *label)
{}

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

static const struct iio_info mt6359_auxadc_iio_info =;

static int mt6359_auxadc_probe(struct platform_device *pdev)
{}

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

static struct platform_driver mt6359_auxadc_driver =;
module_platform_driver();

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