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>
9 #include <linux/init.h>
10 #include <linux/pci.h>
11 #include <linux/types.h>
13 #include <asm/ip32/mace.h>
16 # define DPRINTK(args...) printk(args);
18 # define DPRINTK(args...)
22 * O2 has up to 5 PCI devices connected into the MACE bridge. The device
23 * map looks like this:
32 static inline int mkaddr(struct pci_bus
*bus
, unsigned int devfn
,
35 return ((bus
->number
& 0xff) << 16) |
36 ((devfn
& 0xff) << 8) |
42 mace_pci_read_config(struct pci_bus
*bus
, unsigned int devfn
,
43 int reg
, int size
, u32
*val
)
45 u32 control
= mace
->pci
.control
;
47 /* disable master aborts interrupts during config read */
48 mace
->pci
.control
= control
& ~MACEPCI_CONTROL_MAR_INT
;
49 mace
->pci
.config_addr
= mkaddr(bus
, devfn
, reg
);
52 *val
= mace
->pci
.config_data
.b
[(reg
& 3) ^ 3];
55 *val
= mace
->pci
.config_data
.w
[((reg
>> 1) & 1) ^ 1];
58 *val
= mace
->pci
.config_data
.l
;
61 /* ack possible master abort */
62 mace
->pci
.error
&= ~MACEPCI_ERROR_MASTER_ABORT
;
63 mace
->pci
.control
= control
;
65 DPRINTK("read%d: reg=%08x,val=%02x\n", size
* 8, reg
, *val
);
67 return PCIBIOS_SUCCESSFUL
;
71 mace_pci_write_config(struct pci_bus
*bus
, unsigned int devfn
,
72 int reg
, int size
, u32 val
)
74 mace
->pci
.config_addr
= mkaddr(bus
, devfn
, reg
);
77 mace
->pci
.config_data
.b
[(reg
& 3) ^ 3] = val
;
80 mace
->pci
.config_data
.w
[((reg
>> 1) & 1) ^ 1] = val
;
83 mace
->pci
.config_data
.l
= val
;
87 DPRINTK("write%d: reg=%08x,val=%02x\n", size
* 8, reg
, val
);
89 return PCIBIOS_SUCCESSFUL
;
92 struct pci_ops mace_pci_ops
= {
93 .read
= mace_pci_read_config
,
94 .write
= mace_pci_write_config
,