fixup-emma2rh.c 2.9 KB

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