[uClinux-dev] [RFC] m68knommu: Add support for the Freescale m5253demo board.

Steven King sfking at fdwdc.com
Sun May 13 20:50:04 EDT 2012


Basic support for the m5253demo board from Freescale.  This is a work in
progress, currently only the dm9000 ethernet interface is supported.  More
patches to come ;)

This patch is against the v3.4-rc6 for_next branch of the m68knommu.git

Signed-off-by: Steven King <sfking at fdwdc.com>
---
 arch/m68k/Kconfig.machine               |    7 ++
 arch/m68k/include/asm/io_no.h           |    8 ++
 arch/m68k/include/asm/m525xsim.h        |    4 +
 arch/m68k/platform/coldfire/Makefile    |    1 +
 arch/m68k/platform/coldfire/m5253demo.c |  125 +++++++++++++++++++++++++++++++
 5 files changed, 145 insertions(+)

diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
index 7cdf6b0..10c97dc 100644
--- a/arch/m68k/Kconfig.machine
+++ b/arch/m68k/Kconfig.machine
@@ -252,6 +252,13 @@ config M5249C3
 	help
 	  Support for the Motorola M5249C3 board.
 
+config M5253DEMO
+	bool "Freescale M5253DEMO board support"
+	depends on M525x
+	select FREESCALE
+	help
+	  Support for the Freescale M5253DEMO board.
+
 config M5271EVB
 	bool "Freescale (Motorola) M5271EVB board support"
 	depends on M5271
diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h
index 353bf75..3d18c94 100644
--- a/arch/m68k/include/asm/io_no.h
+++ b/arch/m68k/include/asm/io_no.h
@@ -135,6 +135,14 @@ static inline void io_insl(unsigned int addr, void *buf, int len)
 #define insw(a,b,l) io_insw(a,b,l)
 #define insl(a,b,l) io_insl(a,b,l)
 
+#define writesb(a, b, l) io_outsb((unsigned int)a, b, l)
+#define writesw(a, b, l) io_outsw((unsigned int)a, b, l)
+#define writesl(a, b, l) io_outsl((unsigned int)a, b, l)
+
+#define readsb(a, b, l) io_insb((unsigned int)a, b, l)
+#define readsw(a, b, l) io_insw((unsigned int)a, b, l)
+#define readsl(a, b, l) io_insl((unsigned int)a, b, l)
+
 #define IO_SPACE_LIMIT 0xffffffff
 
 
diff --git a/arch/m68k/include/asm/m525xsim.h b/arch/m68k/include/asm/m525xsim.h
index 3d62b9d..46fbb34 100644
--- a/arch/m68k/include/asm/m525xsim.h
+++ b/arch/m68k/include/asm/m525xsim.h
@@ -105,6 +105,10 @@
 #define MCFQSPI_CS0		15
 #define MCFQSPI_CS1		16
 #define MCFQSPI_CS2		24
+#if !IS_ENABLED(CONFIG_DM9000)
+/* on the m5253demo the CS1/QSPICS3 is used as CS for the dm9000 */
+#define MCFQSPI_CS3		28
+#endif
 
 /*
  *	I2C module.
diff --git a/arch/m68k/platform/coldfire/Makefile b/arch/m68k/platform/coldfire/Makefile
index 82f0764..612f8cd 100644
--- a/arch/m68k/platform/coldfire/Makefile
+++ b/arch/m68k/platform/coldfire/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_M54xx)	+= m54xx.o sltimers.o intc-2.o
 obj-$(CONFIG_NETtel)	+= nettel.o
 obj-$(CONFIG_CLEOPATRA)	+= nettel.o
 obj-$(CONFIG_FIREBEE)	+= firebee.o
+obj-$(CONFIG_M5253DEMO)	+= m5253demo.o
 
 obj-y			+= pinmux.o gpio.o
 extra-y := head.o
diff --git a/arch/m68k/platform/coldfire/m5253demo.c b/arch/m68k/platform/coldfire/m5253demo.c
new file mode 100644
index 0000000..9041e1b
--- /dev/null
+++ b/arch/m68k/platform/coldfire/m5253demo.c
@@ -0,0 +1,125 @@
+/***************************************************************************/
+/*
+ *	m5253demo.c -- board support for the Freescale M5253demo board
+ *
+ *	Copyright (C) 2012, Steven King <sfking at fdwdc.com>
+ */
+
+/***************************************************************************/
+
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/dm9000.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+
+
+/***************************************************************************/
+#if IS_ENABLED(CONFIG_DM9000)
+
+/* The m5253demo has the DM9000 at 0x0e0000300/0x0e0000304, gpio5/irq 37 */
+
+#define DM9000_ADDR	0xe0000300
+#define DM9000_DATA	0xe0000304
+#define DM9000_IRQ	MCF_IRQ_GPIO5
+
+#define DM9000_GPIO	(DM9000_IRQ - MCF_IRQ_GPIO0)
+
+static struct resource m5253demo_dm9000_resources[] = {
+	[0] = {
+		.start		= DM9000_ADDR,
+		.end		= DM9000_ADDR + 0x3,
+		.flags		= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start		= DM9000_DATA,
+		.end		= DM9000_DATA + 0x3,
+		.flags		= IORESOURCE_MEM,
+	},
+	[2] = {
+		.start		= DM9000_IRQ,
+		.end		= DM9000_IRQ,
+		.flags		= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
+	},
+};
+
+static void m5253demo_dm9000_inblk(void __iomem *reg, void *data, int len)
+{
+	u16 *buf = data;
+	int n = (len + 1) >> 1;
+	while (n-- > 0)
+		*buf++ = readw(reg);
+}
+
+static void m5253demo_dm9000_outblk(void __iomem *reg, void *data, int len)
+{
+	u16 *buf = data;
+	int n = (len + 1) >> 1;
+	while (n-- > 0)
+		writew(*buf++, reg);
+}
+
+static void m5253demo_dm9000_dumpblk(void __iomem *reg, int len)
+{
+	int n = (len + 1) >> 1;
+	while (n-- > 0)
+		readw(reg);
+}
+
+static struct dm9000_plat_data m5253demo_dm9000_platdata = {
+	.flags		= DM9000_PLATF_NO_EEPROM,
+	.inblk		= m5253demo_dm9000_inblk,
+	.outblk		= m5253demo_dm9000_outblk,
+	.dumpblk	= m5253demo_dm9000_dumpblk,
+};
+
+static struct platform_device m5253demo_dm9000 = {
+	.name			= "dm9000",
+	.id			= -1,
+	.num_resources		= ARRAY_SIZE(m5253demo_dm9000_resources),
+	.resource		= m5253demo_dm9000_resources,
+	.dev.platform_data	= &m5253demo_dm9000_platdata,
+};
+
+static void __init m5253demo_dm9000_init(void)
+{
+	u32 r;
+	int status;
+
+	/* set the gpio function for DM9000_GPIO to gpio */
+	/* FIXME: replace with pinmux/pinctl support */
+	r = readl(MCFSIM2_GPIOFUNC);
+	r |= 1 << DM9000_GPIO;
+	writel(r, MCFSIM2_GPIOFUNC);
+
+	/* reserve the gpio so nothing else can request it */
+	/* FIXME: replace with pinmux/pinctl support */
+	status = gpio_request(DM9000_GPIO, "DM9000_GPIO");
+	if (status)
+		pr_warn("gpio_request for DM9000_GPIO failed\n");
+	/* set the priority level for DM9000 gpio irq */
+	r = readl(MCFINTC2_INTPRI_REG(DM9000_IRQ));
+	r &= ~MCFINTC2_INTPRI_BITS(0xf, DM9000_IRQ);
+	r |= MCFINTC2_INTPRI_BITS(0x4, DM9000_IRQ);
+	writel(r, MCFINTC2_INTPRI_REG(DM9000_IRQ));
+}
+#endif /* IS_ENABLED(CONFIG_DM9000) */
+
+static struct platform_device *m5253demo_devices[] __initdata = {
+	&m5253demo_dm9000,
+};
+
+static int __init m5253demo_init(void)
+{
+	m5253demo_dm9000_init();
+	platform_add_devices(m5253demo_devices, ARRAY_SIZE(m5253demo_devices));
+	return 0;
+}
+
+arch_initcall(m5253demo_init);
+
+/***************************************************************************/



More information about the uClinux-dev mailing list