linux/drivers/misc/lis3lv02d/lis3lv02d.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  lis3lv02d.c - ST LIS3LV02DL accelerometer driver
 *
 *  Copyright (C) 2007-2008 Yan Burman
 *  Copyright (C) 2008 Eric Piel
 *  Copyright (C) 2008-2009 Pavel Machek
 */

#define pr_fmt(fmt)

#include <linux/kernel.h>
#include <linux/sched/signal.h>
#include <linux/dmi.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/delay.h>
#include <linux/wait.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/freezer.h>
#include <linux/uaccess.h>
#include <linux/miscdevice.h>
#include <linux/pm_runtime.h>
#include <linux/atomic.h>
#include <linux/of.h>
#include "lis3lv02d.h"

#define DRIVER_NAME

/* joystick device poll interval in milliseconds */
#define MDPS_POLL_INTERVAL
#define MDPS_POLL_MIN
#define MDPS_POLL_MAX

#define LIS3_SYSFS_POWERDOWN_DELAY

#define SELFTEST_OK
#define SELFTEST_FAIL
#define SELFTEST_IRQ

#define IRQ_LINE0
#define IRQ_LINE1

/*
 * The sensor can also generate interrupts (DRDY) but it's pretty pointless
 * because they are generated even if the data do not change. So it's better
 * to keep the interrupt for the free-fall event. The values are updated at
 * 40Hz (at the lowest frequency), but as it can be pretty time consuming on
 * some low processor, we poll the sensor only at 20Hz... enough for the
 * joystick.
 */

#define LIS3_PWRON_DELAY_WAI_12B
#define LIS3_PWRON_DELAY_WAI_8B

/*
 * LIS3LV02D spec says 1024 LSBs corresponds 1 G -> 1LSB is 1000/1024 mG
 * LIS302D spec says: 18 mG / digit
 * LIS3_ACCURACY is used to increase accuracy of the intermediate
 * calculation results.
 */
#define LIS3_ACCURACY
/* Sensitivity values for -2G +2G scale */
#define LIS3_SENSITIVITY_12B
#define LIS3_SENSITIVITY_8B

/*
 * LIS331DLH spec says 1LSBs corresponds 4G/4096 -> 1LSB is 1000/1024 mG.
 * Below macros defines sensitivity values for +/-2G. Dataout bits for
 * +/-2G range is 12 bits so 4 bits adjustment must be done to get 12bit
 * data from 16bit value. Currently this driver supports only 2G range.
 */
#define LIS3DLH_SENSITIVITY_2G
#define SHIFT_ADJ_2G

#define LIS3_DEFAULT_FUZZ_12B
#define LIS3_DEFAULT_FLAT_12B
#define LIS3_DEFAULT_FUZZ_8B
#define LIS3_DEFAULT_FLAT_8B

struct lis3lv02d lis3_dev =;
EXPORT_SYMBOL_GPL();

/* just like param_set_int() but does sanity-check so that it won't point
 * over the axis array size
 */
static int param_set_axis(const char *val, const struct kernel_param *kp)
{}

static const struct kernel_param_ops param_ops_axis =;

#define param_check_axis(name, p)

module_param_array_named();
MODULE_PARM_DESC();

static s16 lis3lv02d_read_8(struct lis3lv02d *lis3, int reg)
{}

static s16 lis3lv02d_read_12(struct lis3lv02d *lis3, int reg)
{}

/* 12bits for 2G range, 13 bits for 4G range and 14 bits for 8G range */
static s16 lis331dlh_read_data(struct lis3lv02d *lis3, int reg)
{}

/**
 * lis3lv02d_get_axis - For the given axis, give the value converted
 * @axis:      1,2,3 - can also be negative
 * @hw_values: raw values returned by the hardware
 *
 * Returns the converted value.
 */
static inline int lis3lv02d_get_axis(s8 axis, int hw_values[3])
{}

/**
 * lis3lv02d_get_xyz - Get X, Y and Z axis values from the accelerometer
 * @lis3: pointer to the device struct
 * @x:    where to store the X axis value
 * @y:    where to store the Y axis value
 * @z:    where to store the Z axis value
 *
 * Note that 40Hz input device can eat up about 10% CPU at 800MHZ
 */
static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z)
{}

/* conversion btw sampling rate and the register values */
static int lis3_12_rates[4] =;
static int lis3_8_rates[2] =;
static int lis3_3dc_rates[16] =;
static int lis3_3dlh_rates[4] =;

/* ODR is Output Data Rate */
static int lis3lv02d_get_odr_index(struct lis3lv02d *lis3)
{}

static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3)
{}

static int lis3lv02d_set_odr(struct lis3lv02d *lis3, int rate)
{}

static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
{}

/*
 * Order of registers in the list affects to order of the restore process.
 * Perhaps it is a good idea to set interrupt enable register as a last one
 * after all other configurations
 */
static u8 lis3_wai8_regs[] =;

static u8 lis3_wai12_regs[] =;

static inline void lis3_context_save(struct lis3lv02d *lis3)
{}

static inline void lis3_context_restore(struct lis3lv02d *lis3)
{}

void lis3lv02d_poweroff(struct lis3lv02d *lis3)
{}
EXPORT_SYMBOL_GPL();

int lis3lv02d_poweron(struct lis3lv02d *lis3)
{}
EXPORT_SYMBOL_GPL();


static void lis3lv02d_joystick_poll(struct input_dev *input)
{}

static int lis3lv02d_joystick_open(struct input_dev *input)
{}

static void lis3lv02d_joystick_close(struct input_dev *input)
{}

static irqreturn_t lis302dl_interrupt(int irq, void *data)
{}

static void lis302dl_interrupt_handle_click(struct lis3lv02d *lis3)
{}

static inline void lis302dl_data_ready(struct lis3lv02d *lis3, int index)
{}

static irqreturn_t lis302dl_interrupt_thread1_8b(int irq, void *data)
{}

static irqreturn_t lis302dl_interrupt_thread2_8b(int irq, void *data)
{}

static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
{}

static int lis3lv02d_misc_release(struct inode *inode, struct file *file)
{}

static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
				size_t count, loff_t *pos)
{}

static __poll_t lis3lv02d_misc_poll(struct file *file, poll_table *wait)
{}

static int lis3lv02d_misc_fasync(int fd, struct file *file, int on)
{}

static const struct file_operations lis3lv02d_misc_fops =;

int lis3lv02d_joystick_enable(struct lis3lv02d *lis3)
{}
EXPORT_SYMBOL_GPL();

void lis3lv02d_joystick_disable(struct lis3lv02d *lis3)
{}
EXPORT_SYMBOL_GPL();

/* Sysfs stuff */
static void lis3lv02d_sysfs_poweron(struct lis3lv02d *lis3)
{}

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

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

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

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

static DEVICE_ATTR(selftest, S_IRUSR, lis3lv02d_selftest_show, NULL);
static DEVICE_ATTR(position, S_IRUGO, lis3lv02d_position_show, NULL);
static DEVICE_ATTR(rate, S_IRUGO | S_IWUSR, lis3lv02d_rate_show,
					    lis3lv02d_rate_set);

static struct attribute *lis3lv02d_attributes[] =;

static const struct attribute_group lis3lv02d_attribute_group =;


static int lis3lv02d_add_fs(struct lis3lv02d *lis3)
{}

void lis3lv02d_remove_fs(struct lis3lv02d *lis3)
{}
EXPORT_SYMBOL_GPL();

static void lis3lv02d_8b_configure(struct lis3lv02d *lis3,
				struct lis3lv02d_platform_data *p)
{}

#ifdef CONFIG_OF
int lis3lv02d_init_dt(struct lis3lv02d *lis3)
{}

#else
int lis3lv02d_init_dt(struct lis3lv02d *lis3)
{
	return 0;
}
#endif
EXPORT_SYMBOL_GPL();

/*
 * Initialise the accelerometer and the various subsystems.
 * Should be rather independent of the bus system.
 */
int lis3lv02d_init_device(struct lis3lv02d *lis3)
{}
EXPORT_SYMBOL_GPL();

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