Loading Documentation/devicetree/bindings/power/supply/qcom/qpnp-fg-gen3.txt +32 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,8 @@ First Level Node - FG Gen3 device Definition: For details about IIO bindings see: Documentation/devicetree/bindings/iio/iio-bindings.txt - #thermal-sensor-cells: Should be 0. See thermal.txt for a description. - qcom,rradc-base Usage: required Value type: <u32> Loading Loading @@ -489,6 +491,7 @@ pmi8998_fg: qpnp,fg { qcom,slope-limit-temp-threshold = <100>; qcom,slope-limit-coeffs = <10 11 12 13>; qcom,battery-thermal-coefficients = [9d 50 ff]; #thermal-sensor-cells = <0>; status = "okay"; qcom,fg-batt-soc@4000 { Loading Loading @@ -517,3 +520,32 @@ pmi8998_fg: qpnp,fg { reg = <0x4400 0x100>; }; }; ====================================== Example for thermal zone configuration ====================================== thermal_zones { pmi8998_fg { polling-delay-passive = <200>; polling-delay = <200>; thermal-governor = <userspace>; thermal-sensors = <&pmi8998_fg>; pmi8998_fg_trip1: pmi8998-fg-trip0 { temperature = <45000>; hysteresis = <0>; type = "passive"; }; pmi8998_fg_trip2: pmi8998-fg-trip2 { temperature = <50000>; hysteresis = <0>; type = "hot"; }; pmi8998_fg_trip3: pmi8998-fg-trip3 { temperature = <60000>; hysteresis = <0>; type = "alert"; }; }; }; drivers/power/supply/qcom/fg-core.h +1 −0 Original line number Diff line number Diff line Loading @@ -412,6 +412,7 @@ static const struct fg_pt fg_tsmc_osc_table[] = { }; struct fg_chip { struct thermal_zone_device *tz_dev; struct device *dev; struct pmic_revid_data *pmic_rev_id; struct regmap *regmap; Loading drivers/power/supply/qcom/qpnp-fg-gen3.c +35 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <linux/of_platform.h> #include <linux/of_batterydata.h> #include <linux/platform_device.h> #include <linux/thermal.h> #include <linux/iio/consumer.h> #include <linux/qpnp/qpnp-revid.h> #include "fg-core.h" Loading Loading @@ -5355,6 +5356,29 @@ static void fg_cleanup(struct fg_chip *chip) dev_set_drvdata(chip->dev, NULL); } static int fg_tz_get_temp(void *data, int *temperature) { struct fg_chip *chip = (struct fg_chip *)data; int rc, batt_temp = 0; if (!temperature) return -EINVAL; rc = fg_get_battery_temp(chip, &batt_temp); if (rc < 0) { pr_err("Error in getting batt_temp\n"); return rc; } /* Convert deciDegC to milliDegC */ *temperature = batt_temp * 100; return 0; } static struct thermal_zone_of_device_ops fg_gen3_tz_ops = { .get_temp = fg_tz_get_temp, }; static int fg_gen3_probe(struct platform_device *pdev) { struct fg_chip *chip; Loading Loading @@ -5537,6 +5561,15 @@ static int fg_gen3_probe(struct platform_device *pdev) pr_err("Error in configuring ESR filter rc:%d\n", rc); } chip->tz_dev = thermal_zone_of_sensor_register(chip->dev, 0, chip, &fg_gen3_tz_ops); if (IS_ERR_OR_NULL(chip->tz_dev)) { rc = PTR_ERR(chip->tz_dev); chip->tz_dev = NULL; dev_err(chip->dev, "thermal_zone_of_sensor_register() failed rc:%d\n", rc); } device_init_wakeup(chip->dev, true); schedule_delayed_work(&chip->profile_load_work, 0); Loading Loading @@ -5601,6 +5634,8 @@ static int fg_gen3_remove(struct platform_device *pdev) { struct fg_chip *chip = dev_get_drvdata(&pdev->dev); if (chip->tz_dev) thermal_zone_of_sensor_unregister(chip->dev, chip->tz_dev); fg_cleanup(chip); return 0; } Loading Loading
Documentation/devicetree/bindings/power/supply/qcom/qpnp-fg-gen3.txt +32 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,8 @@ First Level Node - FG Gen3 device Definition: For details about IIO bindings see: Documentation/devicetree/bindings/iio/iio-bindings.txt - #thermal-sensor-cells: Should be 0. See thermal.txt for a description. - qcom,rradc-base Usage: required Value type: <u32> Loading Loading @@ -489,6 +491,7 @@ pmi8998_fg: qpnp,fg { qcom,slope-limit-temp-threshold = <100>; qcom,slope-limit-coeffs = <10 11 12 13>; qcom,battery-thermal-coefficients = [9d 50 ff]; #thermal-sensor-cells = <0>; status = "okay"; qcom,fg-batt-soc@4000 { Loading Loading @@ -517,3 +520,32 @@ pmi8998_fg: qpnp,fg { reg = <0x4400 0x100>; }; }; ====================================== Example for thermal zone configuration ====================================== thermal_zones { pmi8998_fg { polling-delay-passive = <200>; polling-delay = <200>; thermal-governor = <userspace>; thermal-sensors = <&pmi8998_fg>; pmi8998_fg_trip1: pmi8998-fg-trip0 { temperature = <45000>; hysteresis = <0>; type = "passive"; }; pmi8998_fg_trip2: pmi8998-fg-trip2 { temperature = <50000>; hysteresis = <0>; type = "hot"; }; pmi8998_fg_trip3: pmi8998-fg-trip3 { temperature = <60000>; hysteresis = <0>; type = "alert"; }; }; };
drivers/power/supply/qcom/fg-core.h +1 −0 Original line number Diff line number Diff line Loading @@ -412,6 +412,7 @@ static const struct fg_pt fg_tsmc_osc_table[] = { }; struct fg_chip { struct thermal_zone_device *tz_dev; struct device *dev; struct pmic_revid_data *pmic_rev_id; struct regmap *regmap; Loading
drivers/power/supply/qcom/qpnp-fg-gen3.c +35 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <linux/of_platform.h> #include <linux/of_batterydata.h> #include <linux/platform_device.h> #include <linux/thermal.h> #include <linux/iio/consumer.h> #include <linux/qpnp/qpnp-revid.h> #include "fg-core.h" Loading Loading @@ -5355,6 +5356,29 @@ static void fg_cleanup(struct fg_chip *chip) dev_set_drvdata(chip->dev, NULL); } static int fg_tz_get_temp(void *data, int *temperature) { struct fg_chip *chip = (struct fg_chip *)data; int rc, batt_temp = 0; if (!temperature) return -EINVAL; rc = fg_get_battery_temp(chip, &batt_temp); if (rc < 0) { pr_err("Error in getting batt_temp\n"); return rc; } /* Convert deciDegC to milliDegC */ *temperature = batt_temp * 100; return 0; } static struct thermal_zone_of_device_ops fg_gen3_tz_ops = { .get_temp = fg_tz_get_temp, }; static int fg_gen3_probe(struct platform_device *pdev) { struct fg_chip *chip; Loading Loading @@ -5537,6 +5561,15 @@ static int fg_gen3_probe(struct platform_device *pdev) pr_err("Error in configuring ESR filter rc:%d\n", rc); } chip->tz_dev = thermal_zone_of_sensor_register(chip->dev, 0, chip, &fg_gen3_tz_ops); if (IS_ERR_OR_NULL(chip->tz_dev)) { rc = PTR_ERR(chip->tz_dev); chip->tz_dev = NULL; dev_err(chip->dev, "thermal_zone_of_sensor_register() failed rc:%d\n", rc); } device_init_wakeup(chip->dev, true); schedule_delayed_work(&chip->profile_load_work, 0); Loading Loading @@ -5601,6 +5634,8 @@ static int fg_gen3_remove(struct platform_device *pdev) { struct fg_chip *chip = dev_get_drvdata(&pdev->dev); if (chip->tz_dev) thermal_zone_of_sensor_unregister(chip->dev, chip->tz_dev); fg_cleanup(chip); return 0; } Loading