| 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> | 
| Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 13 | #include <asm/txx9/pci.h> | 
| Atsushi Nemoto | 22b1d70 | 2008-07-11 00:31:36 +0900 | [diff] [blame] | 14 | #include <asm/txx9/rbtx4938.h> | 
| Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 15 |  | 
| Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 16 | int __init rbtx4938_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 
| Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 17 | { | 
| Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 18 | 	int irq = tx4938_pcic1_map_irq(dev, slot); | 
| Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 19 |  | 
| Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 20 | 	if (irq >= 0) | 
 | 21 | 		return irq; | 
 | 22 | 	irq = pin; | 
| Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 23 | 	/* IRQ rotation */ | 
 | 24 | 	irq--;	/* 0-3 */ | 
| Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 25 | 	if (slot == TX4927_PCIC_IDSEL_AD_TO_SLOT(23)) { | 
| Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 26 | 		/* PCI CardSlot (IDSEL=A23) */ | 
 | 27 | 		/* PCIA => PCIA (IDSEL=A23) */ | 
 | 28 | 		irq = (irq + 0 + slot) % 4; | 
 | 29 | 	} else { | 
 | 30 | 		/* PCI Backplane */ | 
| Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame] | 31 | 		if (txx9_pci_option & TXX9_PCI_OPT_PICMG) | 
 | 32 | 			irq = (irq + 33 - slot) % 4; | 
 | 33 | 		else | 
 | 34 | 			irq = (irq + 3 + slot) % 4; | 
| Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 35 | 	} | 
 | 36 | 	irq++;	/* 1-4 */ | 
 | 37 |  | 
 | 38 | 	switch (irq) { | 
 | 39 | 	case 1: | 
 | 40 | 		irq = RBTX4938_IRQ_IOC_PCIA; | 
 | 41 | 		break; | 
 | 42 | 	case 2: | 
 | 43 | 		irq = RBTX4938_IRQ_IOC_PCIB; | 
 | 44 | 		break; | 
 | 45 | 	case 3: | 
 | 46 | 		irq = RBTX4938_IRQ_IOC_PCIC; | 
 | 47 | 		break; | 
 | 48 | 	case 4: | 
 | 49 | 		irq = RBTX4938_IRQ_IOC_PCID; | 
 | 50 | 		break; | 
 | 51 | 	} | 
 | 52 | 	return irq; | 
 | 53 | } |