18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * BRIEF MODULE DESCRIPTION
48c2ecf20Sopenharmony_ci *      Board specific pci fixups for the Toshiba rbtx4927
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright 2001 MontaVista Software Inc.
78c2ecf20Sopenharmony_ci * Author: MontaVista Software, Inc.
88c2ecf20Sopenharmony_ci *              ppopov@mvista.com or source@mvista.com
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * Copyright (C) 2000-2001 Toshiba Corporation
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Copyright (C) 2004 MontaVista Software Inc.
138c2ecf20Sopenharmony_ci * Author: Manish Lachwani (mlachwani@mvista.com)
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci *  This program is free software; you can redistribute  it and/or modify it
168c2ecf20Sopenharmony_ci *  under  the terms of  the GNU General  Public License as published by the
178c2ecf20Sopenharmony_ci *  Free Software Foundation;  either version 2 of the  License, or (at your
188c2ecf20Sopenharmony_ci *  option) any later version.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
218c2ecf20Sopenharmony_ci *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
228c2ecf20Sopenharmony_ci *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
238c2ecf20Sopenharmony_ci *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
248c2ecf20Sopenharmony_ci *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
258c2ecf20Sopenharmony_ci *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
268c2ecf20Sopenharmony_ci *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
278c2ecf20Sopenharmony_ci *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
288c2ecf20Sopenharmony_ci *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
298c2ecf20Sopenharmony_ci *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
308c2ecf20Sopenharmony_ci *
318c2ecf20Sopenharmony_ci *  You should have received a copy of the  GNU General Public License along
328c2ecf20Sopenharmony_ci *  with this program; if not, write  to the Free Software Foundation, Inc.,
338c2ecf20Sopenharmony_ci *  675 Mass Ave, Cambridge, MA 02139, USA.
348c2ecf20Sopenharmony_ci */
358c2ecf20Sopenharmony_ci#include <linux/types.h>
368c2ecf20Sopenharmony_ci#include <asm/txx9/pci.h>
378c2ecf20Sopenharmony_ci#include <asm/txx9/rbtx4927.h>
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciint rbtx4927_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
408c2ecf20Sopenharmony_ci{
418c2ecf20Sopenharmony_ci	unsigned char irq = pin;
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	/* IRQ rotation */
448c2ecf20Sopenharmony_ci	irq--;			/* 0-3 */
458c2ecf20Sopenharmony_ci	if (slot == TX4927_PCIC_IDSEL_AD_TO_SLOT(23)) {
468c2ecf20Sopenharmony_ci		/* PCI CardSlot (IDSEL=A23) */
478c2ecf20Sopenharmony_ci		/* PCIA => PCIA */
488c2ecf20Sopenharmony_ci		irq = (irq + 0 + slot) % 4;
498c2ecf20Sopenharmony_ci	} else {
508c2ecf20Sopenharmony_ci		/* PCI Backplane */
518c2ecf20Sopenharmony_ci		if (txx9_pci_option & TXX9_PCI_OPT_PICMG)
528c2ecf20Sopenharmony_ci			irq = (irq + 33 - slot) % 4;
538c2ecf20Sopenharmony_ci		else
548c2ecf20Sopenharmony_ci			irq = (irq + 3 + slot) % 4;
558c2ecf20Sopenharmony_ci	}
568c2ecf20Sopenharmony_ci	irq++;	/* 1-4 */
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	switch (irq) {
598c2ecf20Sopenharmony_ci	case 1:
608c2ecf20Sopenharmony_ci		irq = RBTX4927_IRQ_IOC_PCIA;
618c2ecf20Sopenharmony_ci		break;
628c2ecf20Sopenharmony_ci	case 2:
638c2ecf20Sopenharmony_ci		irq = RBTX4927_IRQ_IOC_PCIB;
648c2ecf20Sopenharmony_ci		break;
658c2ecf20Sopenharmony_ci	case 3:
668c2ecf20Sopenharmony_ci		irq = RBTX4927_IRQ_IOC_PCIC;
678c2ecf20Sopenharmony_ci		break;
688c2ecf20Sopenharmony_ci	case 4:
698c2ecf20Sopenharmony_ci		irq = RBTX4927_IRQ_IOC_PCID;
708c2ecf20Sopenharmony_ci		break;
718c2ecf20Sopenharmony_ci	}
728c2ecf20Sopenharmony_ci	return irq;
738c2ecf20Sopenharmony_ci}
74