~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to arch/sh/drivers/pci/pci-sh7780.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Low-Level PCI Support for the SH7780
3
3
 *
4
 
 *  Copyright (C) 2005 - 2009  Paul Mundt
 
4
 *  Copyright (C) 2005 - 2010  Paul Mundt
5
5
 *
6
6
 * This file is subject to the terms and conditions of the GNU General Public
7
7
 * License.  See the file "COPYING" in the main directory of this archive
11
11
#include <linux/kernel.h>
12
12
#include <linux/init.h>
13
13
#include <linux/pci.h>
 
14
#include <linux/interrupt.h>
 
15
#include <linux/timer.h>
 
16
#include <linux/irq.h>
14
17
#include <linux/errno.h>
15
18
#include <linux/delay.h>
 
19
#include <linux/log2.h>
16
20
#include "pci-sh4.h"
17
 
 
18
 
static struct resource sh7785_io_resource = {
19
 
        .name   = "SH7785_IO",
20
 
        .start  = SH7780_PCI_IO_BASE,
21
 
        .end    = SH7780_PCI_IO_BASE + SH7780_PCI_IO_SIZE - 1,
22
 
        .flags  = IORESOURCE_IO
23
 
};
24
 
 
25
 
static struct resource sh7785_mem_resource = {
26
 
        .name   = "SH7785_mem",
27
 
        .start  = SH7780_PCI_MEMORY_BASE,
28
 
        .end    = SH7780_PCI_MEMORY_BASE + SH7780_PCI_MEM_SIZE - 1,
29
 
        .flags  = IORESOURCE_MEM
 
21
#include <asm/mmu.h>
 
22
#include <asm/sizes.h>
 
23
 
 
24
static struct resource sh7785_pci_resources[] = {
 
25
        {
 
26
                .name   = "PCI IO",
 
27
                .start  = 0x1000,
 
28
                .end    = SZ_4M - 1,
 
29
                .flags  = IORESOURCE_IO,
 
30
        }, {
 
31
                .name   = "PCI MEM 0",
 
32
                .start  = 0xfd000000,
 
33
                .end    = 0xfd000000 + SZ_16M - 1,
 
34
                .flags  = IORESOURCE_MEM,
 
35
        }, {
 
36
                .name   = "PCI MEM 1",
 
37
                .start  = 0x10000000,
 
38
                .end    = 0x10000000 + SZ_64M - 1,
 
39
                .flags  = IORESOURCE_MEM,
 
40
        }, {
 
41
                /*
 
42
                 * 32-bit only resources must be last.
 
43
                 */
 
44
                .name   = "PCI MEM 2",
 
45
                .start  = 0xc0000000,
 
46
                .end    = 0xc0000000 + SZ_512M - 1,
 
47
                .flags  = IORESOURCE_MEM | IORESOURCE_MEM_32BIT,
 
48
        },
30
49
};
31
50
 
32
51
static struct pci_channel sh7780_pci_controller = {
33
52
        .pci_ops        = &sh4_pci_ops,
34
 
        .mem_resource   = &sh7785_mem_resource,
35
 
        .mem_offset     = 0x00000000,
36
 
        .io_resource    = &sh7785_io_resource,
37
 
        .io_offset      = 0x00000000,
38
 
        .io_map_base    = SH7780_PCI_IO_BASE,
39
 
};
40
 
 
41
 
static struct sh4_pci_address_map sh7780_pci_map = {
42
 
        .window0        = {
43
 
#if defined(CONFIG_32BIT)
44
 
                .base   = SH7780_32BIT_DDR_BASE_ADDR,
45
 
                .size   = 0x40000000,
46
 
#else
47
 
                .base   = SH7780_CS0_BASE_ADDR,
48
 
                .size   = 0x20000000,
49
 
#endif
50
 
        },
51
 
};
 
53
        .resources      = sh7785_pci_resources,
 
54
        .nr_resources   = ARRAY_SIZE(sh7785_pci_resources),
 
55
        .io_offset      = 0,
 
56
        .mem_offset     = 0,
 
57
        .io_map_base    = 0xfe200000,
 
58
        .serr_irq       = evt2irq(0xa00),
 
59
        .err_irq        = evt2irq(0xaa0),
 
60
};
 
61
 
 
62
struct pci_errors {
 
63
        unsigned int    mask;
 
64
        const char      *str;
 
65
} pci_arbiter_errors[] = {
 
66
        { SH4_PCIAINT_MBKN,     "master broken" },
 
67
        { SH4_PCIAINT_TBTO,     "target bus time out" },
 
68
        { SH4_PCIAINT_MBTO,     "master bus time out" },
 
69
        { SH4_PCIAINT_TABT,     "target abort" },
 
70
        { SH4_PCIAINT_MABT,     "master abort" },
 
71
        { SH4_PCIAINT_RDPE,     "read data parity error" },
 
72
        { SH4_PCIAINT_WDPE,     "write data parity error" },
 
73
}, pci_interrupt_errors[] = {
 
74
        { SH4_PCIINT_MLCK,      "master lock error" },
 
75
        { SH4_PCIINT_TABT,      "target-target abort" },
 
76
        { SH4_PCIINT_TRET,      "target retry time out" },
 
77
        { SH4_PCIINT_MFDE,      "master function disable erorr" },
 
78
        { SH4_PCIINT_PRTY,      "address parity error" },
 
79
        { SH4_PCIINT_SERR,      "SERR" },
 
80
        { SH4_PCIINT_TWDP,      "data parity error for target write" },
 
81
        { SH4_PCIINT_TRDP,      "PERR detected for target read" },
 
82
        { SH4_PCIINT_MTABT,     "target abort for master" },
 
83
        { SH4_PCIINT_MMABT,     "master abort for master" },
 
84
        { SH4_PCIINT_MWPD,      "master write data parity error" },
 
85
        { SH4_PCIINT_MRPD,      "master read data parity error" },
 
86
};
 
87
 
 
88
static irqreturn_t sh7780_pci_err_irq(int irq, void *dev_id)
 
89
{
 
90
        struct pci_channel *hose = dev_id;
 
91
        unsigned long addr;
 
92
        unsigned int status;
 
93
        unsigned int cmd;
 
94
        int i;
 
95
 
 
96
        addr = __raw_readl(hose->reg_base + SH4_PCIALR);
 
97
 
 
98
        /*
 
99
         * Handle status errors.
 
100
         */
 
101
        status = __raw_readw(hose->reg_base + PCI_STATUS);
 
102
        if (status & (PCI_STATUS_PARITY |
 
103
                      PCI_STATUS_DETECTED_PARITY |
 
104
                      PCI_STATUS_SIG_TARGET_ABORT |
 
105
                      PCI_STATUS_REC_TARGET_ABORT |
 
106
                      PCI_STATUS_REC_MASTER_ABORT)) {
 
107
                cmd = pcibios_handle_status_errors(addr, status, hose);
 
108
                if (likely(cmd))
 
109
                        __raw_writew(cmd, hose->reg_base + PCI_STATUS);
 
110
        }
 
111
 
 
112
        /*
 
113
         * Handle arbiter errors.
 
114
         */
 
115
        status = __raw_readl(hose->reg_base + SH4_PCIAINT);
 
116
        for (i = cmd = 0; i < ARRAY_SIZE(pci_arbiter_errors); i++) {
 
117
                if (status & pci_arbiter_errors[i].mask) {
 
118
                        printk(KERN_DEBUG "PCI: %s, addr=%08lx\n",
 
119
                               pci_arbiter_errors[i].str, addr);
 
120
                        cmd |= pci_arbiter_errors[i].mask;
 
121
                }
 
122
        }
 
123
        __raw_writel(cmd, hose->reg_base + SH4_PCIAINT);
 
124
 
 
125
        /*
 
126
         * Handle the remaining PCI errors.
 
127
         */
 
128
        status = __raw_readl(hose->reg_base + SH4_PCIINT);
 
129
        for (i = cmd = 0; i < ARRAY_SIZE(pci_interrupt_errors); i++) {
 
130
                if (status & pci_interrupt_errors[i].mask) {
 
131
                        printk(KERN_DEBUG "PCI: %s, addr=%08lx\n",
 
132
                               pci_interrupt_errors[i].str, addr);
 
133
                        cmd |= pci_interrupt_errors[i].mask;
 
134
                }
 
135
        }
 
136
        __raw_writel(cmd, hose->reg_base + SH4_PCIINT);
 
137
 
 
138
        return IRQ_HANDLED;
 
139
}
 
140
 
 
141
static irqreturn_t sh7780_pci_serr_irq(int irq, void *dev_id)
 
142
{
 
143
        struct pci_channel *hose = dev_id;
 
144
 
 
145
        printk(KERN_DEBUG "PCI: system error received: ");
 
146
        pcibios_report_status(PCI_STATUS_SIG_SYSTEM_ERROR, 1);
 
147
        printk("\n");
 
148
 
 
149
        /* Deassert SERR */
 
150
        __raw_writel(SH4_PCIINTM_SDIM, hose->reg_base + SH4_PCIINTM);
 
151
 
 
152
        /* Back off the IRQ for awhile */
 
153
        disable_irq_nosync(irq);
 
154
        hose->serr_timer.expires = jiffies + HZ;
 
155
        add_timer(&hose->serr_timer);
 
156
 
 
157
        return IRQ_HANDLED;
 
158
}
 
159
 
 
160
static int __init sh7780_pci_setup_irqs(struct pci_channel *hose)
 
161
{
 
162
        int ret;
 
163
 
 
164
        /* Clear out PCI arbiter IRQs */
 
165
        __raw_writel(0, hose->reg_base + SH4_PCIAINT);
 
166
 
 
167
        /* Clear all error conditions */
 
168
        __raw_writew(PCI_STATUS_DETECTED_PARITY  | \
 
169
                     PCI_STATUS_SIG_SYSTEM_ERROR | \
 
170
                     PCI_STATUS_REC_MASTER_ABORT | \
 
171
                     PCI_STATUS_REC_TARGET_ABORT | \
 
172
                     PCI_STATUS_SIG_TARGET_ABORT | \
 
173
                     PCI_STATUS_PARITY, hose->reg_base + PCI_STATUS);
 
174
 
 
175
        ret = request_irq(hose->serr_irq, sh7780_pci_serr_irq, IRQF_DISABLED,
 
176
                          "PCI SERR interrupt", hose);
 
177
        if (unlikely(ret)) {
 
178
                printk(KERN_ERR "PCI: Failed hooking SERR IRQ\n");
 
179
                return ret;
 
180
        }
 
181
 
 
182
        /*
 
183
         * The PCI ERR IRQ needs to be IRQF_SHARED since all of the power
 
184
         * down IRQ vectors are routed through the ERR IRQ vector. We
 
185
         * only request_irq() once as there is only a single masking
 
186
         * source for multiple events.
 
187
         */
 
188
        ret = request_irq(hose->err_irq, sh7780_pci_err_irq, IRQF_SHARED,
 
189
                          "PCI ERR interrupt", hose);
 
190
        if (unlikely(ret)) {
 
191
                free_irq(hose->serr_irq, hose);
 
192
                return ret;
 
193
        }
 
194
 
 
195
        /* Unmask all of the arbiter IRQs. */
 
196
        __raw_writel(SH4_PCIAINT_MBKN | SH4_PCIAINT_TBTO | SH4_PCIAINT_MBTO | \
 
197
                     SH4_PCIAINT_TABT | SH4_PCIAINT_MABT | SH4_PCIAINT_RDPE | \
 
198
                     SH4_PCIAINT_WDPE, hose->reg_base + SH4_PCIAINTM);
 
199
 
 
200
        /* Unmask all of the PCI IRQs */
 
201
        __raw_writel(SH4_PCIINTM_TTADIM  | SH4_PCIINTM_TMTOIM  | \
 
202
                     SH4_PCIINTM_MDEIM   | SH4_PCIINTM_APEDIM  | \
 
203
                     SH4_PCIINTM_SDIM    | SH4_PCIINTM_DPEITWM | \
 
204
                     SH4_PCIINTM_PEDITRM | SH4_PCIINTM_TADIMM  | \
 
205
                     SH4_PCIINTM_MADIMM  | SH4_PCIINTM_MWPDIM  | \
 
206
                     SH4_PCIINTM_MRDPEIM, hose->reg_base + SH4_PCIINTM);
 
207
 
 
208
        return ret;
 
209
}
 
210
 
 
211
static inline void __init sh7780_pci_teardown_irqs(struct pci_channel *hose)
 
212
{
 
213
        free_irq(hose->err_irq, hose);
 
214
        free_irq(hose->serr_irq, hose);
 
215
}
 
216
 
 
217
static void __init sh7780_pci66_init(struct pci_channel *hose)
 
218
{
 
219
        unsigned int tmp;
 
220
 
 
221
        if (!pci_is_66mhz_capable(hose, 0, 0))
 
222
                return;
 
223
 
 
224
        /* Enable register access */
 
225
        tmp = __raw_readl(hose->reg_base + SH4_PCICR);
 
226
        tmp |= SH4_PCICR_PREFIX;
 
227
        __raw_writel(tmp, hose->reg_base + SH4_PCICR);
 
228
 
 
229
        /* Enable 66MHz operation */
 
230
        tmp = __raw_readw(hose->reg_base + PCI_STATUS);
 
231
        tmp |= PCI_STATUS_66MHZ;
 
232
        __raw_writew(tmp, hose->reg_base + PCI_STATUS);
 
233
 
 
234
        /* Done */
 
235
        tmp = __raw_readl(hose->reg_base + SH4_PCICR);
 
236
        tmp |= SH4_PCICR_PREFIX | SH4_PCICR_CFIN;
 
237
        __raw_writel(tmp, hose->reg_base + SH4_PCICR);
 
238
}
52
239
 
53
240
static int __init sh7780_pci_init(void)
54
241
{
55
242
        struct pci_channel *chan = &sh7780_pci_controller;
 
243
        phys_addr_t memphys;
 
244
        size_t memsize;
56
245
        unsigned int id;
57
 
        const char *type = NULL;
58
 
        int ret;
59
 
        u32 word;
 
246
        const char *type;
 
247
        int ret, i;
60
248
 
61
 
        printk(KERN_NOTICE "PCI: Starting intialization.\n");
 
249
        printk(KERN_NOTICE "PCI: Starting initialization.\n");
62
250
 
63
251
        chan->reg_base = 0xfe040000;
64
252
 
65
253
        /* Enable CPU access to the PCIC registers. */
66
254
        __raw_writel(PCIECR_ENBL, PCIECR);
67
255
 
68
 
        id = __raw_readw(chan->reg_base + SH7780_PCIVID);
69
 
        if (id != SH7780_VENDOR_ID) {
 
256
        /* Reset */
 
257
        __raw_writel(SH4_PCICR_PREFIX | SH4_PCICR_PRST,
 
258
                     chan->reg_base + SH4_PCICR);
 
259
 
 
260
        /*
 
261
         * Wait for it to come back up. The spec says to allow for up to
 
262
         * 1 second after toggling the reset pin, but in practice 100ms
 
263
         * is more than enough.
 
264
         */
 
265
        mdelay(100);
 
266
 
 
267
        id = __raw_readw(chan->reg_base + PCI_VENDOR_ID);
 
268
        if (id != PCI_VENDOR_ID_RENESAS) {
70
269
                printk(KERN_ERR "PCI: Unknown vendor ID 0x%04x.\n", id);
71
270
                return -ENODEV;
72
271
        }
73
272
 
74
 
        id = __raw_readw(chan->reg_base + SH7780_PCIDID);
75
 
        type = (id == SH7763_DEVICE_ID) ? "SH7763" :
76
 
               (id == SH7780_DEVICE_ID) ? "SH7780" :
77
 
               (id == SH7781_DEVICE_ID) ? "SH7781" :
78
 
               (id == SH7785_DEVICE_ID) ? "SH7785" :
 
273
        id = __raw_readw(chan->reg_base + PCI_DEVICE_ID);
 
274
        type = (id == PCI_DEVICE_ID_RENESAS_SH7763) ? "SH7763" :
 
275
               (id == PCI_DEVICE_ID_RENESAS_SH7780) ? "SH7780" :
 
276
               (id == PCI_DEVICE_ID_RENESAS_SH7781) ? "SH7781" :
 
277
               (id == PCI_DEVICE_ID_RENESAS_SH7785) ? "SH7785" :
79
278
                                          NULL;
80
279
        if (unlikely(!type)) {
81
280
                printk(KERN_ERR "PCI: Found an unsupported Renesas host "
85
284
 
86
285
        printk(KERN_NOTICE "PCI: Found a Renesas %s host "
87
286
               "controller, revision %d.\n", type,
88
 
               __raw_readb(chan->reg_base + SH7780_PCIRID));
89
 
 
90
 
        if ((ret = sh4_pci_check_direct(chan)) != 0)
 
287
               __raw_readb(chan->reg_base + PCI_REVISION_ID));
 
288
 
 
289
        /*
 
290
         * Now throw it in to register initialization mode and
 
291
         * start the real work.
 
292
         */
 
293
        __raw_writel(SH4_PCICR_PREFIX, chan->reg_base + SH4_PCICR);
 
294
 
 
295
        memphys = __pa(memory_start);
 
296
        memsize = roundup_pow_of_two(memory_end - memory_start);
 
297
 
 
298
        /*
 
299
         * If there's more than 512MB of memory, we need to roll over to
 
300
         * LAR1/LSR1.
 
301
         */
 
302
        if (memsize > SZ_512M) {
 
303
                __raw_writel(memphys + SZ_512M, chan->reg_base + SH4_PCILAR1);
 
304
                __raw_writel((((memsize - SZ_512M) - SZ_1M) & 0x1ff00000) | 1,
 
305
                             chan->reg_base + SH4_PCILSR1);
 
306
                memsize = SZ_512M;
 
307
        } else {
 
308
                /*
 
309
                 * Otherwise just zero it out and disable it.
 
310
                 */
 
311
                __raw_writel(0, chan->reg_base + SH4_PCILAR1);
 
312
                __raw_writel(0, chan->reg_base + SH4_PCILSR1);
 
313
        }
 
314
 
 
315
        /*
 
316
         * LAR0/LSR0 covers up to the first 512MB, which is enough to
 
317
         * cover all of lowmem on most platforms.
 
318
         */
 
319
        __raw_writel(memphys, chan->reg_base + SH4_PCILAR0);
 
320
        __raw_writel(((memsize - SZ_1M) & 0x1ff00000) | 1,
 
321
                     chan->reg_base + SH4_PCILSR0);
 
322
 
 
323
        /*
 
324
         * Hook up the ERR and SERR IRQs.
 
325
         */
 
326
        ret = sh7780_pci_setup_irqs(chan);
 
327
        if (unlikely(ret))
91
328
                return ret;
92
329
 
93
330
        /*
94
 
         * Set the class and sub-class codes.
95
 
         */
96
 
        __raw_writeb(PCI_CLASS_BRIDGE_HOST >> 8,
97
 
                     chan->reg_base + SH7780_PCIBCC);
98
 
        __raw_writeb(PCI_CLASS_BRIDGE_HOST & 0xff,
99
 
                     chan->reg_base + SH7780_PCISUB);
100
 
 
101
 
        /*
102
 
         * Set IO and Mem windows to local address
103
 
         * Make PCI and local address the same for easy 1 to 1 mapping
104
 
         */
105
 
        pci_write_reg(chan, sh7780_pci_map.window0.size - 0xfffff, SH4_PCILSR0);
106
 
        /* Set the values on window 0 PCI config registers */
107
 
        pci_write_reg(chan, sh7780_pci_map.window0.base, SH4_PCILAR0);
108
 
        pci_write_reg(chan, sh7780_pci_map.window0.base, SH7780_PCIMBAR0);
109
 
 
110
 
        pci_write_reg(chan, 0x0000380f, SH4_PCIAINTM);
111
 
 
112
 
        /* Set up standard PCI config registers */
113
 
        __raw_writew(0xFB00, chan->reg_base + SH7780_PCISTATUS);
114
 
        __raw_writew(0x0047, chan->reg_base + SH7780_PCICMD);
115
 
        __raw_writew(0x1912, chan->reg_base + SH7780_PCISVID);
116
 
        __raw_writew(0x0001, chan->reg_base + SH7780_PCISID);
117
 
 
118
 
        __raw_writeb(0x00, chan->reg_base + SH7780_PCIPIF);
119
 
 
120
 
        /* Apply any last-minute PCIC fixups */
121
 
        pci_fixup_pcic(chan);
122
 
 
123
 
        pci_write_reg(chan, 0xfd000000, SH7780_PCIMBR0);
124
 
        pci_write_reg(chan, 0x00fc0000, SH7780_PCIMBMR0);
125
 
 
126
 
#ifdef CONFIG_32BIT
127
 
        pci_write_reg(chan, 0xc0000000, SH7780_PCIMBR2);
128
 
        pci_write_reg(chan, 0x20000000 - SH7780_PCI_IO_SIZE, SH7780_PCIMBMR2);
129
 
#endif
130
 
 
131
 
        /* Set IOBR for windows containing area specified in pci.h */
132
 
        pci_write_reg(chan, chan->io_resource->start & ~(SH7780_PCI_IO_SIZE-1),
133
 
                      SH7780_PCIIOBR);
134
 
        pci_write_reg(chan, ((SH7780_PCI_IO_SIZE-1) & (7<<18)),
135
 
                      SH7780_PCIIOBMR);
136
 
 
137
 
        /* SH7780 init done, set central function init complete */
138
 
        /* use round robin mode to stop a device starving/overruning */
139
 
        word = SH4_PCICR_PREFIX | SH4_PCICR_CFIN | SH4_PCICR_FTO;
140
 
        pci_write_reg(chan, word, SH4_PCICR);
141
 
 
142
 
        register_pci_controller(chan);
 
331
         * Disable the cache snoop controller for non-coherent DMA.
 
332
         */
 
333
        __raw_writel(0, chan->reg_base + SH7780_PCICSCR0);
 
334
        __raw_writel(0, chan->reg_base + SH7780_PCICSAR0);
 
335
        __raw_writel(0, chan->reg_base + SH7780_PCICSCR1);
 
336
        __raw_writel(0, chan->reg_base + SH7780_PCICSAR1);
 
337
 
 
338
        /*
 
339
         * Setup the memory BARs
 
340
         */
 
341
        for (i = 1; i < chan->nr_resources; i++) {
 
342
                struct resource *res = chan->resources + i;
 
343
                resource_size_t size;
 
344
 
 
345
                if (unlikely(res->flags & IORESOURCE_IO))
 
346
                        continue;
 
347
 
 
348
                /*
 
349
                 * Make sure we're in the right physical addressing mode
 
350
                 * for dealing with the resource.
 
351
                 */
 
352
                if ((res->flags & IORESOURCE_MEM_32BIT) && __in_29bit_mode()) {
 
353
                        chan->nr_resources--;
 
354
                        continue;
 
355
                }
 
356
 
 
357
                size = resource_size(res);
 
358
 
 
359
                /*
 
360
                 * The MBMR mask is calculated in units of 256kB, which
 
361
                 * keeps things pretty simple.
 
362
                 */
 
363
                __raw_writel(((roundup_pow_of_two(size) / SZ_256K) - 1) << 18,
 
364
                             chan->reg_base + SH7780_PCIMBMR(i - 1));
 
365
                __raw_writel(res->start, chan->reg_base + SH7780_PCIMBR(i - 1));
 
366
        }
 
367
 
 
368
        /*
 
369
         * And I/O.
 
370
         */
 
371
        __raw_writel(0, chan->reg_base + PCI_BASE_ADDRESS_0);
 
372
        __raw_writel(0, chan->reg_base + SH7780_PCIIOBR);
 
373
        __raw_writel(0, chan->reg_base + SH7780_PCIIOBMR);
 
374
 
 
375
        __raw_writew(PCI_COMMAND_SERR   | PCI_COMMAND_WAIT   | \
 
376
                     PCI_COMMAND_PARITY | PCI_COMMAND_MASTER | \
 
377
                     PCI_COMMAND_MEMORY, chan->reg_base + PCI_COMMAND);
 
378
 
 
379
        /*
 
380
         * Initialization mode complete, release the control register and
 
381
         * enable round robin mode to stop device overruns/starvation.
 
382
         */
 
383
        __raw_writel(SH4_PCICR_PREFIX | SH4_PCICR_CFIN | SH4_PCICR_FTO,
 
384
                     chan->reg_base + SH4_PCICR);
 
385
 
 
386
        ret = register_pci_controller(chan);
 
387
        if (unlikely(ret))
 
388
                goto err;
 
389
 
 
390
        sh7780_pci66_init(chan);
 
391
 
 
392
        printk(KERN_NOTICE "PCI: Running at %dMHz.\n",
 
393
               (__raw_readw(chan->reg_base + PCI_STATUS) & PCI_STATUS_66MHZ) ?
 
394
               66 : 33);
143
395
 
144
396
        return 0;
 
397
 
 
398
err:
 
399
        sh7780_pci_teardown_irqs(chan);
 
400
        return ret;
145
401
}
146
402
arch_initcall(sh7780_pci_init);