xref: /openbmc/linux/arch/mips/pci/fixup-rbtx4927.c (revision 19a8d6b7)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *
31da177e4SLinus Torvalds  * BRIEF MODULE DESCRIPTION
41da177e4SLinus Torvalds  *      Board specific pci fixups for the Toshiba rbtx4927
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  * Copyright 2001 MontaVista Software Inc.
71da177e4SLinus Torvalds  * Author: MontaVista Software, Inc.
81da177e4SLinus Torvalds  *              ppopov@mvista.com or source@mvista.com
91da177e4SLinus Torvalds  *
101da177e4SLinus Torvalds  * Copyright (C) 2000-2001 Toshiba Corporation
111da177e4SLinus Torvalds  *
121da177e4SLinus Torvalds  * Copyright (C) 2004 MontaVista Software Inc.
131da177e4SLinus Torvalds  * Author: Manish Lachwani (mlachwani@mvista.com)
141da177e4SLinus Torvalds  *
151da177e4SLinus Torvalds  *  This program is free software; you can redistribute  it and/or modify it
161da177e4SLinus Torvalds  *  under  the terms of  the GNU General  Public License as published by the
171da177e4SLinus Torvalds  *  Free Software Foundation;  either version 2 of the  License, or (at your
181da177e4SLinus Torvalds  *  option) any later version.
191da177e4SLinus Torvalds  *
201da177e4SLinus Torvalds  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
211da177e4SLinus Torvalds  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
221da177e4SLinus Torvalds  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
231da177e4SLinus Torvalds  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
241da177e4SLinus Torvalds  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
251da177e4SLinus Torvalds  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
261da177e4SLinus Torvalds  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
271da177e4SLinus Torvalds  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
281da177e4SLinus Torvalds  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
291da177e4SLinus Torvalds  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
301da177e4SLinus Torvalds  *
311da177e4SLinus Torvalds  *  You should have received a copy of the  GNU General Public License along
321da177e4SLinus Torvalds  *  with this program; if not, write  to the Free Software Foundation, Inc.,
331da177e4SLinus Torvalds  *  675 Mass Ave, Cambridge, MA 02139, USA.
341da177e4SLinus Torvalds  */
351da177e4SLinus Torvalds #include <linux/types.h>
3689d63fe1SAtsushi Nemoto #include <asm/txx9/pci.h>
3789d63fe1SAtsushi Nemoto #include <asm/txx9/rbtx4927.h>
381da177e4SLinus Torvalds 
rbtx4927_pci_map_irq(const struct pci_dev * dev,u8 slot,u8 pin)3919a8d6b7SLorenzo Pieralisi int rbtx4927_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
401da177e4SLinus Torvalds {
4189d63fe1SAtsushi Nemoto 	unsigned char irq = pin;
421da177e4SLinus Torvalds 
4389d63fe1SAtsushi Nemoto 	/* IRQ rotation */
4489d63fe1SAtsushi Nemoto 	irq--;			/* 0-3 */
4589d63fe1SAtsushi Nemoto 	if (slot == TX4927_PCIC_IDSEL_AD_TO_SLOT(23)) {
4689d63fe1SAtsushi Nemoto 		/* PCI CardSlot (IDSEL=A23) */
4789d63fe1SAtsushi Nemoto 		/* PCIA => PCIA */
4889d63fe1SAtsushi Nemoto 		irq = (irq + 0 + slot) % 4;
4989d63fe1SAtsushi Nemoto 	} else {
5089d63fe1SAtsushi Nemoto 		/* PCI Backplane */
5189d63fe1SAtsushi Nemoto 		if (txx9_pci_option & TXX9_PCI_OPT_PICMG)
5289d63fe1SAtsushi Nemoto 			irq = (irq + 33 - slot) % 4;
531da177e4SLinus Torvalds 		else
5489d63fe1SAtsushi Nemoto 			irq = (irq + 3 + slot) % 4;
5589d63fe1SAtsushi Nemoto 	}
5689d63fe1SAtsushi Nemoto 	irq++;	/* 1-4 */
571da177e4SLinus Torvalds 
5889d63fe1SAtsushi Nemoto 	switch (irq) {
5989d63fe1SAtsushi Nemoto 	case 1:
6089d63fe1SAtsushi Nemoto 		irq = RBTX4927_IRQ_IOC_PCIA;
6189d63fe1SAtsushi Nemoto 		break;
6289d63fe1SAtsushi Nemoto 	case 2:
6389d63fe1SAtsushi Nemoto 		irq = RBTX4927_IRQ_IOC_PCIB;
6489d63fe1SAtsushi Nemoto 		break;
6589d63fe1SAtsushi Nemoto 	case 3:
6689d63fe1SAtsushi Nemoto 		irq = RBTX4927_IRQ_IOC_PCIC;
6789d63fe1SAtsushi Nemoto 		break;
6889d63fe1SAtsushi Nemoto 	case 4:
6989d63fe1SAtsushi Nemoto 		irq = RBTX4927_IRQ_IOC_PCID;
7089d63fe1SAtsushi Nemoto 		break;
7189d63fe1SAtsushi Nemoto 	}
721da177e4SLinus Torvalds 	return irq;
731da177e4SLinus Torvalds }
74