aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/drivers/pci/pci-sh7780.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/drivers/pci/pci-sh7780.c')
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.c139
1 files changed, 139 insertions, 0 deletions
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
new file mode 100644
index 000000000000..bd3064a82087
--- /dev/null
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -0,0 +1,139 @@
1/*
2 * Low-Level PCI Support for the SH7780
3 *
4 * Dustin McIntire (dustin@sensoria.com)
5 * Derived from arch/i386/kernel/pci-*.c which bore the message:
6 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
7 *
8 * Ported to the new API by Paul Mundt <lethal@linux-sh.org>
9 * With cleanup by Paul van Gool <pvangool@mimotech.com>
10 *
11 * May be copied or modified under the terms of the GNU General Public
12 * License. See linux/COPYING for more information.
13 *
14 */
15
16#undef DEBUG
17
18#include <linux/config.h>
19#include <linux/types.h>
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/pci.h>
23#include <linux/errno.h>
24#include <linux/delay.h>
25#include "pci-sh4.h"
26
27/*
28 * Initialization. Try all known PCI access methods. Note that we support
29 * using both PCI BIOS and direct access: in such cases, we use I/O ports
30 * to access config space.
31 *
32 * Note that the platform specific initialization (BSC registers, and memory
33 * space mapping) will be called via the platform defined function
34 * pcibios_init_platform().
35 */
36static int __init sh7780_pci_init(void)
37{
38 unsigned int id;
39 int ret;
40
41 pr_debug("PCI: Starting intialization.\n");
42
43 outl(0x00000001, SH7780_PCI_VCR2); /* Enable PCIC */
44
45 /* check for SH7780/SH7780R hardware */
46 id = pci_read_reg(SH7780_PCIVID);
47 if ((id != ((SH7780_DEVICE_ID << 16) | SH7780_VENDOR_ID)) &&
48 (id != ((SH7781_DEVICE_ID << 16) | SH7780_VENDOR_ID))) {
49 printk(KERN_ERR "PCI: This is not an SH7780 (%x)\n", id);
50 return -ENODEV;
51 }
52
53 /* Setup the INTC */
54 ctrl_outl(0x00200000, INTC_ICR0); /* INTC SH-4 Mode */
55 ctrl_outl(0x00078000, INTC_INT2MSKCR); /* enable PCIINTA - PCIINTD */
56 ctrl_outl(0x40000000, INTC_INTMSK1); /* disable IRL4-7 Interrupt */
57 ctrl_outl(0x0000fffe, INTC_INTMSK2); /* disable IRL4-7 Interrupt */
58 ctrl_outl(0x80000000, INTC_INTMSKCLR1); /* enable IRL0-3 Interrupt */
59 ctrl_outl(0xfffe0000, INTC_INTMSKCLR2); /* enable IRL0-3 Interrupt */
60
61 if ((ret = sh4_pci_check_direct()) != 0)
62 return ret;
63
64 return pcibios_init_platform();
65}
66core_initcall(sh7780_pci_init);
67
68int __init sh7780_pcic_init(struct sh4_pci_address_map *map)
69{
70 u32 word;
71
72 /*
73 * This code is unused for some boards as it is done in the
74 * bootloader and doing it here means the MAC addresses loaded
75 * by the bootloader get lost.
76 */
77 if (!(map->flags & SH4_PCIC_NO_RESET)) {
78 /* toggle PCI reset pin */
79 word = SH4_PCICR_PREFIX | SH4_PCICR_PRST;
80 pci_write_reg(word, SH4_PCICR);
81 /* Wait for a long time... not 1 sec. but long enough */
82 mdelay(100);
83 word = SH4_PCICR_PREFIX;
84 pci_write_reg(word, SH4_PCICR);
85 }
86
87 /* set the command/status bits to:
88 * Wait Cycle Control + Parity Enable + Bus Master +
89 * Mem space enable
90 */
91 pci_write_reg(0x00000046, SH7780_PCICMD);
92
93 /* define this host as the host bridge */
94 word = PCI_BASE_CLASS_BRIDGE << 24;
95 pci_write_reg(word, SH7780_PCIRID);
96
97 /* Set IO and Mem windows to local address
98 * Make PCI and local address the same for easy 1 to 1 mapping
99 * Window0 = map->window0.size @ non-cached area base = SDRAM
100 * Window1 = map->window1.size @ cached area base = SDRAM
101 */
102 word = ((map->window0.size - 1) & 0x1ff00001) | 0x01;
103 pci_write_reg(0x07f00001, SH4_PCILSR0);
104 word = ((map->window1.size - 1) & 0x1ff00001) | 0x01;
105 pci_write_reg(0x00000001, SH4_PCILSR1);
106 /* Set the values on window 0 PCI config registers */
107 word = P2SEGADDR(map->window0.base);
108 pci_write_reg(0xa8000000, SH4_PCILAR0);
109 pci_write_reg(0x08000000, SH7780_PCIMBAR0);
110 /* Set the values on window 1 PCI config registers */
111 word = P2SEGADDR(map->window1.base);
112 pci_write_reg(0x00000000, SH4_PCILAR1);
113 pci_write_reg(0x00000000, SH7780_PCIMBAR1);
114
115 /* Map IO space into PCI IO window
116 * The IO window is 64K-PCIBIOS_MIN_IO in size
117 * IO addresses will be translated to the
118 * PCI IO window base address
119 */
120 pr_debug("PCI: Mapping IO address 0x%x - 0x%x to base 0x%x\n",
121 PCIBIOS_MIN_IO, (64 << 10),
122 SH7780_PCI_IO_BASE + PCIBIOS_MIN_IO);
123
124 /* NOTE: I'm ignoring the PCI error IRQs for now..
125 * TODO: add support for the internal error interrupts and
126 * DMA interrupts...
127 */
128
129#ifdef CONFIG_SH_R7780RP
130 pci_fixup_pcic();
131#endif
132
133 /* SH7780 init done, set central function init complete */
134 /* use round robin mode to stop a device starving/overruning */
135 word = SH4_PCICR_PREFIX | SH4_PCICR_CFIN | SH4_PCICR_FTO;
136 pci_write_reg(word, SH4_PCICR);
137
138 return 1;
139}