fixup-tx4938.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Toshiba rbtx4938 pci routines
  3. * Copyright (C) 2000-2001 Toshiba Corporation
  4. *
  5. * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
  6. * terms of the GNU General Public License version 2. This program is
  7. * licensed "as is" without any warranty of any kind, whether express
  8. * or implied.
  9. *
  10. * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
  11. */
  12. #include <linux/types.h>
  13. #include <linux/pci.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <asm/tx4938/rbtx4938.h>
  17. extern struct pci_controller tx4938_pci_controller[];
  18. static int pci_get_irq(const struct pci_dev *dev, int pin)
  19. {
  20. int irq = pin;
  21. u8 slot = PCI_SLOT(dev->devfn);
  22. struct pci_controller *controller = (struct pci_controller *)dev->sysdata;
  23. if (controller == &tx4938_pci_controller[1]) {
  24. /* TX4938 PCIC1 */
  25. switch (slot) {
  26. case TX4938_PCIC_IDSEL_AD_TO_SLOT(31):
  27. if (tx4938_ccfgptr->pcfg & TX4938_PCFG_ETH0_SEL)
  28. return RBTX4938_IRQ_IRC + TX4938_IR_ETH0;
  29. break;
  30. case TX4938_PCIC_IDSEL_AD_TO_SLOT(30):
  31. if (tx4938_ccfgptr->pcfg & TX4938_PCFG_ETH1_SEL)
  32. return RBTX4938_IRQ_IRC + TX4938_IR_ETH1;
  33. break;
  34. }
  35. return 0;
  36. }
  37. /* IRQ rotation */
  38. irq--; /* 0-3 */
  39. if (dev->bus->parent == NULL &&
  40. (slot == TX4938_PCIC_IDSEL_AD_TO_SLOT(23))) {
  41. /* PCI CardSlot (IDSEL=A23) */
  42. /* PCIA => PCIA (IDSEL=A23) */
  43. irq = (irq + 0 + slot) % 4;
  44. } else {
  45. /* PCI Backplane */
  46. irq = (irq + 33 - slot) % 4;
  47. }
  48. irq++; /* 1-4 */
  49. switch (irq) {
  50. case 1:
  51. irq = RBTX4938_IRQ_IOC_PCIA;
  52. break;
  53. case 2:
  54. irq = RBTX4938_IRQ_IOC_PCIB;
  55. break;
  56. case 3:
  57. irq = RBTX4938_IRQ_IOC_PCIC;
  58. break;
  59. case 4:
  60. irq = RBTX4938_IRQ_IOC_PCID;
  61. break;
  62. }
  63. return irq;
  64. }
  65. int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  66. {
  67. unsigned char irq = 0;
  68. irq = pci_get_irq(dev, pin);
  69. printk(KERN_INFO "PCI: 0x%02x:0x%02x(0x%02x,0x%02x) IRQ=%d\n",
  70. dev->bus->number, dev->devfn, PCI_SLOT(dev->devfn),
  71. PCI_FUNC(dev->devfn), irq);
  72. return irq;
  73. }
  74. /*
  75. * Do platform specific device initialization at pci_enable_device() time
  76. */
  77. int pcibios_plat_dev_init(struct pci_dev *dev)
  78. {
  79. return 0;
  80. }