diff options
author | Ben Dooks <ben-linux@fluff.org> | 2008-07-25 04:45:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:29 -0400 |
commit | 472dba7d117844c746be97db6be26c2810d79b62 (patch) | |
tree | 8d87f062253a1e295436dcdebe2a1ce6c2a73310 | |
parent | 717115e1a5856b57af0f71e1df7149108294fc10 (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>
-rw-r--r-- | drivers/mfd/sm501.c | 31 | ||||
-rw-r--r-- | include/linux/sm501.h | 7 |
2 files changed, 38 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 | ||
1144 | static 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 | |||
1143 | static int sm501_plat_suspend(struct platform_device *pdev, pm_message_t state) | 1166 | static 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); |
diff --git a/include/linux/sm501.h b/include/linux/sm501.h index b530fa6a1d34..145405bf9efa 100644 --- a/include/linux/sm501.h +++ b/include/linux/sm501.h | |||
@@ -157,6 +157,8 @@ struct sm501_init_gpio { | |||
157 | struct sm501_reg_init gpio_ddr_high; | 157 | struct sm501_reg_init gpio_ddr_high; |
158 | }; | 158 | }; |
159 | 159 | ||
160 | #define SM501_FLAG_SUSPEND_OFF (1<<4) | ||
161 | |||
160 | /* sm501_platdata | 162 | /* sm501_platdata |
161 | * | 163 | * |
162 | * This is passed with the platform device to allow the board | 164 | * This is passed with the platform device to allow the board |
@@ -170,6 +172,11 @@ struct sm501_platdata { | |||
170 | struct sm501_init_gpio *init_gpiop; | 172 | struct sm501_init_gpio *init_gpiop; |
171 | struct sm501_platdata_fb *fb; | 173 | struct sm501_platdata_fb *fb; |
172 | 174 | ||
175 | int flags; | ||
176 | |||
177 | int (*get_power)(struct device *dev); | ||
178 | int (*set_power)(struct device *dev, unsigned int on); | ||
179 | |||
173 | struct sm501_platdata_gpio_i2c *gpio_i2c; | 180 | struct sm501_platdata_gpio_i2c *gpio_i2c; |
174 | unsigned int gpio_i2c_nr; | 181 | unsigned int gpio_i2c_nr; |
175 | }; | 182 | }; |