mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 13:49:24 -04:00
motorola: dlkm: Add Sarsensor sx931x
-Add the Semtech Sx9310/Sx9311 DLKM. Change-Id: I13cc4e70a43d02f6de6148895c168fd9db3ff497 Signed-off-by: Wen Xie <xiewen3@motorola.com> Reviewed-on: https://gerrit.mot.com/1188111 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
3ca806f96d
commit
fd4d86b0cd
5 changed files with 2208 additions and 0 deletions
8
drivers/misc/sx9310/Android.mk
Normal file
8
drivers/misc/sx9310/Android.mk
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
DLKM_DIR := motorola/kernel/modules
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := sx931x_triple.ko
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
include $(DLKM_DIR)/AndroidKernelModule.mk
|
||||
9
drivers/misc/sx9310/Kbuild
Normal file
9
drivers/misc/sx9310/Kbuild
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# add -Wall to try to catch everything we can.
|
||||
EXTRA_CFLAGS += -Wall
|
||||
EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/include
|
||||
|
||||
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../../sensors/Module.symvers
|
||||
|
||||
sx931x_triple-y := sx9310_triple.o
|
||||
|
||||
obj-m += sx931x_triple.o
|
||||
11
drivers/misc/sx9310/Makefile
Normal file
11
drivers/misc/sx9310/Makefile
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
|
||||
|
||||
all:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS)
|
||||
|
||||
modules_install:
|
||||
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
|
||||
|
||||
1768
drivers/misc/sx9310/sx9310_triple.c
Normal file
1768
drivers/misc/sx9310/sx9310_triple.c
Normal file
File diff suppressed because it is too large
Load diff
412
include/linux/input/sx9310_triple.h
Normal file
412
include/linux/input/sx9310_triple.h
Normal file
|
|
@ -0,0 +1,412 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*/
|
||||
#ifndef SX9310_TRIPLE_H
|
||||
#define SX9310_TRIPLE_H
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
/*
|
||||
* I2C Registers
|
||||
*/
|
||||
#define SX9310_IRQSTAT_REG 0x00
|
||||
#define SX9310_STAT0_REG 0x01
|
||||
#define SX9310_STAT1_REG 0x02
|
||||
#define SX9310_IRQ_ENABLE_REG 0x03
|
||||
#define SX9310_IRQFUNC_REG 0x04
|
||||
|
||||
#define SX9310_CPS_CTRL0_REG 0x10
|
||||
#define SX9310_CPS_CTRL1_REG 0x11
|
||||
#define SX9310_CPS_CTRL2_REG 0x12
|
||||
#define SX9310_CPS_CTRL3_REG 0x13
|
||||
#define SX9310_CPS_CTRL4_REG 0x14
|
||||
#define SX9310_CPS_CTRL5_REG 0x15
|
||||
#define SX9310_CPS_CTRL6_REG 0x16
|
||||
#define SX9310_CPS_CTRL7_REG 0x17
|
||||
#define SX9310_CPS_CTRL8_REG 0x18
|
||||
#define SX9310_CPS_CTRL9_REG 0x19
|
||||
#define SX9310_CPS_CTRL10_REG 0x1A
|
||||
#define SX9310_CPS_CTRL11_REG 0x1B
|
||||
#define SX9310_CPS_CTRL12_REG 0x1C
|
||||
#define SX9310_CPS_CTRL13_REG 0x1D
|
||||
#define SX9310_CPS_CTRL14_REG 0x1E
|
||||
#define SX9310_CPS_CTRL15_REG 0x1F
|
||||
#define SX9310_CPS_CTRL16_REG 0x20
|
||||
#define SX9310_CPS_CTRL17_REG 0x21
|
||||
#define SX9310_CPS_CTRL18_REG 0x22
|
||||
#define SX9310_CPS_CTRL19_REG 0x23
|
||||
#define SX9310_SAR_CTRL0_REG 0x2A
|
||||
#define SX9310_SAR_CTRL1_REG 0x2B
|
||||
#define SX9310_SAR_CTRL2_REG 0x2C
|
||||
|
||||
#define SX9310_SOFTRESET_REG 0x7F
|
||||
|
||||
/* Sensor Readback */
|
||||
#define SX9310_CPSRD 0x30
|
||||
|
||||
#define SX9310_USEMSB 0x31
|
||||
#define SX9310_USELSB 0x32
|
||||
|
||||
#define SX9310_AVGMSB 0x33
|
||||
#define SX9310_AVGLSB 0x34
|
||||
|
||||
#define SX9310_DIFFMSB 0x35
|
||||
#define SX9310_DIFFLSB 0x36
|
||||
#define SX9310_OFFSETMSB 0x37
|
||||
#define SX9310_OFFSETLSB 0x38
|
||||
|
||||
#define SX9310_SARMSB 0x39
|
||||
#define SX9310_SARLSB 0x3A
|
||||
|
||||
#define SX9310_WHOAMI 0x42
|
||||
|
||||
/* IrqStat 0:Inactive 1:Active */
|
||||
#define SX9310_IRQSTAT_RESET_FLAG 0x80
|
||||
#define SX9310_IRQSTAT_TOUCH_FLAG 0x40
|
||||
#define SX9310_IRQSTAT_RELEASE_FLAG 0x20
|
||||
#define SX9310_IRQSTAT_COMPDONE_FLAG 0x10
|
||||
#define SX9310_IRQSTAT_CONV_FLAG 0x08
|
||||
#define SX9310_IRQSTAT_CLOSEALL_FLAG 0x04
|
||||
#define SX9310_IRQSTAT_FARALL_FLAG 0x02
|
||||
#define SX9310_IRQSTAT_SMARTSAR_FLAG 0x01
|
||||
|
||||
|
||||
/* CpsStat */
|
||||
#define SX9310_TCHCMPSTAT_TCHCOMB_FLAG 0x08
|
||||
/* enable body stat */
|
||||
#define SX9310_TCHCMPSTAT_TCHSTAT2_FLAG 0x84
|
||||
/* enable body stat */
|
||||
#define SX9310_TCHCMPSTAT_TCHSTAT1_FLAG 0x42
|
||||
/* enable body stat */
|
||||
#define SX9310_TCHCMPSTAT_TCHSTAT0_FLAG 0x11
|
||||
|
||||
|
||||
/* SoftReset */
|
||||
#define SX9310_SOFTRESET 0xDE
|
||||
|
||||
/* useful channel number */
|
||||
#define USE_CHANNEL_NUM 3
|
||||
|
||||
/* default settings */
|
||||
/* Channel enable: CS0:1,CS1:2,CS2:4,COMB:8
|
||||
* Defines the Active scan period :
|
||||
* 0000: Min (no idle time)
|
||||
* 0001: 15ms
|
||||
* 0010: 30 ms (Typ.)
|
||||
* 0011: 45 ms
|
||||
* 0100: 60 ms
|
||||
* 0101: 90 ms
|
||||
* 0110: 120 ms
|
||||
* 0111: 200 ms
|
||||
* 1000: 400 ms
|
||||
* 1001: 600 ms
|
||||
* 1010: 800 ms
|
||||
* 1011: 1 s
|
||||
* 1100: 2 s
|
||||
* 1101: 3 s
|
||||
* 1110: 4 s
|
||||
* 1111: 5 s
|
||||
*/
|
||||
#define DUMMY_USE_CHANNEL 0x1
|
||||
#define DUMMY_SCAN_PERIOD 0x2
|
||||
#define DUMMY_RAW_DATA_CHANNEL 0x00
|
||||
|
||||
/* Cap sensor report key, including cs0, cs1, cs2 and comb */
|
||||
#define KEY_CAP_CS0 0x270
|
||||
#define KEY_CAP_CS1 0x271
|
||||
#define KEY_CAP_CS2 0x272
|
||||
#define KEY_CAP_COMB 0x272
|
||||
|
||||
/**************************************
|
||||
* define platform data
|
||||
*
|
||||
**************************************/
|
||||
struct smtc_reg_data {
|
||||
unsigned char reg;
|
||||
unsigned char val;
|
||||
};
|
||||
|
||||
typedef struct smtc_reg_data smtc_reg_data_t;
|
||||
typedef struct smtc_reg_data *psmtc_reg_data_t;
|
||||
|
||||
|
||||
struct _buttonInfo {
|
||||
/* The Key to send to the input */
|
||||
int keycode;
|
||||
/* Mask to look for on Touch Status */
|
||||
int mask;
|
||||
/* Current state of button. */
|
||||
int state;
|
||||
};
|
||||
|
||||
struct _totalButtonInformation {
|
||||
struct _buttonInfo *buttons;
|
||||
int buttonSize;
|
||||
struct input_dev *input_top;
|
||||
struct input_dev *input_bottom;
|
||||
};
|
||||
|
||||
typedef struct _totalButtonInformation buttonInformation_t;
|
||||
typedef struct _totalButtonInformation *pbuttonInformation_t;
|
||||
|
||||
/* Define Registers that need to be initialized to values different than
|
||||
* default
|
||||
*/
|
||||
static struct smtc_reg_data sx9310_i2c_reg_setup[] = {
|
||||
{
|
||||
.reg = SX9310_IRQ_ENABLE_REG,
|
||||
.val = 0xF0,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_IRQFUNC_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL1_REG,
|
||||
.val = 0x02,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL2_REG,
|
||||
.val = 0x0b,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL3_REG,
|
||||
.val = 0x0A,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL4_REG,
|
||||
.val = 0x0D,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL5_REG,
|
||||
.val = 0xC1,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL6_REG,
|
||||
.val = 0x20,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL7_REG,
|
||||
.val = 0x4C,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL8_REG,
|
||||
.val = 0x7A,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL9_REG,
|
||||
.val = 0x7D,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL10_REG,
|
||||
.val = 0x10,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL11_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL12_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL13_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL14_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL15_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL16_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL17_REG,
|
||||
.val = 0x04,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL18_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL19_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_SAR_CTRL0_REG,
|
||||
.val = 0x00,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_SAR_CTRL1_REG,
|
||||
.val = 0x80,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_SAR_CTRL2_REG,
|
||||
.val = 0x0C,
|
||||
},
|
||||
{
|
||||
.reg = SX9310_CPS_CTRL0_REG,
|
||||
.val = 0x27,
|
||||
},
|
||||
};
|
||||
|
||||
static struct _buttonInfo psmtcButtons[] = {
|
||||
{
|
||||
.keycode = KEY_CAP_CS0,
|
||||
.mask = SX9310_TCHCMPSTAT_TCHSTAT0_FLAG,
|
||||
},
|
||||
{
|
||||
.keycode = KEY_CAP_CS1,
|
||||
.mask = SX9310_TCHCMPSTAT_TCHSTAT1_FLAG,
|
||||
},
|
||||
{
|
||||
.keycode = KEY_CAP_CS2,
|
||||
.mask = SX9310_TCHCMPSTAT_TCHSTAT2_FLAG,
|
||||
},
|
||||
{
|
||||
.keycode = KEY_CAP_COMB,
|
||||
.mask = SX9310_TCHCMPSTAT_TCHCOMB_FLAG,
|
||||
},
|
||||
};
|
||||
|
||||
struct sx9310_platform_data {
|
||||
int i2c_reg_num;
|
||||
struct smtc_reg_data *pi2c_reg;
|
||||
struct regulator *cap_vdd;
|
||||
struct regulator *cap_svdd;
|
||||
bool cap_vdd_en;
|
||||
bool cap_svdd_en;
|
||||
unsigned irq_gpio;
|
||||
/* used for custom setting for channel and scan period */
|
||||
u32 cust_prox_ctrl0;
|
||||
u32 cust_raw_data_channel;
|
||||
int cap_channel_top;
|
||||
int cap_channel_bottom;
|
||||
pbuttonInformation_t pbuttonInformation;
|
||||
|
||||
int (*get_is_nirq_low)(unsigned irq_gpio);
|
||||
int (*init_platform_hw)(void);
|
||||
void (*exit_platform_hw)(void);
|
||||
};
|
||||
typedef struct sx9310_platform_data sx9310_platform_data_t;
|
||||
typedef struct sx9310_platform_data *psx9310_platform_data_t;
|
||||
|
||||
#ifdef USE_SENSORS_CLASS
|
||||
static struct sensors_classdev sensors_capsensor_top_cdev = {
|
||||
.name = "capsense_top",
|
||||
.vendor = "semtech",
|
||||
.version = 1,
|
||||
.type = SENSOR_TYPE_MOTO_CAPSENSE,
|
||||
.max_range = "5",
|
||||
.resolution = "5.0",
|
||||
.sensor_power = "3",
|
||||
.min_delay = 0, /* in microseconds */
|
||||
.fifo_reserved_event_count = 0,
|
||||
.fifo_max_event_count = 0,
|
||||
.enabled = 0,
|
||||
.delay_msec = 100,
|
||||
.sensors_enable = NULL,
|
||||
.sensors_poll_delay = NULL,
|
||||
};
|
||||
static struct sensors_classdev sensors_capsensor_bottom_cdev = {
|
||||
.name = "capsense_bottom",
|
||||
.vendor = "semtech",
|
||||
.version = 1,
|
||||
.type = SENSOR_TYPE_MOTO_CAPSENSE,
|
||||
.max_range = "5",
|
||||
.resolution = "5.0",
|
||||
.sensor_power = "3",
|
||||
.min_delay = 0, /* in microseconds */
|
||||
.fifo_reserved_event_count = 0,
|
||||
.fifo_max_event_count = 0,
|
||||
.enabled = 0,
|
||||
.delay_msec = 100,
|
||||
.sensors_enable = NULL,
|
||||
.sensors_poll_delay = NULL,
|
||||
};
|
||||
#endif
|
||||
/***************************************
|
||||
* define data struct/interrupt
|
||||
* @pdev: pdev common device struction for linux
|
||||
* @dworker: work struct for worker function
|
||||
* @board: constant pointer to platform data
|
||||
* @mutex: mutex for interrupt process
|
||||
* @lock: Spin Lock used for nirq worker function
|
||||
* @bus: either i2c_client or spi_client
|
||||
* @pDevice: device specific struct pointer
|
||||
*@read_flag : used for dump specified register
|
||||
* @irq: irq number used
|
||||
* @irqTimeout: msecs only set if useIrqTimer is true
|
||||
* @irq_disabled: whether irq should be ignored
|
||||
* @irq_gpio: irq gpio number
|
||||
* @useIrqTimer: older models need irq timer for pen up cases
|
||||
* @read_reg: record reg address which want to read
|
||||
*@cust_prox_ctrl0 : used for custom setting for channel and scan period
|
||||
* @init: (re)initialize device
|
||||
* @refreshStatus: read register status
|
||||
* @get_nirq_low: get whether nirq is low (platform data)
|
||||
* @statusFunc: array of functions to call for corresponding status bit
|
||||
***************************************/
|
||||
#define USE_THREADED_IRQ
|
||||
|
||||
#define MAX_NUM_STATUS_BITS (8)
|
||||
|
||||
typedef struct sx93XX sx93XX_t, *psx93XX_t;
|
||||
struct sx93XX {
|
||||
struct device *pdev;
|
||||
struct delayed_work dworker;
|
||||
struct sx9310_platform_data *board;
|
||||
#if defined(USE_THREADED_IRQ)
|
||||
struct mutex mutex;
|
||||
#else
|
||||
spinlock_t lock;
|
||||
#endif
|
||||
void *bus;
|
||||
void *pDevice;
|
||||
int read_flag;
|
||||
int irq;
|
||||
int irqTimeout;
|
||||
char irq_disabled;
|
||||
/* whether irq should be ignored..
|
||||
* cases if enable/disable irq is not used
|
||||
* or does not work properly */
|
||||
u8 useIrqTimer;
|
||||
u8 read_reg;
|
||||
|
||||
struct work_struct ps_notify_work;
|
||||
struct notifier_block ps_notif;
|
||||
bool ps_is_present;
|
||||
|
||||
#if defined(CONFIG_FB)
|
||||
struct work_struct fb_notify_work;
|
||||
struct notifier_block fb_notif;
|
||||
#endif
|
||||
|
||||
/* Function Pointers */
|
||||
int (*init)(psx93XX_t this);
|
||||
/* since we are trying to avoid knowing registers, create a pointer to a
|
||||
* common read register which would be to read what the interrupt source
|
||||
* is from
|
||||
*/
|
||||
int (*refreshStatus)(psx93XX_t this);
|
||||
int (*get_nirq_low)(unsigned irq_gpio);
|
||||
|
||||
void (*statusFunc[MAX_NUM_STATUS_BITS])(psx93XX_t this);
|
||||
|
||||
};
|
||||
|
||||
void sx93XX_suspend(psx93XX_t this);
|
||||
void sx93XX_resume(psx93XX_t this);
|
||||
int sx93XX_sar_init(psx93XX_t this);
|
||||
int sx93XX_sar_remove(psx93XX_t this);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in a new issue