Loading Documentation/devicetree/bindings/input/qpnp-power-on.txt +4 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,10 @@ Optional properties: - qcom,use-legacy-hard-reset-offset Boolean property to support legacy hard-reset offset of the PON_RB_SPARE register for some (PON gen2) platforms. - 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. All the below properties are in the sub-node section (properties of the child node). Loading Documentation/devicetree/bindings/misc/qpnp-misc.txt +6 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ Optional properties: if a non-zero PWM source is specified under "qcom,pwm-sel" property. - qcom,support-twm-config Enable configuration for TWM mode. - qcom,twm-mode The TWM mode which PMIC enters post power-off. Valid only if 'qcom,support-twm-config' is defined. If not specified, the default mode is 3. Example: qcom,misc@900 { compatible = "qcom,qpnp-misc"; Loading arch/arm64/boot/dts/qcom/8909w-pm660.dtsi +9 −0 Original line number Diff line number Diff line Loading @@ -469,6 +469,15 @@ qcom,support-twm-config; }; &pm660_pbs { status = "okay"; }; &pm660_pon { qcom,support-twm-config; qcom,pbs-client = <&pm660_pbs>; }; / { /delete-node/ qcom,battery-data; mtp_batterydata: qcom,battery-data { Loading arch/arm64/boot/dts/qcom/pm660.dtsi +7 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ reg = <0x900 0x100>; }; qcom,power-on@800 { pm660_pon: qcom,power-on@800 { compatible = "qcom,qpnp-power-on"; reg = <0x800 0x100>; interrupts = <0x0 0x8 0x0 IRQ_TYPE_NONE>, Loading Loading @@ -349,6 +349,12 @@ }; }; pm660_pbs: qcom,pbs@7400 { compatible = "qcom,qpnp-pbs"; reg = <0x7400 0x100>; status = "disabled"; }; bcl_sensor: bcl@4200 { compatible = "qcom,msm-bcl-lmh"; reg = <0x4200 0xff>, Loading drivers/input/misc/qpnp-power-on.c +65 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ #include <linux/regulator/machine.h> #include <linux/regulator/of_regulator.h> #include <linux/input/qpnp-power-on.h> #include <linux/qpnp/qpnp-pbs.h> #include <linux/qpnp/qpnp-misc.h> #include <linux/power_supply.h> #define PMIC_VER_8941 0x01 Loading Loading @@ -203,6 +205,7 @@ struct qpnp_pon { struct list_head list; struct delayed_work bark_work; struct dentry *debugfs; struct device_node *pbs_dev_node; int pon_trigger_reason; int pon_power_off_reason; int num_pon_reg; Loading @@ -220,6 +223,7 @@ struct qpnp_pon { u8 pon_ver; u8 warm_reset_reason1; u8 warm_reset_reason2; u8 twm_state; bool is_spon; bool store_hard_reset_reason; bool resin_hard_reset_disable; Loading @@ -227,8 +231,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; bool legacy_hard_reset_offset; }; Loading Loading @@ -483,6 +489,7 @@ static ssize_t qpnp_pon_dbc_store(struct device *dev, static DEVICE_ATTR(debounce_us, 0664, qpnp_pon_dbc_show, qpnp_pon_dbc_store); #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 @@ -490,6 +497,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 @@ -2087,6 +2107,35 @@ static int 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_probe(struct platform_device *pdev) { struct qpnp_pon *pon; Loading Loading @@ -2364,6 +2413,22 @@ static int qpnp_pon_probe(struct platform_device *pdev) goto err_out; } if (of_property_read_bool(pon->pdev->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(pon->pdev->dev.of_node, "qcom,pbs-client", 0); if (!pon->pbs_dev_node) { pr_err("Missing qcom,pbs-client property\n"); return -EINVAL; } } rc = of_property_read_u32(pon->pdev->dev.of_node, "qcom,pon-dbc-delay", &delay); if (rc) { Loading Loading
Documentation/devicetree/bindings/input/qpnp-power-on.txt +4 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,10 @@ Optional properties: - qcom,use-legacy-hard-reset-offset Boolean property to support legacy hard-reset offset of the PON_RB_SPARE register for some (PON gen2) platforms. - 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. All the below properties are in the sub-node section (properties of the child node). Loading
Documentation/devicetree/bindings/misc/qpnp-misc.txt +6 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ Optional properties: if a non-zero PWM source is specified under "qcom,pwm-sel" property. - qcom,support-twm-config Enable configuration for TWM mode. - qcom,twm-mode The TWM mode which PMIC enters post power-off. Valid only if 'qcom,support-twm-config' is defined. If not specified, the default mode is 3. Example: qcom,misc@900 { compatible = "qcom,qpnp-misc"; Loading
arch/arm64/boot/dts/qcom/8909w-pm660.dtsi +9 −0 Original line number Diff line number Diff line Loading @@ -469,6 +469,15 @@ qcom,support-twm-config; }; &pm660_pbs { status = "okay"; }; &pm660_pon { qcom,support-twm-config; qcom,pbs-client = <&pm660_pbs>; }; / { /delete-node/ qcom,battery-data; mtp_batterydata: qcom,battery-data { Loading
arch/arm64/boot/dts/qcom/pm660.dtsi +7 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ reg = <0x900 0x100>; }; qcom,power-on@800 { pm660_pon: qcom,power-on@800 { compatible = "qcom,qpnp-power-on"; reg = <0x800 0x100>; interrupts = <0x0 0x8 0x0 IRQ_TYPE_NONE>, Loading Loading @@ -349,6 +349,12 @@ }; }; pm660_pbs: qcom,pbs@7400 { compatible = "qcom,qpnp-pbs"; reg = <0x7400 0x100>; status = "disabled"; }; bcl_sensor: bcl@4200 { compatible = "qcom,msm-bcl-lmh"; reg = <0x4200 0xff>, Loading
drivers/input/misc/qpnp-power-on.c +65 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ #include <linux/regulator/machine.h> #include <linux/regulator/of_regulator.h> #include <linux/input/qpnp-power-on.h> #include <linux/qpnp/qpnp-pbs.h> #include <linux/qpnp/qpnp-misc.h> #include <linux/power_supply.h> #define PMIC_VER_8941 0x01 Loading Loading @@ -203,6 +205,7 @@ struct qpnp_pon { struct list_head list; struct delayed_work bark_work; struct dentry *debugfs; struct device_node *pbs_dev_node; int pon_trigger_reason; int pon_power_off_reason; int num_pon_reg; Loading @@ -220,6 +223,7 @@ struct qpnp_pon { u8 pon_ver; u8 warm_reset_reason1; u8 warm_reset_reason2; u8 twm_state; bool is_spon; bool store_hard_reset_reason; bool resin_hard_reset_disable; Loading @@ -227,8 +231,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; bool legacy_hard_reset_offset; }; Loading Loading @@ -483,6 +489,7 @@ static ssize_t qpnp_pon_dbc_store(struct device *dev, static DEVICE_ATTR(debounce_us, 0664, qpnp_pon_dbc_show, qpnp_pon_dbc_store); #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 @@ -490,6 +497,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 @@ -2087,6 +2107,35 @@ static int 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_probe(struct platform_device *pdev) { struct qpnp_pon *pon; Loading Loading @@ -2364,6 +2413,22 @@ static int qpnp_pon_probe(struct platform_device *pdev) goto err_out; } if (of_property_read_bool(pon->pdev->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(pon->pdev->dev.of_node, "qcom,pbs-client", 0); if (!pon->pbs_dev_node) { pr_err("Missing qcom,pbs-client property\n"); return -EINVAL; } } rc = of_property_read_u32(pon->pdev->dev.of_node, "qcom,pon-dbc-delay", &delay); if (rc) { Loading