Skip to contentSkip to conversation

sh: Add support for Solution Engine SH7721 board

PATCH Superseded Yoshihiro Shimoda 3 participants 3 messages Mar 19, 2008 – Mar 20, 2008 SuperH

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh: Add support for Solution Engine SH7721 board

Add support for Solution Engine SH7721 board(MS7721RP01).

---
 arch/sh/Kconfig                  |    9
 arch/sh/Makefile                 |    1
 arch/sh/boards/se/7721/Makefile  |   10
 arch/sh/boards/se/7721/io.c      |  223 +++++
 arch/sh/boards/se/7721/irq.c     |   86 ++
 arch/sh/boards/se/7721/setup.c   |  119 +++
 arch/sh/configs/se7721_defconfig | 1086 +++++++++++++++++++++++++++++
 arch/sh/kernel/cf-enabler.c      |    9
 arch/sh/tools/mach-types         |    1
 include/asm-sh/se7721.h          |   71 +
 10 files changed, 1612 insertions(+), 3 deletions(-)
arch/sh/boards/se/7721/io.c +223 -0
diff -uprN a/arch/sh/boards/se/7721/io.c b/arch/sh/boards/se/7721/io.c
@@ -0,0 +1,223 @@
+/*
+ * I/O routine for SH7721 SolutionEngine.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <asm/se.h>
+#include <asm/io.h>
+
+#define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
+
+struct iop {
+	unsigned long base;
+	struct iop *(*check) (struct iop *p, unsigned long port);
+	u8 (*inb) (struct iop *p, unsigned long port);
+	u16 (*inw) (struct iop *p, unsigned long port);
+	void (*outb) (struct iop *p, u8 value, unsigned long port);
+	void (*outw) (struct iop *p, u16 value, unsigned long port);
+};
+
+static struct iop *ide_check(struct iop *p, unsigned long port)
+{
+	if (((PA_MRSHPC_IO + 0x1f0) <= port &&
+	      port < (PA_MRSHPC_IO + 0x1f8)) || port = (PA_MRSHPC_IO + 0x3f6))
+		return p;
+	else
+		return NULL;
+}
+
+u8 pcc_inb(struct iop *p, unsigned long port)
+{
+	return ctrl_inb(p->base + port + 0x40000);
+}
+
+u16 pcc_inw(struct iop *p, unsigned long port)
+{
+	return ctrl_inw(p->base + port);
+}
+
+void pcc_outb(struct iop *p, u8 value, unsigned long port)
+{
+	ctrl_outb(value, p->base + port + 0x40000);
+}
+
+void pcc_outw(struct iop *p, u16 value, unsigned long port)
+{
+	ctrl_outw(value, p->base + port);
+}
+
+static struct iop cfiop = {
+	.base	= 0x00000000,
+	.check	= ide_check,
+	.inb	= pcc_inb,
+	.inw	= pcc_inw,
+	.outb	= pcc_outb,
+	.outw	= pcc_outw,
+};
+
+static struct iop *port2iop(unsigned long port)
+{
+	if (cfiop.check(&cfiop, port))
+		return &cfiop;
+	else
+		return NULL;
+}
+
+u8 se7721_inb(unsigned long port)
+{
+	struct iop *p = port2iop(port);
+
+	if (p)
+		return (p->inb)(p, port);
+	else
+		return ctrl_inb(port);
+}
+
+u8 se7721_inb_p(unsigned long port)
+{
+	u8 v = se7721_inb(port);
+
+	ctrl_delay();
+
+	return v;
+}
+
+u16 se7721_inw(unsigned long port)
+{
+	struct iop *p = port2iop(port);
+
+	if (p)
+		return (p->inw)(p, port);
+	else
+		return ctrl_inw(port);
+}
+
+u32 se7721_inl(unsigned long port)
+{
+	return ctrl_inl(port);
+}
+
+void se7721_outb(u8 value, unsigned long port)
+{
+	struct iop *p = port2iop(port);
+
+	if (p)
+		(p->outb)(p, value, port);
+	else
+		ctrl_outb(value, port);
+}
+
+void se7721_outb_p(u8 value, unsigned long port)
+{
+	se7721_outb(value, port);
+	ctrl_delay();
+}
+
+void se7721_outw(u16 value, unsigned long port)
+{
+	struct iop *p = port2iop(port);
+
+	if (p)
+		(p->outw)(p, value, port);
+	else
+		ctrl_outw(value, port);
+}
+
+void se7721_outl(unsigned int value, unsigned long port)
+{
+	ctrl_outl(value, port);
+}
+
+void se7721_insb(unsigned long port, void *addr, unsigned long count)
+{
+	u8 *a = addr;
+	struct iop *p = port2iop(port);
+
+	if (p) {
+		while (count--)
+			*a++ = (p->inb)(p, port);
+	} else {
+		while (count--)
+			*a++ = ctrl_inb(port);
+	}
+}
+
+void se7721_insw(unsigned long port, void *addr, unsigned long count)
+{
+	u16 *a = addr;
+	struct iop *p = port2iop(port);
+
+	if (p) {
+		while (count--)
+			*a++ = (p->inw)(p, port);
+	} else {
+		while (count--)
+			*a++ = ctrl_inw(port);
+	}
+}
+
+void se7721_insl(unsigned long port, void *addr, unsigned long count)
+{
+	u32 *a = addr;
+
+	while (count--)
+		*a++ = ctrl_inl(port);
+}
+
+void se7721_outsb(unsigned long port, const void *addr, unsigned long count)
+{
+	const u8 *a = (unsigned char *)addr;
+	struct iop *p = port2iop(port);
+
+	if (p) {
+		while (count--)
+			(p->outb)(p, *a++, port);
+	} else {
+		while (count--)
+			ctrl_outb(*a++, port);
+	}
+}
+
+void se7721_outsw(unsigned long port, const void *addr, unsigned long count)
+{
+	const u16 *a = (unsigned short *)addr;
+	struct iop *p = port2iop(port);
+
+	if (p) {
+		while (count--)
+			(p->outw)(p, *a++, port);
+	} else {
+		while (count--)
+			ctrl_outw(*a++, port);
+	}
+}
+
+void se7721_outsl(unsigned long port, const void *addr, unsigned long count)
+{
+	const u32 *a = (u32 *)addr;
+
+	while (count--)
+		ctrl_outl(*a++, port);
+}
+
+u8 se7721_readb(void __iomem *addr)
+{
+	if (((PA_MRSHPC_IO + 0x1f0) <= (unsigned long)addr &&
+	    (unsigned long)addr < (PA_MRSHPC_IO + 0x1f8)) ||
+	    (unsigned long)addr = (PA_MRSHPC_IO + 0x3f6))
+		return se7721_inb((unsigned long)addr);
+	else
+		return ctrl_inb((unsigned long)addr);
+}
+
+void se7721_writeb(u8 b, void __iomem *addr)
+{
+	if (((PA_MRSHPC_IO + 0x1f0) <= (unsigned long)addr &&
+	    (unsigned long)addr < (PA_MRSHPC_IO + 0x1f8)) ||
+	    (unsigned long)addr = (PA_MRSHPC_IO + 0x3f6))
+		se7721_outb(b, (unsigned long)addr);
+	else
+		ctrl_outb(b, (unsigned long)addr);
+}
arch/sh/boards/se/7721/irq.c +86 -0

86 lines not on this page · raw message

arch/sh/boards/se/7721/Makefile +10 -0
diff -uprN a/arch/sh/boards/se/7721/Makefile b/arch/sh/boards/se/7721/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the HITACHI UL SolutionEngine 7721 specific parts of the kernel
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License.  See the file "COPYING" in the main directory of this archive
+# for more details.
+#
+#
+
+obj-y	 := setup.o irq.o io.o
arch/sh/boards/se/7721/setup.c +119 -0

119 lines not on this page · raw message

arch/sh/configs/se7721_defconfig +1086 -0

1,086 lines not on this page · raw message

arch/sh/Kconfig +9 -0
diff -uprN a/arch/sh/Kconfig b/arch/sh/Kconfig
@@ -375,6 +375,15 @@ config SH_7619_SOLUTION_ENGINE
 	  Select 7619 SolutionEngine if configuring for a Hitachi SH7619
 	  evaluation board.
 	
+config SH_7721_SOLUTION_ENGINE
+	bool "SolutionEngine7721"
+	select SOLUTION_ENGINE
+	select CPU_HAS_IPR_IRQ
+	depends on CPU_SUBTYPE_SH7721
+	help
+	  Select 7721 SolutionEngine if configuring for a Hitachi SH7721
+	  evaluation board.
+
 config SH_7722_SOLUTION_ENGINE
 	bool "SolutionEngine7722"
 	select SOLUTION_ENGINE
arch/sh/kernel/cf-enabler.c +6 -3
diff -uprN a/arch/sh/kernel/cf-enabler.c b/arch/sh/kernel/cf-enabler.c
@@ -83,6 +83,8 @@ static int __init cf_init_default(void)
 #include <asm/se.h>
 #elif defined(CONFIG_SH_7722_SOLUTION_ENGINE)
 #include <asm/se7722.h>
+#elif defined(CONFIG_SH_7721_SOLUTION_ENGINE)
+#include <asm/se7721.h>
 #endif
 
 /*
@@ -99,7 +101,9 @@ static int __init cf_init_default(void)
  * 0xB0600000 : I/O
  */
 
-#if defined(CONFIG_SH_SOLUTION_ENGINE) || defined(CONFIG_SH_7722_SOLUTION_ENGINE)
+#if defined(CONFIG_SH_SOLUTION_ENGINE) || \
+    defined(CONFIG_SH_7722_SOLUTION_ENGINE) || \
+    defined(CONFIG_SH_7721_SOLUTION_ENGINE)
 static int __init cf_init_se(void)
 {
 	if ((ctrl_inw(MRSHPC_CSR) & 0x000c) != 0)
@@ -155,9 +159,8 @@ static int __init cf_init_se(void)
 
 int __init cf_init(void)
 {
-	if( mach_is_se() || mach_is_7722se() ){
+	if (mach_is_se() || mach_is_7722se() || mach_is_7721se())
 		return cf_init_se();
-	}
 	
 	return cf_init_default();
 }
arch/sh/Makefile +1 -0
diff -uprN a/arch/sh/Makefile b/arch/sh/Makefile
@@ -107,6 +107,7 @@ machdir-$(CONFIG_SH_7722_SOLUTION_ENGINE
 machdir-$(CONFIG_SH_7751_SOLUTION_ENGINE)	+= se/7751
 machdir-$(CONFIG_SH_7780_SOLUTION_ENGINE)	+= se/7780
 machdir-$(CONFIG_SH_7343_SOLUTION_ENGINE)	+= se/7343
+machdir-$(CONFIG_SH_7721_SOLUTION_ENGINE)	+= se/7721
 machdir-$(CONFIG_SH_HP6XX)			+= hp6xx
 machdir-$(CONFIG_SH_DREAMCAST)			+= dreamcast
 machdir-$(CONFIG_SH_MPC1211)			+= mpc1211
arch/sh/tools/mach-types +1 -0
diff -uprN a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
@@ -21,6 +21,7 @@ HD64465			HD64465
 7206SE			SH_7206_SOLUTION_ENGINE
 7343SE			SH_7343_SOLUTION_ENGINE
 7619SE			SH_7619_SOLUTION_ENGINE
+7721SE			SH_7721_SOLUTION_ENGINE		
 7722SE			SH_7722_SOLUTION_ENGINE		
 7751SE			SH_7751_SOLUTION_ENGINE		
 7780SE			SH_7780_SOLUTION_ENGINE
include/asm-sh/se7721.h +71 -0

71 lines not on this page · raw message

#1 lore raw
Quoted 6 lines · Yoshihiro Shimoda

diff -uprN a/arch/sh/boards/se/7721/io.c b/arch/sh/boards/se/7721/io.c

arch/sh/boards/se/7721/io.c +2 -0
@@ -0,0 +1,223 @@
+/*
+ * I/O routine for SH7721 SolutionEngine.

arch/sh/boards/se/7721/io.c line 12

Quoted 10 lines
arch/sh/boards/se/7721/io.c +10 -0
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <asm/se.h>
+#include <asm/io.h>
+
+#define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
+

This io.c is useless, kill it off and use the proper addresses when registering the platform device.

Quoted 4 lines

diff -uprN a/arch/sh/boards/se/7721/Makefile b/arch/sh/boards/se/7721/Makefile

arch/sh/boards/se/7721/Makefile line 10

Quoted 10 lines
arch/sh/boards/se/7721/Makefile +10 -0
@@ -0,0 +1,10 @@
+#
+# Makefile for the HITACHI UL SolutionEngine 7721 specific parts of the kernel
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License.  See the file "COPYING" in the main directory of this archive
+# for more details.
+#
+#
+
+obj-y	 := setup.o irq.o io.o

Please get rid of the Makefile comments.

#2 lore raw
In reply to Yoshihiro Shimoda
Quoted 3 lines · Yoshihiro Shimoda

Add support for Solution Engine SH7721 board(MS7721RP01).

[snip]

Quoted 87 lines

diff -uprN a/arch/sh/boards/se/7721/irq.c b/arch/sh/boards/se/7721/irq.c
--- a/arch/sh/boards/se/7721/irq.c 1970-01-01 09:00:00.000000000 +0900
+++ b/arch/sh/boards/se/7721/irq.c 2008-03-19 23:12:00.000000000 +0900
@@ -0,0 +1,86 @@
+/*
+ * linux/arch/sh/boards/se/7721/irq.c
+ *

 + * Copyright (C) 2000  Kazumoto Kojima
 + * Copyright (C) 2006  Nobuhiro Iwamatsu
 + * Copyright (C) 2008  Renesas Solutions Corp.
 + *
 + * Hitachi SolutionEngine Support.
 + *
 + */
 +
 +#include <linux/init.h>
 +#include <linux/interrupt.h>
 +#include <linux/irq.h>
 +#include <asm/irq.h>
 +#include <asm/io.h>
 +#include <asm/se.h>
 +
 +static struct ipr_data ipr_irq_table[] = {
 +       /*
 +       * Super I/O (Just mimic PC):
 +       *  1: keyboard
 +       *  3: serial 0
 +       *  4: serial 1
 +       *  5: printer
 +       *  6: floppy
 +       *  8: rtc
 +       * 12: mouse
 +       * 14: ide0
 +       */
 +       { 14, 0,  8, 0x0f - 14, },
 +       { 12, 0,  4, 0x0f - 12, },
 +       {  8, 1,  4, 0x0f -  8, },
 +       {  6, 2, 12, 0x0f -  6, },
 +       {  5, 2,  8, 0x0f -  5, },
 +       {  4, 2,  4, 0x0f -  4, },
 +       {  3, 2,  0, 0x0f -  3, },
 +       {  1, 3, 12, 0x0f -  1, },
 +       /* MRSHPC IRQs setting */
 +       {  0, 4, 12, 0x0f -  0, },      /* PCIRQ3 */
 +       { 11, 4,  8, 0x0f - 11, },      /* PCIRQ2 */
 +       {  9, 4,  4, 0x0f -  9, },      /* PCIRQ1 */
 +       {  7, 4,  0, 0x0f -  7, },      /* PCIRQ0 */
 +       /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
 +       /* NOTE: #2 and #13 are not used on PC */
 +       { 13, 6,  4, 0x0f - 13, },      /* SLOTIRQ2 */
 +       {  2, 6,  0, 0x0f -  2, },      /* SLOTIRQ1 */
 +};
 +
 +static unsigned long ipr_offsets[] = {
 +       BCR_ILCRA,
 +       BCR_ILCRB,
 +       BCR_ILCRC,
 +       BCR_ILCRD,
 +       BCR_ILCRE,
 +       BCR_ILCRF,
 +       BCR_ILCRG,
 +};
 +
 +static struct ipr_desc ipr_irq_desc = {
 +       .ipr_offsets    = ipr_offsets,
 +       .nr_offsets     = ARRAY_SIZE(ipr_offsets),
 +
 +       .ipr_data       = ipr_irq_table,
 +       .nr_irqs        = ARRAY_SIZE(ipr_irq_table),
 +       .chip = {
 +               .name   = "IPR-se7721",
 +       },
 +};
 +
 +/*
 + * Initialize IRQ setting
 + */
 +void __init init_se7721_IRQ(void)
 +{
 +       /* Disable all interrupts */
 +       ctrl_outw(0, BCR_ILCRA);
 +       ctrl_outw(0, BCR_ILCRB);
 +       ctrl_outw(0, BCR_ILCRC);
 +       ctrl_outw(0, BCR_ILCRD);
 +       ctrl_outw(0, BCR_ILCRE);
 +       ctrl_outw(0, BCR_ILCRF);
 +       ctrl_outw(0, BCR_ILCRG);
Quoted 3 lines

+
+ register_ipr_controller(&ipr_irq_desc);
+}

This looks like duplicated untested code.

How many of the IRQs above are actually used by device drivers? I can't see any platform devices that use these IRQ numbers. The IRQ code above is unfortunately using the legacy ipr controller. New code should use intc, have a look at the code in arch/sh/boards/renesas/rts7751r2d/irq.c.

Please consider converting the code to intc and/or removing unused/untested interrupts.

Thanks!

/ magnus