Add system controller register driver (SYSCON)
Subsystems (2)
RFC 1/1 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 <[email protected]>
--- drivers/mfd/Kconfig | 5 +++ drivers/mfd/Makefile | 1 + drivers/mfd/syscon.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/mfd/syscon.h | 31 ++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 drivers/mfd/syscon.c create mode 100644 include/mfd/syscon.h
drivers/mfd/Kconfig +5 -0
@@ -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
drivers/mfd/Makefile +1 -0
@@ -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
drivers/mfd/syscon.c new file +89 -0
89 lines not on this page · raw message
include/mfd/syscon.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* System Control Driver +* +* Based on linux driver by: +* Copyright (C) 2012 Freescale Semiconductor, Inc. +* Copyright (C) 2012 Linaro Ltd. +* Author: Dong Aisheng <[email protected]> +* +* 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__ + +struct syscon_pdata { +const char *compatible; +}; + +#ifdef CONFIG_MFD_SYSCON +void __iomem *syscon_base_lookup_by_compatible (const char *); +#else +static inline void __iomem *syscon_base_lookup_by_compatible (const char *) +{ +return NULL ; +} +#endif + +#endif /* __MFD_SYSCON_H__ */
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 4 lines · Alexander Shiyan
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 <[email protected]>
Looks good to me. If you have a user for it we can apply it.
Sascha
Quoted 178 lines
--- drivers/mfd/Kconfig | 5 +++ drivers/mfd/Makefile | 1 + drivers/mfd/syscon.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/mfd/syscon.h | 31 ++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 drivers/mfd/syscon.c create mode 100644 include/mfd/syscon.hdrivers/mfd/Kconfig +5
-0@@ -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 booldrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/syscon.c new file +89
-0@@ -0,0 +1,89 @@ +/* +* System Control Driver +* +* Based on linux driver by: +* Copyright (C) 2012 Freescale Semiconductor, Inc. +* Copyright (C) 2012 Linaro Ltd. +* Author: Dong Aisheng <[email protected]> +* +* 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 <xfuncs.h> + +#include <mfd/syscon.h> + +struct syscon { +void __iomem *base; +}; + +void __iomem *syscon_base_lookup_by_compatible (const char *s) +{ +struct syscon *syscon; +struct syscon_pdata *pdata; +struct device_d *dev; + +for_each_device (dev) { +if (strncmp (dev_name (dev),"syscon" ,6 )) +continue ; + + pdata = dev->platform_data; +if (!pdata) +continue ; + +if (!strcmp (pdata->compatible, s)) { + syscon = dev->priv; +return syscon->base; + } + } + +return NULL ; +} + +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) +return -ENOENT ; + + res =request_iomem_region (dev_name (dev), res->start, res->end); +if (!res) +return -EIO ; + + syscon->base = (void __iomem *)res->start; + dev->priv = syscon; + +dev_info (dev,"syscon start 0x%x end 0x%x registered\n" , + res->start, res->end); + +return 0 ; +} + +static struct driver_d syscon_driver = { + .name ="syscon" , + .probe = syscon_probe, +}; + +static int __init syscon_init (void ) +{ +return platform_driver_register (&syscon_driver); +} +postcore_initcall (syscon_init); + +MODULE_AUTHOR ("Dong Aisheng <[email protected]>" ); +MODULE_DESCRIPTION ("System Control driver" ); +MODULE_LICENSE ("GPL v2" );include/mfd/syscon.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* System Control Driver +* +* Based on linux driver by: +* Copyright (C) 2012 Freescale Semiconductor, Inc. +* Copyright (C) 2012 Linaro Ltd. +* Author: Dong Aisheng <[email protected]> +* +* 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__ + +struct syscon_pdata { +const char *compatible; +}; + +#ifdef CONFIG_MFD_SYSCON +void __iomem *syscon_base_lookup_by_compatible (const char *); +#else +static inline void __iomem *syscon_base_lookup_by_compatible (const char *) +{ +return NULL ; +} +#endif + +#endif /* __MFD_SYSCON_H__ */ Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox