linux/drivers/iio/light/cm32181.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2013 Capella Microsystems Inc.
 * Author: Kevin Tsai <[email protected]>
 */

#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/interrupt.h>
#include <linux/regulator/consumer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/events.h>
#include <linux/init.h>

/* Registers Address */
#define CM32181_REG_ADDR_CMD
#define CM32181_REG_ADDR_WH
#define CM32181_REG_ADDR_WL
#define CM32181_REG_ADDR_TEST
#define CM32181_REG_ADDR_ALS
#define CM32181_REG_ADDR_STATUS
#define CM32181_REG_ADDR_ID

/* Number of Configurable Registers */
#define CM32181_CONF_REG_NUM

/* CMD register */
#define CM32181_CMD_ALS_DISABLE
#define CM32181_CMD_ALS_INT_EN
#define CM32181_CMD_ALS_THRES_WINDOW

#define CM32181_CMD_ALS_PERS_SHIFT
#define CM32181_CMD_ALS_PERS_MASK
#define CM32181_CMD_ALS_PERS_DEFAULT

#define CM32181_CMD_ALS_IT_SHIFT
#define CM32181_CMD_ALS_IT_MASK
#define CM32181_CMD_ALS_IT_DEFAULT

#define CM32181_CMD_ALS_SM_SHIFT
#define CM32181_CMD_ALS_SM_MASK
#define CM32181_CMD_ALS_SM_DEFAULT

#define CM32181_LUX_PER_BIT
#define CM32181_LUX_PER_BIT_RESOLUTION
#define CM32181_LUX_PER_BIT_BASE_IT
#define CM32181_CALIBSCALE_DEFAULT
#define CM32181_CALIBSCALE_RESOLUTION

#define SMBUS_ALERT_RESPONSE_ADDRESS

/* CPM0 Index 0: device-id (3218 or 32181), 1: Unknown, 2: init_regs_bitmap */
#define CPM0_REGS_BITMAP
#define CPM0_HEADER_SIZE

/* CPM1 Index 0: lux_per_bit, 1: calibscale, 2: resolution (100000) */
#define CPM1_LUX_PER_BIT
#define CPM1_CALIBSCALE
#define CPM1_SIZE

/* CM3218 Family */
static const int cm3218_als_it_bits[] =;
static const int cm3218_als_it_values[] =;

/* CM32181 Family */
static const int cm32181_als_it_bits[] =;
static const int cm32181_als_it_values[] =;

struct cm32181_chip {};

static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val2);

#ifdef CONFIG_ACPI
/**
 * cm32181_acpi_get_cpm() - Get CPM object from ACPI
 * @dev:	pointer of struct device.
 * @obj_name:	pointer of ACPI object name.
 * @values:	pointer of array for return elements.
 * @count:	maximum size of return array.
 *
 * Convert ACPI CPM table to array.
 *
 * Return: -ENODEV for fail.  Otherwise is number of elements.
 */
static int cm32181_acpi_get_cpm(struct device *dev, char *obj_name,
				u64 *values, int count)
{}

static void cm32181_acpi_parse_cpm_tables(struct cm32181_chip *cm32181)
{}
#else
static void cm32181_acpi_parse_cpm_tables(struct cm32181_chip *cm32181)
{
}
#endif /* CONFIG_ACPI */

/**
 * cm32181_reg_init() - Initialize CM32181 registers
 * @cm32181:	pointer of struct cm32181.
 *
 * Initialize CM32181 ambient light sensor register to default values.
 *
 * Return: 0 for success; otherwise for error code.
 */
static int cm32181_reg_init(struct cm32181_chip *cm32181)
{}

/**
 *  cm32181_read_als_it() - Get sensor integration time (ms)
 *  @cm32181:	pointer of struct cm32181
 *  @val2:	pointer of int to load the als_it value.
 *
 *  Report the current integration time in milliseconds.
 *
 *  Return: IIO_VAL_INT_PLUS_MICRO for success, otherwise -EINVAL.
 */
static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val2)
{}

/**
 * cm32181_write_als_it() - Write sensor integration time
 * @cm32181:	pointer of struct cm32181.
 * @val:	integration time by millisecond.
 *
 * Convert integration time (ms) to sensor value.
 *
 * Return: i2c_smbus_write_word_data command return value.
 */
static int cm32181_write_als_it(struct cm32181_chip *cm32181, int val)
{}

/**
 * cm32181_get_lux() - report current lux value
 * @cm32181:	pointer of struct cm32181.
 *
 * Convert sensor raw data to lux.  It depends on integration
 * time and calibscale variable.
 *
 * Return: Positive value is lux, otherwise is error code.
 */
static int cm32181_get_lux(struct cm32181_chip *cm32181)
{}

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

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

/**
 * cm32181_get_it_available() - Get available ALS IT value
 * @dev:	pointer of struct device.
 * @attr:	pointer of struct device_attribute.
 * @buf:	pointer of return string buffer.
 *
 * Display the available integration time values by millisecond.
 *
 * Return: string length.
 */
static ssize_t cm32181_get_it_available(struct device *dev,
			struct device_attribute *attr, char *buf)
{}

static const struct iio_chan_spec cm32181_channels[] =;

static IIO_DEVICE_ATTR(in_illuminance_integration_time_available,
			S_IRUGO, cm32181_get_it_available, NULL, 0);

static struct attribute *cm32181_attributes[] =;

static const struct attribute_group cm32181_attribute_group =;

static const struct iio_info cm32181_info =;

static void cm32181_unregister_dummy_client(void *data)
{}

static int cm32181_probe(struct i2c_client *client)
{}

static int cm32181_suspend(struct device *dev)
{}

static int cm32181_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(cm32181_pm_ops, cm32181_suspend, cm32181_resume);

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

#ifdef CONFIG_ACPI
static const struct acpi_device_id cm32181_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, cm32181_acpi_match);
#endif

static struct i2c_driver cm32181_driver =;

module_i2c_driver();

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