10 #include <linux/kernel.h>
12 #include <linux/pci.h>
22 static int sh7786_pcie_config_access(
unsigned char access_type,
33 if (bus->
number > 255 || dev > 31 || func > 7)
51 if (pci_is_root_bus(bus)) {
54 *data = pci_read_reg(chan,
PCI_REG(reg));
56 pci_write_reg(chan, *data,
PCI_REG(reg));
67 pci_write_reg(chan, (bus->
number << 24) | (dev << 19) |
92 static int sh7786_pcie_read(
struct pci_bus *bus,
unsigned int devfn,
99 if ((size == 2) && (where & 1))
101 else if ((size == 4) && (where & 3))
106 devfn, where, &data);
113 *val = (data >> ((where & 3) << 3)) & 0xff;
115 *val = (data >> ((where & 2) << 3)) & 0xffff;
119 dev_dbg(&bus->
dev,
"pcie-config-read: bus=%3d devfn=0x%04x "
120 "where=0x%04x size=%d val=0x%08lx\n", bus->
number,
121 devfn, where, size, (
unsigned long)*val);
128 static int sh7786_pcie_write(
struct pci_bus *bus,
unsigned int devfn,
129 int where,
int size,
u32 val)
135 if ((size == 2) && (where & 1))
137 else if ((size == 4) && (where & 3))
142 devfn, where, &data);
146 dev_dbg(&bus->
dev,
"pcie-config-write: bus=%3d devfn=0x%04x "
147 "where=0x%04x size=%d val=%08lx\n", bus->
number,
148 devfn, where, size, (
unsigned long)val);
151 shift = (where & 3) << 3;
152 data &= ~(0xff << shift);
153 data |= ((val & 0xff) << shift);
154 }
else if (size == 2) {
155 shift = (where & 2) << 3;
156 data &= ~(0xffff << shift);
157 data |= ((val & 0xffff) << shift);
162 devfn, where, &data);
169 .read = sh7786_pcie_read,
170 .write = sh7786_pcie_write,