All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yoshinori Sato <ysato@users.sourceforge.jp>
To: linux-ide@vger.kernel.org
Subject: H8/300 target support patch
Date: Sun, 15 Feb 2004 15:05:18 +0900	[thread overview]
Message-ID: <m2y8r4naht.wl%ysato@users.sourceforge.jp> (raw)

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]

Hello.
I develop H8/300 support of linux kernel.

I made a patch to use IDE driver with a H8/300 target.
I want to do merge to source if possible.

How will about it?

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>


[-- Attachment #2: h8300-ide.diff --]
[-- Type: application/octet-stream, Size: 9939 bytes --]

diff -Nru -x CVS -x '.*' -x '*.o' linux-2.6.2/drivers/ide/Makefile linux-2.6.2-h8300/drivers/ide/Makefile
--- linux-2.6.2/drivers/ide/Makefile		2004-02-15 08:20:48.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/Makefile	2004-02-13 15:59:05.000000000 +0900
@@ -30,5 +30,5 @@
 obj-$(CONFIG_PROC_FS)			+= ide-proc.o
 endif
 
-obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ ppc/ arm/
+obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ ppc/ arm/ h8300/
 obj-$(CONFIG_BLK_DEV_HD)		+= legacy/
diff -Nru linux-2.6.2/drivers/ide/h8300/Makefile linux-2.6.2-h8300/drivers/ide/h8300/Makefile
--- linux-2.6.2/drivers/ide/h8300/Makefile		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/h8300/Makefile	2004-02-13 16:27:26.000000000 +0900
@@ -0,0 +1,2 @@
+obj-$(CONFIG_H8300H_H8MAX) := h8max_ide.o
+obj-$(CONFIG_H8300H_AKI3068NET) := aki3068_ide.o
diff -Nru linux-2.6.2/drivers/ide/h8300/aki3068_ide.c linux-2.6.2-h8300/drivers/ide/h8300/aki3068_ide.c
--- linux-2.6.2/drivers/ide/h8300/aki3068_ide.c		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.2-h8300drivers/ide/h8300/aki3068_ide.c	2004-02-13 16:28:27.000000000 +0900
@@ -0,0 +1,139 @@
+/****************************************************************************/
+/*
+ *  linux/drivers/ide/h8300/aki3068_ide.c
+ *  AE-3068/AE-3069 IDE I/F support
+ *  reference schematic is http://www.linet.gr.jp/mituiwa/h8/h8osv3/hddprog/hdd.png
+ *
+ *  Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ *  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.
+ *
+ */
+/****************************************************************************/
+
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <asm/irq.h>
+#include <asm/regs306x.h>
+
+/* IDE I/F configuration */
+#define IDE_BASE CONFIG_H8300_IDE_BASE
+#define IDE_CTRL CONFIG_H8300_IDE_ALT
+#define IDE_IRQ  (EXT_IRQ0 + CONFIG_H8300_IDE_IRQNO)
+
+#define IDE_DATA	0x00
+#define IDE_ERROR	0x02
+#define IDE_NSECTOR	0x04
+#define IDE_SECTOR	0x06
+#define IDE_LCYL	0x08
+#define IDE_HCYL	0x0A
+#define IDE_SELECT	0x0C
+#define IDE_STATUS	0x0E
+
+const static int offsets[IDE_NR_PORTS] = {
+    IDE_DATA, IDE_ERROR,  IDE_NSECTOR, IDE_SECTOR, IDE_LCYL,
+    IDE_HCYL, IDE_SELECT, IDE_STATUS,          -1,       -1
+};
+
+static void _outb(u8 d, unsigned long a)
+{
+	*(unsigned short *)a = (d & 0xff);
+}
+
+static void _outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	*(unsigned short *)a = (d & 0xff);
+}
+
+static u8 _inb(unsigned long a)
+{
+	return *(unsigned short *)a;
+}
+
+static void _outw(u16 d, unsigned long a)
+{
+	*(unsigned short *)a = (d << 8) | (d >> 8);
+}
+
+static u16 _inw(unsigned long a)
+{
+	unsigned short d;
+	d = *(unsigned short *)a;
+	return (d << 8) | (d >> 8);
+}
+
+static void _outl(u32 d, unsigned long a)
+{
+}
+
+static u32 _inl(unsigned long a)
+{
+	return 0xffffffffUL;
+}
+
+static void _outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *bp++;
+		*ap = (d << 8) | (d >> 8);
+	}
+}
+
+static void _insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *ap;
+		*bp++ = (d << 8) | (d >> 8);
+	}
+}
+
+void __init h8300_ide_init(void)
+{
+	hw_regs_t hw;
+	ide_hwif_t *hwif;
+	volatile unsigned char *abwcr = (volatile unsigned char *)ABWCR;
+	volatile unsigned char *cscr = (volatile unsigned char *)CSCR;
+	*abwcr &= ~((1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)));
+	*cscr  |= (1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)) | 0x0f;
+	memset(&hw,0,sizeof(hw));
+	ide_setup_ports(&hw, IDE_BASE, (int *)offsets,
+                             IDE_CTRL, 0, NULL,IDE_IRQ);
+	if (ide_register_hw(&hw, &hwif) != -1) {
+		hwif->mmio  = 0;
+		hwif->OUTB  = _outb;
+		hwif->OUTBSYNC = _outbsync;
+		hwif->OUTW  = _outw;
+		hwif->OUTL  = _outl;
+		hwif->OUTSW = _outsw;
+		hwif->OUTSL = NULL;
+		hwif->INB   = _inb;
+		hwif->INW   = _inw;
+		hwif->INL   = _inl;
+		hwif->INSW  = _insw;
+		hwif->INSL  = NULL;
+	}
+}
+
+void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
+{
+	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
+		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
+		hw->irq);
+}
diff -Nru linux-2.6.2/drivers/ide/h8300/h8max_ide.c linux-2.6.2-h8300/drivers/ide/h8300/h8max_ide.c
--- linux-2.6.2/drivers/ide/h8300/h8max_ide.c		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/h8300/h8max_ide.c	2004-02-13 16:28:14.000000000 +0900
@@ -0,0 +1,134 @@
+/****************************************************************************/
+/*
+ *  linux/drivers/ide/h8300/h8max_ide.c
+ *  H8MAX IDE Interface support
+ *
+ *  Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ *  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.
+ *
+ */
+/****************************************************************************/
+
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <asm/irq.h>
+
+/* IDE I/F configuration */
+#define IDE_BASE 0x200000
+#define IDE_CTRL 0x60000c
+#define IDE_IRQ  EXT_IRQ5
+
+#define IDE_DATA	0x00
+#define IDE_ERROR	0x02
+#define IDE_NSECTOR	0x04
+#define IDE_SECTOR	0x06
+#define IDE_LCYL	0x08
+#define IDE_HCYL	0x0A
+#define IDE_SELECT	0x0C
+#define IDE_STATUS	0x0E
+
+const static int offsets[IDE_NR_PORTS] = {
+    IDE_DATA, IDE_ERROR,  IDE_NSECTOR, IDE_SECTOR, IDE_LCYL,
+    IDE_HCYL, IDE_SELECT, IDE_STATUS,          -1,       -1
+};
+
+static void h8max_outb(u8 d, unsigned long a)
+{
+	*(unsigned short *)a = (d & 0xff);
+}
+
+static void h8max_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	*(unsigned short *)a = (d & 0xff);
+}
+
+static u8 h8max_inb(unsigned long a)
+{
+	return (*(unsigned short *)a) & 0xff;
+}
+
+static void h8max_outw(u16 d, unsigned long a)
+{
+	*(unsigned short *)a = ((d << 8) & 0xff00) | ((d >> 8) & 0x00ff);
+}
+
+static u16 h8max_inw(unsigned long a)
+{
+	unsigned short d;
+	d = *(unsigned short *)a;
+	return ((d << 8) & 0xff00) | ((d >> 8) & 0x00ff);
+}
+
+static void h8max_outl(u32 d, unsigned long a)
+{
+}
+
+static u32 h8max_inl(unsigned long a)
+{
+	return 0xffffffffUL;
+}
+
+static void h8max_outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *bp++;
+		*ap = (d >> 8) | (d << 8);
+	}
+}
+
+static void h8max_insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *ap;
+		*bp++ = (d >> 8) | (d << 8);
+	}
+}
+
+void __init h8300_ide_init(void)
+{
+	hw_regs_t hw;
+	ide_hwif_t *hwif;
+
+	memset(&hw,0,sizeof(hw));
+	ide_setup_ports(&hw, IDE_BASE, (int *)offsets,
+                             IDE_CTRL, 0, NULL,IDE_IRQ);
+	if (ide_register_hw(&hw, &hwif) != -1) {
+		hwif->mmio  = 0;
+		hwif->OUTB  = h8max_outb;
+		hwif->OUTBSYNC = h8max_outbsync;
+		hwif->OUTW  = h8max_outw;
+		hwif->OUTL  = h8max_outl;
+		hwif->OUTSW = h8max_outsw;
+		hwif->OUTSL = NULL;
+		hwif->INB   = h8max_inb;
+		hwif->INW   = h8max_inw;
+		hwif->INL   = h8max_inl;
+		hwif->INSW  = h8max_insw;
+		hwif->INSL  = NULL;
+	}
+}
+
+void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
+{
+	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
+		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
+		hw->irq);
+}
diff -Nru linux-2.6.2/drivers/ide/ide-probe.c linux-2.6.2-h8300/drivers/ide/ide-probe.c
--- linux-2.6.2/drivers/ide/ide-probe.c		2004-02-15 08:20:53.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/ide-probe.c	2004-02-13 15:58:15.000000000 +0900
@@ -1102,7 +1102,8 @@
 		spin_unlock_irq(&ide_lock);
 	}
 
-#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
+#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__) && \
+    !defined(__H8300H__) && !defined(__H8300S__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET],
 		hwif->io_ports[IDE_DATA_OFFSET]+7,
@@ -1112,6 +1113,8 @@
 		hwif->io_ports[IDE_DATA_OFFSET],
 		hwif->io_ports[IDE_DATA_OFFSET]+7,
 		hwif->io_ports[IDE_CONTROL_OFFSET], __irq_itoa(hwif->irq));
+#elif defined(__H8300H__) || defined(__H8300S__)
+	h8300_ide_print_resource(hwif->name,&(hwif->hw));
 #else
 	printk("%s at 0x%08lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET], hwif->irq);
diff -Nru linux-2.6.2/drivers/ide/ide.c linux-2.6.2-h8300/drivers/ide/ide.c
--- linux-2.6.2/drivers/ide/ide.c	2004-02-15 08:20:58.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/ide.c	2004-02-13 15:55:51.000000000 +0900
@@ -2274,6 +2274,12 @@
 		pnpide_init(1);
 	}
 #endif /* CONFIG_BLK_DEV_IDEPNP */
+#if defined(__H8300H__) || defined(__H8300S__)
+        {
+		extern void h8300_ide_init(void);
+		h8300_ide_init();
+	}
+#endif /* defined(__H8300H__) || defined(__H8300S__) */
 }
 
 void __init ide_init_builtin_drivers (void)

             reply	other threads:[~2004-02-15  6:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-15  6:05 Yoshinori Sato [this message]
2004-02-15 14:40 ` H8/300 target support patch Bartlomiej Zolnierkiewicz
2004-02-16 16:09   ` Yoshinori Sato
2004-02-16 16:40     ` Bartlomiej Zolnierkiewicz
2004-02-16 22:07       ` Benjamin Herrenschmidt
2004-02-16 22:09     ` Benjamin Herrenschmidt
2004-02-17 11:33       ` Yoshinori Sato
2004-02-17 12:55         ` Benjamin Herrenschmidt
2004-02-19 16:12           ` Yoshinori Sato
2004-02-19 16:34             ` Bartlomiej Zolnierkiewicz
2004-02-20 12:28               ` Yoshinori Sato
2004-02-20 15:25                 ` Bartlomiej Zolnierkiewicz
2004-02-20 17:58                   ` Yoshinori Sato
2004-02-20 18:42                     ` Bartlomiej Zolnierkiewicz
2004-02-22 16:30                       ` Yoshinori Sato
2004-02-22 17:08                         ` Bartlomiej Zolnierkiewicz
2004-02-22 17:28                           ` Bartlomiej Zolnierkiewicz
2004-02-26 16:46                             ` Yoshinori Sato
2004-02-26 19:26                               ` Bartlomiej Zolnierkiewicz
2004-02-28 17:02                                 ` Yoshinori Sato
2004-02-28 17:55                                   ` Bartlomiej Zolnierkiewicz

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=m2y8r4naht.wl%ysato@users.sourceforge.jp \
    --to=ysato@users.sourceforge.jp \
    --cc=linux-ide@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.