Hello Ralf, This patch fixes the PCI fixup function for NEC Eagle. Please apply to CVS. Yoichi diff -urN -X dontdiff linux-orig/arch/mips/pci/Makefile linux/arch/mips/pci/Makefile --- linux-orig/arch/mips/pci/Makefile Thu Apr 15 00:06:22 2004 +++ linux/arch/mips/pci/Makefile Thu Apr 22 00:34:12 2004 @@ -38,7 +38,7 @@ obj-$(CONFIG_MOMENCO_OCELOT) += fixup-ocelot.o pci-ocelot.o obj-$(CONFIG_MOMENCO_OCELOT_C) += pci-ocelot-c.o obj-$(CONFIG_MOMENCO_OCELOT_G) += pci-ocelot-g.o -obj-$(CONFIG_NEC_EAGLE) += fixup-eagle.o ops-vrc4173.o +obj-$(CONFIG_NEC_EAGLE) += fixup-eagle.o obj-$(CONFIG_PMC_YOSEMITE) += fixup-yosemite.o ops-titan.o obj-$(CONFIG_SGI_IP27) += pci-ip27.o obj-$(CONFIG_SGI_IP32) += fixup-ip32.o ops-mace.o pci-ip32.o diff -urN -X dontdiff linux-orig/arch/mips/pci/fixup-eagle.c linux/arch/mips/pci/fixup-eagle.c --- linux-orig/arch/mips/pci/fixup-eagle.c Fri Feb 20 00:49:46 2004 +++ linux/arch/mips/pci/fixup-eagle.c Thu Apr 22 00:34:12 2004 @@ -1,15 +1,25 @@ /* - * arch/mips/vr41xx/nec-eagle/pci_fixup.c + * fixup-eagle.c, The NEC Eagle/Hawk Board specific PCI fixups. * - * The NEC Eagle/Hawk Board specific PCI fixups. + * Copyright (C) 2001-2002,2004 MontaVista Software, Inc. + * Author: Yoichi Yuasa <yyuasa@xxxxxxxxxx, or source@xxxxxxxxxx> + * Copyright (C) 2004 Yoichi Yuasa <yuasa@xxxxxxxxxxxxxx> * - * Author: Yoichi Yuasa <you@xxxxxxxxxx, or source@xxxxxxxxxx> + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * 2001-2002,2004 (c) MontaVista, Software, Inc. This file is licensed under - * the terms of the GNU General Public License version 2. This program - * is licensed "as is" without any warranty of any kind, whether express - * or implied. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <linux/config.h> #include <linux/init.h> #include <linux/pci.h> @@ -29,13 +39,13 @@ #define SLOT PCISLOT_IRQ static char irq_tab_eagle[][5] __initdata = { - [ 8] = { 0, INTA, INTB, INTC, INTD }, - [ 9] = { 0, INTD, INTA, INTB, INTC }, - [10] = { 0, INTC, INTD, INTA, INTB }, - [12] = { 0, PCMCIA1, 0, 0, 0 }, - [13] = { 0, PCMCIA2, 0, 0, 0 }, - [28] = { 0, LAN, 0, 0, 0 }, - [29] = { 0, SLOT, INTB, INTC, INTD }, + [ 8] = { -1, INTA, INTB, INTC, INTD }, + [ 9] = { -1, INTD, INTA, INTB, INTC }, + [10] = { -1, INTC, INTD, INTA, INTB }, + [12] = { -1, PCMCIA1, -1, -1, -1 }, + [13] = { -1, PCMCIA2, -1, -1, -1 }, + [28] = { -1, LAN, LAN, LAN, LAN }, + [29] = { -1, SLOT, INTB, INTC, INTD }, }; /* @@ -58,3 +68,97 @@ struct pci_fixup pcibios_fixups[] __initdata = { { .pass = 0, }, }; + +#ifdef CONFIG_VRC4173 +/* + * PCI configuration registers + */ +#define PCICONFAREG KSEG1ADDR(0x0f000c18) +#define PCICONFDREG KSEG1ADDR(0x0f000c14) + +static inline void pci_config_write_byte(u8 reg, u8 val) +{ + u32 data; + int shift; + + writel((1UL << 0x1e) | (reg & 0xfc), PCICONFAREG); + data = readl(PCICONFDREG); + + shift = (reg & 3) << 3; + data &= ~(0xff << shift); + data |= (((u32) val) << shift); + + writel(data, PCICONFDREG); +} + +static inline u16 pci_config_read_halfword(u8 reg) +{ + u32 data; + + writel(((1UL << 30) | (reg & 0xfc)), PCICONFAREG); + data = readl(PCICONFDREG); + + return (u16) (data >> ((reg & 2) << 3)); +} + +static inline u32 pci_config_read_word(u8 reg) +{ + writel(((1UL << 30) | (reg & 0xfc)), PCICONFAREG); + + return readl(PCICONFDREG); +} + +static inline void pci_config_write_word(u8 reg, u32 val) +{ + writel((1UL << 0x1e) | (reg & 0xfc), PCICONFAREG); + writel(val, PCICONFDREG); +} + +/* + * Pre-fixup for AC97U/CARDU/USBU of VRC4173 + */ +static int __init vrc4173_prefixup(void) +{ + u32 cmdsts, base; + u16 cmu_mask; + + + if ((pci_config_read_halfword(PCI_VENDOR_ID) == PCI_VENDOR_ID_NEC) && + (pci_config_read_halfword(PCI_DEVICE_ID) == PCI_DEVICE_ID_NEC_VRC4173)) { + /* + * Initialized NEC VRC4173 Bus Control Unit + */ + cmdsts = pci_config_read_word(PCI_COMMAND); + pci_config_write_word(PCI_COMMAND, + cmdsts | PCI_COMMAND_IO | + PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); + + pci_config_write_byte(PCI_LATENCY_TIMER, 0x80); + + pci_config_write_word(PCI_BASE_ADDRESS_0, VR41XX_PCI_IO_START); + base = pci_config_read_word(PCI_BASE_ADDRESS_0); + base &= PCI_BASE_ADDRESS_IO_MASK; + pci_config_write_byte(0x40, 0x01); + + /* CARDU1 IDSEL = AD12, CARDU2 IDSEL = AD13 */ + pci_config_write_byte(0x41, 0); + + cmu_mask = 0x1000; + outw(cmu_mask, base + 0x040); + cmu_mask |= 0x0800; + outw(cmu_mask, base + 0x040); + + outw(0x000f, base + 0x042); /* Soft reset of CMU */ + cmu_mask |= 0x05e0; + outw(cmu_mask, base + 0x040); + cmu_mask = inw(base + 0x040); /* dummy read */ + outw(0x0000, base + 0x042); + + return 0; + } + + return -ENODEV; +} + +early_initcall(vrc4173_prefixup); +#endif diff -urN -X dontdiff linux-orig/arch/mips/pci/ops-vrc4173.c linux/arch/mips/pci/ops-vrc4173.c --- linux-orig/arch/mips/pci/ops-vrc4173.c Fri Jun 13 23:19:56 2003 +++ linux/arch/mips/pci/ops-vrc4173.c Thu Jan 1 09:00:00 1970 @@ -1,120 +0,0 @@ -/* - * FILE NAME - * arch/mips/vr41xx/nec-eagle/vrc4173.c - * - * BRIEF MODULE DESCRIPTION - * Pre-setup for NEC VRC4173. - * - * Author: Yoichi Yuasa - * yyuasa@xxxxxxxxxx or source@xxxxxxxxxx - * - * Copyright 2001,2002 MontaVista Software Inc. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include <linux/init.h> -#include <linux/pci.h> -#include <linux/module.h> - -#include <asm/io.h> -#include <asm/vr41xx/eagle.h> -#include <asm/vr41xx/vrc4173.h> - -#define PCI_CONFIG_ADDR KSEG1ADDR(0x0f000c18) -#define PCI_CONFIG_DATA KSEG1ADDR(0x0f000c14) - -static inline void config_writeb(u8 reg, u8 val) -{ - u32 data; - int shift; - - writel((1UL << 0x1e) | (reg & 0xfc), PCI_CONFIG_ADDR); - data = readl(PCI_CONFIG_DATA); - - shift = (reg & 3) << 3; - data &= ~(0xff << shift); - data |= (((u32) val) << shift); - - writel(data, PCI_CONFIG_DATA); -} - -static inline u16 config_readw(u8 reg) -{ - u32 data; - - writel(((1UL << 30) | (reg & 0xfc)), PCI_CONFIG_ADDR); - data = readl(PCI_CONFIG_DATA); - - return (u16) (data >> ((reg & 2) << 3)); -} - -static inline u32 config_readl(u8 reg) -{ - writel(((1UL << 30) | (reg & 0xfc)), PCI_CONFIG_ADDR); - - return readl(PCI_CONFIG_DATA); -} - -static inline void config_writel(u8 reg, u32 val) -{ - writel((1UL << 0x1e) | (reg & 0xfc), PCI_CONFIG_ADDR); - writel(val, PCI_CONFIG_DATA); -} - -void __init vrc4173_preinit(void) -{ - u32 cmdsts, base; - u16 cmu_mask; - - - if ((config_readw(PCI_VENDOR_ID) == PCI_VENDOR_ID_NEC) && - (config_readw(PCI_DEVICE_ID) == PCI_DEVICE_ID_NEC_VRC4173)) { - /* - * Initialized NEC VRC4173 Bus Control Unit - */ - cmdsts = config_readl(PCI_COMMAND); - config_writel(PCI_COMMAND, - cmdsts | - PCI_COMMAND_IO | - PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); - - config_writeb(PCI_LATENCY_TIMER, 0x80); - - config_writel(PCI_BASE_ADDRESS_0, VR41XX_PCI_IO_START); - base = config_readl(PCI_BASE_ADDRESS_0); - base &= PCI_BASE_ADDRESS_IO_MASK; - config_writeb(0x40, 0x01); - - /* CARDU1 IDSEL = AD12, CARDU2 IDSEL = AD13 */ - config_writeb(0x41, 0); - - cmu_mask = 0x1000; - outw(cmu_mask, base + 0x040); - cmu_mask |= 0x0800; - outw(cmu_mask, base + 0x040); - - outw(0x000f, base + 0x042); /* Soft reset of CMU */ - cmu_mask |= 0x05e0; - outw(cmu_mask, base + 0x040); - cmu_mask = inw(base + 0x040); /* dummy read */ - outw(0x0000, base + 0x042); - } -} diff -urN -X dontdiff linux-orig/arch/mips/vr41xx/nec-eagle/setup.c linux/arch/mips/vr41xx/nec-eagle/setup.c --- linux-orig/arch/mips/vr41xx/nec-eagle/setup.c Thu Feb 26 07:05:00 2004 +++ linux/arch/mips/vr41xx/nec-eagle/setup.c Thu Apr 22 00:34:12 2004 @@ -86,8 +86,6 @@ #ifdef CONFIG_PCI vr41xx_pciu_init(&pci_address_map); - - vrc4173_preinit(); #endif return 0;