return -ENODEV;
}
+#if defined(HX_USB_DETECT_GLOBAL)
+static int charger_notifier_callback(struct notifier_block *nb,
+ unsigned long val, void *v) {
+ int ret = 0;
+ struct power_supply *psy = NULL;
+ struct himax_ts_data *ts = container_of(nb, struct himax_ts_data, charger_notif);
+ union power_supply_propval prop;
+
+ psy= power_supply_get_by_name("usb");
+ if (!psy) {
+ return -EINVAL;
+ E("Couldn't get usbpsy\n");
+ }
+ if (!strcmp(psy->desc->name, "usb")) {
+ if (psy && ts && val == POWER_SUPPLY_PROP_STATUS) {
+ ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE,&prop);
+ if (ret < 0) {
+ E("Couldn't get POWER_SUPPLY_PROP_ONLINE rc=%d\n", ret);
+ return ret;
+ } else {
+ USB_detect_flag = prop.intval;
+ }
+ }
+ }
+ return 0;
+}
+#endif
+
int himax_chip_common_init(void)
{
#if defined(HX_USB_DETECT_CALLBACK) || defined(HX_USB_DETECT_GLOBAL)
ts->usb_connected = 0x00;
ts->cable_config = pdata->cable_config;
+
+ ts->charger_notif.notifier_call = charger_notifier_callback;
+ ret = power_supply_reg_notifier(&ts->charger_notif);
+ if (ret) {
+ E("Unable to register charger_notifier: %d\n",ret);
+ goto err_register_charger_notify_failed;
+ }
#endif
#ifdef HX_PROTOCOL_A
ts->protocol_type = PROTOCOL_TYPE_A;
}
err_update_wq_failed:
#endif
+#if defined(HX_USB_DETECT_GLOBAL)
+err_register_charger_notify_failed:
+ if (ts->charger_notif.notifier_call)
+ power_supply_unreg_notifier(&ts->charger_notif);
+#endif
error_ic_detect_failed:
if (gpio_is_valid(pdata->gpio_irq)) {
gpio_free(pdata->gpio_irq);
/*#define HX_GESTURE_TRACK*/
/*#define HX_HIGH_SENSE*/
/*#define HX_PALM_REPORT*/
-/*#define HX_USB_DETECT_GLOBAL*/
+#define HX_USB_DETECT_GLOBAL
/*#define HX_USB_DETECT_CALLBACK*/
/*#define HX_PROTOCOL_A*/ /* for MTK special platform.If turning on,it will report to system by using specific format. */
/*#define HX_RESUME_HW_RESET*/
/*#define HX_PLATFOME_DEFINE_KEY*/ /* for specfic platform to set key(button) */
#endif
+#ifdef HX_USB_DETECT_GLOBAL
+#include <linux/power_supply.h>
+#endif
+
#define HX_KEY_MAX_COUNT 4
#define DEFAULT_RETRY_CNT 3
#if defined(HX_USB_DETECT_CALLBACK) || defined(HX_USB_DETECT_GLOBAL)
uint8_t usb_connected;
uint8_t *cable_config;
+ struct notifier_block charger_notif;
#endif
-
-
};
struct himax_debug {
struct fb_event *evdata = data;
int *blank;
struct himax_ts_data *ts =
- container_of(self, struct himax_ts_data, fb_notif);
- I(" %s\n", __func__);
+ container_of(self, struct himax_ts_data, fb_notif);
- if (evdata && evdata->data && event == FB_EVENT_BLANK && ts &&
- ts->client) {
+ if (evdata && evdata->data && event == FB_EVENT_BLANK && ts && ts->client) {
blank = evdata->data;
switch (*blank) {
int himax_chip_common_remove(struct i2c_client *client)
{
+ struct himax_ts_data *ts = private_ts;
himax_chip_common_deinit();
+#if defined(HX_USB_DETECT_GLOBAL)
+ if (ts->charger_notif.notifier_call)
+ power_supply_unreg_notifier(&ts->charger_notif);
+#endif
+
return 0;
}
#elif defined(CONFIG_HAS_EARLYSUSPEND)
#include <linux/earlysuspend.h>
#endif
+
+#include "nt36xxx.h"
+
#if defined(CONFIG_CHARGER_NOTIFY)
#include <linux/power_supply.h>
#endif
-#include "nt36xxx.h"
-
#if NVT_TOUCH_ESD_PROTECT
#include <linux/jiffies.h>
}
if (!strcmp(psy->desc->name, "usb")){
if (psy && ts && val == POWER_SUPPLY_PROP_STATUS) {
- ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT,&prop);
+ ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE,&prop);
if (ret < 0) {
NVT_ERR("Couldn't get POWER_SUPPLY_PROP_ONLINE rc=%d\n", ret);
return ret;
ts->usb_connected = USB_DETECT_OUT;
}
if (bTouchIsAwake){
- queue_work(ts->nvt_charger_notify_wq, &ts->charger_notify_work);
+ queue_work(ts->nvt_charger_notify_wq, &ts->charger_notify_work);
}
}
}
#include "nt36xxx_mem_map.h"
#define NVT_DEBUG 0
+#define CONFIG_CHARGER_NOTIFY
//---GPIO number---
#define NVTTOUCH_RST_PIN 980