From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoshinori Sato Subject: Re: H8/300 target support patch Date: Fri, 27 Feb 2004 01:46:59 +0900 Sender: linux-ide-owner@vger.kernel.org Message-ID: References: <200402221808.06615.bzolnier@elka.pw.edu.pl> <200402221828.18830.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]:41709 "EHLO mitou.ysato.dip.jp") by vger.kernel.org with ESMTP id S262830AbUBZQrC (ORCPT ); Thu, 26 Feb 2004 11:47:02 -0500 In-Reply-To: <200402221828.18830.bzolnier@elka.pw.edu.pl> List-Id: linux-ide@vger.kernel.org To: Bartlomiej Zolnierkiewicz Cc: Benjamin Herrenschmidt , linux-ide@vger.kernel.org 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. Examination is necessary for a call method of h8300_hwif_iops. CONFIG_H8300_IDE_foo defines it with arch/h8300/Kconfig. diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/Makefile linux-2.6.3-h8300/drivers/ide/Makefile --- linux-2.6.3/drivers/ide/Makefile 2004-02-20 01:08:02.000000000 +0900 +++ linux-2.6.3-h8300/drivers/ide/Makefile 2004-02-20 17:42:40.000000000 +0900 @@ -46,5 +46,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/ diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/Makefile linux-2.6.3-h8300/drivers/ide/h8300/Makefile --- linux-2.6.3/drivers/ide/h8300/Makefile 1970-01-01 09:00:00.000000000 +0900 +++ linux-2.6.3-h8300/drivers/ide/h8300/Makefile 2004-02-23 00:58:43.000000000 +0900 @@ -0,0 +1,2 @@ +obj-$(CONFIG_H8300H_H8MAX) := h8300-iops.o +obj-$(CONFIG_H8300H_AKI3068NET) := h8300-iops.o diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/h8300-iops.c linux-2.6.3-h8300/drivers/ide/h8300/h8300-iops.c --- linux-2.6.3/drivers/ide/h8300/h8300-iops.c 1970-01-01 09:00:00.000000000 +0900 +++ linux-2.6.3-h8300/drivers/ide/h8300/h8300-iops.c 2004-02-27 01:08:20.000000000 +0900 @@ -0,0 +1,67 @@ +/* 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 h8300_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; +} diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/ide-iops.c linux-2.6.3-h8300/drivers/ide/ide-iops.c --- linux-2.6.3/drivers/ide/ide-iops.c 2004-02-20 01:08:02.000000000 +0900 +++ linux-2.6.3-h8300/drivers/ide/ide-iops.c 2004-02-27 01:09:21.000000000 +0900 @@ -31,6 +31,7 @@ * Conventional PIO operations for ATA devices */ +#if !defined(__H8300H__) && !defined(__H8300S__) /* not use H8/300 target */ static u8 ide_inb (unsigned long port) { return (u8) inb(port); @@ -88,9 +158,14 @@ { outsl(port, addr, count); } +#endif /* !defined(__H8300H__) && !defined(__H8300S__) */ void default_hwif_iops (ide_hwif_t *hwif) { +#if defined(__H8300H__) || defined(__H8300S__) + void h8300_hwif_iops (ide_hwif_t *hwif); + h8300_hwif_iops(hwif); +#else hwif->OUTB = ide_outb; hwif->OUTBSYNC = ide_outbsync; hwif->OUTW = ide_outw; @@ -102,6 +177,7 @@ hwif->INL = ide_inl; hwif->INSW = ide_insw; hwif->INSL = ide_insl; +#endif } EXPORT_SYMBOL(default_hwif_iops); diff -X .exclude-diff -Nru linux-2.6.3/include/asm-h8300/ide.h linux-2.6.3-h8300/include/asm-h8300/ide.h --- linux-2.6.3/include/asm-h8300/ide.h 2004-01-09 15:59:09.000000000 +0900 +++ linux-2.6.3-h8300/include/asm-h8300/ide.h 2004-02-27 01:10:27.000000000 +0900 @@ -16,20 +16,61 @@ #ifdef __KERNEL__ /****************************************************************************/ -void h8300_ide_print_resource(char *name, hw_regs_t *hw); -static inline int ide_default_irq(unsigned long base) { return 0; }; -static inline ide_ioreg_t ide_default_io_base(int index) { return 0; }; +#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 + +static __inline__ int ide_default_irq(unsigned long base) +{ + return (base == CONFIG_H8300_IDE_BASE)?(CONFIG_H8300_IDE_IRQ + 12):0; +}; + +static __inline__ unsigned long ide_default_io_base(int index) +{ + return (index == 0)?CONFIG_H8300_IDE_BASE:0UL; +}; static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, - unsigned long ctrl_port, int *irq) + unsigned long ctrl_port, int *irq) { + hw->io_ports[IDE_DATA_OFFSET] = data_port + IDE_DATA; + hw->io_ports[IDE_ERROR_OFFSET] = data_port + IDE_ERROR; + hw->io_ports[IDE_NSECTOR_OFFSET] = data_port + IDE_NSECTOR; + hw->io_ports[IDE_SECTOR_OFFSET] = data_port + IDE_SECTOR; + hw->io_ports[IDE_LCYL_OFFSET] = data_port + IDE_LCYL; + hw->io_ports[IDE_HCYL_OFFSET] = data_port + IDE_HCYL; + hw->io_ports[IDE_SELECT_OFFSET] = data_port + IDE_SELECT; + hw->io_ports[IDE_STATUS_OFFSET] = data_port + IDE_STATUS; } +#define AREABIT(addr) (1 << (((addr) >> 21) & 7)) -static inline void ide_init_default_hwifs(void) +static __inline__ void ide_init_default_hwifs(void) { + hw_regs_t hw; + +#if defined(CONFIG_H8300_AKI3068NET) + { + volatile unsigned char *abwcr = (volatile unsigned char *)ABWCR; + volatile unsigned char *cscr = (volatile unsigned char *)CSCR; + *abwcr &= ~(AREABIT(CONFIG_H8300_IDE_BASE) | AREABIT(CONFIG_H8300_IDE_ALT)); + *cscr |= (AREABIT(CONFIG_H8300_IDE_BASE) | AREABIT(CONFIG_H8300_IDE_ALT)) | 0x0f; + } +#endif + memset(&hw,0,sizeof(hw)); + + ide_init_hwif_ports(&hw, ide_default_io_base(0), 0, NULL); + hw.irq = ide_default_irq(ide_default_io_base(0)); + + ide_register_hw(&hw, NULL); } + #define MAX_HWIFS 1 -- Yoshinori Sato