Loading drivers/regulator/qpnp-lcdb-regulator.c +75 −6 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #define pr_fmt(fmt) "LCDB: %s: " fmt, __func__ Loading Loading @@ -218,6 +218,7 @@ struct qpnp_lcdb { struct device *dev; struct platform_device *pdev; struct regmap *regmap; struct class lcdb_class; struct pmic_revid_data *pmic_rev_id; u32 base; u32 wa_flags; Loading @@ -233,6 +234,8 @@ struct qpnp_lcdb { bool settings_saved; bool lcdb_sc_disable; bool voltage_step_ramp; /* Tracks the secure UI mode entry/exit */ bool secure_mode; int sc_count; ktime_t sc_module_enable_time; Loading Loading @@ -769,9 +772,7 @@ static int qpnp_lcdb_enable_wa(struct qpnp_lcdb *lcdb) return rc; } /* execute the below for rev1.1 */ if (lcdb->pmic_rev_id->rev3 == PM660L_V1P1_REV3 && lcdb->pmic_rev_id->rev4 == PM660L_V1P1_REV4) { if (lcdb->wa_flags & NCP_SCP_DISABLE_WA) { /* * delay to make sure that the MID pin – ie the * output of the LCDB boost – returns to 0V Loading Loading @@ -1326,6 +1327,9 @@ static int qpnp_lcdb_ldo_regulator_enable(struct regulator_dev *rdev) int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; mutex_lock(&lcdb->lcdb_mutex); rc = qpnp_lcdb_enable(lcdb); if (rc < 0) Loading @@ -1340,6 +1344,9 @@ static int qpnp_lcdb_ldo_regulator_disable(struct regulator_dev *rdev) int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; mutex_lock(&lcdb->lcdb_mutex); rc = qpnp_lcdb_disable(lcdb); if (rc < 0) Loading @@ -1362,6 +1369,9 @@ static int qpnp_lcdb_ldo_regulator_set_voltage(struct regulator_dev *rdev, int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; lcdb->ldo.voltage_mv = min_uV / 1000; if (lcdb->voltage_step_ramp) rc = qpnp_lcdb_set_voltage_step(lcdb, Loading Loading @@ -1405,6 +1415,9 @@ static int qpnp_lcdb_ncp_regulator_enable(struct regulator_dev *rdev) int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; mutex_lock(&lcdb->lcdb_mutex); rc = qpnp_lcdb_enable(lcdb); if (rc < 0) Loading @@ -1419,6 +1432,9 @@ static int qpnp_lcdb_ncp_regulator_disable(struct regulator_dev *rdev) int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; mutex_lock(&lcdb->lcdb_mutex); rc = qpnp_lcdb_disable(lcdb); if (rc < 0) Loading @@ -1441,6 +1457,9 @@ static int qpnp_lcdb_ncp_regulator_set_voltage(struct regulator_dev *rdev, int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; lcdb->ncp.voltage_mv = min_uV / 1000; if (lcdb->voltage_step_ramp) rc = qpnp_lcdb_set_voltage_step(lcdb, Loading Loading @@ -2109,9 +2128,10 @@ static int qpnp_lcdb_hw_init(struct qpnp_lcdb *lcdb) return rc; } if (lcdb->sc_irq >= 0 && lcdb->pmic_rev_id->pmic_subtype != PM660L_SUBTYPE) { if (lcdb->sc_irq >= 0 && !(lcdb->wa_flags & NCP_SCP_DISABLE_WA)) { lcdb->sc_count = 0; irq_set_status_flags(lcdb->sc_irq, IRQ_DISABLE_UNLAZY); rc = devm_request_threaded_irq(lcdb->dev, lcdb->sc_irq, NULL, qpnp_lcdb_sc_irq_handler, IRQF_ONESHOT, "qpnp_lcdb_sc_irq", lcdb); Loading Loading @@ -2233,6 +2253,45 @@ static int qpnp_lcdb_parse_dt(struct qpnp_lcdb *lcdb) return 0; } static ssize_t secure_mode_store(struct class *c, struct class_attribute *attr, const char *buf, size_t count) { struct qpnp_lcdb *lcdb = container_of(c, struct qpnp_lcdb, lcdb_class); int val, rc; rc = kstrtouint(buf, 0, &val); if (rc < 0) return rc; if (val != 0 && val != 1) return count; if (val == 1 && !lcdb->secure_mode) { if (lcdb->sc_irq > 0) disable_irq(lcdb->sc_irq); lcdb->secure_mode = true; } else if (val == 0 && lcdb->secure_mode) { if (lcdb->sc_irq > 0) enable_irq(lcdb->sc_irq); lcdb->secure_mode = false; } return count; } static CLASS_ATTR_WO(secure_mode); static struct attribute *lcdb_attrs[] = { &class_attr_secure_mode.attr, NULL, }; ATTRIBUTE_GROUPS(lcdb); static int qpnp_lcdb_regulator_probe(struct platform_device *pdev) { int rc; Loading Loading @@ -2272,6 +2331,16 @@ static int qpnp_lcdb_regulator_probe(struct platform_device *pdev) return rc; } lcdb->lcdb_class.name = "lcd_bias"; lcdb->lcdb_class.owner = THIS_MODULE; lcdb->lcdb_class.class_groups = lcdb_groups; rc = class_register(&lcdb->lcdb_class); if (rc < 0) { pr_err("Failed to register lcdb class rc = %d\n", rc); return rc; } rc = qpnp_lcdb_hw_init(lcdb); if (rc < 0) pr_err("Failed to initialize LCDB module rc=%d\n", rc); Loading Loading
drivers/regulator/qpnp-lcdb-regulator.c +75 −6 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #define pr_fmt(fmt) "LCDB: %s: " fmt, __func__ Loading Loading @@ -218,6 +218,7 @@ struct qpnp_lcdb { struct device *dev; struct platform_device *pdev; struct regmap *regmap; struct class lcdb_class; struct pmic_revid_data *pmic_rev_id; u32 base; u32 wa_flags; Loading @@ -233,6 +234,8 @@ struct qpnp_lcdb { bool settings_saved; bool lcdb_sc_disable; bool voltage_step_ramp; /* Tracks the secure UI mode entry/exit */ bool secure_mode; int sc_count; ktime_t sc_module_enable_time; Loading Loading @@ -769,9 +772,7 @@ static int qpnp_lcdb_enable_wa(struct qpnp_lcdb *lcdb) return rc; } /* execute the below for rev1.1 */ if (lcdb->pmic_rev_id->rev3 == PM660L_V1P1_REV3 && lcdb->pmic_rev_id->rev4 == PM660L_V1P1_REV4) { if (lcdb->wa_flags & NCP_SCP_DISABLE_WA) { /* * delay to make sure that the MID pin – ie the * output of the LCDB boost – returns to 0V Loading Loading @@ -1326,6 +1327,9 @@ static int qpnp_lcdb_ldo_regulator_enable(struct regulator_dev *rdev) int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; mutex_lock(&lcdb->lcdb_mutex); rc = qpnp_lcdb_enable(lcdb); if (rc < 0) Loading @@ -1340,6 +1344,9 @@ static int qpnp_lcdb_ldo_regulator_disable(struct regulator_dev *rdev) int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; mutex_lock(&lcdb->lcdb_mutex); rc = qpnp_lcdb_disable(lcdb); if (rc < 0) Loading @@ -1362,6 +1369,9 @@ static int qpnp_lcdb_ldo_regulator_set_voltage(struct regulator_dev *rdev, int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; lcdb->ldo.voltage_mv = min_uV / 1000; if (lcdb->voltage_step_ramp) rc = qpnp_lcdb_set_voltage_step(lcdb, Loading Loading @@ -1405,6 +1415,9 @@ static int qpnp_lcdb_ncp_regulator_enable(struct regulator_dev *rdev) int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; mutex_lock(&lcdb->lcdb_mutex); rc = qpnp_lcdb_enable(lcdb); if (rc < 0) Loading @@ -1419,6 +1432,9 @@ static int qpnp_lcdb_ncp_regulator_disable(struct regulator_dev *rdev) int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; mutex_lock(&lcdb->lcdb_mutex); rc = qpnp_lcdb_disable(lcdb); if (rc < 0) Loading @@ -1441,6 +1457,9 @@ static int qpnp_lcdb_ncp_regulator_set_voltage(struct regulator_dev *rdev, int rc = 0; struct qpnp_lcdb *lcdb = rdev_get_drvdata(rdev); if (lcdb->secure_mode) return 0; lcdb->ncp.voltage_mv = min_uV / 1000; if (lcdb->voltage_step_ramp) rc = qpnp_lcdb_set_voltage_step(lcdb, Loading Loading @@ -2109,9 +2128,10 @@ static int qpnp_lcdb_hw_init(struct qpnp_lcdb *lcdb) return rc; } if (lcdb->sc_irq >= 0 && lcdb->pmic_rev_id->pmic_subtype != PM660L_SUBTYPE) { if (lcdb->sc_irq >= 0 && !(lcdb->wa_flags & NCP_SCP_DISABLE_WA)) { lcdb->sc_count = 0; irq_set_status_flags(lcdb->sc_irq, IRQ_DISABLE_UNLAZY); rc = devm_request_threaded_irq(lcdb->dev, lcdb->sc_irq, NULL, qpnp_lcdb_sc_irq_handler, IRQF_ONESHOT, "qpnp_lcdb_sc_irq", lcdb); Loading Loading @@ -2233,6 +2253,45 @@ static int qpnp_lcdb_parse_dt(struct qpnp_lcdb *lcdb) return 0; } static ssize_t secure_mode_store(struct class *c, struct class_attribute *attr, const char *buf, size_t count) { struct qpnp_lcdb *lcdb = container_of(c, struct qpnp_lcdb, lcdb_class); int val, rc; rc = kstrtouint(buf, 0, &val); if (rc < 0) return rc; if (val != 0 && val != 1) return count; if (val == 1 && !lcdb->secure_mode) { if (lcdb->sc_irq > 0) disable_irq(lcdb->sc_irq); lcdb->secure_mode = true; } else if (val == 0 && lcdb->secure_mode) { if (lcdb->sc_irq > 0) enable_irq(lcdb->sc_irq); lcdb->secure_mode = false; } return count; } static CLASS_ATTR_WO(secure_mode); static struct attribute *lcdb_attrs[] = { &class_attr_secure_mode.attr, NULL, }; ATTRIBUTE_GROUPS(lcdb); static int qpnp_lcdb_regulator_probe(struct platform_device *pdev) { int rc; Loading Loading @@ -2272,6 +2331,16 @@ static int qpnp_lcdb_regulator_probe(struct platform_device *pdev) return rc; } lcdb->lcdb_class.name = "lcd_bias"; lcdb->lcdb_class.owner = THIS_MODULE; lcdb->lcdb_class.class_groups = lcdb_groups; rc = class_register(&lcdb->lcdb_class); if (rc < 0) { pr_err("Failed to register lcdb class rc = %d\n", rc); return rc; } rc = qpnp_lcdb_hw_init(lcdb); if (rc < 0) pr_err("Failed to initialize LCDB module rc=%d\n", rc); Loading