From: Alexander Shiyan <shc_work@mail.ru>
To: barebox@lists.infradead.org
Subject: [PATCH 11/13] Add system controller register driver (SYSCON)
Date: Mon, 11 Mar 2013 13:26:41 +0400 [thread overview]
Message-ID: <1362994003-22653-11-git-send-email-shc_work@mail.ru> (raw)
In-Reply-To: <1362994003-22653-1-git-send-email-shc_work@mail.ru>
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>
---
drivers/mfd/Kconfig | 5 +++
drivers/mfd/Makefile | 1 +
drivers/mfd/syscon.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/mfd/syscon.h | 26 ++++++++++++++
4 files changed, 124 insertions(+), 0 deletions(-)
create mode 100644 drivers/mfd/syscon.c
create mode 100644 include/mfd/syscon.h
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index c506d67..afb87db 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 542fb0f..1afd52b 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 0000000..87d2f7c
--- /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");
diff --git a/include/mfd/syscon.h b/include/mfd/syscon.h
new file mode 100644
index 0000000..68432b7
--- /dev/null
+++ b/include/mfd/syscon.h
@@ -0,0 +1,26 @@
+/* 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.
+ */
+
+#ifndef __MFD_SYSCON_H__
+#define __MFD_SYSCON_H__
+
+#ifdef CONFIG_MFD_SYSCON
+void __iomem *syscon_base_lookup_by_pdevname(const char *);
+#else
+static inline void __iomem *syscon_base_lookup_by_pdevname(const char *)
+{
+ return NULL;
+}
+#endif
+
+#endif
--
1.7.3.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-03-11 9:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-11 9:26 [PATCH 01/13] ARM: clep7212: Migrate to config-board Alexander Shiyan
2013-03-11 9:26 ` [PATCH 02/13] ARM: clps711x: Fix setup bus wait state scaling factor for 13Mhz mode Alexander Shiyan
2013-03-11 9:26 ` [PATCH 03/13] ARM: clps711x: Replace numeric PLL option with boolean for raise CPU frequency Alexander Shiyan
2013-03-11 9:26 ` [PATCH 04/13] ARM: clps711x: Add clocksource driver Alexander Shiyan
2013-03-11 11:01 ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-11 11:10 ` Sascha Hauer
2013-03-11 16:22 ` Re[2]: " Alexander Shiyan
2013-03-11 18:00 ` Sascha Hauer
2013-03-11 18:17 ` Re[2]: " Alexander Shiyan
2013-03-11 9:26 ` [PATCH 05/13] ARM: clps711x: Using COMMON_CLK Alexander Shiyan
2013-03-11 11:00 ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-11 11:26 ` Re[2]: " Alexander Shiyan
2013-03-11 11:58 ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-11 9:26 ` [PATCH 06/13] Add Generic GPIO driver Alexander Shiyan
2013-03-11 9:26 ` [PATCH 07/13] ARM: clps711x: Add " Alexander Shiyan
2013-03-11 9:26 ` [PATCH 08/13] Add helpers to define resources Alexander Shiyan
2013-03-11 9:26 ` [PATCH 09/13] ARM: clps711x: Migrate to using DEFINE_RES_MEM macro Alexander Shiyan
2013-03-11 9:26 ` [PATCH 10/13] ARM: clps711x: Limit chipselect setup up to CS5 Alexander Shiyan
2013-03-11 9:26 ` Alexander Shiyan [this message]
2013-03-11 9:26 ` [PATCH 12/13] ARM: clps711x: Export system-wide registers through SYSCON driver Alexander Shiyan
2013-03-11 9:26 ` [PATCH 13/13] serial: clps711x: Migrate to using " Alexander Shiyan
2013-03-11 21:18 ` [PATCH 01/13] ARM: clep7212: Migrate to config-board Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1362994003-22653-11-git-send-email-shc_work@mail.ru \
--to=shc_work@mail.ru \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox