sx933x: add recal on flip

Recalibrate the capsensor when the extcon
flip device is changed.

Requires an extcon parameter in the device
tree node.

Change-Id: I7a7408a064620fdd67a55a7f2f877d4a3542bf00
Signed-off-by: Ryan Lattrel <ryanl@motorola.com>
Reviewed-on: https://gerrit.mot.com/1290732
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Konstantin Makariev <kmakariev@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Ryan Lattrel 2019-01-07 17:25:53 -06:00
commit ca50551fda
3 changed files with 55 additions and 1 deletions

View file

@ -11,6 +11,11 @@ EXTRA_CFLAGS += -DCONFIG_CAPSENSE_USB_CAL \
-DCONFIG_CAPSENSE_ATTACH_CAL
endif
ifneq (,$(filter olson%,$(TARGET_PRODUCT)))
EXTRA_CFLAGS += -DCONFIG_CAPSENSE_USB_CAL \
-DCONFIG_CAPSENSE_FLIP_CAL
endif
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../../sensors/Module.symvers
sx932x_sar-y := sx933x_sar.o

View file

@ -803,7 +803,7 @@ static int ps_notify_callback(struct notifier_block *self,
bool present;
int retval;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
if (event == PSY_EVENT_PROP_CHANGED
#else
if ((event == PSY_EVENT_PROP_ADDED || event == PSY_EVENT_PROP_CHANGED)
@ -845,6 +845,25 @@ static int ps_notify_callback(struct notifier_block *self,
return 0;
}
#ifdef CONFIG_CAPSENSE_FLIP_CAL
static int flip_notify_callback(struct notifier_block *self,
unsigned long state, void *p)
{
struct sx933x_platform_data *data =
container_of(self, struct sx933x_platform_data, flip_notif);
struct extcon_dev *edev = p;
if(data->ext_flip_det == edev) {
if(data->phone_flip_state != state) {
data->phone_flip_state = state;
schedule_work(&data->ps_notify_work);
}
}
return 0;
}
#endif
#endif
/*! \fn static int sx933x_probe(struct i2c_client *client, const struct i2c_device_id *id)
@ -1047,6 +1066,27 @@ static int sx933x_probe(struct i2c_client *client, const struct i2c_device_id *i
power_supply_unreg_notifier(&pplatData->ps_notif);
}
}
#ifdef CONFIG_CAPSENSE_FLIP_CAL
if (of_property_read_bool(client->dev.of_node, "extcon")) {
pplatData->flip_notif.notifier_call = flip_notify_callback;
pplatData->ext_flip_det =
extcon_get_edev_by_phandle(&client->dev, 0);
if (IS_ERR(pplatData->ext_flip_det)) {
pplatData->ext_flip_det = NULL;
pr_err("%s: failed to get extcon flip dev\n", __func__);
} else {
if(extcon_register_notifier(pplatData->ext_flip_det,
EXTCON_MECHANICAL, &pplatData->flip_notif))
pr_err("%s: failed to register extcon flip dev notifier\n",
__func__);
else
pplatData->phone_flip_state =
extcon_get_state(pplatData->ext_flip_det,
EXTCON_MECHANICAL);
}
} else
pr_err("%s: extcon not in dev tree!\n", __func__);
#endif
#endif
sx93XX_IRQ_init(this);

View file

@ -10,6 +10,10 @@
#include <linux/slab.h>
#include <linux/interrupt.h>
#ifdef CONFIG_CAPSENSE_FLIP_CAL
#include <linux/extcon.h>
#endif
#if 0
#include <linux/wakelock.h>
#include <linux/earlysuspend.h>
@ -703,6 +707,11 @@ struct sx933x_platform_data
#ifdef CONFIG_CAPSENSE_ATTACH_CAL
bool phone_is_present;
#endif
#ifdef CONFIG_CAPSENSE_FLIP_CAL
struct notifier_block flip_notif;
struct extcon_dev *ext_flip_det;
bool phone_flip_state;
#endif
#endif
pbuttonInformation_t pbuttonInformation;