2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2000, 2001 Keith M Wesolowski
8 #include <linux/kernel.h>
10 #include <linux/types.h>
12 #include <asm/ip32/mace.h>
15 # define DPRINTK(args...) printk(args);
17 # define DPRINTK(args...)
21 * O2 has up to 5 PCI devices connected into the MACE bridge. The device
22 * map looks like this:
31 static inline int mkaddr(struct pci_bus *bus, unsigned int devfn,
34 return ((bus->number & 0xff) << 16) |
35 ((devfn & 0xff) << 8) |
41 mace_pci_read_config(struct pci_bus *bus, unsigned int devfn,
42 int reg, int size, u32 *val)
44 u32 control = mace->pci.control;
46 /* disable master aborts interrupts during config read */
47 mace->pci.control = control & ~MACEPCI_CONTROL_MAR_INT;
48 mace->pci.config_addr = mkaddr(bus, devfn, reg);
51 *val = mace->pci.config_data.b[(reg & 3) ^ 3];
54 *val = mace->pci.config_data.w[((reg >> 1) & 1) ^ 1];
57 *val = mace->pci.config_data.l;
60 /* ack possible master abort */
61 mace->pci.error &= ~MACEPCI_ERROR_MASTER_ABORT;
62 mace->pci.control = control;
64 * someone forgot to set the ultra bit for the onboard
65 * scsi chips; we fake it here
67 if (bus->number == 0 && reg == 0x40 && size == 4 &&
68 (devfn == (1 << 3) || devfn == (2 << 3)))
71 DPRINTK("read%d: reg=%08x,val=%02x\n", size * 8, reg, *val);
73 return PCIBIOS_SUCCESSFUL;
77 mace_pci_write_config(struct pci_bus *bus, unsigned int devfn,
78 int reg, int size, u32 val)
80 mace->pci.config_addr = mkaddr(bus, devfn, reg);
83 mace->pci.config_data.b[(reg & 3) ^ 3] = val;
86 mace->pci.config_data.w[((reg >> 1) & 1) ^ 1] = val;
89 mace->pci.config_data.l = val;
93 DPRINTK("write%d: reg=%08x,val=%02x\n", size * 8, reg, val);
95 return PCIBIOS_SUCCESSFUL;
98 struct pci_ops mace_pci_ops = {
99 .read = mace_pci_read_config,
100 .write = mace_pci_write_config,