summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@stericsson.com>2011-05-05 09:20:56 +0530
committerHenrik Aberg <henrik.aberg@stericsson.com>2011-05-18 09:40:12 +0200
commitc1eeae50e420c6106f02da4e40f6c059dba1d195 (patch)
tree077614dbb6c6e4e1d46f46a61e8f358f42c529e3
parente10e61b1cc9fa26ce60005dd7fdbde61c5100bfc (diff)
ab5500: provide a driver for power off
ST-Ericsson Linux next: - ST-Ericsson ID: WP257121 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I3fcc5c9f1d88c433edc3698da739ecdd11e51711 Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/22352 Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
-rw-r--r--arch/arm/mach-ux500/board-u5500.c1
-rw-r--r--drivers/mfd/Makefile2
-rwxr-xr-xdrivers/mfd/ab5500-core.c16
-rw-r--r--drivers/mfd/ab5500-power.c72
-rw-r--r--include/linux/mfd/abx500/ab5500.h1
5 files changed, 91 insertions, 1 deletions
diff --git a/arch/arm/mach-ux500/board-u5500.c b/arch/arm/mach-ux500/board-u5500.c
index b4e76abd529..69f7b5471a1 100644
--- a/arch/arm/mach-ux500/board-u5500.c
+++ b/arch/arm/mach-ux500/board-u5500.c
@@ -344,6 +344,7 @@ static struct ab5500_platform_data ab5500_plf_data = {
.base = IRQ_AB5500_BASE,
.count = AB5500_NR_IRQS,
},
+ .pm_power_off = true,
.regulator = &u5500_ab5500_regulator_data,
};
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index cc316ad8bd7..b84cd4afc34 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -2,7 +2,7 @@
# Makefile for multifunction miscellaneous devices
#
-obj-$(CONFIG_AB5500_CORE) += ab5500-core.o
+obj-$(CONFIG_AB5500_CORE) += ab5500-core.o ab5500-power.o
88pm860x-objs := 88pm860x-core.o 88pm860x-i2c.o
obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o
obj-$(CONFIG_MFD_SM501) += sm501.o
diff --git a/drivers/mfd/ab5500-core.c b/drivers/mfd/ab5500-core.c
index 43f7cad48e7..2fc1cf1b101 100755
--- a/drivers/mfd/ab5500-core.c
+++ b/drivers/mfd/ab5500-core.c
@@ -529,6 +529,22 @@ static struct ab5500_i2c_banks ab5500_bank_ranges[AB5500_NUM_DEVICES] = {
},
},
},
+ [AB5500_DEVID_POWER] = {
+ .nbanks = 1,
+ .bank = (struct ab5500_i2c_ranges []) {
+ {
+ .bankid = AB5500_BANK_STARTUP,
+ .nranges = 1,
+ .range = (struct ab5500_reg_range[]) {
+ {
+ .first = 0x30,
+ .last = 0x30,
+ .perm = AB5500_PERM_RW,
+ },
+ },
+ }
+ },
+ },
};
#define AB5500_IRQ(bank, bit) ((bank) * 8 + (bit))
diff --git a/drivers/mfd/ab5500-power.c b/drivers/mfd/ab5500-power.c
new file mode 100644
index 00000000000..5bf6a4c5e97
--- /dev/null
+++ b/drivers/mfd/ab5500-power.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ *
+ * License terms: GNU General Public License (GPL) version 2
+ */
+
+#include <linux/kernel.h>
+#include <linux/signal.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <linux/mfd/abx500.h>
+#include <linux/mfd/abx500/ab5500.h>
+
+static struct device *dev;
+
+#define AB5500_SYSPOR_CONTROL 0x30
+
+static void ab5500_power_off(void)
+{
+ sigset_t old;
+ sigset_t all;
+
+ sigfillset(&all);
+
+ if (!sigprocmask(SIG_BLOCK, &all, &old)) {
+ /* Clear dbb_on */
+ int ret = abx500_set(dev, AB5500_BANK_STARTUP,
+ AB5500_SYSPOR_CONTROL, 0);
+ WARN_ON(ret);
+ }
+}
+
+static int __devinit ab5500_power_probe(struct platform_device *pdev)
+{
+ struct ab5500_platform_data *plat = dev_get_platdata(pdev->dev.parent);
+
+ if (!plat->pm_power_off)
+ return -ENODEV;
+
+ dev = &pdev->dev;
+ pm_power_off = ab5500_power_off;
+
+ return 0;
+}
+
+static int __devexit ab5500_power_remove(struct platform_device *pdev)
+{
+ pm_power_off = NULL;
+ dev = NULL;
+
+ return 0;
+}
+
+static struct platform_driver ab5500_power_driver = {
+ .driver = {
+ .name = "ab5500-power",
+ .owner = THIS_MODULE,
+ },
+ .probe = ab5500_power_probe,
+ .remove = __devexit_p(ab5500_power_remove),
+};
+
+static int __init ab8500_sysctrl_init(void)
+{
+ return platform_driver_register(&ab5500_power_driver);
+}
+
+subsys_initcall(ab8500_sysctrl_init);
+
+MODULE_DESCRIPTION("AB5500 power driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/abx500/ab5500.h b/include/linux/mfd/abx500/ab5500.h
index f9230b6444f..1b2b150072a 100644
--- a/include/linux/mfd/abx500/ab5500.h
+++ b/include/linux/mfd/abx500/ab5500.h
@@ -134,6 +134,7 @@ struct ab5500 {
struct ab5500_regulator_platform_data;
struct ab5500_platform_data {
struct {unsigned int base; unsigned int count; } irq;
+ bool pm_power_off;
void *dev_data[AB5500_NUM_DEVICES];
size_t dev_data_sz[AB5500_NUM_DEVICES];
struct ab5500_regulator_platform_data *regulator;