mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 07:03:09 -04:00
input: focaltech_v2_mmi: add usb charger detection
focaltech_v2_mmi: Add usb charger detection function. NO_PROP_NEEDED: <New IC for NPI> Change-Id: Ia93898563a7247a0ab8ae7d1b1bdd83ad4dd912b Signed-off-by: wangyq13 <wangyq13@lenovo.com> Reviewed-on: https://gerrit.mot.com/1824123 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jun Weng <wengjun1@motorola.com> Reviewed-by: Wei Deng <dengwei1@motorola.com> Reviewed-by: Jichao Zou <zoujc@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
c533055001
commit
a587eada61
4 changed files with 88 additions and 0 deletions
|
|
@ -229,6 +229,11 @@
|
|||
*/
|
||||
#define FTS_GET_MODULE_NUM 0
|
||||
|
||||
/*
|
||||
* Usb detect support
|
||||
*/
|
||||
#define FTS_USB_DETECT_EN 1
|
||||
|
||||
/*
|
||||
* module_id: mean vendor_id generally, also maybe gpio or lcm_id...
|
||||
* If means vendor_id, the FTS_MODULE_ID = PANEL_ID << 8 + VENDOR_ID
|
||||
|
|
|
|||
|
|
@ -681,11 +681,64 @@ static int fts_read_parse_touchdata(struct fts_ts_data *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if FTS_USB_DETECT_EN
|
||||
static void fts_mcu_usb_detect_set(uint8_t usb_connected)
|
||||
{
|
||||
uint8_t write_data = 0;
|
||||
uint8_t read_data = 0;
|
||||
uint8_t retry_cnt = 0;
|
||||
int ret = 0;
|
||||
|
||||
do{
|
||||
if (usb_connected == 0x01) {
|
||||
write_data= 0x01;
|
||||
ret = fts_write_reg(FTS_REG_CHARGER_MODE_EN, write_data);
|
||||
if (ret < 0)
|
||||
FTS_ERROR("set register USB IN fail, ret=%d", ret);
|
||||
FTS_INFO("%s: USB detect status IN!\n", __func__);
|
||||
} else {
|
||||
write_data= 0x00;
|
||||
ret = fts_write_reg(FTS_REG_CHARGER_MODE_EN, write_data);
|
||||
if (ret < 0)
|
||||
FTS_ERROR("set register USB OUT fail, ret=%d", ret);
|
||||
FTS_INFO("%s: USB detect status OUT!\n", __func__);
|
||||
}
|
||||
|
||||
ret = fts_read_reg(FTS_REG_CHARGER_MODE_EN, &read_data);
|
||||
if (ret < 0)
|
||||
FTS_ERROR("read 8b register fail, ret=%d", ret);
|
||||
retry_cnt++;
|
||||
}while((write_data != read_data) && retry_cnt < FTS_REG_RETRY_TIMES);
|
||||
}
|
||||
|
||||
void fts_cable_detect_func(bool force_renew)
|
||||
{
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
uint8_t connect_status = 0;
|
||||
connect_status = ts_data->usb_detect_flag;
|
||||
|
||||
if ((connect_status != ts_data->usb_connected) || force_renew) {
|
||||
if (connect_status) {
|
||||
ts_data->usb_connected = 0x01;
|
||||
} else {
|
||||
ts_data->usb_connected = 0x00;
|
||||
}
|
||||
|
||||
fts_mcu_usb_detect_set(ts_data->usb_connected);
|
||||
FTS_INFO("%s: Cable status change: 0x%2.2X\n", __func__, ts_data->usb_connected);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void fts_irq_read_report(void)
|
||||
{
|
||||
int ret = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
|
||||
#if FTS_USB_DETECT_EN
|
||||
fts_cable_detect_func(false);
|
||||
#endif
|
||||
|
||||
#if FTS_ESDCHECK_EN
|
||||
fts_esdcheck_set_intr(1);
|
||||
#endif
|
||||
|
|
@ -1813,6 +1866,10 @@ static int fts_ts_resume(struct device *dev)
|
|||
}
|
||||
|
||||
ts_data->suspended = false;
|
||||
#if FTS_USB_DETECT_EN
|
||||
fts_cable_detect_func(true);
|
||||
#endif
|
||||
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@
|
|||
#if defined(CONFIG_INPUT_TOUCHSCREEN_MMI)
|
||||
#include <linux/touchscreen_mmi.h>
|
||||
#endif
|
||||
#ifdef FTS_USB_DETECT_EN
|
||||
#include <linux/power_supply.h>
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Private constant and macro definitions using #define
|
||||
|
|
@ -103,6 +106,9 @@
|
|||
|
||||
#define FTX_MAX_COMPATIBLE_TYPE 4
|
||||
#define FTX_MAX_COMMMAND_LENGTH 16
|
||||
#ifdef FTS_USB_DETECT_EN
|
||||
#define FTS_REG_RETRY_TIMES 5
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
@ -209,6 +215,11 @@ struct fts_ts_data {
|
|||
struct early_suspend early_suspend;
|
||||
#endif
|
||||
|
||||
#if FTS_USB_DETECT_EN
|
||||
bool usb_detect_flag;
|
||||
uint8_t usb_connected;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_INPUT_TOUCHSCREEN_MMI)
|
||||
struct ts_mmi_class_methods *imports;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -191,6 +191,18 @@ static int fts_mmi_firmware_update(struct device *dev, char *fwname)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if FTS_USB_DETECT_EN
|
||||
static int fts_mmi_charger_mode(struct device *dev, int mode)
|
||||
{
|
||||
struct fts_ts_data *ts_data;
|
||||
|
||||
GET_TS_DATA(dev);
|
||||
ts_data->usb_detect_flag = !!mode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int fts_mmi_panel_state(struct device *dev,
|
||||
enum ts_mmi_pm_mode from, enum ts_mmi_pm_mode to)
|
||||
{
|
||||
|
|
@ -339,6 +351,9 @@ static struct ts_mmi_methods fts_mmi_methods = {
|
|||
.drv_irq = fts_mmi_methods_drv_irq,
|
||||
#if FTS_POWER_SOURCE_CUST_EN
|
||||
.power = fts_mmi_methods_power,
|
||||
#endif
|
||||
#if FTS_USB_DETECT_EN
|
||||
.charger_mode = fts_mmi_charger_mode,
|
||||
#endif
|
||||
/* Firmware */
|
||||
.firmware_update = fts_mmi_firmware_update,
|
||||
|
|
|
|||
Loading…
Reference in a new issue