aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMattias Nilsson <mattias.i.nilsson@stericsson.com>2011-02-14 05:17:12 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2011-03-23 05:41:47 -0400
commit90550d1903da8dac851d220b794e44c90a11c6ce (patch)
tree74c21403382a7e1e8f2e265fcb083994f29c6abe /drivers
parent8546bd4af1251d17d16b0ef682d84fd23c8beaca (diff)
mfd: AB8500 system control driver
This adds a pretty straight-forward system control driver for the AB8500. This driver will be used from the core platform, e.g the clock tree implementation in the machine code, and is by nature singleton. There are a few simple functions to read, write, set and clear registers so that the machine code can control its own foundation. Cc: Mattias Wallin <mattias.wallin@stericsson.com> Signed-off-by: Mattias Nilsson <mattias.i.nilsson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/Makefile2
-rw-r--r--drivers/mfd/ab8500-sysctrl.c80
2 files changed, 81 insertions, 1 deletions
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index f0e25cad762e..61a0b0f901a2 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -71,7 +71,7 @@ obj-$(CONFIG_ABX500_CORE) += abx500-core.o
71obj-$(CONFIG_AB3100_CORE) += ab3100-core.o 71obj-$(CONFIG_AB3100_CORE) += ab3100-core.o
72obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o 72obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o
73obj-$(CONFIG_AB3550_CORE) += ab3550-core.o 73obj-$(CONFIG_AB3550_CORE) += ab3550-core.o
74obj-$(CONFIG_AB8500_CORE) += ab8500-core.o 74obj-$(CONFIG_AB8500_CORE) += ab8500-core.o ab8500-sysctrl.o
75obj-$(CONFIG_AB8500_I2C_CORE) += ab8500-i2c.o 75obj-$(CONFIG_AB8500_I2C_CORE) += ab8500-i2c.o
76obj-$(CONFIG_AB8500_DEBUG) += ab8500-debugfs.o 76obj-$(CONFIG_AB8500_DEBUG) += ab8500-debugfs.o
77obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o 77obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o
diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
new file mode 100644
index 000000000000..392185965b39
--- /dev/null
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -0,0 +1,80 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com> for ST Ericsson.
4 * License terms: GNU General Public License (GPL) version 2
5 */
6
7#include <linux/err.h>
8#include <linux/platform_device.h>
9#include <linux/mfd/ab8500.h>
10#include <linux/mfd/abx500.h>
11#include <linux/mfd/ab8500/sysctrl.h>
12
13static struct device *sysctrl_dev;
14
15static inline bool valid_bank(u8 bank)
16{
17 return ((bank == AB8500_SYS_CTRL1_BLOCK) ||
18 (bank == AB8500_SYS_CTRL2_BLOCK));
19}
20
21int ab8500_sysctrl_read(u16 reg, u8 *value)
22{
23 u8 bank;
24
25 if (sysctrl_dev == NULL)
26 return -EAGAIN;
27
28 bank = (reg >> 8);
29 if (!valid_bank(bank))
30 return -EINVAL;
31
32 return abx500_get_register_interruptible(sysctrl_dev, bank,
33 (u8)(reg & 0xFF), value);
34}
35
36int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
37{
38 u8 bank;
39
40 if (sysctrl_dev == NULL)
41 return -EAGAIN;
42
43 bank = (reg >> 8);
44 if (!valid_bank(bank))
45 return -EINVAL;
46
47 return abx500_mask_and_set_register_interruptible(sysctrl_dev, bank,
48 (u8)(reg & 0xFF), mask, value);
49}
50
51static int __devinit ab8500_sysctrl_probe(struct platform_device *pdev)
52{
53 sysctrl_dev = &pdev->dev;
54 return 0;
55}
56
57static int __devexit ab8500_sysctrl_remove(struct platform_device *pdev)
58{
59 sysctrl_dev = NULL;
60 return 0;
61}
62
63static struct platform_driver ab8500_sysctrl_driver = {
64 .driver = {
65 .name = "ab8500-sysctrl",
66 .owner = THIS_MODULE,
67 },
68 .probe = ab8500_sysctrl_probe,
69 .remove = __devexit_p(ab8500_sysctrl_remove),
70};
71
72static int __init ab8500_sysctrl_init(void)
73{
74 return platform_driver_register(&ab8500_sysctrl_driver);
75}
76subsys_initcall(ab8500_sysctrl_init);
77
78MODULE_AUTHOR("Mattias Nilsson <mattias.i.nilsson@stericsson.com");
79MODULE_DESCRIPTION("AB8500 system control driver");
80MODULE_LICENSE("GPL v2");