Skip to content

Commit 802b7c0

Browse files
robherringbjorn-helgaas
authored andcommitted
ARM: cns3xxx: Convert PCI to use generic config accessors
Convert the cns3xxx PCI driver to use the generic config access functions. This changes accesses from __raw_readl/__raw_writel to readl/writel. [arnd: remove extra open parenthesis] Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Krzysztof Hałasa <khalasa@piap.pl> CC: Russell King <linux@arm.linux.org.uk> CC: linux-arm-kernel@lists.infradead.org
1 parent 1f94a94 commit 802b7c0

File tree

1 file changed

+10
-42
lines changed

1 file changed

+10
-42
lines changed

arch/arm/mach-cns3xxx/pcie.c

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ static struct cns3xxx_pcie *pbus_to_cnspci(struct pci_bus *bus)
5454
return sysdata_to_cnspci(bus->sysdata);
5555
}
5656

57-
static void __iomem *cns3xxx_pci_cfg_base(struct pci_bus *bus,
58-
unsigned int devfn, int where)
57+
static void __iomem *cns3xxx_pci_map_bus(struct pci_bus *bus,
58+
unsigned int devfn, int where)
5959
{
6060
struct cns3xxx_pcie *cnspci = pbus_to_cnspci(bus);
6161
int busno = bus->number;
@@ -91,55 +91,22 @@ static void __iomem *cns3xxx_pci_cfg_base(struct pci_bus *bus,
9191
static int cns3xxx_pci_read_config(struct pci_bus *bus, unsigned int devfn,
9292
int where, int size, u32 *val)
9393
{
94-
u32 v;
95-
void __iomem *base;
94+
int ret;
9695
u32 mask = (0x1ull << (size * 8)) - 1;
9796
int shift = (where % 4) * 8;
9897

99-
base = cns3xxx_pci_cfg_base(bus, devfn, where);
100-
if (!base) {
101-
*val = 0xffffffff;
102-
return PCIBIOS_SUCCESSFUL;
103-
}
104-
105-
v = __raw_readl(base);
98+
ret = pci_generic_config_read32(bus, devfn, where, size, val);
10699

107-
if (bus->number == 0 && devfn == 0 &&
108-
(where & 0xffc) == PCI_CLASS_REVISION) {
100+
if (ret == PCIBIOS_SUCCESSFUL && !bus->number && !devfn &&
101+
(where & 0xffc) == PCI_CLASS_REVISION)
109102
/*
110103
* RC's class is 0xb, but Linux PCI driver needs 0x604
111104
* for a PCIe bridge. So we must fixup the class code
112105
* to 0x604 here.
113106
*/
114-
v &= 0xff;
115-
v |= 0x604 << 16;
116-
}
117-
118-
*val = (v >> shift) & mask;
119-
120-
return PCIBIOS_SUCCESSFUL;
121-
}
122-
123-
static int cns3xxx_pci_write_config(struct pci_bus *bus, unsigned int devfn,
124-
int where, int size, u32 val)
125-
{
126-
u32 v;
127-
void __iomem *base;
128-
u32 mask = (0x1ull << (size * 8)) - 1;
129-
int shift = (where % 4) * 8;
130-
131-
base = cns3xxx_pci_cfg_base(bus, devfn, where);
132-
if (!base)
133-
return PCIBIOS_SUCCESSFUL;
134-
135-
v = __raw_readl(base);
136-
137-
v &= ~(mask << shift);
138-
v |= (val & mask) << shift;
139-
140-
__raw_writel(v, base);
107+
*val = ((((*val << shift) & 0xff) | (0x604 << 16)) >> shift) & mask;
141108

142-
return PCIBIOS_SUCCESSFUL;
109+
return ret;
143110
}
144111

145112
static int cns3xxx_pci_setup(int nr, struct pci_sys_data *sys)
@@ -158,8 +125,9 @@ static int cns3xxx_pci_setup(int nr, struct pci_sys_data *sys)
158125
}
159126

160127
static struct pci_ops cns3xxx_pcie_ops = {
128+
.map_bus = cns3xxx_pci_map_bus,
161129
.read = cns3xxx_pci_read_config,
162-
.write = cns3xxx_pci_write_config,
130+
.write = pci_generic_config_write,
163131
};
164132

165133
static int cns3xxx_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)

0 commit comments

Comments
 (0)