blob: 2541f9bc12dea8f9a730e2b35ca51e80118a5a4e [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001// SPDX-License-Identifier: GPL-2.0-or-later
dmitry pervushin355c4712006-05-21 14:53:06 +04002/*
dmitry pervushin355c4712006-05-21 14:53:06 +04003 * Copyright (C) NEC Electronics Corporation 2004-2006
4 *
5 * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c
6 *
7 * Copyright 2001 MontaVista Software Inc.
dmitry pervushin355c4712006-05-21 14:53:06 +04008 */
9
dmitry pervushin355c4712006-05-21 14:53:06 +040010#include <linux/kernel.h>
11#include <linux/init.h>
12#include <linux/types.h>
13#include <linux/pci.h>
14
15#include <asm/bootinfo.h>
dmitry pervushin355c4712006-05-21 14:53:06 +040016
Shinya Kuribayashid91f2cb2008-10-24 01:30:20 +090017#include <asm/emma/emma2rh.h>
dmitry pervushin355c4712006-05-21 14:53:06 +040018
19#define EMMA2RH_PCI_HOST_SLOT 0x09
20#define EMMA2RH_USB_SLOT 0x03
21#define PCI_DEVICE_ID_NEC_EMMA2RH 0x014b /* EMMA2RH PCI Host */
22
23/*
24 * we fix up irqs based on the slot number.
25 * The first entry is at AD:11.
26 * Fortunately this works because, although we have two pci buses,
27 * they all have different slot numbers (except for rockhopper slot 20
28 * which is handled below).
29 *
30 */
31
Ralf Baechle70342282013-01-22 12:59:30 +010032#define MAX_SLOT_NUM 10
Lorenzo Pieralisi19a8d6b2017-09-19 15:50:42 +010033static unsigned char irq_map[][5] = {
dmitry pervushin355c4712006-05-21 14:53:06 +040034 [3] = {0, MARKEINS_PCI_IRQ_INTB, MARKEINS_PCI_IRQ_INTC,
35 MARKEINS_PCI_IRQ_INTD, 0,},
36 [4] = {0, MARKEINS_PCI_IRQ_INTA, 0, 0, 0,},
37 [5] = {0, 0, 0, 0, 0,},
38 [6] = {0, MARKEINS_PCI_IRQ_INTC, MARKEINS_PCI_IRQ_INTD,
39 MARKEINS_PCI_IRQ_INTA, MARKEINS_PCI_IRQ_INTB,},
40};
41
Greg Kroah-Hartman28eb0e42012-12-21 14:04:39 -080042static void nec_usb_controller_fixup(struct pci_dev *dev)
dmitry pervushin355c4712006-05-21 14:53:06 +040043{
44 if (PCI_SLOT(dev->devfn) == EMMA2RH_USB_SLOT)
45 /* on board USB controller configuration */
46 pci_write_config_dword(dev, 0xe4, 1 << 5);
47}
48
49DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
50 nec_usb_controller_fixup);
51
52/*
53 * Prevent the PCI layer from seeing the resources allocated to this device
54 * if it is the host bridge by marking it as such. These resources are of
55 * no consequence to the PCI layer (they are handled elsewhere).
56 */
Greg Kroah-Hartman28eb0e42012-12-21 14:04:39 -080057static void emma2rh_pci_host_fixup(struct pci_dev *dev)
dmitry pervushin355c4712006-05-21 14:53:06 +040058{
59 int i;
60
61 if (PCI_SLOT(dev->devfn) == EMMA2RH_PCI_HOST_SLOT) {
62 dev->class &= 0xff;
63 dev->class |= PCI_CLASS_BRIDGE_HOST << 8;
64 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
65 dev->resource[i].start = 0;
66 dev->resource[i].end = 0;
67 dev->resource[i].flags = 0;
68 }
69 }
70}
71
72DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_EMMA2RH,
73 emma2rh_pci_host_fixup);
74
Lorenzo Pieralisi19a8d6b2017-09-19 15:50:42 +010075int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
dmitry pervushin355c4712006-05-21 14:53:06 +040076{
77 return irq_map[slot][pin];
78}
79
80/* Do platform specific device initialization at pci_enable_device() time */
81int pcibios_plat_dev_init(struct pci_dev *dev)
82{
83 return 0;
84}