diff options
| author | Yoshihiro Kaneko <ykaneko0929@gmail.com> | 2019-05-13 16:03:53 -0400 |
|---|---|---|
| committer | Eduardo Valentin <edubezval@gmail.com> | 2019-05-24 00:55:47 -0400 |
| commit | 4eb39f79ef443fa566d36bd43f1f578d5c140305 (patch) | |
| tree | 99120afb2166a3b18027affae4dc9afa45bb9b4d | |
| parent | 2380a792dec059338c8d989e64c5d933c553949c (diff) | |
thermal: rcar_gen3_thermal: Update value of Tj_1
As evaluation of hardware team, temperature calculation formula
of M3-W is difference from all other SoCs as below:
- M3-W: Tj_1: 116 (so Tj_1 - Tj_3 = 157)
- Others: Tj_1: 126 (so Tj_1 - Tj_3 = 167)
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| -rw-r--r-- | drivers/thermal/rcar_gen3_thermal.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 83f306265ee1..3d56fe5721c5 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c | |||
| @@ -122,11 +122,11 @@ static inline void rcar_gen3_thermal_write(struct rcar_gen3_thermal_tsc *tsc, | |||
| 122 | #define RCAR3_THERMAL_GRAN 500 /* mili Celsius */ | 122 | #define RCAR3_THERMAL_GRAN 500 /* mili Celsius */ |
| 123 | 123 | ||
| 124 | /* no idea where these constants come from */ | 124 | /* no idea where these constants come from */ |
| 125 | #define TJ_1 116 | ||
| 126 | #define TJ_3 -41 | 125 | #define TJ_3 -41 |
| 127 | 126 | ||
| 128 | static void rcar_gen3_thermal_calc_coefs(struct equation_coefs *coef, | 127 | static void rcar_gen3_thermal_calc_coefs(struct equation_coefs *coef, |
| 129 | int *ptat, int *thcode) | 128 | int *ptat, int *thcode, |
| 129 | int ths_tj_1) | ||
| 130 | { | 130 | { |
| 131 | int tj_2; | 131 | int tj_2; |
| 132 | 132 | ||
| @@ -137,15 +137,15 @@ static void rcar_gen3_thermal_calc_coefs(struct equation_coefs *coef, | |||
| 137 | * the dividend (4095 * 4095 << 14 > INT_MAX) so keep it unscaled | 137 | * the dividend (4095 * 4095 << 14 > INT_MAX) so keep it unscaled |
| 138 | */ | 138 | */ |
| 139 | tj_2 = (FIXPT_INT((ptat[1] - ptat[2]) * 157) | 139 | tj_2 = (FIXPT_INT((ptat[1] - ptat[2]) * 157) |
| 140 | / (ptat[0] - ptat[2])) - FIXPT_INT(41); | 140 | / (ptat[0] - ptat[2])) + FIXPT_INT(TJ_3); |
| 141 | 141 | ||
| 142 | coef->a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]), | 142 | coef->a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]), |
| 143 | tj_2 - FIXPT_INT(TJ_3)); | 143 | tj_2 - FIXPT_INT(TJ_3)); |
| 144 | coef->b1 = FIXPT_INT(thcode[2]) - coef->a1 * TJ_3; | 144 | coef->b1 = FIXPT_INT(thcode[2]) - coef->a1 * TJ_3; |
| 145 | 145 | ||
| 146 | coef->a2 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[0]), | 146 | coef->a2 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[0]), |
| 147 | tj_2 - FIXPT_INT(TJ_1)); | 147 | tj_2 - FIXPT_INT(ths_tj_1)); |
| 148 | coef->b2 = FIXPT_INT(thcode[0]) - coef->a2 * TJ_1; | 148 | coef->b2 = FIXPT_INT(thcode[0]) - coef->a2 * ths_tj_1; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | static int rcar_gen3_thermal_round(int temp) | 151 | static int rcar_gen3_thermal_round(int temp) |
| @@ -294,12 +294,29 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc) | |||
| 294 | usleep_range(1000, 2000); | 294 | usleep_range(1000, 2000); |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | static const int rcar_gen3_ths_tj_1 = 126; | ||
| 298 | static const int rcar_gen3_ths_tj_1_m3_w = 116; | ||
| 297 | static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { | 299 | static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { |
| 298 | { .compatible = "renesas,r8a774a1-thermal", }, | 300 | { |
| 299 | { .compatible = "renesas,r8a7795-thermal", }, | 301 | .compatible = "renesas,r8a774a1-thermal", |
| 300 | { .compatible = "renesas,r8a7796-thermal", }, | 302 | .data = &rcar_gen3_ths_tj_1_m3_w, |
| 301 | { .compatible = "renesas,r8a77965-thermal", }, | 303 | }, |
| 302 | { .compatible = "renesas,r8a77980-thermal", }, | 304 | { |
| 305 | .compatible = "renesas,r8a7795-thermal", | ||
| 306 | .data = &rcar_gen3_ths_tj_1, | ||
| 307 | }, | ||
| 308 | { | ||
| 309 | .compatible = "renesas,r8a7796-thermal", | ||
| 310 | .data = &rcar_gen3_ths_tj_1_m3_w, | ||
| 311 | }, | ||
| 312 | { | ||
| 313 | .compatible = "renesas,r8a77965-thermal", | ||
| 314 | .data = &rcar_gen3_ths_tj_1, | ||
| 315 | }, | ||
| 316 | { | ||
| 317 | .compatible = "renesas,r8a77980-thermal", | ||
| 318 | .data = &rcar_gen3_ths_tj_1, | ||
| 319 | }, | ||
| 303 | {}, | 320 | {}, |
| 304 | }; | 321 | }; |
| 305 | MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids); | 322 | MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids); |
| @@ -328,6 +345,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) | |||
| 328 | { | 345 | { |
| 329 | struct rcar_gen3_thermal_priv *priv; | 346 | struct rcar_gen3_thermal_priv *priv; |
| 330 | struct device *dev = &pdev->dev; | 347 | struct device *dev = &pdev->dev; |
| 348 | const int *rcar_gen3_ths_tj_1 = of_device_get_match_data(dev); | ||
| 331 | struct resource *res; | 349 | struct resource *res; |
| 332 | struct thermal_zone_device *zone; | 350 | struct thermal_zone_device *zone; |
| 333 | int ret, irq, i; | 351 | int ret, irq, i; |
| @@ -399,7 +417,8 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) | |||
| 399 | priv->tscs[i] = tsc; | 417 | priv->tscs[i] = tsc; |
| 400 | 418 | ||
| 401 | priv->thermal_init(tsc); | 419 | priv->thermal_init(tsc); |
| 402 | rcar_gen3_thermal_calc_coefs(&tsc->coef, ptat, thcode[i]); | 420 | rcar_gen3_thermal_calc_coefs(&tsc->coef, ptat, thcode[i], |
| 421 | *rcar_gen3_ths_tj_1); | ||
| 403 | 422 | ||
| 404 | zone = devm_thermal_zone_of_sensor_register(dev, i, tsc, | 423 | zone = devm_thermal_zone_of_sensor_register(dev, i, tsc, |
| 405 | &rcar_gen3_tz_of_ops); | 424 | &rcar_gen3_tz_of_ops); |
