Loading Documentation/devicetree/bindings/input/qpnp-power-on.txt +4 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,10 @@ Optional properties: power off trigger during system shutdown case. - qcom,ps-hold-hard-reset-disable: Boolean property to disable PS_HOLD power off trigger during system hard reset case. - qcom,support-twm-config: Boolean property to allow the PON module to be configured to support TWM modes. - qcom,pbs-client: Phandle of the PBS client node. Should be defined if 'qcom,support-twm-config' is present. Optional Sub-nodes: - qcom,pon_1 ... qcom,pon_n: These PON child nodes correspond to features Loading drivers/input/misc/qpnp-power-on.c +65 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> #include <linux/regulator/of_regulator.h> #include <linux/qpnp/qpnp-pbs.h> #include <linux/qpnp/qpnp-misc.h> #define PMIC_VER_8941 0x01 #define PMIC_VERSION_REG 0x0105 Loading Loading @@ -210,11 +212,13 @@ struct qpnp_pon { struct mutex restore_lock; struct delayed_work bark_work; struct dentry *debugfs; struct device_node *pbs_dev_node; u16 base; u8 subtype; u8 pon_ver; u8 warm_reset_reason1; u8 warm_reset_reason2; u8 twm_state; int num_pon_config; int num_pon_reg; int pon_trigger_reason; Loading @@ -234,8 +238,10 @@ struct qpnp_pon { bool ps_hold_hard_reset_disable; bool ps_hold_shutdown_disable; bool kpdpwr_dbc_enable; bool support_twm_config; bool resin_pon_reset; ktime_t kpdpwr_last_release_time; struct notifier_block pon_nb; }; static int pon_ship_mode_en; Loading Loading @@ -534,6 +540,7 @@ static ssize_t debounce_us_store(struct device *dev, } static DEVICE_ATTR_RW(debounce_us); #define PON_TWM_ENTRY_PBS_BIT BIT(0) static int qpnp_pon_reset_config(struct qpnp_pon *pon, enum pon_power_off_type type) { Loading @@ -541,6 +548,19 @@ static int qpnp_pon_reset_config(struct qpnp_pon *pon, bool disable = false; u16 rst_en_reg; /* Ignore the PS_HOLD reset config if TWM ENTRY is enabled */ if (pon->support_twm_config && pon->twm_state == PMIC_TWM_ENABLE) { rc = qpnp_pbs_trigger_event(pon->pbs_dev_node, PON_TWM_ENTRY_PBS_BIT); if (rc < 0) { pr_err("Unable to trigger PBS trigger for TWM entry rc=%d\n", rc); return rc; } pr_crit("PMIC configured for TWM entry\n"); return 0; } if (pon->pon_ver == QPNP_PON_GEN1_V1) rst_en_reg = QPNP_PON_PS_HOLD_RST_CTL(pon); else Loading Loading @@ -2018,6 +2038,35 @@ static int qpnp_pon_read_gen2_pon_off_reason(struct qpnp_pon *pon, u16 *reason, return 0; } static int pon_twm_notifier_cb(struct notifier_block *nb, unsigned long action, void *data) { struct qpnp_pon *pon = container_of(nb, struct qpnp_pon, pon_nb); if (action != PMIC_TWM_CLEAR && action != PMIC_TWM_ENABLE) { pr_debug("Unsupported option %lu\n", action); return NOTIFY_OK; } pon->twm_state = (u8)action; pr_debug("TWM state = %d\n", pon->twm_state); return NOTIFY_OK; } static int pon_register_twm_notifier(struct qpnp_pon *pon) { int rc; pon->pon_nb.notifier_call = pon_twm_notifier_cb; rc = qpnp_misc_twm_notifier_register(&pon->pon_nb); if (rc < 0) pr_err("Failed to register pon_twm_notifier_cb rc=%d\n", rc); return rc; } static int qpnp_pon_configure_s3_reset(struct qpnp_pon *pon) { struct device *dev = pon->dev; Loading Loading @@ -2287,6 +2336,22 @@ static int qpnp_pon_probe(struct platform_device *pdev) } pon->base = base; if (of_property_read_bool(dev->of_node, "qcom,support-twm-config")) { pon->support_twm_config = true; rc = pon_register_twm_notifier(pon); if (rc < 0) { pr_err("Failed to register TWM notifier rc=%d\n", rc); return rc; } pon->pbs_dev_node = of_parse_phandle(dev->of_node, "qcom,pbs-client", 0); if (!pon->pbs_dev_node) { pr_err("Missing qcom,pbs-client property\n"); return -EINVAL; } } sys_reset = of_property_read_bool(dev->of_node, "qcom,system-reset"); if (sys_reset && sys_reset_dev) { dev_err(dev, "qcom,system-reset property must only be specified for one PMIC PON device in the system\n"); Loading Loading
Documentation/devicetree/bindings/input/qpnp-power-on.txt +4 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,10 @@ Optional properties: power off trigger during system shutdown case. - qcom,ps-hold-hard-reset-disable: Boolean property to disable PS_HOLD power off trigger during system hard reset case. - qcom,support-twm-config: Boolean property to allow the PON module to be configured to support TWM modes. - qcom,pbs-client: Phandle of the PBS client node. Should be defined if 'qcom,support-twm-config' is present. Optional Sub-nodes: - qcom,pon_1 ... qcom,pon_n: These PON child nodes correspond to features Loading
drivers/input/misc/qpnp-power-on.c +65 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> #include <linux/regulator/of_regulator.h> #include <linux/qpnp/qpnp-pbs.h> #include <linux/qpnp/qpnp-misc.h> #define PMIC_VER_8941 0x01 #define PMIC_VERSION_REG 0x0105 Loading Loading @@ -210,11 +212,13 @@ struct qpnp_pon { struct mutex restore_lock; struct delayed_work bark_work; struct dentry *debugfs; struct device_node *pbs_dev_node; u16 base; u8 subtype; u8 pon_ver; u8 warm_reset_reason1; u8 warm_reset_reason2; u8 twm_state; int num_pon_config; int num_pon_reg; int pon_trigger_reason; Loading @@ -234,8 +238,10 @@ struct qpnp_pon { bool ps_hold_hard_reset_disable; bool ps_hold_shutdown_disable; bool kpdpwr_dbc_enable; bool support_twm_config; bool resin_pon_reset; ktime_t kpdpwr_last_release_time; struct notifier_block pon_nb; }; static int pon_ship_mode_en; Loading Loading @@ -534,6 +540,7 @@ static ssize_t debounce_us_store(struct device *dev, } static DEVICE_ATTR_RW(debounce_us); #define PON_TWM_ENTRY_PBS_BIT BIT(0) static int qpnp_pon_reset_config(struct qpnp_pon *pon, enum pon_power_off_type type) { Loading @@ -541,6 +548,19 @@ static int qpnp_pon_reset_config(struct qpnp_pon *pon, bool disable = false; u16 rst_en_reg; /* Ignore the PS_HOLD reset config if TWM ENTRY is enabled */ if (pon->support_twm_config && pon->twm_state == PMIC_TWM_ENABLE) { rc = qpnp_pbs_trigger_event(pon->pbs_dev_node, PON_TWM_ENTRY_PBS_BIT); if (rc < 0) { pr_err("Unable to trigger PBS trigger for TWM entry rc=%d\n", rc); return rc; } pr_crit("PMIC configured for TWM entry\n"); return 0; } if (pon->pon_ver == QPNP_PON_GEN1_V1) rst_en_reg = QPNP_PON_PS_HOLD_RST_CTL(pon); else Loading Loading @@ -2018,6 +2038,35 @@ static int qpnp_pon_read_gen2_pon_off_reason(struct qpnp_pon *pon, u16 *reason, return 0; } static int pon_twm_notifier_cb(struct notifier_block *nb, unsigned long action, void *data) { struct qpnp_pon *pon = container_of(nb, struct qpnp_pon, pon_nb); if (action != PMIC_TWM_CLEAR && action != PMIC_TWM_ENABLE) { pr_debug("Unsupported option %lu\n", action); return NOTIFY_OK; } pon->twm_state = (u8)action; pr_debug("TWM state = %d\n", pon->twm_state); return NOTIFY_OK; } static int pon_register_twm_notifier(struct qpnp_pon *pon) { int rc; pon->pon_nb.notifier_call = pon_twm_notifier_cb; rc = qpnp_misc_twm_notifier_register(&pon->pon_nb); if (rc < 0) pr_err("Failed to register pon_twm_notifier_cb rc=%d\n", rc); return rc; } static int qpnp_pon_configure_s3_reset(struct qpnp_pon *pon) { struct device *dev = pon->dev; Loading Loading @@ -2287,6 +2336,22 @@ static int qpnp_pon_probe(struct platform_device *pdev) } pon->base = base; if (of_property_read_bool(dev->of_node, "qcom,support-twm-config")) { pon->support_twm_config = true; rc = pon_register_twm_notifier(pon); if (rc < 0) { pr_err("Failed to register TWM notifier rc=%d\n", rc); return rc; } pon->pbs_dev_node = of_parse_phandle(dev->of_node, "qcom,pbs-client", 0); if (!pon->pbs_dev_node) { pr_err("Missing qcom,pbs-client property\n"); return -EINVAL; } } sys_reset = of_property_read_bool(dev->of_node, "qcom,system-reset"); if (sys_reset && sys_reset_dev) { dev_err(dev, "qcom,system-reset property must only be specified for one PMIC PON device in the system\n"); Loading