Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame^] | 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 | |
| 17 | #include <asm/tx4938/rbtx4938.h> |
| 18 | |
| 19 | extern struct pci_controller tx4938_pci_controller[]; |
| 20 | |
| 21 | int pci_get_irq(struct pci_dev *dev, int pin) |
| 22 | { |
| 23 | int irq = pin; |
| 24 | u8 slot = PCI_SLOT(dev->devfn); |
| 25 | struct pci_controller *controller = (struct pci_controller *)dev->sysdata; |
| 26 | |
| 27 | if (controller == &tx4938_pci_controller[1]) { |
| 28 | /* TX4938 PCIC1 */ |
| 29 | switch (slot) { |
| 30 | case TX4938_PCIC_IDSEL_AD_TO_SLOT(31): |
| 31 | if (tx4938_ccfgptr->pcfg & TX4938_PCFG_ETH0_SEL) |
| 32 | return RBTX4938_IRQ_IRC + TX4938_IR_ETH0; |
| 33 | break; |
| 34 | case TX4938_PCIC_IDSEL_AD_TO_SLOT(30): |
| 35 | if (tx4938_ccfgptr->pcfg & TX4938_PCFG_ETH1_SEL) |
| 36 | return RBTX4938_IRQ_IRC + TX4938_IR_ETH1; |
| 37 | break; |
| 38 | } |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | /* IRQ rotation */ |
| 43 | irq--; /* 0-3 */ |
| 44 | if (dev->bus->parent == NULL && |
| 45 | (slot == TX4938_PCIC_IDSEL_AD_TO_SLOT(23))) { |
| 46 | /* PCI CardSlot (IDSEL=A23) */ |
| 47 | /* PCIA => PCIA (IDSEL=A23) */ |
| 48 | irq = (irq + 0 + slot) % 4; |
| 49 | } else { |
| 50 | /* PCI Backplane */ |
| 51 | irq = (irq + 33 - slot) % 4; |
| 52 | } |
| 53 | irq++; /* 1-4 */ |
| 54 | |
| 55 | switch (irq) { |
| 56 | case 1: |
| 57 | irq = RBTX4938_IRQ_IOC_PCIA; |
| 58 | break; |
| 59 | case 2: |
| 60 | irq = RBTX4938_IRQ_IOC_PCIB; |
| 61 | break; |
| 62 | case 3: |
| 63 | irq = RBTX4938_IRQ_IOC_PCIC; |
| 64 | break; |
| 65 | case 4: |
| 66 | irq = RBTX4938_IRQ_IOC_PCID; |
| 67 | break; |
| 68 | } |
| 69 | return irq; |
| 70 | } |
| 71 | |
| 72 | int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) |
| 73 | { |
| 74 | unsigned char irq = 0; |
| 75 | |
| 76 | irq = pci_get_irq(dev, pin); |
| 77 | |
| 78 | printk(KERN_INFO "PCI: 0x%02x:0x%02x(0x%02x,0x%02x) IRQ=%d\n", |
| 79 | dev->bus->number, dev->devfn, PCI_SLOT(dev->devfn), |
| 80 | PCI_FUNC(dev->devfn), irq); |
| 81 | |
| 82 | return irq; |
| 83 | } |
| 84 | |
| 85 | /* |
| 86 | * Do platform specific device initialization at pci_enable_device() time |
| 87 | */ |
| 88 | int pcibios_plat_dev_init(struct pci_dev *dev) |
| 89 | { |
| 90 | return 0; |
| 91 | } |
| 92 | |