fixup-emma2rh.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * arch/mips/pci/fixup-emma2rh.c
  3. * This file defines the PCI configration.
  4. *
  5. * Copyright (C) NEC Electronics Corporation 2004-2006
  6. *
  7. * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c
  8. *
  9. * Copyright 2001 MontaVista Software Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <linux/kernel.h>
  26. #include <linux/init.h>
  27. #include <linux/types.h>
  28. #include <linux/pci.h>
  29. #include <asm/bootinfo.h>
  30. #include <asm/emma/emma2rh.h>
  31. #define EMMA2RH_PCI_HOST_SLOT 0x09
  32. #define EMMA2RH_USB_SLOT 0x03
  33. #define PCI_DEVICE_ID_NEC_EMMA2RH 0x014b /* EMMA2RH PCI Host */
  34. /*
  35. * we fix up irqs based on the slot number.
  36. * The first entry is at AD:11.
  37. * Fortunately this works because, although we have two pci buses,
  38. * they all have different slot numbers (except for rockhopper slot 20
  39. * which is handled below).
  40. *
  41. */
  42. #define MAX_SLOT_NUM 10
  43. static unsigned char irq_map[][5] __initdata = {
  44. [3] = {0, MARKEINS_PCI_IRQ_INTB, MARKEINS_PCI_IRQ_INTC,
  45. MARKEINS_PCI_IRQ_INTD, 0,},
  46. [4] = {0, MARKEINS_PCI_IRQ_INTA, 0, 0, 0,},
  47. [5] = {0, 0, 0, 0, 0,},
  48. [6] = {0, MARKEINS_PCI_IRQ_INTC, MARKEINS_PCI_IRQ_INTD,
  49. MARKEINS_PCI_IRQ_INTA, MARKEINS_PCI_IRQ_INTB,},
  50. };
  51. static void __devinit nec_usb_controller_fixup(struct pci_dev *dev)
  52. {
  53. if (PCI_SLOT(dev->devfn) == EMMA2RH_USB_SLOT)
  54. /* on board USB controller configuration */
  55. pci_write_config_dword(dev, 0xe4, 1 << 5);
  56. }
  57. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
  58. nec_usb_controller_fixup);
  59. /*
  60. * Prevent the PCI layer from seeing the resources allocated to this device
  61. * if it is the host bridge by marking it as such. These resources are of
  62. * no consequence to the PCI layer (they are handled elsewhere).
  63. */
  64. static void __devinit emma2rh_pci_host_fixup(struct pci_dev *dev)
  65. {
  66. int i;
  67. if (PCI_SLOT(dev->devfn) == EMMA2RH_PCI_HOST_SLOT) {
  68. dev->class &= 0xff;
  69. dev->class |= PCI_CLASS_BRIDGE_HOST << 8;
  70. for (i = 0; i < PCI_NUM_RESOURCES; i++) {
  71. dev->resource[i].start = 0;
  72. dev->resource[i].end = 0;
  73. dev->resource[i].flags = 0;
  74. }
  75. }
  76. }
  77. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_EMMA2RH,
  78. emma2rh_pci_host_fixup);
  79. int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  80. {
  81. return irq_map[slot][pin];
  82. }
  83. /* Do platform specific device initialization at pci_enable_device() time */
  84. int pcibios_plat_dev_init(struct pci_dev *dev)
  85. {
  86. return 0;
  87. }