From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoshinori Sato Subject: H8/300 target support patch Date: Sun, 15 Feb 2004 15:05:18 +0900 Sender: linux-ide-owner@vger.kernel.org Message-ID: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Sun_Feb_15_15:05:18_2004-1" Content-Transfer-Encoding: 7bit Return-path: Received: from p063229.ppp.asahi-net.or.jp ([221.113.63.229]:7149 "EHLO mitou.ysato.dip.jp") by vger.kernel.org with ESMTP id S264137AbUBOGFU (ORCPT ); Sun, 15 Feb 2004 01:05:20 -0500 Received: from mitou.localdomain (mitou [127.0.0.1]) by mitou.ysato.dip.jp (Postfix) with ESMTP id 601101C1A8 for ; Sun, 15 Feb 2004 15:05:18 +0900 (JST) List-Id: linux-ide@vger.kernel.org To: linux-ide@vger.kernel.org --Multipart_Sun_Feb_15_15:05:18_2004-1 Content-Type: text/plain; charset=US-ASCII 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 --Multipart_Sun_Feb_15_15:05:18_2004-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="h8300-ide.diff" Content-Transfer-Encoding: 7bit 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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* 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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +/* 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) --Multipart_Sun_Feb_15_15:05:18_2004-1--