mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 10/11] ARM: mxs: Add convenience wrapper to register mxs_nand device
Date: Wed, 10 Jul 2013 14:00:00 +0200	[thread overview]
Message-ID: <1373457601-7225-11-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1373457601-7225-1-git-send-email-s.hauer@pengutronix.de>

The convenience wrapper also contains the bch resources to
get rid of the hardcoded base in the driver in the next step.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/freescale-mx28-evk/mx28-evk.c |  4 +--
 arch/arm/boards/karo-tx28/tx28.c              |  4 +--
 arch/arm/mach-mxs/include/mach/devices.h      | 47 +++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/mach-mxs/include/mach/devices.h

diff --git a/arch/arm/boards/freescale-mx28-evk/mx28-evk.c b/arch/arm/boards/freescale-mx28-evk/mx28-evk.c
index 687d3f7..dfb1878 100644
--- a/arch/arm/boards/freescale-mx28-evk/mx28-evk.c
+++ b/arch/arm/boards/freescale-mx28-evk/mx28-evk.c
@@ -30,6 +30,7 @@
 #include <mach/mci.h>
 #include <mach/fb.h>
 #include <mach/ocotp.h>
+#include <mach/devices.h>
 #include <spi/spi.h>
 
 #include <asm/armlinux.h>
@@ -270,8 +271,7 @@ static int mx28_evk_devices_init(void)
 	add_generic_device("imx28-fec", 0, NULL, IMX_FEC0_BASE, 0x4000,
 			   IORESOURCE_MEM, &fec_info);
 
-	add_generic_device("mxs_nand", 0, NULL, MXS_GPMI_BASE, 0x2000,
-			   IORESOURCE_MEM, NULL);
+	imx28_add_nand();
 
 	spi_register_board_info(mx28evk_spi_board_info,
 			ARRAY_SIZE(mx28evk_spi_board_info));
diff --git a/arch/arm/boards/karo-tx28/tx28.c b/arch/arm/boards/karo-tx28/tx28.c
index 6e8da15..4cacca3 100644
--- a/arch/arm/boards/karo-tx28/tx28.c
+++ b/arch/arm/boards/karo-tx28/tx28.c
@@ -21,6 +21,7 @@
 #include <io.h>
 #include <generated/mach-types.h>
 #include <mach/imx-regs.h>
+#include <mach/devices.h>
 #include <asm/mmu.h>
 
 /* setup the CPU card internal signals */
@@ -92,8 +93,7 @@ static int tx28_devices_init(void)
 
 	base_board_init();
 
-	add_generic_device("mxs_nand", 0, NULL, MXS_GPMI_BASE, 0x2000,
-			   IORESOURCE_MEM, NULL);
+	imx28_add_nand();
 
 	return 0;
 }
diff --git a/arch/arm/mach-mxs/include/mach/devices.h b/arch/arm/mach-mxs/include/mach/devices.h
new file mode 100644
index 0000000..012bfc4
--- /dev/null
+++ b/arch/arm/mach-mxs/include/mach/devices.h
@@ -0,0 +1,47 @@
+#ifndef __MACH_MXS_DEVICES_H
+#define __MACH_MXS_DEVICES_H
+
+#include <common.h>
+#include <sizes.h>
+#include <xfuncs.h>
+#include <driver.h>
+#include <mach/imx-regs.h>
+
+static inline struct device_d *mxs_add_nand(unsigned long gpmi_base, unsigned long bch_base)
+{
+	struct resource res[] = {
+		{
+			.start = gpmi_base,
+			.end = gpmi_base + SZ_8K - 1,
+			.flags = IORESOURCE_MEM,
+		}, {
+			.start = bch_base,
+			.end = bch_base + SZ_8K - 1,
+			.flags = IORESOURCE_MEM,
+		},
+	};
+
+	struct device_d *dev = xzalloc(sizeof(*dev));
+
+	dev->resource = xzalloc(sizeof(struct resource) * ARRAY_SIZE(res));
+	memcpy(dev->resource, res, sizeof(struct resource) * ARRAY_SIZE(res));
+	dev->num_resources = ARRAY_SIZE(res);
+	strcpy(dev->name, "mxs_nand");
+	dev->id = DEVICE_ID_DYNAMIC;
+
+	platform_device_register(dev);
+
+	return dev;
+};
+
+static inline struct device_d *imx23_add_nand(void)
+{
+	return mxs_add_nand(MXS_GPMI_BASE, MXS_BCH_BASE);
+}
+
+static inline struct device_d *imx28_add_nand(void)
+{
+	return mxs_add_nand(MXS_GPMI_BASE, MXS_BCH_BASE);
+}
+
+#endif /* __MACH_MXS_DEVICES_H */
-- 
1.8.3.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-07-10 12:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10 11:59 [PATCH] prepare i.MX6 NAND support Sascha Hauer
2013-07-10 11:59 ` [PATCH 01/11] ARM: MXS: introduce stmp device support Sascha Hauer
2013-07-10 11:59 ` [PATCH 02/11] dma: apbh: introduce private struct Sascha Hauer
2013-07-10 11:59 ` [PATCH 03/11] dma: apbh-dma: move header file to common location Sascha Hauer
2013-07-10 11:59 ` [PATCH 04/11] dma: apbh: remove CONFIG_ARCH_DMA_PIO_WORDS Sascha Hauer
2013-07-10 11:59 ` [PATCH 05/11] dma: apbh: Turn into a driver Sascha Hauer
2013-07-10 11:59 ` [PATCH 06/11] dma: apbh: add devicetree probe support Sascha Hauer
2013-07-10 11:59 ` [PATCH 07/11] dma: apbh: cleanup includes Sascha Hauer
2013-07-10 11:59 ` [PATCH 08/11] mtd: nand: gpmi: use io_base instead of MXS_GPMI_BASE Sascha Hauer
2013-07-10 11:59 ` [PATCH 09/11] mtd: nand: gpmi: cleanup includes Sascha Hauer
2013-07-10 12:00 ` Sascha Hauer [this message]
2013-07-10 12:00 ` [PATCH 11/11] mtd: nand: gpmi: replace MXS_BCH_BASE with driver resources 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=1373457601-7225-11-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