From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoshinori Sato Subject: Re: H8/300 target support patch Date: Sun, 29 Feb 2004 02:02:14 +0900 Sender: linux-ide-owner@vger.kernel.org Message-ID: References: <200402221828.18830.bzolnier@elka.pw.edu.pl> <200402262026.51202.bzolnier@elka.pw.edu.pl> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from p062096.ppp.asahi-net.or.jp ([221.113.62.96]:2286 "EHLO mitou.ysato.dip.jp") by vger.kernel.org with ESMTP id S261873AbUB1RCU (ORCPT ); Sat, 28 Feb 2004 12:02:20 -0500 In-Reply-To: <200402262026.51202.bzolnier@elka.pw.edu.pl> List-Id: linux-ide@vger.kernel.org To: Bartlomiej Zolnierkiewicz Cc: Benjamin Herrenschmidt , linux-ide@vger.kernel.org At Thu, 26 Feb 2004 20:26:51 +0100, Bartlomiej Zolnierkiewicz wrote: > > On Thursday 26 of February 2004 17:46, Yoshinori Sato wrote: > > At Sun, 22 Feb 2004 18:28:18 +0100, > > > > Bartlomiej Zolnierkiewicz wrote: > > > On Sunday 22 of February 2004 18:08, Bartlomiej Zolnierkiewicz wrote: > > > > > I corrected it to initialize it with ide_init_default_hwifs. > > > > > A correction of ide.c becomes needless. > > > > > > > > NO!!! ide_init_default_hwifs() should DIE! > > > > The same goes for ide_default_{irq,io_base}(). > > > > > > > > They are not needed - you have driver(s) for H8/300 IDE controllers! > > > > > > It should be like that: > > > > > > You should have host drivers for your IDE controllers, > > > not inline functions for ide.c and ide-probe.c. > > > > I tuned to a driver of PC/AT wherever practicable. > > Just because original/legacy PC/AT driver is braindamaged (and dated) > doesn't mean your code should be, does it? Hiding driver's code into > asm/ide.h causes MAJOR problems for IDE code reorganization. > > > Examination is necessary for a call method of h8300_hwif_iops. > > All ide-iops.c #ifdef-s won't be needed if you separate you driver > properly from asm/ide.h (thus overriding default_hwif_iops() ops > by ones used by your driver). > > Please revert to putting your code into ide/h8300/. > I did overriding of default_hwif_iops in form to replace obj because it was not possible well. It is difference m with linux-2.6.4-rc1. Do not change asm/ide.h. Index: drivers/ide/Makefile =================================================================== RCS file: /var/lib/cvs/linux-2.6/drivers/ide/Makefile,v retrieving revision 1.1.1.7 diff -u -r1.1.1.7 Makefile --- a/drivers/ide/Makefile 19 Feb 2004 16:10:32 -0000 1.1.1.7 +++ b/drivers/ide/Makefile 28 Feb 2004 15:20:10 -0000 @@ -16,6 +16,10 @@ ide-core-y += ide.o ide-default.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ ide-taskfile.o +ifndef CONFIG_H8300 +ide-core-y += ide-lowio.o +endif + ide-core-$(CONFIG_BLK_DEV_CMD640) += pci/cmd640.o # Core IDE code - must come before legacy @@ -46,5 +50,5 @@ obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o -obj-$(CONFIG_BLK_DEV_IDE) += legacy/ arm/ +obj-$(CONFIG_BLK_DEV_IDE) += legacy/ arm/ h8300/ obj-$(CONFIG_BLK_DEV_HD) += legacy/ Index: drivers/ide/ide-iops.c =================================================================== RCS file: /var/lib/cvs/linux-2.6/drivers/ide/ide-iops.c,v retrieving revision 1.1.1.3 diff -u -r1.1.1.3 ide-iops.c --- a/drivers/ide/ide-iops.c 19 Feb 2004 16:10:32 -0000 1.1.1.3 +++ b/drivers/ide/ide-iops.c 28 Feb 2004 15:19:35 -0000 @@ -30,160 +30,6 @@ #include #include -/* - * Conventional PIO operations for ATA devices - */ - -static u8 ide_inb (unsigned long port) -{ - return (u8) inb(port); -} - -static u16 ide_inw (unsigned long port) -{ - return (u16) inw(port); -} - -static void ide_insw (unsigned long port, void *addr, u32 count) -{ - return insw(port, addr, count); -} - -static u32 ide_inl (unsigned long port) -{ - return (u32) inl(port); -} - -static void ide_insl (unsigned long port, void *addr, u32 count) -{ - insl(port, addr, count); -} - -static void ide_outb (u8 val, unsigned long port) -{ - outb(val, port); -} - -static void ide_outbsync (ide_drive_t *drive, u8 addr, unsigned long port) -{ - outb(addr, port); -} - -static void ide_outw (u16 val, unsigned long port) -{ - outw(val, port); -} - -static void ide_outsw (unsigned long port, void *addr, u32 count) -{ - outsw(port, addr, count); -} - -static void ide_outl (u32 val, unsigned long port) -{ - outl(val, port); -} - -static void ide_outsl (unsigned long port, void *addr, u32 count) -{ - outsl(port, addr, count); -} - -void default_hwif_iops (ide_hwif_t *hwif) -{ - hwif->OUTB = ide_outb; - hwif->OUTBSYNC = ide_outbsync; - hwif->OUTW = ide_outw; - hwif->OUTL = ide_outl; - hwif->OUTSW = ide_outsw; - hwif->OUTSL = ide_outsl; - hwif->INB = ide_inb; - hwif->INW = ide_inw; - hwif->INL = ide_inl; - hwif->INSW = ide_insw; - hwif->INSL = ide_insl; -} - -EXPORT_SYMBOL(default_hwif_iops); - -/* - * MMIO operations, typically used for SATA controllers - */ - -static u8 ide_mm_inb (unsigned long port) -{ - return (u8) readb(port); -} - -static u16 ide_mm_inw (unsigned long port) -{ - return (u16) readw(port); -} - -static void ide_mm_insw (unsigned long port, void *addr, u32 count) -{ - __ide_mm_insw(port, addr, count); -} - -static u32 ide_mm_inl (unsigned long port) -{ - return (u32) readl(port); -} - -static void ide_mm_insl (unsigned long port, void *addr, u32 count) -{ - __ide_mm_insl(port, addr, count); -} - -static void ide_mm_outb (u8 value, unsigned long port) -{ - writeb(value, port); -} - -static void ide_mm_outbsync (ide_drive_t *drive, u8 value, unsigned long port) -{ - writeb(value, port); -} - -static void ide_mm_outw (u16 value, unsigned long port) -{ - writew(value, port); -} - -static void ide_mm_outsw (unsigned long port, void *addr, u32 count) -{ - __ide_mm_outsw(port, addr, count); -} - -static void ide_mm_outl (u32 value, unsigned long port) -{ - writel(value, port); -} - -static void ide_mm_outsl (unsigned long port, void *addr, u32 count) -{ - __ide_mm_outsl(port, addr, count); -} - -void default_hwif_mmiops (ide_hwif_t *hwif) -{ - hwif->OUTB = ide_mm_outb; - /* Most systems will need to override OUTBSYNC, alas however - this one is controller specific! */ - hwif->OUTBSYNC = ide_mm_outbsync; - hwif->OUTW = ide_mm_outw; - hwif->OUTL = ide_mm_outl; - hwif->OUTSW = ide_mm_outsw; - hwif->OUTSL = ide_mm_outsl; - hwif->INB = ide_mm_inb; - hwif->INW = ide_mm_inw; - hwif->INL = ide_mm_inl; - hwif->INSW = ide_mm_insw; - hwif->INSL = ide_mm_insl; -} - -EXPORT_SYMBOL(default_hwif_mmiops); - void default_hwif_transport (ide_hwif_t *hwif) { hwif->ata_input_data = ata_input_data; Index: drivers/ide/ide-lowio.c =================================================================== RCS file: drivers/ide/ide-lowio.c diff -N drivers/ide/ide-lowio.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/drivers/ide/ide-lowio.c 28 Feb 2004 14:24:27 -0000 @@ -0,0 +1,231 @@ +/* + * linux/drivers/ide/ide-lowio.c + * + * IDE I/F Lowlevel I/O functions + */ + +#include +#include + +/* + * IDE operator we assign to an unplugged device so that + * we don't trash new hardware assigned the same resources + */ + +static u8 ide_unplugged_inb (unsigned long port) +{ + return 0xFF; +} + +static u16 ide_unplugged_inw (unsigned long port) +{ + return 0xFFFF; +} + +static void ide_unplugged_insw (unsigned long port, void *addr, u32 count) +{ +} + +static u32 ide_unplugged_inl (unsigned long port) +{ + return 0xFFFFFFFF; +} + +static void ide_unplugged_insl (unsigned long port, void *addr, u32 count) +{ +} + +static void ide_unplugged_outb (u8 val, unsigned long port) +{ +} + +static void ide_unplugged_outbsync (ide_drive_t *drive, u8 addr, unsigned long port) +{ +} + +static void ide_unplugged_outw (u16 val, unsigned long port) +{ +} + +static void ide_unplugged_outsw (unsigned long port, void *addr, u32 count) +{ +} + +static void ide_unplugged_outl (u32 val, unsigned long port) +{ +} + +static void ide_unplugged_outsl (unsigned long port, void *addr, u32 count) +{ +} + +void unplugged_hwif_iops (ide_hwif_t *hwif) +{ + hwif->OUTB = ide_unplugged_outb; + hwif->OUTBSYNC = ide_unplugged_outbsync; + hwif->OUTW = ide_unplugged_outw; + hwif->OUTL = ide_unplugged_outl; + hwif->OUTSW = ide_unplugged_outsw; + hwif->OUTSL = ide_unplugged_outsl; + hwif->INB = ide_unplugged_inb; + hwif->INW = ide_unplugged_inw; + hwif->INL = ide_unplugged_inl; + hwif->INSW = ide_unplugged_insw; + hwif->INSL = ide_unplugged_insl; +} + +EXPORT_SYMBOL(unplugged_hwif_iops); + +/* + * Conventional PIO operations for ATA devices + */ + +static u8 ide_inb (unsigned long port) +{ + return (u8) inb(port); +} + +static u16 ide_inw (unsigned long port) +{ + return (u16) inw(port); +} + +static void ide_insw (unsigned long port, void *addr, u32 count) +{ + return insw(port, addr, count); +} + +static u32 ide_inl (unsigned long port) +{ + return (u32) inl(port); +} + +static void ide_insl (unsigned long port, void *addr, u32 count) +{ + insl(port, addr, count); +} + +static void ide_outb (u8 val, unsigned long port) +{ + outb(val, port); +} + +static void ide_outbsync (ide_drive_t *drive, u8 addr, unsigned long port) +{ + outb(addr, port); +} + +static void ide_outw (u16 val, unsigned long port) +{ + outw(val, port); +} + +static void ide_outsw (unsigned long port, void *addr, u32 count) +{ + outsw(port, addr, count); +} + +static void ide_outl (u32 val, unsigned long port) +{ + outl(val, port); +} + +static void ide_outsl (unsigned long port, void *addr, u32 count) +{ + outsl(port, addr, count); +} + +void default_hwif_iops (ide_hwif_t *hwif) +{ + hwif->OUTB = ide_outb; + hwif->OUTBSYNC = ide_outbsync; + hwif->OUTW = ide_outw; + hwif->OUTL = ide_outl; + hwif->OUTSW = ide_outsw; + hwif->OUTSL = ide_outsl; + hwif->INB = ide_inb; + hwif->INW = ide_inw; + hwif->INL = ide_inl; + hwif->INSW = ide_insw; + hwif->INSL = ide_insl; +} + +EXPORT_SYMBOL(default_hwif_iops); + +/* + * MMIO operations, typically used for SATA controllers + */ + +static u8 ide_mm_inb (unsigned long port) +{ + return (u8) readb(port); +} + +static u16 ide_mm_inw (unsigned long port) +{ + return (u16) readw(port); +} + +static void ide_mm_insw (unsigned long port, void *addr, u32 count) +{ + __ide_mm_insw(port, addr, count); +} + +static u32 ide_mm_inl (unsigned long port) +{ + return (u32) readl(port); +} + +static void ide_mm_insl (unsigned long port, void *addr, u32 count) +{ + __ide_mm_insl(port, addr, count); +} + +static void ide_mm_outb (u8 value, unsigned long port) +{ + writeb(value, port); +} + +static void ide_mm_outbsync (ide_drive_t *drive, u8 value, unsigned long port) +{ + writeb(value, port); +} + +static void ide_mm_outw (u16 value, unsigned long port) +{ + writew(value, port); +} + +static void ide_mm_outsw (unsigned long port, void *addr, u32 count) +{ + __ide_mm_outsw(port, addr, count); +} + +static void ide_mm_outl (u32 value, unsigned long port) +{ + writel(value, port); +} + +static void ide_mm_outsl (unsigned long port, void *addr, u32 count) +{ + __ide_mm_outsl(port, addr, count); +} + +void default_hwif_mmiops (ide_hwif_t *hwif) +{ + hwif->OUTB = ide_mm_outb; + /* Most systems will need to override OUTBSYNC, alas however + this one is controller specific! */ + hwif->OUTBSYNC = ide_mm_outbsync; + hwif->OUTW = ide_mm_outw; + hwif->OUTL = ide_mm_outl; + hwif->OUTSW = ide_mm_outsw; + hwif->OUTSL = ide_mm_outsl; + hwif->INB = ide_mm_inb; + hwif->INW = ide_mm_inw; + hwif->INL = ide_mm_inl; + hwif->INSW = ide_mm_insw; + hwif->INSL = ide_mm_insl; +} + +EXPORT_SYMBOL(default_hwif_mmiops); Index: drivers/ide/ide-probe.c =================================================================== RCS file: /var/lib/cvs/linux-2.6/drivers/ide/ide-probe.c,v retrieving revision 1.1.1.8 retrieving revision 1.6 diff -u -r1.1.1.8 -r1.6 --- a/drivers/ide/ide-probe.c 28 Feb 2004 12:51:56 -0000 1.1.1.8 +++ b/drivers/ide/ide-probe.c 28 Feb 2004 13:59:04 -0000 1.6 @@ -978,7 +978,7 @@ unsigned int index; ide_hwgroup_t *hwgroup; ide_hwif_t *match = NULL; - + int ide_regs_gap; BUG_ON(in_interrupt()); BUG_ON(irqs_disabled()); @@ -1097,10 +1097,11 @@ spin_unlock_irq(&ide_lock); } + ide_regs_gap = hwif->io_ports[IDE_ERROR_OFFSET] - hwif->io_ports[IDE_DATA_OFFSET]; #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__) 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, + hwif->io_ports[IDE_DATA_OFFSET] + ide_regs_gap * 8 - 1, hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq); #elif defined(__sparc__) printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %s", hwif->name, Index: drivers/ide/h8300/Makefile =================================================================== RCS file: drivers/ide/h8300/Makefile diff -N drivers/ide/h8300/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/drivers/ide/h8300/Makefile 28 Feb 2004 13:59:04 -0000 1.2 @@ -0,0 +1,2 @@ +obj-$(CONFIG_H8300H_H8MAX) := h8300-lowio.o +obj-$(CONFIG_H8300H_AKI3068NET) := h8300-lowio.o Index: drivers/ide/h8300/h8300-lowio.c =================================================================== RCS file: drivers/ide/h8300/h8300-lowio.c diff -N drivers/ide/h8300/h8300-lowio.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/drivers/ide/h8300/h8300-lowio.c 28 Feb 2004 14:32:02 -0000 @@ -0,0 +1,79 @@ +/* H8/300 IDE I/F I/O operations */ + +/* + support target + + AE-3068/AE-3069 + IDE Expand + H8MAX +*/ + +#include +#include +#include +#include + +static void __ide_outb(u8 d, unsigned long a) +{ + outb(d,a); +} + +static void __ide_outbsync(ide_drive_t *drive, u8 d, unsigned long a) +{ + outb(d,a); +} + +static u8 __ide_inb(unsigned long a) +{ + return inb(a); +} + +static void __ide_outw(u16 d, unsigned long a) +{ + return outw(d,a); +} + +static u16 __ide_inw(unsigned long a) +{ + return inw(a); +} + +static void __ide_outsw(unsigned long addr, void *buf, u32 len) +{ + unsigned short *bp = (unsigned short *)buf; + while(len--) + outw(*bp++,addr); +} + +static void __ide_insw(unsigned long addr, void *buf, u32 len) +{ + unsigned short *bp = (unsigned short *)buf; + while(len--) + *bp++ = inw(addr); +} + +void default_hwif_iops(ide_hwif_t *hwif) +{ + hwif->OUTB = __ide_outb; + hwif->OUTBSYNC = __ide_outbsync; + hwif->OUTW = __ide_outw; + hwif->OUTL = NULL; + hwif->OUTSW = __ide_outsw; + hwif->OUTSL = NULL; + hwif->INB = __ide_inb; + hwif->INW = __ide_inw; + hwif->INL = NULL; + hwif->INSW = __ide_insw; + hwif->INSL = NULL; +} + +void unplugged_hwif_iops (ide_hwif_t *hwif) +{ +} + +void default_hwif_mmiops (ide_hwif_t *hwif) +{ +} + +EXPORT_SYMBOL(default_hwif_iops); +EXPORT_SYMBOL(unplugged_hwif_iops); +EXPORT_SYMBOL(default_hwif_mmiops); -- Yoshiori Sato