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 #define chkslot(_bus,_devfn) \
34 if ((_bus)->number > 0 || PCI_SLOT (_devfn) < 1 \
35 || PCI_SLOT (_devfn) > 3) \
36 return PCIBIOS_DEVICE_NOT_FOUND; \
39 #define mkaddr(_devfn, _reg) \
40 ((((_devfn) & 0xffUL) << 8) | ((_reg) & 0xfcUL))
43 mace_pci_read_config(struct pci_bus
*bus
, unsigned int devfn
,
44 int reg
, int size
, u32
*val
)
47 mace
->pci
.config_addr
= mkaddr(devfn
, reg
);
50 *val
= mace
->pci
.config_data
.b
[(reg
& 3) ^ 3];
53 *val
= mace
->pci
.config_data
.w
[((reg
>> 1) & 1) ^ 1];
56 *val
= mace
->pci
.config_data
.l
;
60 DPRINTK("read%d: reg=%08x,val=%02x\n", size
* 8, reg
, *val
);
62 return PCIBIOS_SUCCESSFUL
;
66 mace_pci_write_config(struct pci_bus
*bus
, unsigned int devfn
,
67 int reg
, int size
, u32 val
)
70 mace
->pci
.config_addr
= mkaddr(devfn
, reg
);
73 mace
->pci
.config_data
.b
[(reg
& 3) ^ 3] = val
;
76 mace
->pci
.config_data
.w
[((reg
>> 1) & 1) ^ 1] = val
;
79 mace
->pci
.config_data
.l
= val
;
83 DPRINTK("write%d: reg=%08x,val=%02x\n", size
* 8, reg
, val
);
85 return PCIBIOS_SUCCESSFUL
;
88 struct pci_ops mace_pci_ops
= {
89 .read
= mace_pci_read_config
,
90 .write
= mace_pci_write_config
,