linux/drivers/iio/adc/rtq6056.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2022 Richtek Technology Corp.
 *
 * ChiYuan Huang <[email protected]>
 */

#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/sysfs.h>
#include <linux/types.h>
#include <linux/util_macros.h>

#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>

#define RTQ6056_REG_CONFIG
#define RTQ6056_REG_SHUNTVOLT
#define RTQ6056_REG_BUSVOLT
#define RTQ6056_REG_POWER
#define RTQ6056_REG_CURRENT
#define RTQ6056_REG_CALIBRATION
#define RTQ6056_REG_MASKENABLE
#define RTQ6056_REG_ALERTLIMIT
#define RTQ6056_REG_MANUFACTID
#define RTQ6056_REG_DIEID

#define RTQ6056_VENDOR_ID
#define RTQ6056_DEFAULT_CONFIG
#define RTQ6056_CONT_ALLON

#define RTQ6059_DEFAULT_CONFIG
#define RTQ6059_VBUS_LSB_OFFSET
#define RTQ6059_AVG_BASE

enum {};

/*
 * The enum is to present the 0x00 CONFIG RG bitfield for the 16bit RG value
 * field value order from LSB to MSB
 * RTQ6053/6 is OPMODE->VSHUNTCT->VBUSCT->AVG->RESET
 * RTQ6059 is OPMODE->SADC->BADC->PGA->RESET
 */
enum {};

struct rtq6056_priv;

struct richtek_dev_data {};

struct rtq6056_priv {};

static const struct reg_field rtq6056_reg_fields[F_MAX_FIELDS] =;

static const struct reg_field rtq6059_reg_fields[F_MAX_FIELDS] =;

static const struct iio_chan_spec rtq6056_channels[RTQ6056_MAX_CHANNEL + 1] =;

/*
 * Difference between RTQ6056 and RTQ6059
 * - Fixed sampling conversion time
 * - Average sample numbers
 * - Channel scale
 * - calibration coefficient
 */
static const struct iio_chan_spec rtq6059_channels[RTQ6056_MAX_CHANNEL + 1] =;

static int rtq6056_adc_read_channel(struct rtq6056_priv *priv,
				    struct iio_chan_spec const *ch,
				    int *val)
{}

static int rtq6056_adc_read_scale(struct iio_chan_spec const *ch, int *val,
				  int *val2)
{}

static int rtq6059_adc_read_scale(struct iio_chan_spec const *ch, int *val,
				  int *val2)
{}

/*
 * Sample frequency for channel VSHUNT and VBUS. The indices correspond
 * with the bit value expected by the chip. And it can be found at
 * https://www.richtek.com/assets/product_file/RTQ6056/DSQ6056-00.pdf
 */
static const int rtq6056_samp_freq_list[] =;

static int rtq6056_adc_set_samp_freq(struct rtq6056_priv *priv,
				     struct iio_chan_spec const *ch, int val)
{}

/*
 * Available averaging rate for rtq6056. The indices correspond with the bit
 * value expected by the chip. And it can be found at
 * https://www.richtek.com/assets/product_file/RTQ6056/DSQ6056-00.pdf
 */
static const int rtq6056_avg_sample_list[] =;

static const int rtq6059_avg_sample_list[] =;

static int rtq6056_adc_set_average(struct rtq6056_priv *priv, int val)
{}

static int rtq6059_adc_set_average(struct rtq6056_priv *priv, int val)
{}

static int rtq6056_adc_get_sample_freq(struct rtq6056_priv *priv,
				       struct iio_chan_spec const *ch, int *val)
{}

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

static int rtq6056_adc_read_avail(struct iio_dev *indio_dev,
				  struct iio_chan_spec const *chan,
				  const int **vals, int *type, int *length,
				  long mask)
{}

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

static const char *rtq6056_channel_labels[RTQ6056_MAX_CHANNEL] =;

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

static int rtq6056_set_shunt_resistor(struct rtq6056_priv *priv,
				      int resistor_uohm)
{}

static ssize_t shunt_resistor_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}

static ssize_t shunt_resistor_store(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t len)
{}

static IIO_DEVICE_ATTR_RW(shunt_resistor, 0);

static struct attribute *rtq6056_attributes[] =;

static const struct attribute_group rtq6056_attribute_group =;

static const struct iio_info rtq6056_info =;

static irqreturn_t rtq6056_buffer_trigger_handler(int irq, void *p)
{}

static void rtq6056_enter_shutdown_state(void *dev)
{}

static bool rtq6056_is_readable_reg(struct device *dev, unsigned int reg)
{}

static bool rtq6056_is_writeable_reg(struct device *dev, unsigned int reg)
{}

static const struct regmap_config rtq6056_regmap_config =;

static int rtq6056_probe(struct i2c_client *i2c)
{}

static int rtq6056_runtime_suspend(struct device *dev)
{}

static int rtq6056_runtime_resume(struct device *dev)
{}

static DEFINE_RUNTIME_DEV_PM_OPS(rtq6056_pm_ops, rtq6056_runtime_suspend,
				 rtq6056_runtime_resume, NULL);

static const struct richtek_dev_data rtq6056_devdata =;

static const struct richtek_dev_data rtq6059_devdata =;

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

static struct i2c_driver rtq6056_driver =;
module_i2c_driver();

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