linux/drivers/input/misc/drv260x.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * DRV260X haptics driver family
 *
 * Author: Dan Murphy <[email protected]>
 *
 * Copyright:   (C) 2014 Texas Instruments, Inc.
 */

#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h>

#include <dt-bindings/input/ti-drv260x.h>

#define DRV260X_STATUS
#define DRV260X_MODE
#define DRV260X_RT_PB_IN
#define DRV260X_LIB_SEL
#define DRV260X_WV_SEQ_1
#define DRV260X_WV_SEQ_2
#define DRV260X_WV_SEQ_3
#define DRV260X_WV_SEQ_4
#define DRV260X_WV_SEQ_5
#define DRV260X_WV_SEQ_6
#define DRV260X_WV_SEQ_7
#define DRV260X_WV_SEQ_8
#define DRV260X_GO
#define DRV260X_OVERDRIVE_OFF
#define DRV260X_SUSTAIN_P_OFF
#define DRV260X_SUSTAIN_N_OFF
#define DRV260X_BRAKE_OFF
#define DRV260X_A_TO_V_CTRL
#define DRV260X_A_TO_V_MIN_INPUT
#define DRV260X_A_TO_V_MAX_INPUT
#define DRV260X_A_TO_V_MIN_OUT
#define DRV260X_A_TO_V_MAX_OUT
#define DRV260X_RATED_VOLT
#define DRV260X_OD_CLAMP_VOLT
#define DRV260X_CAL_COMP
#define DRV260X_CAL_BACK_EMF
#define DRV260X_FEEDBACK_CTRL
#define DRV260X_CTRL1
#define DRV260X_CTRL2
#define DRV260X_CTRL3
#define DRV260X_CTRL4
#define DRV260X_CTRL5
#define DRV260X_LRA_LOOP_PERIOD
#define DRV260X_VBAT_MON
#define DRV260X_LRA_RES_PERIOD
#define DRV260X_MAX_REG

#define DRV260X_GO_BIT

/* Library Selection */
#define DRV260X_LIB_SEL_MASK
#define DRV260X_LIB_SEL_RAM
#define DRV260X_LIB_SEL_OD
#define DRV260X_LIB_SEL_40_60
#define DRV260X_LIB_SEL_60_80
#define DRV260X_LIB_SEL_100_140
#define DRV260X_LIB_SEL_140_PLUS

#define DRV260X_LIB_SEL_HIZ_MASK
#define DRV260X_LIB_SEL_HIZ_EN
#define DRV260X_LIB_SEL_HIZ_DIS

/* Mode register */
#define DRV260X_STANDBY
#define DRV260X_STANDBY_MASK
#define DRV260X_INTERNAL_TRIGGER
#define DRV260X_EXT_TRIGGER_EDGE
#define DRV260X_EXT_TRIGGER_LEVEL
#define DRV260X_PWM_ANALOG_IN
#define DRV260X_AUDIOHAPTIC
#define DRV260X_RT_PLAYBACK
#define DRV260X_DIAGNOSTICS
#define DRV260X_AUTO_CAL

/* Audio to Haptics Control */
#define DRV260X_AUDIO_HAPTICS_PEAK_10MS
#define DRV260X_AUDIO_HAPTICS_PEAK_20MS
#define DRV260X_AUDIO_HAPTICS_PEAK_30MS
#define DRV260X_AUDIO_HAPTICS_PEAK_40MS

#define DRV260X_AUDIO_HAPTICS_FILTER_100HZ
#define DRV260X_AUDIO_HAPTICS_FILTER_125HZ
#define DRV260X_AUDIO_HAPTICS_FILTER_150HZ
#define DRV260X_AUDIO_HAPTICS_FILTER_200HZ

/* Min/Max Input/Output Voltages */
#define DRV260X_AUDIO_HAPTICS_MIN_IN_VOLT
#define DRV260X_AUDIO_HAPTICS_MAX_IN_VOLT
#define DRV260X_AUDIO_HAPTICS_MIN_OUT_VOLT
#define DRV260X_AUDIO_HAPTICS_MAX_OUT_VOLT

/* Feedback register */
#define DRV260X_FB_REG_ERM_MODE
#define DRV260X_FB_REG_LRA_MODE

#define DRV260X_BRAKE_FACTOR_MASK
#define DRV260X_BRAKE_FACTOR_2X
#define DRV260X_BRAKE_FACTOR_3X
#define DRV260X_BRAKE_FACTOR_4X
#define DRV260X_BRAKE_FACTOR_6X
#define DRV260X_BRAKE_FACTOR_8X
#define DRV260X_BRAKE_FACTOR_16
#define DRV260X_BRAKE_FACTOR_DIS

#define DRV260X_LOOP_GAIN_LOW
#define DRV260X_LOOP_GAIN_MED
#define DRV260X_LOOP_GAIN_HIGH
#define DRV260X_LOOP_GAIN_VERY_HIGH

#define DRV260X_BEMF_GAIN_0
#define DRV260X_BEMF_GAIN_1
#define DRV260X_BEMF_GAIN_2
#define DRV260X_BEMF_GAIN_3

/* Control 1 register */
#define DRV260X_AC_CPLE_EN
#define DRV260X_STARTUP_BOOST

/* Control 2 register */

#define DRV260X_IDISS_TIME_45
#define DRV260X_IDISS_TIME_75
#define DRV260X_IDISS_TIME_150
#define DRV260X_IDISS_TIME_225

#define DRV260X_BLANK_TIME_45
#define DRV260X_BLANK_TIME_75
#define DRV260X_BLANK_TIME_150
#define DRV260X_BLANK_TIME_225

#define DRV260X_SAMP_TIME_150
#define DRV260X_SAMP_TIME_200
#define DRV260X_SAMP_TIME_250
#define DRV260X_SAMP_TIME_300

#define DRV260X_BRAKE_STABILIZER
#define DRV260X_UNIDIR_IN
#define DRV260X_BIDIR_IN

/* Control 3 Register */
#define DRV260X_LRA_OPEN_LOOP
#define DRV260X_ANALOG_IN
#define DRV260X_LRA_DRV_MODE
#define DRV260X_RTP_UNSIGNED_DATA
#define DRV260X_SUPPLY_COMP_DIS
#define DRV260X_ERM_OPEN_LOOP
#define DRV260X_NG_THRESH_0
#define DRV260X_NG_THRESH_2
#define DRV260X_NG_THRESH_4
#define DRV260X_NG_THRESH_8

/* Control 4 Register */
#define DRV260X_AUTOCAL_TIME_150MS
#define DRV260X_AUTOCAL_TIME_250MS
#define DRV260X_AUTOCAL_TIME_500MS
#define DRV260X_AUTOCAL_TIME_1000MS

/**
 * struct drv260x_data -
 * @input_dev: Pointer to the input device
 * @client: Pointer to the I2C client
 * @regmap: Register map of the device
 * @work: Work item used to off load the enable/disable of the vibration
 * @enable_gpio: Pointer to the gpio used for enable/disabling
 * @regulator: Pointer to the regulator for the IC
 * @magnitude: Magnitude of the vibration event
 * @mode: The operating mode of the IC (LRA_NO_CAL, ERM or LRA)
 * @library: The vibration library to be used
 * @rated_voltage: The rated_voltage of the actuator
 * @overdrive_voltage: The over drive voltage of the actuator
**/
struct drv260x_data {};

#define DRV260X_DEF_RATED_VOLT
#define DRV260X_DEF_OD_CLAMP_VOLT

/*
 * Rated and Overdriver Voltages:
 * Calculated using the formula r = v * 255 / 5.6
 * where r is what will be written to the register
 * and v is the rated or overdriver voltage of the actuator
 */
static int drv260x_calculate_voltage(unsigned int voltage)
{}

static void drv260x_worker(struct work_struct *work)
{}

static int drv260x_haptics_play(struct input_dev *input, void *data,
				struct ff_effect *effect)
{}

static void drv260x_close(struct input_dev *input)
{}

static const struct reg_sequence drv260x_lra_cal_regs[] =;

static const struct reg_sequence drv260x_lra_init_regs[] =;

static const struct reg_sequence drv260x_erm_cal_regs[] =;

static int drv260x_init(struct drv260x_data *haptics)
{}

static const struct regmap_config drv260x_regmap_config =;

static int drv260x_probe(struct i2c_client *client)
{}

static int drv260x_suspend(struct device *dev)
{}

static int drv260x_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(drv260x_pm_ops, drv260x_suspend, drv260x_resume);

static const struct i2c_device_id drv260x_id[] =;
MODULE_DEVICE_TABLE(i2c, drv260x_id);

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

static struct i2c_driver drv260x_driver =;
module_i2c_driver();

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