Commit a509d7d9 authored by Kishon Vijay Abraham I's avatar Kishon Vijay Abraham I Committed by Bjorn Helgaas

PCI: dwc: all: Modify dbi accessors to access data of 4/2/1 bytes

Previously dbi accessors can be used to access data of size 4 bytes. But
there might be situations (like accessing MSI_MESSAGE_CONTROL in order to
set/get the number of required MSI interrupts in EP mode) where dbi
accessors must be used to access data of size 2. This is in preparation
for adding endpoint mode support to designware driver.
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarNiklas Cassel <niklas.cassel@axis.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Joao Pinto <Joao.Pinto@synopsys.com>
parent b50b2db2
...@@ -521,25 +521,25 @@ static void exynos_pcie_enable_interrupts(struct exynos_pcie *ep) ...@@ -521,25 +521,25 @@ static void exynos_pcie_enable_interrupts(struct exynos_pcie *ep)
exynos_pcie_msi_init(ep); exynos_pcie_msi_init(ep);
} }
static u32 exynos_pcie_readl_dbi(struct dw_pcie *pci, void __iomem *base, static u32 exynos_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base,
u32 reg) u32 reg, size_t size)
{ {
struct exynos_pcie *ep = to_exynos_pcie(pci); struct exynos_pcie *ep = to_exynos_pcie(pci);
u32 val; u32 val;
exynos_pcie_sideband_dbi_r_mode(ep, true); exynos_pcie_sideband_dbi_r_mode(ep, true);
val = readl(base + reg); dw_pcie_read(base + reg, size, &val);
exynos_pcie_sideband_dbi_r_mode(ep, false); exynos_pcie_sideband_dbi_r_mode(ep, false);
return val; return val;
} }
static void exynos_pcie_writel_dbi(struct dw_pcie *pci, void __iomem *base, static void exynos_pcie_write_dbi(struct dw_pcie *pci, void __iomem *base,
u32 reg, u32 val) u32 reg, size_t size, u32 val)
{ {
struct exynos_pcie *ep = to_exynos_pcie(pci); struct exynos_pcie *ep = to_exynos_pcie(pci);
exynos_pcie_sideband_dbi_w_mode(ep, true); exynos_pcie_sideband_dbi_w_mode(ep, true);
writel(val, base + reg); dw_pcie_write(base + reg, size, val);
exynos_pcie_sideband_dbi_w_mode(ep, false); exynos_pcie_sideband_dbi_w_mode(ep, false);
} }
...@@ -646,8 +646,8 @@ static int __init exynos_add_pcie_port(struct exynos_pcie *ep, ...@@ -646,8 +646,8 @@ static int __init exynos_add_pcie_port(struct exynos_pcie *ep,
} }
static const struct dw_pcie_ops dw_pcie_ops = { static const struct dw_pcie_ops dw_pcie_ops = {
.readl_dbi = exynos_pcie_readl_dbi, .read_dbi = exynos_pcie_read_dbi,
.writel_dbi = exynos_pcie_writel_dbi, .write_dbi = exynos_pcie_write_dbi,
.link_up = exynos_pcie_link_up, .link_up = exynos_pcie_link_up,
}; };
......
...@@ -61,21 +61,35 @@ int dw_pcie_write(void __iomem *addr, int size, u32 val) ...@@ -61,21 +61,35 @@ int dw_pcie_write(void __iomem *addr, int size, u32 val)
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
u32 __dw_pcie_readl_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg) u32 __dw_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg,
size_t size)
{ {
if (pci->ops->readl_dbi) int ret;
return pci->ops->readl_dbi(pci, base, reg); u32 val;
return readl(base + reg); if (pci->ops->read_dbi)
return pci->ops->read_dbi(pci, base, reg, size);
ret = dw_pcie_read(base + reg, size, &val);
if (ret)
dev_err(pci->dev, "read DBI address failed\n");
return val;
} }
void __dw_pcie_writel_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg, void __dw_pcie_write_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg,
u32 val) size_t size, u32 val)
{ {
if (pci->ops->writel_dbi) int ret;
pci->ops->writel_dbi(pci, base, reg, val);
else if (pci->ops->write_dbi) {
writel(val, base + reg); pci->ops->write_dbi(pci, base, reg, size, val);
return;
}
ret = dw_pcie_write(base + reg, size, val);
if (ret)
dev_err(pci->dev, "write DBI address failed\n");
} }
static u32 dw_pcie_readl_unroll(struct dw_pcie *pci, u32 index, u32 reg) static u32 dw_pcie_readl_unroll(struct dw_pcie *pci, u32 index, u32 reg)
......
...@@ -144,9 +144,10 @@ struct pcie_port { ...@@ -144,9 +144,10 @@ struct pcie_port {
struct dw_pcie_ops { struct dw_pcie_ops {
u64 (*cpu_addr_fixup)(u64 cpu_addr); u64 (*cpu_addr_fixup)(u64 cpu_addr);
u32 (*readl_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg); u32 (*read_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg,
void (*writel_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg, size_t size);
u32 val); void (*write_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg,
size_t size, u32 val);
int (*link_up)(struct dw_pcie *pcie); int (*link_up)(struct dw_pcie *pcie);
}; };
...@@ -164,9 +165,10 @@ struct dw_pcie { ...@@ -164,9 +165,10 @@ struct dw_pcie {
int dw_pcie_read(void __iomem *addr, int size, u32 *val); int dw_pcie_read(void __iomem *addr, int size, u32 *val);
int dw_pcie_write(void __iomem *addr, int size, u32 val); int dw_pcie_write(void __iomem *addr, int size, u32 val);
u32 __dw_pcie_readl_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg); u32 __dw_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg,
void __dw_pcie_writel_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg, size_t size);
u32 val); void __dw_pcie_write_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg,
size_t size, u32 val);
int dw_pcie_link_up(struct dw_pcie *pci); int dw_pcie_link_up(struct dw_pcie *pci);
int dw_pcie_wait_for_link(struct dw_pcie *pci); int dw_pcie_wait_for_link(struct dw_pcie *pci);
void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index,
...@@ -176,12 +178,12 @@ void dw_pcie_setup(struct dw_pcie *pci); ...@@ -176,12 +178,12 @@ void dw_pcie_setup(struct dw_pcie *pci);
static inline void dw_pcie_writel_dbi(struct dw_pcie *pci, u32 reg, u32 val) static inline void dw_pcie_writel_dbi(struct dw_pcie *pci, u32 reg, u32 val)
{ {
__dw_pcie_writel_dbi(pci, pci->dbi_base, reg, val); __dw_pcie_write_dbi(pci, pci->dbi_base, reg, 0x4, val);
} }
static inline u32 dw_pcie_readl_dbi(struct dw_pcie *pci, u32 reg) static inline u32 dw_pcie_readl_dbi(struct dw_pcie *pci, u32 reg)
{ {
return __dw_pcie_readl_dbi(pci, pci->dbi_base, reg); return __dw_pcie_read_dbi(pci, pci->dbi_base, reg, 0x4);
} }
#ifdef CONFIG_PCIE_DW_HOST #ifdef CONFIG_PCIE_DW_HOST
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment