Skip to content

Commit

Permalink
PCI: ftpci100: Use PCI_CONF1_ADDRESS() macro
Browse files Browse the repository at this point in the history
Simplify pci-ftpci100.c driver code and use new PCI_CONF1_ADDRESS() macro
for accessing PCI config space.

Link: https://lore.kernel.org/r/20220924092404.31776-3-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
  • Loading branch information
Pali Rohár authored and Lorenzo Pieralisi committed Sep 27, 2022
1 parent 8a9b7ef commit f75a27d
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions drivers/pci/controller/pci-ftpci100.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@
#define FARADAY_PCI_DMA_MEM2_BASE 0x00000000
#define FARADAY_PCI_DMA_MEM3_BASE 0x00000000

/* Defines for PCI configuration command register */
#define PCI_CONF_ENABLE BIT(31)
#define PCI_CONF_WHERE(r) ((r) & 0xFC)
#define PCI_CONF_BUS(b) (((b) & 0xFF) << 16)
#define PCI_CONF_DEVICE(d) (((d) & 0x1F) << 11)
#define PCI_CONF_FUNCTION(f) (((f) & 0x07) << 8)

/**
* struct faraday_pci_variant - encodes IP block differences
* @cascaded_irq: this host has cascaded IRQs from an interrupt controller
Expand Down Expand Up @@ -190,11 +183,8 @@ static int faraday_raw_pci_read_config(struct faraday_pci *p, int bus_number,
unsigned int fn, int config, int size,
u32 *value)
{
writel(PCI_CONF_BUS(bus_number) |
PCI_CONF_DEVICE(PCI_SLOT(fn)) |
PCI_CONF_FUNCTION(PCI_FUNC(fn)) |
PCI_CONF_WHERE(config) |
PCI_CONF_ENABLE,
writel(PCI_CONF1_ADDRESS(bus_number, PCI_SLOT(fn),
PCI_FUNC(fn), config),
p->base + FTPCI_CONFIG);

*value = readl(p->base + FTPCI_DATA);
Expand Down Expand Up @@ -225,11 +215,8 @@ static int faraday_raw_pci_write_config(struct faraday_pci *p, int bus_number,
{
int ret = PCIBIOS_SUCCESSFUL;

writel(PCI_CONF_BUS(bus_number) |
PCI_CONF_DEVICE(PCI_SLOT(fn)) |
PCI_CONF_FUNCTION(PCI_FUNC(fn)) |
PCI_CONF_WHERE(config) |
PCI_CONF_ENABLE,
writel(PCI_CONF1_ADDRESS(bus_number, PCI_SLOT(fn),
PCI_FUNC(fn), config),
p->base + FTPCI_CONFIG);

switch (size) {
Expand Down

0 comments on commit f75a27d

Please sign in to comment.