blob: 178b77828aa98475813e733242fbb03801797f52 [file] [log] [blame]
Paul Mundt959f85f2006-09-27 16:43:28 +09001/*
2 * arch/sh/drivers/pci/ops-landisk.c
3 *
4 * PCI initialization for the I-O DATA Device, Inc. LANDISK board
5 *
6 * Copyright (C) 2006 kogiidena
7 *
8 * May be copied or modified under the terms of the GNU General Public
9 * License. See linux/COPYING for more information.
10 */
Paul Mundt959f85f2006-09-27 16:43:28 +090011#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/init.h>
14#include <linux/delay.h>
15#include <linux/pci.h>
16#include "pci-sh4.h"
17
18static struct resource sh7751_io_resource = {
19 .name = "SH7751 IO",
kogiidena00e8c492007-03-19 16:24:12 +090020 .start = SH7751_PCI_IO_BASE,
21 .end = SH7751_PCI_IO_BASE + SH7751_PCI_IO_SIZE - 1,
Paul Mundt959f85f2006-09-27 16:43:28 +090022 .flags = IORESOURCE_IO
23};
24
25static struct resource sh7751_mem_resource = {
26 .name = "SH7751 mem",
27 .start = SH7751_PCI_MEMORY_BASE,
28 .end = SH7751_PCI_MEMORY_BASE + SH7751_PCI_MEM_SIZE - 1,
29 .flags = IORESOURCE_MEM
30};
31
32struct pci_channel board_pci_channels[] = {
Magnus Dammd0e3db42009-03-11 15:46:14 +090033 { sh7751_pci_init, &sh4_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0x3ff},
Paul Mundt959f85f2006-09-27 16:43:28 +090034 {NULL, NULL, NULL, 0, 0},
35};
36
37static struct sh4_pci_address_map sh7751_pci_map = {
38 .window0 = {
39 .base = SH7751_CS3_BASE_ADDR,
40 .size = (64 << 20), /* 64MB */
41 },
Paul Mundt959f85f2006-09-27 16:43:28 +090042};
43
44int __init pcibios_init_platform(void)
45{
Magnus Dammb8b47bf2009-03-11 15:41:51 +090046 return sh7751_pcic_init(&board_pci_channels[0], &sh7751_pci_map);
Paul Mundt959f85f2006-09-27 16:43:28 +090047}
48
49int pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
50{
51 /*
52 * slot0: pin1-4 = irq5,6,7,8
53 * slot1: pin1-4 = irq6,7,8,5
54 * slot2: pin1-4 = irq7,8,5,6
55 * slot3: pin1-4 = irq8,5,6,7
56 */
57 int irq = ((slot + pin - 1) & 0x3) + 5;
58
59 if ((slot | (pin - 1)) > 0x3) {
60 printk("PCI: Bad IRQ mapping request for slot %d pin %c\n",
61 slot, pin - 1 + 'A');
62 return -1;
63 }
64 return irq;
65}