input: fingerprint: goodix_tee: Add support for more supply configs
Change-Id: Ib69d8c347081115ff2c2c2c951e7f95100debf1d Co-authored-by: Arian <arian.kulmer@web.de> Signed-off-by: Jens Reidel <adrian@travitia.xyz> Signed-off-by: Arian <arian.kulmer@web.de>
This commit is contained in:
parent
3f9e307f9e
commit
9f53b09dc1
@ -99,6 +99,48 @@ struct gf_key_map maps[] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
static void disable_regulators(struct gf_supplies *supplies)
|
||||
{
|
||||
if (!IS_ERR_OR_NULL(supplies->vdda))
|
||||
regulator_disable(supplies->vdda);
|
||||
if (!IS_ERR_OR_NULL(supplies->vddb))
|
||||
regulator_disable(supplies->vddb);
|
||||
}
|
||||
|
||||
static int enable_regulators(struct device *dev, struct gf_supplies *supplies)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
supplies->vdda = devm_regulator_get_optional(dev, "vdda");
|
||||
if (IS_ERR(supplies->vdda)) {
|
||||
rc = PTR_ERR(supplies->vdda);
|
||||
return rc;
|
||||
}
|
||||
|
||||
supplies->vddb = devm_regulator_get_optional(dev, "vddb");
|
||||
if (IS_ERR(supplies->vddb)) {
|
||||
rc = PTR_ERR(supplies->vddb);
|
||||
if (rc == -ENODEV)
|
||||
supplies->vddb = NULL;
|
||||
else
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = regulator_set_load(supplies->vdda, 200000);
|
||||
if (rc) return rc;
|
||||
rc = regulator_enable(supplies->vdda);
|
||||
if (rc) return rc;
|
||||
|
||||
if (supplies->vddb) {
|
||||
rc = regulator_set_load(supplies->vddb, 200000);
|
||||
if (rc) return rc;
|
||||
rc = regulator_enable(supplies->vddb);
|
||||
if (rc) return rc;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void gf_enable_irq(struct gf_dev *gf_dev)
|
||||
{
|
||||
if (gf_dev->irq_enabled) {
|
||||
@ -601,35 +643,6 @@ static int gf_open(struct inode *inode, struct file *filp)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_FINGERPRINT_FP_VREG_CONTROL
|
||||
pr_info("Try to enable fp_vdd_vreg\n");
|
||||
gf_dev->vreg = regulator_get(&gf_dev->spi->dev, "fp_vdd_vreg");
|
||||
|
||||
if (gf_dev->vreg == NULL) {
|
||||
dev_err(&gf_dev->spi->dev,
|
||||
"fp_vdd_vreg regulator get failed!\n");
|
||||
mutex_unlock(&device_list_lock);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
if (regulator_is_enabled(gf_dev->vreg)) {
|
||||
pr_info("fp_vdd_vreg is already enabled!\n");
|
||||
} else {
|
||||
rc = regulator_enable(gf_dev->vreg);
|
||||
|
||||
if (rc) {
|
||||
dev_err(&gf_dev->spi->dev,
|
||||
"error enabling fp_vdd_vreg!\n");
|
||||
regulator_put(gf_dev->vreg);
|
||||
gf_dev->vreg = NULL;
|
||||
mutex_unlock(&device_list_lock);
|
||||
return -EPERM;
|
||||
}
|
||||
}
|
||||
|
||||
pr_info("fp_vdd_vreg is enabled %d!\n",
|
||||
regulator_get_voltage(gf_dev->vreg));
|
||||
#endif
|
||||
|
||||
if (status == 0) {
|
||||
#ifdef GF_PW_CTL
|
||||
@ -716,19 +729,6 @@ static int gf_release(struct inode *inode, struct file *filp)
|
||||
mutex_lock(&device_list_lock);
|
||||
gf_dev = filp->private_data;
|
||||
filp->private_data = NULL;
|
||||
/*
|
||||
*Disable fp_vdd_vreg regulator
|
||||
*/
|
||||
#ifdef CONFIG_FINGERPRINT_FP_VREG_CONTROL
|
||||
pr_info("disable fp_vdd_vreg!\n");
|
||||
|
||||
if (regulator_is_enabled(gf_dev->vreg)) {
|
||||
//regulator_disable(gf_dev->vreg);
|
||||
//regulator_put(gf_dev->vreg);
|
||||
//gf_dev->vreg = NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
gf_dev->users--;
|
||||
|
||||
if (!gf_dev->users) {
|
||||
@ -929,6 +929,11 @@ static int gf_probe(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
status = enable_regulators(&gf_dev->spi->dev, &gf_dev->supplies);
|
||||
if (status) {
|
||||
goto error_regulator;
|
||||
}
|
||||
|
||||
#ifdef AP_CONTROL_CLK
|
||||
pr_debug("Get the clk resource.\n");
|
||||
|
||||
@ -956,6 +961,9 @@ static int gf_probe(struct platform_device *pdev)
|
||||
gfspi_ioctl_clk_uninit(gf_dev);
|
||||
gfspi_probe_clk_init_failed:
|
||||
#endif
|
||||
error_regulator:
|
||||
disable_regulators(&gf_dev->supplies);
|
||||
|
||||
input_unregister_device(gf_dev->input);
|
||||
error_input:
|
||||
|
||||
@ -987,6 +995,9 @@ static int gf_remove(struct platform_device *pdev)
|
||||
#endif
|
||||
{
|
||||
struct gf_dev *gf_dev = &gf;
|
||||
|
||||
disable_regulators(&gf_dev->supplies);
|
||||
|
||||
wakeup_source_unregister(fp_wakelock);
|
||||
fp_wakelock = NULL;
|
||||
/* make sure ops on existing fds can abort cleanly */
|
||||
|
@ -78,6 +78,11 @@ struct gf_ioc_chip_info {
|
||||
unsigned char reserved[5];
|
||||
};
|
||||
|
||||
struct gf_supplies {
|
||||
struct regulator *vdda;
|
||||
struct regulator *vddb;
|
||||
};
|
||||
|
||||
#define GF_IOC_MAGIC 'g' /*define magic number*/
|
||||
#define GF_IOC_INIT _IOR(GF_IOC_MAGIC, 0, uint8_t)
|
||||
#define GF_IOC_EXIT _IO(GF_IOC_MAGIC, 1)
|
||||
@ -145,9 +150,7 @@ struct gf_dev {
|
||||
char fb_black;
|
||||
char wait_finger_down;
|
||||
struct work_struct work;
|
||||
#ifdef CONFIG_FINGERPRINT_FP_VREG_CONTROL
|
||||
struct regulator *vreg;
|
||||
#endif
|
||||
struct gf_supplies supplies;
|
||||
};
|
||||
|
||||
int gf_parse_dts(struct gf_dev *gf_dev);
|
||||
|
Loading…
Reference in New Issue
Block a user