diff options
author | Alexander Shiyan <shc_work@mail.ru> | 2013-03-11 13:26:41 +0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-11 22:17:43 +0100 |
commit | e857ff509b43e07eb30b48f283b40ea7dfbde068 (patch) | |
tree | 99890c1186213be91081b3a4f6353f1a069c8241 /drivers/mfd | |
parent | e7123ebafd08bf358cf087b3c63e1f1b467804a0 (diff) | |
download | barebox-e857ff509b43e07eb30b48f283b40ea7dfbde068.tar.gz barebox-e857ff509b43e07eb30b48f283b40ea7dfbde068.tar.xz |
Add system controller register driver (SYSCON)
This patch adds support for system controller register driver (SYSCON).
Code taken from Linux Kernel and adapted for using in barebox.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/Kconfig | 5 | ||||
-rw-r--r-- | drivers/mfd/Makefile | 1 | ||||
-rw-r--r-- | drivers/mfd/syscon.c | 92 |
3 files changed, 98 insertions, 0 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index c506d6782b..afb87dbd2d 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -24,6 +24,11 @@ config MFD_STMPE depends on I2C bool "STMPE-i2c driver" +config MFD_SYSCON + bool "System Controller Register" + help + Select this option to enable accessing system control registers + config MFD_TWLCORE bool diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 542fb0fb3a..1afd52bd30 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_MFD_MC34704) += mc34704.o obj-$(CONFIG_MFD_MC34708) += mc34708.o obj-$(CONFIG_MFD_MC9SDZ60) += mc9sdz60.o obj-$(CONFIG_MFD_STMPE) += stmpe-i2c.o +obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_TWLCORE) += twl-core.o obj-$(CONFIG_MFD_TWL4030) += twl4030.o obj-$(CONFIG_MFD_TWL6030) += twl6030.o diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c new file mode 100644 index 0000000000..87d2f7c8ff --- /dev/null +++ b/drivers/mfd/syscon.c @@ -0,0 +1,92 @@ +/* System Control Driver + * + * Based on linux driver by: + * Copyright (C) 2012 Freescale Semiconductor, Inc. + * Copyright (C) 2012 Linaro Ltd. + * Author: Dong Aisheng <dong.aisheng@linaro.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include <io.h> +#include <init.h> +#include <common.h> +#include <driver.h> +#include <malloc.h> +#include <xfuncs.h> + +#include <linux/err.h> + +#include <mfd/syscon.h> + +struct syscon { + void __iomem *base; +}; + +void __iomem *syscon_base_lookup_by_pdevname(const char *s) +{ + struct syscon *syscon; + struct device_d *dev; + + for_each_device(dev) { + if (!strcmp(dev_name(dev), s)) { + syscon = dev->priv; + return syscon->base; + } + } + + return ERR_PTR(-ENODEV); +} + +static int syscon_probe(struct device_d *dev) +{ + struct syscon *syscon; + struct resource *res; + + syscon = xzalloc(sizeof(struct syscon)); + if (!syscon) + return -ENOMEM; + + res = dev_get_resource(dev, 0); + if (!res) { + free(syscon); + return -ENOENT; + } + + res = request_iomem_region(dev_name(dev), res->start, res->end); + if (!res) { + free(syscon); + return -EBUSY; + } + + syscon->base = (void __iomem *)res->start; + dev->priv = syscon; + + dev_info(dev, "map 0x%x-0x%x registered\n", res->start, res->end); + + return 0; +} + +static struct platform_device_id syscon_ids[] = { + { "syscon", }, + { } +}; + +static struct driver_d syscon_driver = { + .name = "syscon", + .probe = syscon_probe, + .id_table = syscon_ids, +}; + +static int __init syscon_init(void) +{ + return platform_driver_register(&syscon_driver); +} +core_initcall(syscon_init); + +MODULE_AUTHOR("Dong Aisheng <dong.aisheng@linaro.org>"); +MODULE_DESCRIPTION("System Control driver"); +MODULE_LICENSE("GPL v2"); |