summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkalyani chidambaram <kalyanic@nvidia.com>2018-06-13 13:59:11 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-07-18 23:25:32 -0400
commit063ddeb70fd142939ff788c9ec7529fba807436f (patch)
tree6f4a1994226eabd4552f5a98c7f8cd34a8ca9546
parent968b53a455465ba8a44296500eae36ec9c0b3ce1 (diff)
driver: aotag: Use pmc driver for pmc reg access
Replace the direct access to pmc registers with access via. pmc driver. Bug 1811649 Change-Id: Ifbd944e0e81dd0009256e81a453f3c38e319177c Signed-off-by: kalyani chidambaram <kalyanic@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1744182 Reviewed-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: Srikar Srimath Tirumala <srikars@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/thermal/tegra/aotag.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/drivers/thermal/tegra/aotag.c b/drivers/thermal/tegra/aotag.c
index 6f7c017b7..7765c1ff7 100644
--- a/drivers/thermal/tegra/aotag.c
+++ b/drivers/thermal/tegra/aotag.c
@@ -30,6 +30,7 @@
30#include <linux/thermal.h> 30#include <linux/thermal.h>
31#include <linux/tsensor-fuse.h> 31#include <linux/tsensor-fuse.h>
32#include <soc/tegra/fuse.h> 32#include <soc/tegra/fuse.h>
33#include <soc/tegra/pmc.h>
33 34
34#define PDEV2DEVICE(pdev) (&(pdev->dev)) 35#define PDEV2DEVICE(pdev) (&(pdev->dev))
35#define PDEV2SENSOR_INFO(pdev) \ 36#define PDEV2SENSOR_INFO(pdev) \
@@ -250,7 +251,6 @@ struct aotag_sensor_info_t {
250 struct thermal_zone_device *tzd; 251 struct thermal_zone_device *tzd;
251 s32 therm_a; 252 s32 therm_a;
252 s32 therm_b; 253 s32 therm_b;
253 void __iomem *pmc_base;
254}; 254};
255 255
256static void aotag_thermtrip_enable(struct aotag_sensor_info_t *info, int temp) 256static void aotag_thermtrip_enable(struct aotag_sensor_info_t *info, int temp)
@@ -263,11 +263,11 @@ static void aotag_thermtrip_enable(struct aotag_sensor_info_t *info, int temp)
263 temp = MIN_THRESHOLD_TEMP; 263 temp = MIN_THRESHOLD_TEMP;
264 264
265 r = REG_SET(r, THRESH3_CFG, temp/1000); 265 r = REG_SET(r, THRESH3_CFG, temp/1000);
266 writel(r, info->pmc_base + PMC_AOTAG_THRESH3_CFG); 266 tegra_pmc_writel(r, PMC_AOTAG_THRESH3_CFG);
267 267
268 r = readl(info->pmc_base + PMC_AOTAG_CFG); 268 r = tegra_pmc_readl(PMC_AOTAG_CFG);
269 set_bit(CFG_THERMTRIP_EN_POS, &r); 269 set_bit(CFG_THERMTRIP_EN_POS, &r);
270 writel(r, info->pmc_base + PMC_AOTAG_CFG); 270 tegra_pmc_writel(r, PMC_AOTAG_CFG);
271} 271}
272 272
273static int aotag_set_trip_temp(void *data, int trip, int trip_temp) 273static int aotag_set_trip_temp(void *data, int trip, int trip_temp)
@@ -295,7 +295,6 @@ static int aotag_get_temp_generic(void *data, int *temp)
295 int ret = 0; 295 int ret = 0;
296 u32 regval = 0, abs = 0, fraction = 0, valid = 0, sign = 0; 296 u32 regval = 0, abs = 0, fraction = 0, valid = 0, sign = 0;
297 struct platform_device *pdev = (struct platform_device *) data; 297 struct platform_device *pdev = (struct platform_device *) data;
298 struct aotag_sensor_info_t *ps_info = PDEV2SENSOR_INFO(pdev);
299 298
300 if (unlikely(!data)) { 299 if (unlikely(!data)) {
301 pr_err(" Invalid data pointer\n"); 300 pr_err(" Invalid data pointer\n");
@@ -304,7 +303,7 @@ static int aotag_get_temp_generic(void *data, int *temp)
304 goto out; 303 goto out;
305 } 304 }
306 305
307 regval = readl(ps_info->pmc_base + PMC_TSENSOR_STATUS1); 306 regval = tegra_pmc_readl(PMC_TSENSOR_STATUS1);
308 valid = REG_GET(regval, STATUS1_TEMP_VALID); 307 valid = REG_GET(regval, STATUS1_TEMP_VALID);
309 if (!valid) { 308 if (!valid) {
310 *temp = -125; 309 *temp = -125;
@@ -348,16 +347,6 @@ static int aotag_init(struct platform_device *pdev)
348 347
349 pdev->dev.platform_data = info; 348 pdev->dev.platform_data = info;
350 349
351 /*
352 * reading PMC reg base here from the already parsed pmc DT node,
353 * rather than adding this (an extra) value to the DT.
354 */
355 info->pmc_base = of_iomap(pmc_np, 0);
356 if (!info->pmc_base) {
357 dev_err(&pdev->dev, " - unable to map PMC\n");
358 return -ENOMEM;
359 }
360
361 info->config = pdata->config; 350 info->config = pdata->config;
362 /* HW WAR for early parts. Account for incorrect ATE fusing during the 351 /* HW WAR for early parts. Account for incorrect ATE fusing during the
363 * early parts. */ 352 * early parts. */
@@ -452,7 +441,7 @@ static int aotag_calib_init(struct platform_device *pdev)
452 441
453 dev_dbg(&pdev->dev, "thermA:%d, thermB:%d\n", 442 dev_dbg(&pdev->dev, "thermA:%d, thermB:%d\n",
454 ps_info->therm_a, ps_info->therm_b); 443 ps_info->therm_a, ps_info->therm_b);
455 writel(therm_ab, ps_info->pmc_base + PMC_TSENSOR_CONFIG2); 444 tegra_pmc_writel(therm_ab, PMC_TSENSOR_CONFIG2);
456 445
457 return 0; 446 return 0;
458} 447}
@@ -467,7 +456,7 @@ static int aotag_hw_init(struct platform_device *pdev)
467 /* clear CONFIG0_STOP, CONFIG0_RO_SEL, CONFIG0_STATUS_CLR */ 456 /* clear CONFIG0_STOP, CONFIG0_RO_SEL, CONFIG0_STATUS_CLR */
468 r = 0; 457 r = 0;
469 r = REG_SET(r, CONFIG0_TALL, i->config->tall); 458 r = REG_SET(r, CONFIG0_TALL, i->config->tall);
470 writel(r, i->pmc_base + PMC_TSENSOR_CONFIG0); 459 tegra_pmc_writel(r, PMC_TSENSOR_CONFIG0);
471 460
472 /* init CONFIG_1 registers */ 461 /* init CONFIG_1 registers */
473 r = 0; 462 r = 0;
@@ -478,18 +467,18 @@ static int aotag_hw_init(struct platform_device *pdev)
478 */ 467 */
479 r = REG_SET(r, CONFIG1_TSAMPLE, (i->config->tsample - 1)); 468 r = REG_SET(r, CONFIG1_TSAMPLE, (i->config->tsample - 1));
480 set_bit(CONFIG1_TEMP_ENABLE_POS, &r); 469 set_bit(CONFIG1_TEMP_ENABLE_POS, &r);
481 writel(r, i->pmc_base + PMC_TSENSOR_CONFIG1); 470 tegra_pmc_writel(r, PMC_TSENSOR_CONFIG1);
482 471
483 /* init CONFIG_2 registers */ 472 /* init CONFIG_2 registers */
484 r = 0; 473 r = 0;
485 r = REG_SET(r, TSENSOR_PDIV, i->config->pdiv); 474 r = REG_SET(r, TSENSOR_PDIV, i->config->pdiv);
486 writel(r, i->pmc_base + PMC_TSENSOR_PDIV0); 475 tegra_pmc_writel(r, PMC_TSENSOR_PDIV0);
487 476
488 /* Enable AOTAG*/ 477 /* Enable AOTAG*/
489 r = 0; 478 r = 0;
490 set_bit(CFG_TAG_EN_POS, &r); 479 set_bit(CFG_TAG_EN_POS, &r);
491 clear_bit(CFG_DISABLE_CLK_POS, &r); 480 clear_bit(CFG_DISABLE_CLK_POS, &r);
492 writel(r, i->pmc_base + PMC_AOTAG_CFG); 481 tegra_pmc_writel(r, PMC_AOTAG_CFG);
493 482
494 return ret; 483 return ret;
495} 484}