From e49406e787d5d0b68343b2a599f7673ab2ee527a Mon Sep 17 00:00:00 2001 From: Manaf Meethalavalappu Pallikunhi Date: Fri, 9 Mar 2018 18:34:14 +0530 Subject: [PATCH] drivers: thermal: bcl-pmic5: clean up PMIC v5 BCL driver Clean up PMIC v5 BCL driver. It includes rename driver, remove redundant debug logs, remove WARN_ON from ISR etc. Change-Id: Ia6a3a406c6f139cfa6741e4e2f08dc9cd4e4bdaa Signed-off-by: Manaf Meethalavalappu Pallikunhi --- .../bindings/thermal/qcom-bcl-pmic5.txt | 18 +++++----- arch/arm64/boot/dts/qcom/pmi632.dtsi | 4 +-- arch/arm64/configs/msm8953-perf_defconfig | 2 +- arch/arm64/configs/msm8953_defconfig | 2 +- drivers/thermal/qcom/Kconfig | 2 +- drivers/thermal/qcom/Makefile | 2 +- drivers/thermal/qcom/bcl_pmic5.c | 34 +++++++------------ 7 files changed, 28 insertions(+), 36 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/qcom-bcl-pmic5.txt b/Documentation/devicetree/bindings/thermal/qcom-bcl-pmic5.txt index 5322d89599ce..9f12e4830a7b 100644 --- a/Documentation/devicetree/bindings/thermal/qcom-bcl-pmic5.txt +++ b/Documentation/devicetree/bindings/thermal/qcom-bcl-pmic5.txt @@ -14,7 +14,7 @@ with the multiple BCL peripherals. Required Parameters: - compatible: must be - 'qcom,msm-bcl-pmic5' for bcl peripheral in PMIC version 5. + 'qcom,bcl-v5' for bcl peripheral in PMIC version 5. - reg: where 'a' is the starting register address of the PMIC peripheral and 'b' is the size of the peripheral address space. - interrupts: Where 'a' is the SLAVE ID of the PMIC, 'b' is @@ -27,11 +27,11 @@ Required Parameters: "bcl-high-ibat" Example: - bcl@4200 { - compatible = "qcom,msm-bcl-pmic5"; - reg = <0x4200 0xFF>; - interrupts = <0x2 0x42 0x0>, - <0x2 0x42 0x1>; - interrupt-names = "bcl-high-ibat", - "bcl-low-vbat"; - }; + bcl@4200 { + compatible = "qcom,bcl-v5"; + reg = <0x4200 0x100>; + interrupts = <0x2 0x42 0x0>, + <0x2 0x42 0x1>; + interrupt-names = "bcl-high-ibat", + "bcl-low-vbat"; + }; diff --git a/arch/arm64/boot/dts/qcom/pmi632.dtsi b/arch/arm64/boot/dts/qcom/pmi632.dtsi index becc510e0b80..b6f983847af3 100644 --- a/arch/arm64/boot/dts/qcom/pmi632.dtsi +++ b/arch/arm64/boot/dts/qcom/pmi632.dtsi @@ -414,8 +414,8 @@ }; bcl_sensor: bcl@3d00 { - compatible = "qcom,msm-bcl-pmic5"; - reg = <0x3d00 0xff>; + compatible = "qcom,bcl-v5"; + reg = <0x3d00 0x100>; interrupts = <0x2 0x3d 0x0 IRQ_TYPE_NONE>, <0x2 0x3d 0x1 IRQ_TYPE_NONE>; interrupt-names = "bcl-high-ibat", diff --git a/arch/arm64/configs/msm8953-perf_defconfig b/arch/arm64/configs/msm8953-perf_defconfig index 1db7cbe69c58..a440896d26e4 100644 --- a/arch/arm64/configs/msm8953-perf_defconfig +++ b/arch/arm64/configs/msm8953-perf_defconfig @@ -341,7 +341,7 @@ CONFIG_THERMAL_TSENS=y CONFIG_QTI_VIRTUAL_SENSOR=y CONFIG_QTI_QMI_COOLING_DEVICE=y CONFIG_REGULATOR_COOLING_DEVICE=y -CONFIG_MSM_BCL_PMIC5=y +CONFIG_QTI_BCL_PMIC5=y CONFIG_QTI_BCL_SOC_DRIVER=y CONFIG_MFD_SPMI_PMIC=y CONFIG_REGULATOR_FIXED_VOLTAGE=y diff --git a/arch/arm64/configs/msm8953_defconfig b/arch/arm64/configs/msm8953_defconfig index 49812fb83539..2620856b0fb9 100644 --- a/arch/arm64/configs/msm8953_defconfig +++ b/arch/arm64/configs/msm8953_defconfig @@ -353,7 +353,7 @@ CONFIG_THERMAL_TSENS=y CONFIG_QTI_VIRTUAL_SENSOR=y CONFIG_QTI_QMI_COOLING_DEVICE=y CONFIG_REGULATOR_COOLING_DEVICE=y -CONFIG_MSM_BCL_PMIC5=y +CONFIG_QTI_BCL_PMIC5=y CONFIG_QTI_BCL_SOC_DRIVER=y CONFIG_MFD_SPMI_PMIC=y CONFIG_REGULATOR_FIXED_VOLTAGE=y diff --git a/drivers/thermal/qcom/Kconfig b/drivers/thermal/qcom/Kconfig index c3c662d0ef64..8085606218b8 100644 --- a/drivers/thermal/qcom/Kconfig +++ b/drivers/thermal/qcom/Kconfig @@ -72,7 +72,7 @@ config REGULATOR_COOLING_DEVICE If you want this support, you should say Y here. -config MSM_BCL_PMIC5 +config QTI_BCL_PMIC5 bool "BCL driver for BCL peripherals in PMIC5" depends on SPMI && THERMAL_OF help diff --git a/drivers/thermal/qcom/Makefile b/drivers/thermal/qcom/Makefile index b5b56c745175..83872854e4a4 100644 --- a/drivers/thermal/qcom/Makefile +++ b/drivers/thermal/qcom/Makefile @@ -6,5 +6,5 @@ obj-$(CONFIG_QTI_VIRTUAL_SENSOR) += qti_virtual_sensor.o obj-$(CONFIG_QTI_AOP_REG_COOLING_DEVICE) += regulator_aop_cdev.o obj-$(CONFIG_REGULATOR_COOLING_DEVICE) += regulator_cdev.o obj-$(CONFIG_QTI_QMI_COOLING_DEVICE) += thermal_mitigation_device_service_v01.o qmi_cooling.o -obj-$(CONFIG_MSM_BCL_PMIC5) += bcl_pmic5.o +obj-$(CONFIG_QTI_BCL_PMIC5) += bcl_pmic5.o obj-$(CONFIG_QTI_BCL_SOC_DRIVER) += bcl_soc.o diff --git a/drivers/thermal/qcom/bcl_pmic5.c b/drivers/thermal/qcom/bcl_pmic5.c index 9c35c7996e57..1cf378f64c2c 100644 --- a/drivers/thermal/qcom/bcl_pmic5.c +++ b/drivers/thermal/qcom/bcl_pmic5.c @@ -61,7 +61,7 @@ static char bcl_int_names[BCL_TYPE_MAX][25] = { "bcl-very-high-ibat", "bcl-low-vbat", "bcl-very-low-vbat", - "bcl-crit-low-vbat" + "bcl-crit-low-vbat", }; struct bcl_peripheral_data { @@ -93,10 +93,9 @@ static int bcl_read_register(int16_t reg_offset, unsigned int *data) ret = regmap_read(bcl_perph->regmap, (bcl_perph->fg_bcl_addr + reg_offset), data); - if (ret < 0) { - pr_err("Error reading register %d. err:%d", reg_offset, ret); - return ret; - } + if (ret < 0) + pr_err("Error reading register %d. err:%d\n", + reg_offset, ret); return ret; } @@ -113,7 +112,8 @@ static int bcl_write_general_register(int16_t reg_offset, } ret = regmap_write(bcl_perph->regmap, (base + reg_offset), *write_buf); if (ret < 0) { - pr_err("Error reading register %d. err:%d", reg_offset, ret); + pr_err("Error reading register %d. err:%d\n", + reg_offset, ret); return ret; } pr_debug("wrote 0x%02x to 0x%04x\n", data, base + reg_offset); @@ -192,10 +192,8 @@ static int bcl_set_ibat(void *data, int low, int high) goto set_trip_exit; } ret = bcl_write_register(addr, val); - if (ret) { - pr_err("Error accessing BCL peripheral. err:%d\n", ret); + if (ret) goto set_trip_exit; - } bat_data->trip_thresh = ibat_ua; if (bat_data->irq_num && !bat_data->irq_enabled) { @@ -218,10 +216,8 @@ static int bcl_read_ibat(void *data, int *adc_value) *adc_value = val; ret = bcl_read_register(BCL_IBAT_READ, &val); - if (ret) { - pr_err("BCL register read error. err:%d\n", ret); + if (ret) goto bcl_read_exit; - } *adc_value = val; if (*adc_value == 0) { /* @@ -258,10 +254,8 @@ static int bcl_get_vbat_trip(void *data, int type, int *trip) return -ENODEV; ret = bcl_read_register(addr, &val); - if (ret) { - pr_err("BCL register read error. err:%d\n", ret); + if (ret) return ret; - } if (addr == BCL_VBAT_ADC_LOW) { *trip = val; @@ -317,10 +311,8 @@ static int bcl_read_vbat(void *data, int *adc_value) *adc_value = val; ret = bcl_read_register(BCL_VBAT_READ, &val); - if (ret) { - pr_err("BCL register read error. err:%d\n", ret); + if (ret) goto bcl_read_exit; - } *adc_value = val; if (*adc_value == BCL_VBAT_NO_READING) { *adc_value = bat_data->last_val; @@ -341,7 +333,7 @@ static irqreturn_t bcl_handle_irq(int irq, void *data) mutex_lock(&perph_data->state_trans_lock); if (!perph_data->irq_enabled) { - WARN_ON(1); + pr_err("irq:%d not in expected state\n", irq); disable_irq_nosync(irq); perph_data->irq_enabled = false; goto exit_intr; @@ -396,7 +388,7 @@ static void bcl_fetch_trip(struct platform_device *pdev, const char *int_name, int_name, data); if (ret) { dev_err(&pdev->dev, - "Error requesting trip irq. err:%d", + "Error requesting trip irq. err:%d\n", ret); mutex_unlock(&data->state_trans_lock); return; @@ -511,7 +503,7 @@ static int bcl_probe(struct platform_device *pdev) static const struct of_device_id bcl_match[] = { { - .compatible = "qcom,msm-bcl-pmic5", + .compatible = "qcom,bcl-v5", }, {}, };