From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 6/8] ARM i.MX: Turn iomux-v2 into driver
Date: Fri, 5 Oct 2012 12:53:34 +0200 [thread overview]
Message-ID: <1349434416-4231-7-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1349434416-4231-1-git-send-email-s.hauer@pengutronix.de>
To get proper resources allocated for it and to get rid of IOMUXC_BASE
usage.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/imx31.c | 1 +
arch/arm/mach-imx/iomux-v2.c | 66 +++++++++++++++++++++++++++++++++++-------
2 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-imx/imx31.c b/arch/arm/mach-imx/imx31.c
index 90eee0a..d4955bf 100644
--- a/arch/arm/mach-imx/imx31.c
+++ b/arch/arm/mach-imx/imx31.c
@@ -31,6 +31,7 @@ static int imx31_init(void)
add_generic_device("imx_iim", 0, NULL, MX31_IIM_BASE_ADDR, SZ_4K,
IORESOURCE_MEM, NULL);
+ add_generic_device("imx31-iomux", 0, NULL, MX31_IOMUXC_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx31-ccm", 0, NULL, MX31_CCM_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx31-gpt", 0, NULL, MX31_GPT1_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
add_generic_device("imx-gpio", 0, NULL, MX31_GPIO1_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
diff --git a/arch/arm/mach-imx/iomux-v2.c b/arch/arm/mach-imx/iomux-v2.c
index 08af54c..dbbb8a2 100644
--- a/arch/arm/mach-imx/iomux-v2.c
+++ b/arch/arm/mach-imx/iomux-v2.c
@@ -16,19 +16,22 @@
#include <common.h>
#include <io.h>
-#include <mach/imx-regs.h>
+#include <init.h>
#include <mach/iomux-mx31.h>
/*
* IOMUX register (base) addresses
*/
-#define IOMUXINT_OBS1 (IOMUXC_BASE + 0x000)
-#define IOMUXINT_OBS2 (IOMUXC_BASE + 0x004)
-#define IOMUXGPR (IOMUXC_BASE + 0x008)
-#define IOMUXSW_MUX_CTL (IOMUXC_BASE + 0x00C)
-#define IOMUXSW_PAD_CTL (IOMUXC_BASE + 0x154)
+#define IOMUXINT_OBS1 0x000
+#define IOMUXINT_OBS2 0x004
+#define IOMUXGPR 0x008
+#define IOMUXSW_MUX_CTL 0x00C
+#define IOMUXSW_PAD_CTL 0x154
#define IOMUX_REG_MASK (IOMUX_PADNUM_MASK & ~0x3)
+
+static void __iomem *base;
+
/*
* set the mode for a IOMUX pin.
*/
@@ -37,7 +40,10 @@ int imx_iomux_mode(unsigned int pin_mode)
u32 field, l, mode, ret = 0;
void __iomem *reg;
- reg = (void *)(IOMUXSW_MUX_CTL + (pin_mode & IOMUX_REG_MASK));
+ if (!base)
+ return -EINVAL;
+
+ reg = base + IOMUXSW_MUX_CTL + (pin_mode & IOMUX_REG_MASK);
field = pin_mode & 0x3;
mode = (pin_mode & IOMUX_MODE_MASK) >> IOMUX_MODE_SHIFT;
@@ -61,8 +67,11 @@ void imx_iomux_set_pad(enum iomux_pins pin, u32 config)
u32 field, l;
void __iomem *reg;
+ if (!base)
+ return;
+
pin &= IOMUX_PADNUM_MASK;
- reg = (void *)(IOMUXSW_PAD_CTL + (pin + 2) / 3 * 4);
+ reg = base + IOMUXSW_PAD_CTL + (pin + 2) / 3 * 4;
field = (pin + 2) % 3;
pr_debug("%s: reg offset = 0x%x, field = %d\n",
@@ -83,14 +92,51 @@ void imx_iomux_set_gpr(enum iomux_gp_func gp, int en)
{
u32 l;
- l = readl(IOMUXGPR);
+ if (!base)
+ return;
+
+ l = readl(base + IOMUXGPR);
if (en)
l |= gp;
else
l &= ~gp;
- writel(l, IOMUXGPR);
+ writel(l, base + IOMUXGPR);
}
EXPORT_SYMBOL(mxc_iomux_set_gpr);
+static int imx_iomux_probe(struct device_d *dev)
+{
+ base = dev_request_mem_region(dev, 0);
+
+ return 0;
+}
+static __maybe_unused struct of_device_id imx_iomux_dt_ids[] = {
+ {
+ .compatible = "fsl,imx31-iomux",
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct platform_device_id imx_iomux_ids[] = {
+ {
+ .name = "imx31-iomux",
+ }, {
+ /* sentinel */
+ },
+};
+
+static struct driver_d imx_iomux_driver = {
+ .name = "imx-iomuxv2",
+ .probe = imx_iomux_probe,
+ .of_compatible = DRV_OF_COMPAT(imx_iomux_dt_ids),
+ .id_table = imx_iomux_ids,
+};
+
+static int imx_iomux_init(void)
+{
+ return platform_driver_register(&imx_iomux_driver);
+}
+postcore_initcall(imx_iomux_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-10-05 10:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-05 10:53 [PATCH] i.MX SoC work Sascha Hauer
2012-10-05 10:53 ` [PATCH 1/8] ARM i.MX27: Use standard IMX_CHIP_REV_* defines Sascha Hauer
2012-10-05 10:53 ` [PATCH 2/8] ARM i.MX: streamline imx_silicon_revision Sascha Hauer
2012-10-05 10:53 ` [PATCH 3/8] ARM i.MX1: move iomux definitions to separate header file Sascha Hauer
2012-10-05 10:53 ` [PATCH 4/8] ARM i.MX boards: Use IMX_GPIO_NR Sascha Hauer
2012-10-05 10:53 ` [PATCH 5/8] ARM i.MX iomux-v1: Add separate header file Sascha Hauer
2012-10-05 10:53 ` Sascha Hauer [this message]
2012-10-05 10:53 ` [PATCH 7/8] ARM i.MX: Turn iomux-v3 into driver Sascha Hauer
2012-10-05 10:53 ` [PATCH 8/8] ARM i.MX: rework bootsource setting 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=1349434416-4231-7-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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