1 diff -Nur linux-2.6.15/arch/mips/pci/fixup-aruba.c linux-2.6.15-openwrt/arch/mips/pci/fixup-aruba.c
2 --- linux-2.6.15/arch/mips/pci/fixup-aruba.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.15-openwrt/arch/mips/pci/fixup-aruba.c 2006-01-10 00:34:41.000000000 +0100
5 +/**************************************************************************
7 + * BRIEF MODULE DESCRIPTION
8 + * PCI fixups for IDT EB434 board
10 + * Copyright 2004 IDT Inc. (rischelp@idt.com)
12 + * This program is free software; you can redistribute it and/or modify it
13 + * under the terms of the GNU General Public License as published by the
14 + * Free Software Foundation; either version 2 of the License, or (at your
15 + * option) any later version.
17 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 + * You should have received a copy of the GNU General Public License along
29 + * with this program; if not, write to the Free Software Foundation, Inc.,
30 + * 675 Mass Ave, Cambridge, MA 02139, USA.
33 + **************************************************************************
40 + **************************************************************************
43 +#include <linux/autoconf.h>
44 +#include <linux/types.h>
45 +#include <linux/pci.h>
46 +#include <linux/kernel.h>
47 +#include <linux/init.h>
48 +#include <asm/idt-boards/rc32434/rc32434.h>
49 +#include <asm/idt-boards/rc32434/rc32434_pci.h>
51 +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
54 + if (dev->bus->number != 0) {
58 + slot = PCI_SLOT(dev->devfn);
61 + if (slot > 0 && slot <= 15) {
64 + if(pin == 1) dev->irq = GROUP4_IRQ_BASE + 9; // intA
65 + } else if(slot == 11) {
66 + if(pin == 1) dev->irq = GROUP4_IRQ_BASE + 10; // intA
67 + if(pin == 2) dev->irq = GROUP4_IRQ_BASE + 10; // intA
68 + if(pin == 3) dev->irq = GROUP4_IRQ_BASE + 10; // intA
69 + } else if(slot == 12) {
70 + if(pin == 1) dev->irq = GROUP4_IRQ_BASE + 11; // intA
71 + if(pin == 2) dev->irq = GROUP4_IRQ_BASE + 12; // intB
72 + } else if (slot == 13) {
73 + if(pin == 1) dev->irq = GROUP4_IRQ_BASE + 12; // intA
74 + if(pin == 2) dev->irq = GROUP4_IRQ_BASE + 11; // intB
76 + dev->irq = GROUP4_IRQ_BASE + 11;
81 + dev->irq = GROUP4_IRQ_BASE + 11;
84 + dev->irq = GROUP4_IRQ_BASE + 11;
87 + dev->irq = GROUP4_IRQ_BASE + 11;
90 + dev->irq = GROUP4_IRQ_BASE + 11;
98 + printk("irq fixup: slot %d, pin %d, irq %d\n",
99 + slot, pin, dev->irq);
101 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE,dev->irq);
106 +struct pci_fixup pcibios_fixups[] = {
120 diff -Nur linux-2.6.15/arch/mips/pci/Makefile linux-2.6.15-openwrt/arch/mips/pci/Makefile
121 --- linux-2.6.15/arch/mips/pci/Makefile 2006-01-03 04:21:10.000000000 +0100
122 +++ linux-2.6.15-openwrt/arch/mips/pci/Makefile 2006-01-10 00:32:32.000000000 +0100
124 obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o
125 obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o
126 obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o
127 +obj-$(CONFIG_MACH_ARUBA) += fixup-aruba.o ops-aruba.o pci-aruba.o
128 diff -Nur linux-2.6.15/arch/mips/pci/ops-aruba.c linux-2.6.15-openwrt/arch/mips/pci/ops-aruba.c
129 --- linux-2.6.15/arch/mips/pci/ops-aruba.c 1970-01-01 01:00:00.000000000 +0100
130 +++ linux-2.6.15-openwrt/arch/mips/pci/ops-aruba.c 2006-01-10 00:32:32.000000000 +0100
132 +/**************************************************************************
134 + * BRIEF MODULE DESCRIPTION
135 + * pci_ops for IDT EB434 board
137 + * Copyright 2004 IDT Inc. (rischelp@idt.com)
139 + * This program is free software; you can redistribute it and/or modify it
140 + * under the terms of the GNU General Public License as published by the
141 + * Free Software Foundation; either version 2 of the License, or (at your
142 + * option) any later version.
144 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
145 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
146 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
147 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
148 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
149 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
150 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
151 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
152 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
153 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
155 + * You should have received a copy of the GNU General Public License along
156 + * with this program; if not, write to the Free Software Foundation, Inc.,
157 + * 675 Mass Ave, Cambridge, MA 02139, USA.
160 + **************************************************************************
161 + * May 2004 rkt, neb
167 + **************************************************************************
170 +#include <linux/autoconf.h>
171 +#include <linux/init.h>
172 +#include <linux/pci.h>
173 +#include <linux/types.h>
174 +#include <linux/delay.h>
176 +#include <asm/cpu.h>
179 +#include <asm/idt-boards/rc32434/rc32434.h>
180 +#include <asm/idt-boards/rc32434/rc32434_pci.h>
182 +#define PCI_ACCESS_READ 0
183 +#define PCI_ACCESS_WRITE 1
186 +#define PCI_CFG_SET(slot,func,off) \
187 + (rc32434_pci->pcicfga = (0x80000000 | ((slot)<<11) | \
188 + ((func)<<8) | (off)))
190 +static int config_access(unsigned char access_type, struct pci_bus *bus,
191 + unsigned int devfn, unsigned char where,
195 + * config cycles are on 4 byte boundary only
197 + unsigned int slot = PCI_SLOT(devfn);
198 + u8 func = PCI_FUNC(devfn);
200 + if (slot < 2 || slot > 15) {
201 + *data = 0xFFFFFFFF;
204 + /* Setup address */
205 + PCI_CFG_SET(slot, func, where);
208 + if (access_type == PCI_ACCESS_WRITE) {
210 + rc32434_pci->pcicfgd = *data;
213 + *data = rc32434_pci->pcicfgd;
223 + * We can't address 8 and 16 bit words directly. Instead we have to
224 + * read/write a 32bit word and mask/modify the data we actually want.
226 +static int read_config_byte(struct pci_bus *bus, unsigned int devfn,
227 + int where, u8 * val)
232 + ret = config_access(PCI_ACCESS_READ, bus, devfn, where, &data);
233 + *val = (data >> ((where & 3) << 3)) & 0xff;
237 +static int read_config_word(struct pci_bus *bus, unsigned int devfn,
238 + int where, u16 * val)
243 + ret = config_access(PCI_ACCESS_READ, bus, devfn, where, &data);
244 + *val = (data >> ((where & 3) << 3)) & 0xffff;
248 +static int read_config_dword(struct pci_bus *bus, unsigned int devfn,
249 + int where, u32 * val)
253 + ret = config_access(PCI_ACCESS_READ, bus, devfn, where, val);
258 +write_config_byte(struct pci_bus *bus, unsigned int devfn, int where,
263 + if (config_access(PCI_ACCESS_READ, bus, devfn, where, &data))
266 + data = (data & ~(0xff << ((where & 3) << 3))) |
267 + (val << ((where & 3) << 3));
269 + if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data))
272 + return PCIBIOS_SUCCESSFUL;
277 +write_config_word(struct pci_bus *bus, unsigned int devfn, int where,
282 + if (config_access(PCI_ACCESS_READ, bus, devfn, where, &data))
285 + data = (data & ~(0xffff << ((where & 3) << 3))) |
286 + (val << ((where & 3) << 3));
288 + if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data))
292 + return PCIBIOS_SUCCESSFUL;
297 +write_config_dword(struct pci_bus *bus, unsigned int devfn, int where,
300 + if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &val))
303 + return PCIBIOS_SUCCESSFUL;
306 +static int pci_config_read(struct pci_bus *bus, unsigned int devfn,
307 + int where, int size, u32 * val)
311 + return read_config_byte(bus, devfn, where, (u8 *) val);
313 + return read_config_word(bus, devfn, where, (u16 *) val);
315 + return read_config_dword(bus, devfn, where, val);
319 +static int pci_config_write(struct pci_bus *bus, unsigned int devfn,
320 + int where, int size, u32 val)
324 + return write_config_byte(bus, devfn, where, (u8) val);
326 + return write_config_word(bus, devfn, where, (u16) val);
328 + return write_config_dword(bus, devfn, where, val);
332 +struct pci_ops rc32434_pci_ops = {
333 + .read = pci_config_read,
334 + .write = pci_config_write,
336 diff -Nur linux-2.6.15/arch/mips/pci/pci-aruba.c linux-2.6.15-openwrt/arch/mips/pci/pci-aruba.c
337 --- linux-2.6.15/arch/mips/pci/pci-aruba.c 1970-01-01 01:00:00.000000000 +0100
338 +++ linux-2.6.15-openwrt/arch/mips/pci/pci-aruba.c 2006-01-10 00:32:32.000000000 +0100
340 +/**************************************************************************
342 + * BRIEF MODULE DESCRIPTION
343 + * PCI initialization for IDT EB434 board
345 + * Copyright 2004 IDT Inc. (rischelp@idt.com)
347 + * This program is free software; you can redistribute it and/or modify it
348 + * under the terms of the GNU General Public License as published by the
349 + * Free Software Foundation; either version 2 of the License, or (at your
350 + * option) any later version.
352 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
353 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
354 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
355 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
356 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
357 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
358 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
359 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
360 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
361 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
363 + * You should have received a copy of the GNU General Public License along
364 + * with this program; if not, write to the Free Software Foundation, Inc.,
365 + * 675 Mass Ave, Cambridge, MA 02139, USA.
368 + **************************************************************************
369 + * May 2004 rkt, neb
375 + **************************************************************************
378 +#include <linux/autoconf.h>
379 +#include <linux/types.h>
380 +#include <linux/pci.h>
381 +#include <linux/kernel.h>
382 +#include <linux/init.h>
383 +#include <asm/idt-boards/rc32434/rc32434.h>
384 +#include <asm/idt-boards/rc32434/rc32434_pci.h>
386 +#define PCI_ACCESS_READ 0
387 +#define PCI_ACCESS_WRITE 1
391 +#define DBG(x...) printk(x)
395 +/* define an unsigned array for the PCI registers */
396 +unsigned int korinaCnfgRegs[25] = {
397 + KORINA_CNFG1, KORINA_CNFG2, KORINA_CNFG3, KORINA_CNFG4,
398 + KORINA_CNFG5, KORINA_CNFG6, KORINA_CNFG7, KORINA_CNFG8,
399 + KORINA_CNFG9, KORINA_CNFG10, KORINA_CNFG11, KORINA_CNFG12,
400 + KORINA_CNFG13, KORINA_CNFG14, KORINA_CNFG15, KORINA_CNFG16,
401 + KORINA_CNFG17, KORINA_CNFG18, KORINA_CNFG19, KORINA_CNFG20,
402 + KORINA_CNFG21, KORINA_CNFG22, KORINA_CNFG23, KORINA_CNFG24
405 +static struct resource rc32434_res_pci_mem2;
407 +static struct resource rc32434_res_pci_mem1 = {
408 + .name = "PCI MEM1",
409 + .start = 0x50000000,
411 + .flags = IORESOURCE_MEM,
412 + .child = &rc32434_res_pci_mem2,
414 +static struct resource rc32434_res_pci_mem2 = {
415 + .name = "PCI MEM2",
416 + .start = 0x60000000,
418 + .flags = IORESOURCE_MEM,
419 + .parent = &rc32434_res_pci_mem1,
421 +static struct resource rc32434_res_pci_io1 = {
422 + .name = "PCI I/O1",
423 + .start = 0x18800000,
425 + .flags = IORESOURCE_IO,
428 +extern struct pci_ops rc32434_pci_ops;
430 +struct pci_controller rc32434_controller = {
431 + .pci_ops = &rc32434_pci_ops,
432 + .mem_resource = &rc32434_res_pci_mem1,
433 + .io_resource = &rc32434_res_pci_io1,
434 + .mem_offset = 0x00000000UL,
435 + .io_offset = 0x00000000UL,
438 +extern unsigned int arch_has_pci;
440 +static int __init rc32434_pcibridge_init(void)
443 + unsigned int pciConfigAddr = 0;/*used for writing pci config values */
444 + int loopCount=0 ;/*used for the loop */
446 + unsigned int pcicValue, pcicData=0;
447 + unsigned int dummyRead, pciCntlVal = 0;
449 + if (!arch_has_pci) return 0;
451 + printk("PCI: Initializing PCI\n");
453 + /* Disable the IP bus error for PCI scaning */
454 + pciCntlVal=rc32434_pci->pcic;
455 + pciCntlVal &= 0xFFFFFF7;
456 + rc32434_pci->pcic = pciCntlVal;
458 + ioport_resource.start = rc32434_res_pci_io1.start;
459 + ioport_resource.end = rc32434_res_pci_io1.end;
461 + iomem_resource.start = rc32434_res_pci_mem1.start;
462 + iomem_resource.end = rc32434_res_pci_mem1.end;
465 + pcicValue = rc32434_pci->pcic;
466 + pcicValue = (pcicValue >> PCIM_SHFT) & PCIM_BIT_LEN;
467 + if (!((pcicValue == PCIM_H_EA) ||
468 + (pcicValue == PCIM_H_IA_FIX) ||
469 + (pcicValue == PCIM_H_IA_RR))) {
470 + /* Not in Host Mode, return ERROR */
474 + /* Enables the Idle Grant mode, Arbiter Parking */
475 + pcicData |=(PCIC_igm_m|PCIC_eap_m|PCIC_en_m);
476 + rc32434_pci->pcic = pcicData; /* Enable the PCI bus Interface */
477 + /* Zero out the PCI status & PCI Status Mask */
479 + pcicData = rc32434_pci->pcis;
480 + if (!(pcicData & PCIS_rip_m))
484 + rc32434_pci->pcis = 0;
485 + rc32434_pci->pcism = 0xFFFFFFFF;
486 + /* Zero out the PCI decoupled registers */
487 + rc32434_pci->pcidac=0; /* disable PCI decoupled accesses at initialization */
488 + rc32434_pci->pcidas=0; /* clear the status */
489 + rc32434_pci->pcidasm=0x0000007F; /* Mask all the interrupts */
490 + /* Mask PCI Messaging Interrupts */
491 + rc32434_pci_msg->pciiic = 0;
492 + rc32434_pci_msg->pciiim = 0xFFFFFFFF;
493 + rc32434_pci_msg->pciioic = 0;
494 + rc32434_pci_msg->pciioim = 0;
496 + /* Setup PCILB0 as Memory Window */
497 + rc32434_pci->pcilba[0].a = (unsigned int) (PCI_ADDR_START);
499 + /* setup the PCI map address as same as the local address */
501 + rc32434_pci->pcilba[0].m = (unsigned int) (PCI_ADDR_START);
503 + /* Setup PCILBA1 as MEM */
505 + rc32434_pci->pcilba[0].c = ( ((SIZE_16MB & 0x1f) << PCILBAC_size_b) | PCILBAC_sb_m);
507 + rc32434_pci->pcilba[0].c = ( ((SIZE_16MB & 0x1f) << PCILBAC_size_b));
509 + dummyRead = rc32434_pci->pcilba[0].c; /* flush the CPU write Buffers */
511 + rc32434_pci->pcilba[1].a = 0x60000000;
513 + rc32434_pci->pcilba[1].m = 0x60000000;
514 + /* setup PCILBA2 as IO Window*/
516 + rc32434_pci->pcilba[1].c = ( ((SIZE_256MB & 0x1f) << PCILBAC_size_b) | PCILBAC_sb_m);
518 + rc32434_pci->pcilba[1].c = ((SIZE_256MB & 0x1f) << PCILBAC_size_b);
520 + dummyRead = rc32434_pci->pcilba[1].c; /* flush the CPU write Buffers */
521 + rc32434_pci->pcilba[2].a = 0x18C00000;
523 + rc32434_pci->pcilba[2].m = 0x18FFFFFF;
524 + /* setup PCILBA2 as IO Window*/
526 + rc32434_pci->pcilba[2].c = ( ((SIZE_4MB & 0x1f) << PCILBAC_size_b) | PCILBAC_sb_m);
528 + rc32434_pci->pcilba[2].c = ((SIZE_4MB & 0x1f) << PCILBAC_size_b);
531 + dummyRead = rc32434_pci->pcilba[2].c; /* flush the CPU write Buffers */
534 + rc32434_pci->pcilba[3].a = 0x18800000;
536 + rc32434_pci->pcilba[3].m = 0x18800000;
537 + /* Setup PCILBA3 as IO Window */
540 + rc32434_pci->pcilba[3].c = ( (((SIZE_1MB & 0x1ff) << PCILBAC_size_b) | PCILBAC_msi_m) | PCILBAC_sb_m);
542 + rc32434_pci->pcilba[3].c = (((SIZE_1MB & 0x1ff) << PCILBAC_size_b) | PCILBAC_msi_m);
544 + dummyRead = rc32434_pci->pcilba[2].c; /* flush the CPU write Buffers */
546 + pciConfigAddr = (unsigned int)(0x80000004);
547 + for(loopCount = 0; loopCount < 24; loopCount++){
548 + rc32434_pci->pcicfga = pciConfigAddr;
549 + dummyRead = rc32434_pci->pcicfga;
550 + rc32434_pci->pcicfgd = korinaCnfgRegs[loopCount];
551 + dummyRead=rc32434_pci->pcicfgd;
552 + pciConfigAddr += 4;
554 + rc32434_pci->pcitc=(unsigned int)((PCITC_RTIMER_VAL&0xff) << PCITC_rtimer_b) |
555 + ((PCITC_DTIMER_VAL&0xff)<<PCITC_dtimer_b);
557 + pciCntlVal = rc32434_pci->pcic;
558 + pciCntlVal &= ~(PCIC_tnr_m);
559 + rc32434_pci->pcic = pciCntlVal;
560 + pciCntlVal = rc32434_pci->pcic;
562 + register_pci_controller(&rc32434_controller);
568 +arch_initcall(rc32434_pcibridge_init);
570 +/* Do platform specific device initialization at pci_enable_device() time */
571 +int pcibios_plat_dev_init(struct pci_dev *dev)
575 diff -Nur linux-2.6.15/drivers/pci/access.c linux-2.6.15-openwrt/drivers/pci/access.c
576 --- linux-2.6.15/drivers/pci/access.c 2006-01-03 04:21:10.000000000 +0100
577 +++ linux-2.6.15-openwrt/drivers/pci/access.c 2006-01-10 00:43:10.000000000 +0100
579 #define PCI_word_BAD (pos & 1)
580 #define PCI_dword_BAD (pos & 3)
583 #define PCI_OP_READ(size,type,len) \
584 int pci_bus_read_config_##size \
585 (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
587 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
588 spin_lock_irqsave(&pci_lock, flags); \
589 res = bus->ops->read(bus, devfn, pos, len, &data); \
591 + *value = (type)((data >> 24) & 0xff); \
592 + else if (len == 2) \
593 + *value = (type)((data >> 16) & 0xffff); \
595 *value = (type)data; \
596 spin_unlock_irqrestore(&pci_lock, flags); \
601 +#define PCI_OP_READ(size,type,len) \
602 +int pci_bus_read_config_##size \
603 + (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
606 + unsigned long flags; \
608 + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
609 + spin_lock_irqsave(&pci_lock, flags); \
610 + res = bus->ops->read(bus, devfn, pos, len, &data); \
611 + *value = (type)data; \
612 + spin_unlock_irqrestore(&pci_lock, flags); \
616 #define PCI_OP_WRITE(size,type,len) \
617 int pci_bus_write_config_##size \
618 (struct pci_bus *bus, unsigned int devfn, int pos, type value) \