blob: dd2c5df283079b0f6bbbacd2c581774afb892534 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/sh/drivers/pci/ops-snapgear.c
3 *
4 * Author: David McCullough <davidm@snapgear.com>
Paul Mundt959f85f2006-09-27 16:43:28 +09005 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * Ported to new API by Paul Mundt <lethal@linux-sh.org>
7 *
8 * Highly leveraged from pci-bigsur.c, written by Dustin McIntire.
9 *
10 * May be copied or modified under the terms of the GNU General Public
11 * License. See linux/COPYING for more information.
12 *
13 * PCI initialization for the SnapGear boards
14 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/kernel.h>
16#include <linux/types.h>
17#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/pci.h>
Paul Mundt959f85f2006-09-27 16:43:28 +090019#include "pci-sh4.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#define SNAPGEAR_PCI_IO 0x4000
22#define SNAPGEAR_PCI_MEM 0xfd000000
23
24/* PCI: default LOCAL memory window sizes (seen from PCI bus) */
25#define SNAPGEAR_LSR0_SIZE (64*(1<<20)) //64MB
26#define SNAPGEAR_LSR1_SIZE (64*(1<<20)) //64MB
27
28static struct resource sh7751_io_resource = {
29 .name = "SH7751 IO",
30 .start = SNAPGEAR_PCI_IO,
31 .end = SNAPGEAR_PCI_IO + (64*1024) - 1, /* 64KiB I/O */
32 .flags = IORESOURCE_IO,
33};
34
35static struct resource sh7751_mem_resource = {
36 .name = "SH7751 mem",
37 .start = SNAPGEAR_PCI_MEM,
38 .end = SNAPGEAR_PCI_MEM + (64*1024*1024) - 1, /* 64MiB mem */
39 .flags = IORESOURCE_MEM,
40};
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042struct pci_channel board_pci_channels[] = {
Magnus Dammd0e3db42009-03-11 15:46:14 +090043 { sh7751_pci_init, &sh4_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff },
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 { 0, }
45};
46
Paul Mundt959f85f2006-09-27 16:43:28 +090047static struct sh4_pci_address_map sh7751_pci_map = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 .window0 = {
49 .base = SH7751_CS2_BASE_ADDR,
50 .size = SNAPGEAR_LSR0_SIZE,
51 },
52
53 .window1 = {
54 .base = SH7751_CS2_BASE_ADDR,
55 .size = SNAPGEAR_LSR1_SIZE,
56 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070057};
58
59/*
Paul Mundt959f85f2006-09-27 16:43:28 +090060 * Initialize the SnapGear PCI interface
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 * Setup hardware to be Central Funtion
62 * Copy the BSR regs to the PCI interface
63 * Setup PCI windows into local RAM
64 */
65int __init pcibios_init_platform(void)
66{
Magnus Dammb8b47bf2009-03-11 15:41:51 +090067 return sh7751_pcic_init(&board_pci_channels[0], &sh7751_pci_map);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068}
69
Paul Mundt959f85f2006-09-27 16:43:28 +090070int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
72 int irq = -1;
73
74 switch (slot) {
75 case 8: /* the PCI bridge */ break;
76 case 11: irq = 8; break; /* USB */
77 case 12: irq = 11; break; /* PCMCIA */
78 case 13: irq = 5; break; /* eth0 */
79 case 14: irq = 8; break; /* eth1 */
80 case 15: irq = 11; break; /* safenet (unused) */
81 }
82
83 printk("PCI: Mapping SnapGear IRQ for slot %d, pin %c to irq %d\n",
84 slot, pin - 1 + 'A', irq);
85
86 return irq;
87}
88
89void __init pcibios_fixup(void)
90{
91 /* Nothing to fixup .. */
92}