Loading Documentation/devicetree/bindings/leds/leds-qpnp-haptics.txt +5 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,11 @@ Properties: Definition: Short circuit debounce cycles for internal PWM. Allowed values: 0, 8, 16 or 32. - vcc_pon-supply Usage: optional Value type: <phandle> Definition: PON driver regulator required to force MBG_ON Following properties are specific only to LRA vibrators. - qcom,lra-auto-mode Loading drivers/leds/leds-qpnp-haptics.c +33 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <linux/platform_device.h> #include <linux/pwm.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/qpnp/qpnp-misc.h> #include <linux/qpnp/qpnp-revid.h> Loading Loading @@ -321,6 +322,7 @@ struct hap_chip { int sc_irq; struct pwm_param pwm_data; struct hap_lra_ares_param ares_cfg; struct regulator *vcc_pon; u32 play_time_ms; u32 max_play_time_ms; u32 vmax_mv; Loading Loading @@ -355,6 +357,7 @@ struct hap_chip { bool lra_auto_mode; bool play_irq_en; bool auto_res_err_recovery_hw; bool vcc_pon_enabled; }; static int qpnp_haptics_parse_buffer_dt(struct hap_chip *chip); Loading Loading @@ -801,10 +804,29 @@ static void qpnp_haptics_work(struct work_struct *work) enable = atomic_read(&chip->state); pr_debug("state: %d\n", enable); if (chip->vcc_pon && enable && !chip->vcc_pon_enabled) { rc = regulator_enable(chip->vcc_pon); if (rc < 0) pr_err("%s: could not enable vcc_pon regulator rc=%d\n", __func__, rc); else chip->vcc_pon_enabled = true; } rc = qpnp_haptics_play(chip, enable); if (rc < 0) pr_err("Error in %sing haptics, rc=%d\n", enable ? "play" : "stopp", rc); if (chip->vcc_pon && !enable && chip->vcc_pon_enabled) { rc = regulator_disable(chip->vcc_pon); if (rc) pr_err("%s: could not disable vcc_pon regulator rc=%d\n", __func__, rc); else chip->vcc_pon_enabled = false; } } static enum hrtimer_restart hap_stop_timer(struct hrtimer *timer) Loading Loading @@ -2054,6 +2076,7 @@ static int qpnp_haptics_parse_dt(struct hap_chip *chip) struct device_node *revid_node, *misc_node; const char *temp_str; int rc, temp; struct regulator *vcc_pon; rc = of_property_read_u32(node, "reg", &temp); if (rc < 0) { Loading Loading @@ -2381,6 +2404,16 @@ static int qpnp_haptics_parse_dt(struct hap_chip *chip) else if (chip->play_mode == HAP_PWM) rc = qpnp_haptics_parse_pwm_dt(chip); if (of_find_property(node, "vcc_pon-supply", NULL)) { vcc_pon = regulator_get(&chip->pdev->dev, "vcc_pon"); if (IS_ERR(vcc_pon)) { rc = PTR_ERR(vcc_pon); dev_err(&chip->pdev->dev, "regulator get failed vcc_pon rc=%d\n", rc); } chip->vcc_pon = vcc_pon; } return rc; } Loading Loading
Documentation/devicetree/bindings/leds/leds-qpnp-haptics.txt +5 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,11 @@ Properties: Definition: Short circuit debounce cycles for internal PWM. Allowed values: 0, 8, 16 or 32. - vcc_pon-supply Usage: optional Value type: <phandle> Definition: PON driver regulator required to force MBG_ON Following properties are specific only to LRA vibrators. - qcom,lra-auto-mode Loading
drivers/leds/leds-qpnp-haptics.c +33 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <linux/platform_device.h> #include <linux/pwm.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/qpnp/qpnp-misc.h> #include <linux/qpnp/qpnp-revid.h> Loading Loading @@ -321,6 +322,7 @@ struct hap_chip { int sc_irq; struct pwm_param pwm_data; struct hap_lra_ares_param ares_cfg; struct regulator *vcc_pon; u32 play_time_ms; u32 max_play_time_ms; u32 vmax_mv; Loading Loading @@ -355,6 +357,7 @@ struct hap_chip { bool lra_auto_mode; bool play_irq_en; bool auto_res_err_recovery_hw; bool vcc_pon_enabled; }; static int qpnp_haptics_parse_buffer_dt(struct hap_chip *chip); Loading Loading @@ -801,10 +804,29 @@ static void qpnp_haptics_work(struct work_struct *work) enable = atomic_read(&chip->state); pr_debug("state: %d\n", enable); if (chip->vcc_pon && enable && !chip->vcc_pon_enabled) { rc = regulator_enable(chip->vcc_pon); if (rc < 0) pr_err("%s: could not enable vcc_pon regulator rc=%d\n", __func__, rc); else chip->vcc_pon_enabled = true; } rc = qpnp_haptics_play(chip, enable); if (rc < 0) pr_err("Error in %sing haptics, rc=%d\n", enable ? "play" : "stopp", rc); if (chip->vcc_pon && !enable && chip->vcc_pon_enabled) { rc = regulator_disable(chip->vcc_pon); if (rc) pr_err("%s: could not disable vcc_pon regulator rc=%d\n", __func__, rc); else chip->vcc_pon_enabled = false; } } static enum hrtimer_restart hap_stop_timer(struct hrtimer *timer) Loading Loading @@ -2054,6 +2076,7 @@ static int qpnp_haptics_parse_dt(struct hap_chip *chip) struct device_node *revid_node, *misc_node; const char *temp_str; int rc, temp; struct regulator *vcc_pon; rc = of_property_read_u32(node, "reg", &temp); if (rc < 0) { Loading Loading @@ -2381,6 +2404,16 @@ static int qpnp_haptics_parse_dt(struct hap_chip *chip) else if (chip->play_mode == HAP_PWM) rc = qpnp_haptics_parse_pwm_dt(chip); if (of_find_property(node, "vcc_pon-supply", NULL)) { vcc_pon = regulator_get(&chip->pdev->dev, "vcc_pon"); if (IS_ERR(vcc_pon)) { rc = PTR_ERR(vcc_pon); dev_err(&chip->pdev->dev, "regulator get failed vcc_pon rc=%d\n", rc); } chip->vcc_pon = vcc_pon; } return rc; } Loading