123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #include <linux/kernel.h>
- #include <linux/pci.h>
- #include <linux/types.h>
- #include <asm/ip32/mace.h>
- #if 0
- # define DPRINTK(args...) printk(args);
- #else
- # define DPRINTK(args...)
- #endif
- static inline int mkaddr(struct pci_bus *bus, unsigned int devfn,
- unsigned int reg)
- {
- return ((bus->number & 0xff) << 16) |
- ((devfn & 0xff) << 8) |
- (reg & 0xfc);
- }
- static int
- mace_pci_read_config(struct pci_bus *bus, unsigned int devfn,
- int reg, int size, u32 *val)
- {
- u32 control = mace->pci.control;
-
- mace->pci.control = control & ~MACEPCI_CONTROL_MAR_INT;
- mace->pci.config_addr = mkaddr(bus, devfn, reg);
- switch (size) {
- case 1:
- *val = mace->pci.config_data.b[(reg & 3) ^ 3];
- break;
- case 2:
- *val = mace->pci.config_data.w[((reg >> 1) & 1) ^ 1];
- break;
- case 4:
- *val = mace->pci.config_data.l;
- break;
- }
-
- mace->pci.error &= ~MACEPCI_ERROR_MASTER_ABORT;
- mace->pci.control = control;
-
- if (bus->number == 0 && reg == 0x40 && size == 4 &&
- (devfn == (1 << 3) || devfn == (2 << 3)))
- *val |= 0x1000;
- DPRINTK("read%d: reg=%08x,val=%02x\n", size * 8, reg, *val);
- return PCIBIOS_SUCCESSFUL;
- }
- static int
- mace_pci_write_config(struct pci_bus *bus, unsigned int devfn,
- int reg, int size, u32 val)
- {
- mace->pci.config_addr = mkaddr(bus, devfn, reg);
- switch (size) {
- case 1:
- mace->pci.config_data.b[(reg & 3) ^ 3] = val;
- break;
- case 2:
- mace->pci.config_data.w[((reg >> 1) & 1) ^ 1] = val;
- break;
- case 4:
- mace->pci.config_data.l = val;
- break;
- }
- DPRINTK("write%d: reg=%08x,val=%02x\n", size * 8, reg, val);
- return PCIBIOS_SUCCESSFUL;
- }
- struct pci_ops mace_pci_ops = {
- .read = mace_pci_read_config,
- .write = mace_pci_write_config,
- };
|