/*1* Copyright (C) NEC Electronics Corporation 2004-20062*3* This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c4*5* Copyright 2001 MontaVista Software Inc.6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA20*/2122#include <linux/kernel.h>23#include <linux/init.h>24#include <linux/types.h>25#include <linux/pci.h>2627#include <asm/bootinfo.h>2829#include <asm/emma/emma2rh.h>3031#define EMMA2RH_PCI_HOST_SLOT 0x0932#define EMMA2RH_USB_SLOT 0x0333#define PCI_DEVICE_ID_NEC_EMMA2RH 0x014b /* EMMA2RH PCI Host */3435/*36* we fix up irqs based on the slot number.37* The first entry is at AD:11.38* Fortunately this works because, although we have two pci buses,39* they all have different slot numbers (except for rockhopper slot 2040* which is handled below).41*42*/4344#define MAX_SLOT_NUM 1045static unsigned char irq_map[][5] __initdata = {46[3] = {0, MARKEINS_PCI_IRQ_INTB, MARKEINS_PCI_IRQ_INTC,47MARKEINS_PCI_IRQ_INTD, 0,},48[4] = {0, MARKEINS_PCI_IRQ_INTA, 0, 0, 0,},49[5] = {0, 0, 0, 0, 0,},50[6] = {0, MARKEINS_PCI_IRQ_INTC, MARKEINS_PCI_IRQ_INTD,51MARKEINS_PCI_IRQ_INTA, MARKEINS_PCI_IRQ_INTB,},52};5354static void __devinit nec_usb_controller_fixup(struct pci_dev *dev)55{56if (PCI_SLOT(dev->devfn) == EMMA2RH_USB_SLOT)57/* on board USB controller configuration */58pci_write_config_dword(dev, 0xe4, 1 << 5);59}6061DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,62nec_usb_controller_fixup);6364/*65* Prevent the PCI layer from seeing the resources allocated to this device66* if it is the host bridge by marking it as such. These resources are of67* no consequence to the PCI layer (they are handled elsewhere).68*/69static void __devinit emma2rh_pci_host_fixup(struct pci_dev *dev)70{71int i;7273if (PCI_SLOT(dev->devfn) == EMMA2RH_PCI_HOST_SLOT) {74dev->class &= 0xff;75dev->class |= PCI_CLASS_BRIDGE_HOST << 8;76for (i = 0; i < PCI_NUM_RESOURCES; i++) {77dev->resource[i].start = 0;78dev->resource[i].end = 0;79dev->resource[i].flags = 0;80}81}82}8384DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_EMMA2RH,85emma2rh_pci_host_fixup);8687int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)88{89return irq_map[slot][pin];90}9192/* Do platform specific device initialization at pci_enable_device() time */93int pcibios_plat_dev_init(struct pci_dev *dev)94{95return 0;96}979899