aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip, Avinash2012-03-08 23:40:11 -0600
committerPhilip, Avinash2012-03-13 08:20:11 -0500
commit87136b5169577877639e347a974c8e8503bec7d6 (patch)
tree866fa54c80599277ac1056ca5be77bfa5d7e6186
parenta4730018b6d386b5add0ce06a25a7a912a97a5fb (diff)
downloadsitara-epos-kernel-87136b5169577877639e347a974c8e8503bec7d6.tar.gz
sitara-epos-kernel-87136b5169577877639e347a974c8e8503bec7d6.tar.xz
sitara-epos-kernel-87136b5169577877639e347a974c8e8503bec7d6.zip
PWM: ehrpwm: Support for low power sleep
This pattch 1. Adds context save/restore functionality to support low power sleep transitions. 2. Adds pm_runtime [get_sync/put_sync] in context save function to handle unenabled clock situation. 3. Removes check for clock use count. Signed-off-by: Philip, Avinash <avinashphilip@ti.com>
-rw-r--r--drivers/pwm/ehrpwm.c46
-rw-r--r--include/linux/pwm/ehrpwm.h15
2 files changed, 59 insertions, 2 deletions
diff --git a/drivers/pwm/ehrpwm.c b/drivers/pwm/ehrpwm.c
index 8140ce7f1bbf..d37db5229dbe 100644
--- a/drivers/pwm/ehrpwm.c
+++ b/drivers/pwm/ehrpwm.c
@@ -1509,12 +1509,53 @@ err_mem_failure:
1509} 1509}
1510 1510
1511#ifdef CONFIG_PM 1511#ifdef CONFIG_PM
1512
1513void ehrpwm_context_save(struct ehrpwm_pwm *ehrpwm,
1514 struct ehrpwm_context *ehrpwm_ctx)
1515{
1516 pm_runtime_get_sync(ehrpwm->dev);
1517 ehrpwm_ctx->tbctl = ehrpwm_read(ehrpwm, TBCTL);
1518 ehrpwm_ctx->tbprd = ehrpwm_read(ehrpwm, TBPRD);
1519 if (ehrpwm->version == PWM_VERSION_1)
1520 ehrpwm_ctx->hrcfg = ehrpwm_read(ehrpwm, AM335X_HRCNFG);
1521 else
1522 ehrpwm_ctx->hrcfg = ehrpwm_read(ehrpwm, HRCNFG);
1523 ehrpwm_ctx->aqctla = ehrpwm_read(ehrpwm, AQCTLA);
1524 ehrpwm_ctx->aqctlb = ehrpwm_read(ehrpwm, AQCTLB);
1525 ehrpwm_ctx->cmpa = ehrpwm_read(ehrpwm, CMPA);
1526 ehrpwm_ctx->cmpb = ehrpwm_read(ehrpwm, CMPB);
1527 ehrpwm_ctx->tzctl = ehrpwm_read(ehrpwm, TZCTL);
1528 ehrpwm_ctx->tzflg = ehrpwm_read(ehrpwm, TZFLG);
1529 ehrpwm_ctx->tzclr = ehrpwm_read(ehrpwm, TZCLR);
1530 ehrpwm_ctx->tzfrc = ehrpwm_read(ehrpwm, TZFRC);
1531 pm_runtime_put_sync(ehrpwm->dev);
1532}
1533
1534void ehrpwm_context_restore(struct ehrpwm_pwm *ehrpwm,
1535 struct ehrpwm_context *ehrpwm_ctx)
1536{
1537 ehrpwm_write(ehrpwm, TBCTL, ehrpwm_ctx->tbctl);
1538 ehrpwm_write(ehrpwm, TBPRD, ehrpwm_ctx->tbprd);
1539 if (ehrpwm->version == PWM_VERSION_1)
1540 ehrpwm_write(ehrpwm, AM335X_HRCNFG, ehrpwm_ctx->hrcfg);
1541 else
1542 ehrpwm_write(ehrpwm, HRCNFG, ehrpwm_ctx->hrcfg);
1543 ehrpwm_write(ehrpwm, AQCTLA, ehrpwm_ctx->aqctla);
1544 ehrpwm_write(ehrpwm, AQCTLB, ehrpwm_ctx->aqctlb);
1545 ehrpwm_write(ehrpwm, CMPA, ehrpwm_ctx->cmpa);
1546 ehrpwm_write(ehrpwm, CMPB, ehrpwm_ctx->cmpb);
1547 ehrpwm_write(ehrpwm, TZCTL, ehrpwm_ctx->tzctl);
1548 ehrpwm_write(ehrpwm, TZFLG, ehrpwm_ctx->tzflg);
1549 ehrpwm_write(ehrpwm, TZCLR, ehrpwm_ctx->tzclr);
1550 ehrpwm_write(ehrpwm, TZFRC, ehrpwm_ctx->tzfrc);
1551}
1552
1512static int ehrpwm_suspend(struct platform_device *pdev, pm_message_t state) 1553static int ehrpwm_suspend(struct platform_device *pdev, pm_message_t state)
1513{ 1554{
1514 struct ehrpwm_pwm *ehrpwm = platform_get_drvdata(pdev); 1555 struct ehrpwm_pwm *ehrpwm = platform_get_drvdata(pdev);
1515 1556
1516 if (ehrpwm->clk->usecount > 0) 1557 ehrpwm_context_save(ehrpwm, &ehrpwm->ctx);
1517 pm_runtime_put_sync(ehrpwm->dev); 1558 pm_runtime_put_sync(ehrpwm->dev);
1518 1559
1519 return 0; 1560 return 0;
1520} 1561}
@@ -1524,6 +1565,7 @@ static int ehrpwm_resume(struct platform_device *pdev)
1524 struct ehrpwm_pwm *ehrpwm = platform_get_drvdata(pdev); 1565 struct ehrpwm_pwm *ehrpwm = platform_get_drvdata(pdev);
1525 1566
1526 pm_runtime_get_sync(ehrpwm->dev); 1567 pm_runtime_get_sync(ehrpwm->dev);
1568 ehrpwm_context_restore(ehrpwm, &ehrpwm->ctx);
1527 1569
1528 return 0; 1570 return 0;
1529} 1571}
diff --git a/include/linux/pwm/ehrpwm.h b/include/linux/pwm/ehrpwm.h
index 56f88068bf43..53a448143dcc 100644
--- a/include/linux/pwm/ehrpwm.h
+++ b/include/linux/pwm/ehrpwm.h
@@ -19,6 +19,20 @@ struct tz_int {
19 p_fcallback pcallback; 19 p_fcallback pcallback;
20}; 20};
21 21
22struct ehrpwm_context {
23 u32 tbctl;
24 u32 tbprd;
25 u32 hrcfg;
26 u32 aqctla;
27 u32 aqctlb;
28 u32 cmpa;
29 u32 cmpb;
30 u32 tzctl;
31 u32 tzflg;
32 u32 tzclr;
33 u32 tzfrc;
34};
35
22struct ehrpwm_pwm { 36struct ehrpwm_pwm {
23 struct pwm_device pwm[NCHAN]; 37 struct pwm_device pwm[NCHAN];
24 struct pwm_device_ops ops; 38 struct pwm_device_ops ops;
@@ -32,6 +46,7 @@ struct ehrpwm_pwm {
32 u8 version; 46 u8 version;
33 void __iomem *config_mem_base; 47 void __iomem *config_mem_base;
34 struct device *dev; 48 struct device *dev;
49 struct ehrpwm_context ctx;
35}; 50};
36 51
37enum tz_event { 52enum tz_event {