mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 21:22:09 -04:00
touchu:gc7372 tp modify for charger test and gesture
add charger test and gesture driver code. charger test defaut set false . Change-Id: If5f5776ea9add55ee768a4800f2a3413aa223262 Signed-off-by: liaohj <liaohj@lenovo.com> Reviewed-on: https://gerrit.mot.com/2051575 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
c9837700df
commit
aae469fe31
4 changed files with 232 additions and 3 deletions
|
|
@ -33,6 +33,10 @@
|
|||
#include <asm/uaccess.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/mmi_wake_lock.h>
|
||||
#include <linux/power_supply.h>
|
||||
|
||||
//#define GCORE_SENSOR_EN 1
|
||||
#define CHARGER_NOTIFIER 0
|
||||
|
||||
/* display state */
|
||||
#ifdef GCORE_SENSOR_EN
|
||||
|
|
@ -279,8 +283,24 @@ enum FW_MODE {
|
|||
enum fw_event_type {
|
||||
FW_UPDATE = 0,
|
||||
FW_READ_REG,
|
||||
FW_WRITE_REG,
|
||||
FW_READ_OPEN,
|
||||
FW_READ_SHORT,
|
||||
FW_EDGE_0,
|
||||
FW_EDGE_90,
|
||||
FW_CHARGER_PLUG,
|
||||
FW_CHARGER_UNPLUG,
|
||||
FW_HEADSET_PLUG,
|
||||
FW_HEADSET_UNPLUG,
|
||||
FW_READ_RAWDATA,
|
||||
FW_READ_DIFFDATA,
|
||||
FW_GESTURE_ENABLE,
|
||||
FW_GESTURE_DISABLE,
|
||||
};
|
||||
|
||||
enum GCORE_TS_STAT {
|
||||
TS_NORMAL = 0,
|
||||
TS_SUSPEND,
|
||||
};
|
||||
|
||||
struct gcore_dev {
|
||||
|
|
@ -423,7 +443,7 @@ extern s32 gcore_idm_write_reg(u32 addr, u8 *buffer, s32 len);
|
|||
extern void gcore_irq_disable(struct gcore_dev *gdev);
|
||||
extern void gcore_irq_enable(struct gcore_dev *gdev);
|
||||
|
||||
|
||||
extern int gcore_fw_event_notify(enum fw_event_type event);
|
||||
|
||||
extern struct gcore_exp_fn fw_update_fn;
|
||||
extern struct gcore_exp_fn fs_interf_fn;
|
||||
|
|
@ -452,5 +472,18 @@ extern int gcore_start_mp_test(void);
|
|||
extern void gcore_resume_wq_init(void);
|
||||
#endif
|
||||
|
||||
#if CHARGER_NOTIFIER
|
||||
struct usb_charger_detection {
|
||||
struct notifier_block charger_notif;
|
||||
u8 usb_connected;
|
||||
struct workqueue_struct *gcore_charger_notify_wq;
|
||||
struct work_struct charger_notify_work;
|
||||
};
|
||||
|
||||
extern int gcore_charger_notifier_init(void);
|
||||
#endif
|
||||
|
||||
extern int gcore_idm_tddi_reset(void);
|
||||
|
||||
#endif /* GCORE_TPD_COMMON_H_ */
|
||||
|
||||
|
|
|
|||
|
|
@ -428,6 +428,70 @@ int gcore_fw_read_reg_reply(u8 *buf, int len)
|
|||
|
||||
}
|
||||
|
||||
int gcore_fw_event_notify(enum fw_event_type event)
|
||||
{
|
||||
u8 cmd[] = { 0x80, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
u8 cmd_len = sizeof(cmd);
|
||||
int ret = 0;
|
||||
|
||||
switch (event) {
|
||||
case FW_EDGE_0:
|
||||
cmd[cmd_len - 1] = 0x02;
|
||||
GTP_DEBUG("gcore fw event:edge 0");
|
||||
break;
|
||||
|
||||
case FW_EDGE_90:
|
||||
cmd[cmd_len - 1] = 0x03;
|
||||
GTP_DEBUG("gcore fw event:edge 90");
|
||||
break;
|
||||
|
||||
case FW_CHARGER_PLUG:
|
||||
cmd[cmd_len - 1] = 0x04;
|
||||
GTP_DEBUG("gcore fw event:charger plug");
|
||||
break;
|
||||
|
||||
case FW_CHARGER_UNPLUG:
|
||||
cmd[cmd_len - 1] = 0x05;
|
||||
GTP_DEBUG("gcore fw event:charger unplug");
|
||||
break;
|
||||
|
||||
case FW_HEADSET_PLUG:
|
||||
cmd[cmd_len - 1] = 0x06;
|
||||
GTP_DEBUG("gcore fw event:headset plug");
|
||||
break;
|
||||
|
||||
case FW_HEADSET_UNPLUG:
|
||||
cmd[cmd_len - 1] = 0x07;
|
||||
GTP_DEBUG("gcore fw event:headset unplug");
|
||||
break;
|
||||
|
||||
case FW_GESTURE_ENABLE:
|
||||
cmd[cmd_len - 1] = 0x0A;
|
||||
GTP_DEBUG("gcore fw event:gesture enable");
|
||||
break;
|
||||
|
||||
case FW_GESTURE_DISABLE:
|
||||
cmd[cmd_len - 1] = 0x0B;
|
||||
GTP_DEBUG("gcore fw event:gesture disable");
|
||||
break;
|
||||
|
||||
default:
|
||||
GTP_DEBUG("unknown fw event type.");
|
||||
break;
|
||||
}
|
||||
|
||||
mutex_lock(&gdev_fwu->transfer_lock);
|
||||
|
||||
ret = gcore_bus_write(cmd, cmd_len);
|
||||
if (ret) {
|
||||
GTP_ERROR("gcore write fw event fail.");
|
||||
}
|
||||
|
||||
mutex_unlock(&gdev_fwu->transfer_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int gcore_reg_enable_write_on(void)
|
||||
{
|
||||
u32 addr = 0xC0000020;
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ s32 gcore_touch_event_handler(struct gcore_dev *gdev)
|
|||
|
||||
set_bit(id, &curr_touch);
|
||||
|
||||
gcore_touch_down(gdev->input_device, input_x, input_y, id);
|
||||
gcore_touch_down(gdev->input_device, input_x, input_y, id - 1);
|
||||
|
||||
coor_data += 6;
|
||||
|
||||
|
|
@ -780,7 +780,7 @@ s32 gcore_touch_event_handler(struct gcore_dev *gdev)
|
|||
#ifdef CONFIG_ENABLE_TYPE_B_PROCOTOL
|
||||
for (i = 1; i <= GTP_MAX_TOUCH; i++) {
|
||||
if (!test_bit(i, &curr_touch) && test_bit(i, &prev_touch)) {
|
||||
gcore_touch_up(gdev->input_device, i);
|
||||
gcore_touch_up(gdev->input_device, i - 1);
|
||||
}
|
||||
|
||||
if (test_bit(i, &curr_touch)) {
|
||||
|
|
@ -1119,6 +1119,10 @@ int gcore_touch_probe(struct gcore_dev *gdev)
|
|||
gcore_resume_wq_init();
|
||||
#endif
|
||||
|
||||
#if CHARGER_NOTIFIER
|
||||
gcore_charger_notifier_init();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,129 @@ void gcore_resume_wq_init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if CHARGER_NOTIFIER
|
||||
struct usb_charger_detection charger_detection;
|
||||
static int usb_detect_flag;
|
||||
|
||||
static void gcore_charger_notify_work(struct work_struct *work)
|
||||
{
|
||||
GTP_DEBUG("enter gcore_charger_notify_work");
|
||||
if (1 == usb_detect_flag) {
|
||||
gcore_fw_event_notify(FW_CHARGER_PLUG);
|
||||
} else if (0 == usb_detect_flag) {
|
||||
gcore_fw_event_notify(FW_CHARGER_UNPLUG);
|
||||
} else {
|
||||
GTP_DEBUG("Charger flag:%d not currently required!",usb_detect_flag);
|
||||
}
|
||||
}
|
||||
|
||||
static int charger_notifier_callback(struct notifier_block *nb,
|
||||
unsigned long val, void *v)
|
||||
{
|
||||
int ret = 0;
|
||||
struct power_supply *psy = NULL;
|
||||
struct usb_charger_detection *charger_detection =
|
||||
container_of(nb, struct usb_charger_detection, charger_notif);
|
||||
union power_supply_propval prop;
|
||||
|
||||
psy= power_supply_get_by_name("usb");
|
||||
if (!psy){
|
||||
return -EINVAL;
|
||||
GTP_ERROR("Couldn't get usbpsy\n");
|
||||
}
|
||||
|
||||
if (!strcmp(psy->desc->name, "usb")){
|
||||
if (psy && charger_detection && val == POWER_SUPPLY_PROP_STATUS) {
|
||||
ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT,&prop);
|
||||
if (ret < 0) {
|
||||
GTP_ERROR("Couldn't get POWER_SUPPLY_PROP_ONLINE rc=%d\n", ret);
|
||||
return ret;
|
||||
}else{
|
||||
usb_detect_flag = prop.intval;
|
||||
if(usb_detect_flag != charger_detection->usb_connected) {
|
||||
if (1 == usb_detect_flag) {
|
||||
charger_detection->usb_connected = 1;
|
||||
}else{
|
||||
charger_detection->usb_connected = 0;
|
||||
}
|
||||
|
||||
queue_work(charger_detection->gcore_charger_notify_wq, \
|
||||
&charger_detection->charger_notify_work);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gcore_charger_notifier_init(void)
|
||||
{
|
||||
struct power_supply *psy = NULL;
|
||||
union power_supply_propval prop = {0};
|
||||
int ret = 0;
|
||||
|
||||
GTP_ERROR("charger_detection on");
|
||||
|
||||
charger_detection.usb_connected = 0;
|
||||
charger_detection.gcore_charger_notify_wq = create_singlethread_workqueue("gcore_charge_wq");
|
||||
if (!charger_detection.gcore_charger_notify_wq) {
|
||||
GTP_ERROR("allocate gcore_charger_notify_wq failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
INIT_WORK(&charger_detection.charger_notify_work, gcore_charger_notify_work);
|
||||
|
||||
charger_detection.charger_notif.notifier_call = charger_notifier_callback;
|
||||
ret = power_supply_reg_notifier(&charger_detection.charger_notif);
|
||||
if (ret) {
|
||||
GTP_ERROR("Unable to register charger_notifier:%d\n", ret);
|
||||
goto fail1;
|
||||
}
|
||||
|
||||
/* if power supply supplier registered brfore TP
|
||||
* ps_notify_callback will not receive PSY_EVENT_PROP_ADDED
|
||||
* event, and will cause miss to set TP into charger state.
|
||||
* So check PS state in probe.
|
||||
*/
|
||||
psy = power_supply_get_by_name("usb");
|
||||
if (psy) {
|
||||
ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT,&prop);
|
||||
if (ret < 0) {
|
||||
GTP_ERROR("Couldn't get POWER_SUPPLY_PROP_ONLINE rc=%d\n", ret);
|
||||
goto fail1;
|
||||
} else {
|
||||
usb_detect_flag = prop.intval;
|
||||
if (usb_detect_flag != charger_detection.usb_connected) {
|
||||
if (1 == usb_detect_flag) {
|
||||
charger_detection.usb_connected = 1;
|
||||
} else {
|
||||
charger_detection.usb_connected = 0;
|
||||
}
|
||||
|
||||
if (charger_detection.usb_connected) {
|
||||
gcore_fw_event_notify(FW_CHARGER_PLUG);
|
||||
} else {
|
||||
gcore_fw_event_notify(FW_CHARGER_UNPLUG);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail1:
|
||||
if (charger_detection.charger_notif.notifier_call)
|
||||
power_supply_unreg_notifier(&charger_detection.charger_notif);
|
||||
|
||||
destroy_workqueue(charger_detection.gcore_charger_notify_wq);
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ENABLE_GESTURE_WAKEUP) && defined(CONFIG_GESTURE_SPECIAL_INT)
|
||||
|
||||
int gcore_enable_irq_wake(struct gcore_dev *gdev)
|
||||
|
|
@ -132,15 +255,20 @@ void gcore_suspend(void)
|
|||
fn_data.gdev->tp_suspend = true;
|
||||
|
||||
if (fn_data.gdev->should_enable_gesture) {
|
||||
gcore_fw_event_notify(FW_GESTURE_ENABLE);
|
||||
fn_data.gdev->gesture_enabled = true;
|
||||
fn_data.gdev->wakeable = true;
|
||||
enable_irq_wake(gdev->touch_irq);
|
||||
GTP_DEBUG("Enable gcore irq wake");
|
||||
}
|
||||
else {
|
||||
gcore_fw_event_notify(FW_GESTURE_DISABLE);
|
||||
}
|
||||
fn_data.gdev->screen_state = SCREEN_OFF;
|
||||
mutex_unlock(&fn_data.gdev->state_mutex);
|
||||
#else
|
||||
fn_data.gdev->tp_suspend = true;
|
||||
gcore_fw_event_notify(FW_GESTURE_DISABLE);
|
||||
#endif
|
||||
|
||||
msleep(20);
|
||||
|
|
|
|||
Loading…
Reference in a new issue