aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/sm501.c
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-07-25 04:45:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:29 -0400
commit472dba7d117844c746be97db6be26c2810d79b62 (patch)
tree8d87f062253a1e295436dcdebe2a1ce6c2a73310 /drivers/mfd/sm501.c
parent717115e1a5856b57af0f71e1df7149108294fc10 (diff)
sm501: add power control callback
Add callback to get or set the power control if the device has the sleep connected to some form of GPIO. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Cc: Arnaud Patard <apatard@mandriva.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mfd/sm501.c')
-rw-r--r--drivers/mfd/sm501.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index e2530df4d85c..9296b2673b52 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -1138,8 +1138,31 @@ static int sm501_plat_probe(struct platform_device *dev)
1138} 1138}
1139 1139
1140#ifdef CONFIG_PM 1140#ifdef CONFIG_PM
1141
1141/* power management support */ 1142/* power management support */
1142 1143
1144static void sm501_set_power(struct sm501_devdata *sm, int on)
1145{
1146 struct sm501_platdata *pd = sm->platdata;
1147
1148 if (pd == NULL)
1149 return;
1150
1151 if (pd->get_power) {
1152 if (pd->get_power(sm->dev) == on) {
1153 dev_dbg(sm->dev, "is already %d\n", on);
1154 return;
1155 }
1156 }
1157
1158 if (pd->set_power) {
1159 dev_dbg(sm->dev, "setting power to %d\n", on);
1160
1161 pd->set_power(sm->dev, on);
1162 sm501_mdelay(sm, 10);
1163 }
1164}
1165
1143static int sm501_plat_suspend(struct platform_device *pdev, pm_message_t state) 1166static int sm501_plat_suspend(struct platform_device *pdev, pm_message_t state)
1144{ 1167{
1145 struct sm501_devdata *sm = platform_get_drvdata(pdev); 1168 struct sm501_devdata *sm = platform_get_drvdata(pdev);
@@ -1148,6 +1171,12 @@ static int sm501_plat_suspend(struct platform_device *pdev, pm_message_t state)
1148 sm->pm_misc = readl(sm->regs + SM501_MISC_CONTROL); 1171 sm->pm_misc = readl(sm->regs + SM501_MISC_CONTROL);
1149 1172
1150 sm501_dump_regs(sm); 1173 sm501_dump_regs(sm);
1174
1175 if (sm->platdata) {
1176 if (sm->platdata->flags & SM501_FLAG_SUSPEND_OFF)
1177 sm501_set_power(sm, 0);
1178 }
1179
1151 return 0; 1180 return 0;
1152} 1181}
1153 1182
@@ -1155,6 +1184,8 @@ static int sm501_plat_resume(struct platform_device *pdev)
1155{ 1184{
1156 struct sm501_devdata *sm = platform_get_drvdata(pdev); 1185 struct sm501_devdata *sm = platform_get_drvdata(pdev);
1157 1186
1187 sm501_set_power(sm, 1);
1188
1158 sm501_dump_regs(sm); 1189 sm501_dump_regs(sm);
1159 sm501_dump_gate(sm); 1190 sm501_dump_gate(sm);
1160 sm501_dump_clk(sm); 1191 sm501_dump_clk(sm);