DLKM/fps:optimise power ctl for focal

optimise log process
Enable ff_device_control_reset

Change-Id: Ibb899cd1bfa22acd42066ec9368b9312afe4d273
Signed-off-by: chenlj2 <chenlj2@motorola.com>
Reviewed-on: https://gerrit.mot.com/2156913
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Weilong Wu <wuwl10@motorola.com>
Reviewed-by: Yan Zhang <zhangy26@motorola.com>
Reviewed-by: Tao Sun <suntao2@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
chenlj2 2021-12-29 15:31:39 +08:00 • committed by Lijun Chen
commit 3775caaa65
3 changed files with 41 additions and 35 deletions

View file

@ -51,7 +51,7 @@
/*
* Define the driver version string.
*/
#define FF_DRV_VERSION "v2.1.2"
#define FF_DRV_VERSION "v2.1.3"
/*
* Define the driver name.
@ -75,6 +75,7 @@ typedef struct {
#endif
bool b_driver_inited;
bool b_config_dirtied;
bool irq_wake_enabled;
} ff_ctl_context_t;
static ff_ctl_context_t *g_context = NULL;
@ -182,7 +183,7 @@ extern int ff_ctl_free_pins(void);
extern int ff_ctl_enable_spiclk(bool on);
#endif
extern int ff_ctl_enable_power(bool on);
extern int ff_ctl_reset_device(void);
extern int ff_ctl_reset_device(uint32_t level);
extern const char *ff_ctl_arch_str(void);
@ -389,9 +390,11 @@ static int ff_ctl_free_driver(void)
/* Release IRQ resource. */
if (g_context->irq_num > 0) {
err = disable_irq_wake(g_context->irq_num);
if (err) {
FF_LOGE("disable_irq_wake(%d) = %d.", g_context->irq_num, err);
if (g_context->irq_wake_enabled) {
err = disable_irq_wake(g_context->irq_num);
if (err) {
FF_LOGE("disable_irq_wake(%d) = %d.", g_context->irq_num, err);
}
}
free_irq(g_context->irq_num, (void*)g_context);
g_context->irq_num = -1;
@ -413,6 +416,8 @@ static int ff_ctl_init_driver(void)
return (-ENOSYS);
}
g_context->irq_wake_enabled = false;
do {
/* Initialize the PWR/SPI/RST/INT pins resource. */
err = ff_ctl_init_pins(&g_context->irq_num);
@ -437,6 +442,7 @@ static int ff_ctl_init_driver(void)
if (err) {
FF_LOGE("enable_irq_wake(%d) = %d.", g_context->irq_num, err);
}
g_context->irq_wake_enabled = true;
/* Register spidev device. For REE-Emulation solution only. */
if (g_config && g_config->enable_spidev) {
@ -498,6 +504,7 @@ static int ff_ctl_fasync(int fd, struct file *filp, int mode)
static long ff_ctl_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
int err = 0;
uint32_t level = 0;
struct miscdevice *dev = (struct miscdevice *)filp->private_data;
ff_ctl_context_t *ctx = container_of(dev, ff_ctl_context_t, miscdev);
FF_LOGV("'%s' enter.", __func__);
@ -539,7 +546,9 @@ static long ff_ctl_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
break;
case FF_IOC_RESET_DEVICE:
err = ff_ctl_reset_device();
level = (uint32_t) arg;
FF_LOGD("level = %d", level);
err = ff_ctl_reset_device(level);
break;
case FF_IOC_ENABLE_IRQ:
err = ff_ctl_enable_irq(1);

View file

@ -89,7 +89,7 @@ typedef struct {
#define FF_IOC_FREE_DRIVER _IO(FF_IOC_MAGIC, 0x01)
/* HW reset the fingerprint module. */
#define FF_IOC_RESET_DEVICE _IO(FF_IOC_MAGIC, 0x02)
#define FF_IOC_RESET_DEVICE _IOW(FF_IOC_MAGIC, 0x02, uint32_t)
/* Low-level IRQ control. */
#define FF_IOC_ENABLE_IRQ _IO(FF_IOC_MAGIC, 0x03)

View file

@ -50,40 +50,40 @@ int ff_ctl_init_pins(int *irq_num)
struct device_node *dev_node = NULL;
struct platform_device *pdev = NULL;
printk("'%s' enter.", __func__);
FF_LOGV("'%s' enter.", __func__);
/* Find device tree node. */
dev_node = of_find_compatible_node(NULL, NULL, FF_COMPATIBLE_NODE);
if (!dev_node) {
printk("of_find_compatible_node(.., '%s') failed.", FF_COMPATIBLE_NODE);
FF_LOGE("of_find_compatible_node(.., '%s') failed.", FF_COMPATIBLE_NODE);
return (-ENODEV);
}
printk("dev_node :%s",dev_node->name);
FF_LOGI("dev_node :%s",dev_node->name);
irq_num1 = irq_of_parse_and_map(dev_node, 0);
*irq_num = irq_num1;
printk("irq number is %d.", irq_num1);
FF_LOGI("irq number is %d.", irq_num1);
/* Convert to platform device. */
pdev = of_find_device_by_node(dev_node);
if (!pdev) {
printk("of_find_device_by_node(..) failed.");
FF_LOGE("of_find_device_by_node(..) failed.");
return (-ENODEV);
}
/* Retrieve the pinctrl handler. */
g_context->pinctrl = devm_pinctrl_get(&pdev->dev);
if (!g_context->pinctrl) {
printk("devm_pinctrl_get(..) failed.");
FF_LOGE("devm_pinctrl_get(..) failed.");
return (-ENODEV);
}
printk("register pins.");
FF_LOGI("register pins.");
/* Register all pins. */
for (i = 0; i < FF_PINCTRL_STATE_MAXIMUM; ++i) {
g_context->pin_states[i] = pinctrl_lookup_state(g_context->pinctrl, g_pinctrl_state_names[i]);
if (!g_context->pin_states[i]) {
printk("can't find pinctrl state for '%s'.", g_pinctrl_state_names[i]);
FF_LOGE("can't find pinctrl state for '%s'.", g_pinctrl_state_names[i]);
err = (-ENODEV);
break;
}
@ -93,7 +93,7 @@ int ff_ctl_init_pins(int *irq_num)
}
/* Initialize the INT pin. */
printk("init int pin.");
FF_LOGI("init int pin.");
err = pinctrl_select_state(g_context->pinctrl, g_context->pin_states[FF_PINCTRL_STATE_INT_ACT]);
/* Initialize the RST pin. */
@ -101,21 +101,21 @@ int ff_ctl_init_pins(int *irq_num)
ff_ctl_enable_power(true);
printk("'%s' leave.", __func__);
FF_LOGV("'%s' leave.", __func__);
return err;
}
int ff_ctl_free_pins(void)
{
int err = 0;
printk("'%s' enter.", __func__);
FF_LOGV("'%s' enter.", __func__);
// TODO:
if (g_context->pinctrl) {
pinctrl_put(g_context->pinctrl);
g_context->pinctrl = NULL;
}
printk("'%s' leave.", __func__);
FF_LOGV("'%s' leave.", __func__);
return err;
}
@ -138,8 +138,8 @@ int ff_ctl_enable_spiclk(bool on)
int ff_ctl_enable_power(bool on)
{
int err = 0;
printk("'%s' enter.", __func__);
printk("power: '%s'.", on ? "on" : "off");
FF_LOGV("'%s' enter.", __func__);
FF_LOGI("power: '%s'.", on ? "on" : "off");
if (unlikely(!g_context->pinctrl)) {
return (-ENOSYS);
@ -151,31 +151,28 @@ int ff_ctl_enable_power(bool on)
err = pinctrl_select_state(g_context->pinctrl, g_context->pin_states[FF_PINCTRL_STATE_PWR_CLR]);
}
printk("'%s' leave.", __func__);
FF_LOGV("'%s' leave.", __func__);
return err;
}
int ff_ctl_reset_device(void)
int ff_ctl_reset_device(uint32_t level)
{
int err = 0;
printk("'%s' enter.", __func__);
FF_LOGV("'%s' enter.", __func__);
if (unlikely(!g_context->pinctrl)) {
return (-ENOSYS);
}
err = pinctrl_select_state(g_context->pinctrl, g_context->pin_states[FF_PINCTRL_STATE_RST_ACT]);
mdelay(1);
/* 3-1: Pull down RST pin. */
err = pinctrl_select_state(g_context->pinctrl, g_context->pin_states[FF_PINCTRL_STATE_RST_CLR]);
if (level) {
/* Pull up RST pin. */
err = pinctrl_select_state(g_context->pinctrl, g_context->pin_states[FF_PINCTRL_STATE_RST_ACT]);
} else {
/* Pull down RST pin. */
err = pinctrl_select_state(g_context->pinctrl, g_context->pin_states[FF_PINCTRL_STATE_RST_CLR]);
}
/* 3-2: Delay for 10ms. */
mdelay(10);
/* Pull up RST pin. */
err = pinctrl_select_state(g_context->pinctrl, g_context->pin_states[FF_PINCTRL_STATE_RST_ACT]);
printk("'%s' leave.", __func__);
FF_LOGV("'%s' leave.", __func__);
return err;
}