From 38fc4e8bc0fc6328e79c81fcc397b491fdb163eb Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Mon, 19 Apr 2004 02:31:45 -0700 Subject: [PATCH] [PATCH] generic ide_init_hwif_ports() Add generic ide_init_hwif_ports() to and remove arch specific versions except arm26, arm, h8300, i386-pc9800, m68k and m68knommu ones. --- include/asm-alpha/ide.h | 20 -------------- include/asm-i386/ide.h | 11 +++----- include/asm-ia64/ide.h | 20 -------------- include/asm-mips/mach-generic/ide.h | 20 -------------- include/asm-parisc/ide.h | 20 -------------- include/asm-ppc/ide.h | 27 ------------------- include/asm-ppc64/ide.h | 20 -------------- include/asm-sh/ide.h | 20 -------------- include/asm-sparc/ide.h | 23 ---------------- include/asm-sparc64/ide.h | 19 ------------- include/asm-x86_64/ide.h | 20 -------------- include/linux/ide.h | 41 +++++++++++++++++++++++++++++ 12 files changed, 44 insertions(+), 217 deletions(-) diff --git a/include/asm-alpha/ide.h b/include/asm-alpha/ide.h index dd04280d33a7..9444b3d6dccc 100644 --- a/include/asm-alpha/ide.h +++ b/include/asm-alpha/ide.h @@ -43,26 +43,6 @@ static inline unsigned long ide_default_io_base(int index) } } -static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, - unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hw->io_ports[i] = reg; - reg += 1; - } - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; -} - #ifdef CONFIG_PCI #define ide_init_default_irq(base) (0) #else diff --git a/include/asm-i386/ide.h b/include/asm-i386/ide.h index d4fb98cb894c..e241be6d6e40 100644 --- a/include/asm-i386/ide.h +++ b/include/asm-i386/ide.h @@ -59,29 +59,23 @@ static __inline__ unsigned long ide_default_io_base(int index) } } +#ifdef CONFIG_X86_PC9800 static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, unsigned long ctrl_port, int *irq) { unsigned long reg = data_port; int i; -#ifdef CONFIG_X86_PC9800 + unsigned long increment = data_port == 0x640 ? 2 : 1; -#endif for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { hw->io_ports[i] = reg; -#ifdef CONFIG_X86_PC9800 reg += increment; -#else - reg += 1; -#endif } if (ctrl_port) { hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; -#ifdef CONFIG_X86_PC9800 } else if (data_port == 0x640) { hw->io_ports[IDE_CONTROL_OFFSET] = 0x74c; -#endif } else { hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; } @@ -89,6 +83,7 @@ static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_por *irq = 0; hw->io_ports[IDE_IRQ_OFFSET] = 0; } +#endif #ifdef CONFIG_BLK_DEV_IDEPCI #define ide_init_default_irq(base) (0) diff --git a/include/asm-ia64/ide.h b/include/asm-ia64/ide.h index b8ed7fccfbdf..778d69ec67a2 100644 --- a/include/asm-ia64/ide.h +++ b/include/asm-ia64/ide.h @@ -53,26 +53,6 @@ static inline unsigned long ide_default_io_base(int index) } } -static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, - unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hw->io_ports[i] = reg; - reg += 1; - } - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; -} - #ifdef CONFIG_PCI #define ide_init_default_irq(base) (0) #else diff --git a/include/asm-mips/mach-generic/ide.h b/include/asm-mips/mach-generic/ide.h index 91c7a93cfa85..a4618ca9fa81 100644 --- a/include/asm-mips/mach-generic/ide.h +++ b/include/asm-mips/mach-generic/ide.h @@ -48,26 +48,6 @@ static inline unsigned long ide_default_io_base(int index) } } -static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, - unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hw->io_ports[i] = reg; - reg += 1; - } - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; -} - #ifdef CONFIG_BLK_DEV_IDEPCI #define ide_init_default_irq(base) (0) #else diff --git a/include/asm-parisc/ide.h b/include/asm-parisc/ide.h index f3b12b6fabef..61c3792177b3 100644 --- a/include/asm-parisc/ide.h +++ b/include/asm-parisc/ide.h @@ -22,26 +22,6 @@ #define ide_default_irq(base) (0) #define ide_default_io_base(index) (0) -static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, - unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hw->io_ports[i] = reg; - reg += 1; - } - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; -} - #define ide_init_default_irq(base) (0) #define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id)) diff --git a/include/asm-ppc/ide.h b/include/asm-ppc/ide.h index 0464fdaf07e1..1393d51c3e3e 100644 --- a/include/asm-ppc/ide.h +++ b/include/asm-ppc/ide.h @@ -57,33 +57,6 @@ static __inline__ unsigned long ide_default_io_base(int index) return 0; } -/* - * This is only used for PC-style IDE controllers (e.g. as on PReP) - * or for PCI IDE devices, not for other types of IDE interface such - * as the pmac IDE interfaces. - */ -static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, - unsigned long data_port, - unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) - hw->io_ports[i] = reg++; - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = - hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; - if (ppc_ide_md.ide_init_hwif != NULL) - ppc_ide_md.ide_init_hwif(hw, data_port, ctrl_port, irq); -} - #ifdef CONFIG_PCI #define ide_init_default_irq(base) (0) #else diff --git a/include/asm-ppc64/ide.h b/include/asm-ppc64/ide.h index c1abb05c1c5c..88d3645e5d26 100644 --- a/include/asm-ppc64/ide.h +++ b/include/asm-ppc64/ide.h @@ -25,26 +25,6 @@ static inline int ide_default_irq(unsigned long base) { return 0; } static inline unsigned long ide_default_io_base(int index) { return 0; } -static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, - unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hw->io_ports[i] = reg; - reg += 1; - } - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; -} - #define ide_init_default_irq(base) (0) #endif /* __KERNEL__ */ diff --git a/include/asm-sh/ide.h b/include/asm-sh/ide.h index 35db4da08bb1..4aa1568d2fc3 100644 --- a/include/asm-sh/ide.h +++ b/include/asm-sh/ide.h @@ -72,26 +72,6 @@ static inline unsigned long ide_default_io_base(int index) } } -static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, - unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hw->io_ports[i] = reg; - reg += 1; - } - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; -} - #ifdef CONFIG_PCI #define ide_init_default_irq(base) (0) #else diff --git a/include/asm-sparc/ide.h b/include/asm-sparc/ide.h index 956b021d21a1..1f4397221b14 100644 --- a/include/asm-sparc/ide.h +++ b/include/asm-sparc/ide.h @@ -29,29 +29,6 @@ static __inline__ unsigned long ide_default_io_base(int index) return 0; } -/* - * Doing any sort of ioremap() here does not work - * because this function may be called with null aguments. - */ -static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hw->io_ports[i] = reg; - reg += 1; - } - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; -} - #define ide_init_default_irq(base) (0) #define __ide_insl(data_reg, buffer, wcount) \ diff --git a/include/asm-sparc64/ide.h b/include/asm-sparc64/ide.h index 180cc806fa88..9ce42e117719 100644 --- a/include/asm-sparc64/ide.h +++ b/include/asm-sparc64/ide.h @@ -34,25 +34,6 @@ static __inline__ unsigned long ide_default_io_base(int index) return 0; } -static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hw->io_ports[i] = reg; - reg += 1; - } - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; -} - #define ide_init_default_irq(base) (0) #define __ide_insl(data_reg, buffer, wcount) \ diff --git a/include/asm-x86_64/ide.h b/include/asm-x86_64/ide.h index 283d4f6d04f0..870bf0e782d3 100644 --- a/include/asm-x86_64/ide.h +++ b/include/asm-x86_64/ide.h @@ -51,26 +51,6 @@ static __inline__ unsigned long ide_default_io_base(int index) } } -static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, - unsigned long ctrl_port, int *irq) -{ - unsigned long reg = data_port; - int i; - - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hw->io_ports[i] = reg; - reg += 1; - } - if (ctrl_port) { - hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; - } else { - hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; - } - if (irq != NULL) - *irq = 0; - hw->io_ports[IDE_IRQ_OFFSET] = 0; -} - #ifdef CONFIG_BLK_DEV_IDEPCI #define ide_init_default_irq(base) (0) #else diff --git a/include/linux/ide.h b/include/linux/ide.h index 5da715ef383b..abfe784b24cc 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -293,8 +293,49 @@ void ide_setup_ports( hw_regs_t *hw, #endif int irq); +static inline void ide_std_init_ports(hw_regs_t *hw, + unsigned long io_addr, + unsigned long ctl_addr) +{ + unsigned int i; + + for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) + hw->io_ports[i] = io_addr++; + + hw->io_ports[IDE_CONTROL_OFFSET] = ctl_addr; +} + #include +/* + * ide_init_hwif_ports() is OBSOLETE and will be removed in 2.7 series. + * + * arm26, arm, h8300, m68k, m68knommu (broken) and i386-pc9800 (broken) + * still have their own versions. + */ +#if !defined(CONFIG_ARM) && !defined(CONFIG_H8300) && !defined(CONFIG_M68K) +static inline void ide_init_hwif_ports(hw_regs_t *hw, + unsigned long io_addr, + unsigned long ctl_addr, + int *irq) +{ + if (!ctl_addr) + ide_std_init_ports(hw, io_addr, io_addr + 0x206); + else + ide_std_init_ports(hw, io_addr, ctl_addr); + + if (irq) + *irq = 0; + + hw->io_ports[IDE_IRQ_OFFSET] = 0; + +#ifdef CONFIG_PPC32 + if (ppc_ide_md.ide_init_hwif) + ppc_ide_md.ide_init_hwif(hw, io_addr, ctl_addr, irq); +#endif +} +#endif /* !ARM && !H8300 && !M68K */ + /* Currently only m68k, apus and m8xx need it */ #ifndef IDE_ARCH_ACK_INTR # define ide_ack_intr(hwif) (1) -- 2.39.5