Skip to content

Commit 379749c

Browse files
author
Lee Jones
committed
mfd: ab8500-sysctrl: Provide a platform specific pm_power_off() call-back
The kernel allows us to specify a function call-back which will be invoked when a system power-off request has been received. Here we provide one which is to be used when shutting down AB8500 based platforms. Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent 949db15 commit 379749c

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎drivers/mfd/ab8500-sysctrl.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,29 @@
77
#include <linux/err.h>
88
#include <linux/module.h>
99
#include <linux/platform_device.h>
10+
#include <linux/pm.h>
11+
#include <linux/signal.h>
1012
#include <linux/mfd/abx500.h>
1113
#include <linux/mfd/abx500/ab8500.h>
1214
#include <linux/mfd/abx500/ab8500-sysctrl.h>
1315

1416
static struct device *sysctrl_dev;
1517

18+
void ab8500_power_off(void)
19+
{
20+
sigset_t old;
21+
sigset_t all;
22+
23+
sigfillset(&all);
24+
25+
if (!sigprocmask(SIG_BLOCK, &all, &old)) {
26+
(void)ab8500_sysctrl_set(AB8500_STW4500CTRL1,
27+
AB8500_STW4500CTRL1_SWOFF |
28+
AB8500_STW4500CTRL1_SWRESET4500N);
29+
(void)sigprocmask(SIG_SETMASK, &old, NULL);
30+
}
31+
}
32+
1633
static inline bool valid_bank(u8 bank)
1734
{
1835
return ((bank == AB8500_SYS_CTRL1_BLOCK) ||
@@ -51,7 +68,12 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
5168

5269
static int ab8500_sysctrl_probe(struct platform_device *pdev)
5370
{
71+
struct ab8500_platform_data *plat;
72+
5473
sysctrl_dev = &pdev->dev;
74+
plat = dev_get_platdata(pdev->dev.parent);
75+
if (plat->pm_power_off)
76+
pm_power_off = ab8500_power_off;
5577
return 0;
5678
}
5779

‎include/linux/mfd/abx500/ab8500.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ struct ab8500_codec_platform_data;
274274
/**
275275
* struct ab8500_platform_data - AB8500 platform data
276276
* @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used
277+
* @pm_power_off: Should machine pm power off hook be registered or not
277278
* @init: board-specific initialization after detection of ab8500
278279
* @num_regulator_reg_init: number of regulator init registers
279280
* @regulator_reg_init: regulator init registers
@@ -282,6 +283,7 @@ struct ab8500_codec_platform_data;
282283
*/
283284
struct ab8500_platform_data {
284285
int irq_base;
286+
bool pm_power_off;
285287
void (*init) (struct ab8500 *);
286288
int num_regulator_reg_init;
287289
struct ab8500_regulator_reg_init *regulator_reg_init;

0 commit comments

Comments
 (0)