From 427a9919456fe4e616d27a4775e93e3e5cd0559c Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Fri, 3 Mar 2017 18:01:56 -0800 Subject: [PATCH] soc: qcom: qpnp-haptic: Remove use-play-irq and use-sc-irq flags Remove use_play_irq and use_sc_irq flags as they are not really needed. Interrupts can be obtained and registered always. Keep the play interrupt enabled only for buffer mode. Change-Id: Ie530819ed18b048d43d59dd7a0dc5f73cc3a9b70 Signed-off-by: Subbaraman Narayanamurthy --- .../devicetree/bindings/soc/qcom/qpnp-haptic.txt | 4 -- arch/arm/boot/dts/qcom/msm-pm660.dtsi | 6 +- arch/arm/boot/dts/qcom/msm-pmi8994.dtsi | 8 +-- arch/arm/boot/dts/qcom/msm-pmi8998.dtsi | 6 +- drivers/soc/qcom/qpnp-haptic.c | 70 +++++++++------------- 5 files changed, 34 insertions(+), 60 deletions(-) diff --git a/Documentation/devicetree/bindings/soc/qcom/qpnp-haptic.txt b/Documentation/devicetree/bindings/soc/qcom/qpnp-haptic.txt index 20cae18ce408..17a510a5ee6a 100644 --- a/Documentation/devicetree/bindings/soc/qcom/qpnp-haptic.txt +++ b/Documentation/devicetree/bindings/soc/qcom/qpnp-haptic.txt @@ -24,8 +24,6 @@ Optional Properties: 2-bit amplitude control 0x00: 0, 0x01: vmax/4, 0x02: vmax/2, 0x03: vmax. Default values are 0x00. - qcom,sc-deb-cycles : short circuit debounce in internal pwm switching clock cycles - - qcom,use-play-irq : boolean, use this if the device uses irq for play - - qcom,use-sc-irq : boolean, use this if the device uses irq for play - interrupts: Specifies the interrupt associated with Haptics. The available interrupts are play and short circuit. The values for play and short circuit are <0x3 0xc0 0x0> and <0x3 0xc0 0x1>. @@ -132,8 +130,6 @@ Example: qcom,int-pwm-freq-khz = <505>; qcom,en-brake; qcom,brake-pattern = [03 03 00 00]; - qcom,use-play-irq; - qcom,use-sc-irq; qcom,wave-samples = [3e 3e 3e 3e 3e 3e 3e 3e]; qcom,wave-rep-cnt = <1>; qcom,wave-samp-rep-cnt = <1>; diff --git a/arch/arm/boot/dts/qcom/msm-pm660.dtsi b/arch/arm/boot/dts/qcom/msm-pm660.dtsi index 929a56bf912a..beb014c37779 100644 --- a/arch/arm/boot/dts/qcom/msm-pm660.dtsi +++ b/arch/arm/boot/dts/qcom/msm-pm660.dtsi @@ -609,8 +609,8 @@ pm660_haptics: qcom,haptic@c000 { compatible = "qcom,qpnp-haptic"; reg = <0xc000 0x100>; - interrupts = <0x1 0xc0 0x0 IRQ_TYPE_NONE>, - <0x1 0xc0 0x1 IRQ_TYPE_NONE>; + interrupts = <0x1 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>, + <0x1 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>; interrupt-names = "sc-irq", "play-irq"; qcom,pmic-revid = <&pm660_revid>; qcom,pmic-misc = <&pm660_misc>; @@ -625,8 +625,6 @@ qcom,sc-deb-cycles = <8>; qcom,en-brake; qcom,brake-pattern = [03 03 00 00]; - qcom,use-play-irq; - qcom,use-sc-irq; qcom,lra-high-z = "opt0"; qcom,lra-auto-res-mode = "qwd"; qcom,lra-calibrate-at-eop = <0>; diff --git a/arch/arm/boot/dts/qcom/msm-pmi8994.dtsi b/arch/arm/boot/dts/qcom/msm-pmi8994.dtsi index c820d213165b..73ea5fae041e 100644 --- a/arch/arm/boot/dts/qcom/msm-pmi8994.dtsi +++ b/arch/arm/boot/dts/qcom/msm-pmi8994.dtsi @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -544,8 +544,8 @@ status = "disabled"; compatible = "qcom,qpnp-haptic"; reg = <0xc000 0x100>; - interrupts = <0x3 0xc0 0x0 IRQ_TYPE_NONE>, - <0x3 0xc0 0x1 IRQ_TYPE_NONE>; + interrupts = <0x3 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>, + <0x3 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>; interrupt-names = "sc-irq", "play-irq"; vcc_pon-supply = <&pon_perph_reg>; qcom,play-mode = "direct"; @@ -558,8 +558,6 @@ qcom,int-pwm-freq-khz = <505>; qcom,en-brake; qcom,brake-pattern = [03 03 00 00]; - qcom,use-play-irq; - qcom,use-sc-irq; qcom,wave-samples = [3e 3e 3e 3e 3e 3e 3e 3e]; qcom,wave-rep-cnt = <1>; qcom,wave-samp-rep-cnt = <1>; diff --git a/arch/arm/boot/dts/qcom/msm-pmi8998.dtsi b/arch/arm/boot/dts/qcom/msm-pmi8998.dtsi index 8607984a54cf..0cf67dd938e6 100644 --- a/arch/arm/boot/dts/qcom/msm-pmi8998.dtsi +++ b/arch/arm/boot/dts/qcom/msm-pmi8998.dtsi @@ -633,8 +633,8 @@ status = "disabled"; compatible = "qcom,qpnp-haptic"; reg = <0xc000 0x100>; - interrupts = <0x3 0xc0 0x0 IRQ_TYPE_NONE>, - <0x3 0xc0 0x1 IRQ_TYPE_NONE>; + interrupts = <0x3 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>, + <0x3 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>; interrupt-names = "sc-irq", "play-irq"; qcom,pmic-revid = <&pmi8998_revid>; qcom,pmic-misc = <&pmi8998_misc>; @@ -649,8 +649,6 @@ qcom,sc-deb-cycles = <8>; qcom,en-brake; qcom,brake-pattern = [03 03 00 00]; - qcom,use-play-irq; - qcom,use-sc-irq; qcom,lra-high-z = "opt1"; qcom,lra-auto-res-mode = "qwd"; qcom,lra-res-cal-period = <4>; diff --git a/drivers/soc/qcom/qpnp-haptic.c b/drivers/soc/qcom/qpnp-haptic.c index 776dcb30eb05..f0f9306ebe47 100644 --- a/drivers/soc/qcom/qpnp-haptic.c +++ b/drivers/soc/qcom/qpnp-haptic.c @@ -33,10 +33,6 @@ #include #include "../../staging/android/timed_output.h" -#define QPNP_IRQ_FLAGS (IRQF_TRIGGER_RISING | \ - IRQF_TRIGGER_FALLING | \ - IRQF_ONESHOT) - #define QPNP_HAP_STATUS(b) (b + 0x0A) #define QPNP_HAP_LRA_AUTO_RES_LO(b) (b + 0x0B) #define QPNP_HAP_LRA_AUTO_RES_HI(b) (b + 0x0C) @@ -313,8 +309,6 @@ struct qpnp_pwm_info { * @ lra_res_cal_period - period for resonance calibration * @ sc_duration - counter to determine the duration of short circuit condition * @ state - current state of haptics - * @ use_play_irq - play irq usage state - * @ use_sc_irq - short circuit irq usage state * @ wf_update - waveform update flag * @ pwm_cfg_state - pwm mode configuration state * @ buffer_cfg_state - buffer mode configuration state @@ -381,8 +375,6 @@ struct qpnp_hap { u8 clk_trim_error_code; bool vcc_pon_enabled; bool state; - bool use_play_irq; - bool use_sc_irq; bool manage_pon_supply; bool wf_update; bool pwm_cfg_state; @@ -660,19 +652,6 @@ static int qpnp_hap_buffer_config(struct qpnp_hap *hap) return rc; } - /* setup play irq */ - if (hap->use_play_irq) { - rc = devm_request_threaded_irq(&hap->pdev->dev, hap->play_irq, - NULL, qpnp_hap_play_irq, - QPNP_IRQ_FLAGS, - "qpnp_play_irq", hap); - if (rc < 0) { - pr_err("Unable to request play(%d) IRQ(err:%d)\n", - hap->play_irq, rc); - return rc; - } - } - hap->buffer_cfg_state = true; return 0; } @@ -937,16 +916,6 @@ static int qpnp_hap_parse_buffer_dt(struct qpnp_hap *hap) memcpy(hap->wave_samp, prop->value, QPNP_HAP_WAV_SAMP_LEN); } - hap->use_play_irq = of_property_read_bool(pdev->dev.of_node, - "qcom,use-play-irq"); - if (hap->use_play_irq) { - hap->play_irq = platform_get_irq_byname(hap->pdev, "play-irq"); - if (hap->play_irq < 0) { - pr_err("Unable to get play irq\n"); - return hap->play_irq; - } - } - return 0; } @@ -2056,12 +2025,27 @@ static int qpnp_hap_config(struct qpnp_hap *hap) if (rc) return rc; + /* setup play irq */ + if (hap->play_irq >= 0) { + rc = devm_request_threaded_irq(&hap->pdev->dev, hap->play_irq, + NULL, qpnp_hap_play_irq, IRQF_ONESHOT, "qpnp_hap_play", + hap); + if (rc < 0) { + pr_err("Unable to request play(%d) IRQ(err:%d)\n", + hap->play_irq, rc); + return rc; + } + + /* use play_irq only for buffer mode */ + if (hap->play_mode != QPNP_HAP_BUFFER) + disable_irq(hap->play_irq); + } + /* setup short circuit irq */ - if (hap->use_sc_irq) { + if (hap->sc_irq >= 0) { rc = devm_request_threaded_irq(&hap->pdev->dev, hap->sc_irq, - NULL, qpnp_hap_sc_irq, - QPNP_IRQ_FLAGS, - "qpnp_sc_irq", hap); + NULL, qpnp_hap_sc_irq, IRQF_ONESHOT, "qpnp_hap_sc", + hap); if (rc < 0) { pr_err("Unable to request sc(%d) IRQ(err:%d)\n", hap->sc_irq, rc); @@ -2362,14 +2346,14 @@ static int qpnp_hap_parse_dt(struct qpnp_hap *hap) } } - hap->use_sc_irq = of_property_read_bool(pdev->dev.of_node, - "qcom,use-sc-irq"); - if (hap->use_sc_irq) { - hap->sc_irq = platform_get_irq_byname(hap->pdev, "sc-irq"); - if (hap->sc_irq < 0) { - pr_err("Unable to get sc irq\n"); - return hap->sc_irq; - } + hap->play_irq = platform_get_irq_byname(hap->pdev, "play-irq"); + if (hap->play_irq < 0) + pr_warn("Unable to get play irq\n"); + + hap->sc_irq = platform_get_irq_byname(hap->pdev, "sc-irq"); + if (hap->sc_irq < 0) { + pr_err("Unable to get sc irq\n"); + return hap->sc_irq; } if (of_find_property(pdev->dev.of_node, "vcc_pon-supply", NULL)) -- 2.11.0