mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 01:54:09 +08:00
Merge branch 'remotes/lorenzo/pci/dwc'
- Add dwc API support to de-initialize host (Vidya Sagar) - Clean up dwc DBI,ATU read and write APIs (Vidya Sagar) - Export dwc APIs to support .remove() so drivers can be modular (Vidya Sagar) - Simplify imx6 Kconfig dependencies (Leonard Crestez) - Fix dra7xx build error when !CONFIG_GPIOLIB (YueHaibing) * remotes/lorenzo/pci/dwc: PCI: dwc: pci-dra7xx: Fix compilation when !CONFIG_GPIOLIB PCI: imx6: Simplify Kconfig depends on PCI: dwc: Export APIs to support .remove() implementation PCI: dwc: Cleanup DBI,ATU read and write APIs PCI: dwc: Add API support to de-initialize host
This commit is contained in:
commit
6c90132f0e
@ -90,7 +90,7 @@ config PCI_EXYNOS
|
|||||||
|
|
||||||
config PCI_IMX6
|
config PCI_IMX6
|
||||||
bool "Freescale i.MX6/7/8 PCIe controller"
|
bool "Freescale i.MX6/7/8 PCIe controller"
|
||||||
depends on SOC_IMX6Q || SOC_IMX7D || (ARM64 && ARCH_MXC) || COMPILE_TEST
|
depends on ARCH_MXC || COMPILE_TEST
|
||||||
depends on PCI_MSI_IRQ_DOMAIN
|
depends on PCI_MSI_IRQ_DOMAIN
|
||||||
select PCIE_DW_HOST
|
select PCIE_DW_HOST
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/mfd/syscon.h>
|
#include <linux/mfd/syscon.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
|
|
||||||
#include "../../pci.h"
|
#include "../../pci.h"
|
||||||
#include "pcie-designware.h"
|
#include "pcie-designware.h"
|
||||||
|
@ -311,6 +311,7 @@ void dw_pcie_msi_init(struct pcie_port *pp)
|
|||||||
dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4,
|
dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_HI, 4,
|
||||||
upper_32_bits(msi_target));
|
upper_32_bits(msi_target));
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dw_pcie_msi_init);
|
||||||
|
|
||||||
int dw_pcie_host_init(struct pcie_port *pp)
|
int dw_pcie_host_init(struct pcie_port *pp)
|
||||||
{
|
{
|
||||||
@ -495,6 +496,16 @@ err_free_msi:
|
|||||||
dw_pcie_free_msi(pp);
|
dw_pcie_free_msi(pp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dw_pcie_host_init);
|
||||||
|
|
||||||
|
void dw_pcie_host_deinit(struct pcie_port *pp)
|
||||||
|
{
|
||||||
|
pci_stop_root_bus(pp->root_bus);
|
||||||
|
pci_remove_root_bus(pp->root_bus);
|
||||||
|
if (pci_msi_enabled() && !pp->ops->msi_host_init)
|
||||||
|
dw_pcie_free_msi(pp);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dw_pcie_host_deinit);
|
||||||
|
|
||||||
static int dw_pcie_access_other_conf(struct pcie_port *pp, struct pci_bus *bus,
|
static int dw_pcie_access_other_conf(struct pcie_port *pp, struct pci_bus *bus,
|
||||||
u32 devfn, int where, int size, u32 *val,
|
u32 devfn, int where, int size, u32 *val,
|
||||||
@ -687,3 +698,4 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
|
|||||||
val |= PORT_LOGIC_SPEED_CHANGE;
|
val |= PORT_LOGIC_SPEED_CHANGE;
|
||||||
dw_pcie_wr_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, val);
|
dw_pcie_wr_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, val);
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dw_pcie_setup_rc);
|
||||||
|
@ -34,6 +34,7 @@ int dw_pcie_read(void __iomem *addr, int size, u32 *val)
|
|||||||
|
|
||||||
return PCIBIOS_SUCCESSFUL;
|
return PCIBIOS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dw_pcie_read);
|
||||||
|
|
||||||
int dw_pcie_write(void __iomem *addr, int size, u32 val)
|
int dw_pcie_write(void __iomem *addr, int size, u32 val)
|
||||||
{
|
{
|
||||||
@ -51,69 +52,97 @@ int dw_pcie_write(void __iomem *addr, int size, u32 val)
|
|||||||
|
|
||||||
return PCIBIOS_SUCCESSFUL;
|
return PCIBIOS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dw_pcie_write);
|
||||||
|
|
||||||
u32 __dw_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg,
|
u32 dw_pcie_read_dbi(struct dw_pcie *pci, u32 reg, size_t size)
|
||||||
size_t size)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
if (pci->ops->read_dbi)
|
if (pci->ops->read_dbi)
|
||||||
return pci->ops->read_dbi(pci, base, reg, size);
|
return pci->ops->read_dbi(pci, pci->dbi_base, reg, size);
|
||||||
|
|
||||||
ret = dw_pcie_read(base + reg, size, &val);
|
ret = dw_pcie_read(pci->dbi_base + reg, size, &val);
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(pci->dev, "Read DBI address failed\n");
|
dev_err(pci->dev, "Read DBI address failed\n");
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dw_pcie_read_dbi);
|
||||||
|
|
||||||
void __dw_pcie_write_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg,
|
void dw_pcie_write_dbi(struct dw_pcie *pci, u32 reg, size_t size, u32 val)
|
||||||
size_t size, u32 val)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (pci->ops->write_dbi) {
|
if (pci->ops->write_dbi) {
|
||||||
pci->ops->write_dbi(pci, base, reg, size, val);
|
pci->ops->write_dbi(pci, pci->dbi_base, reg, size, val);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = dw_pcie_write(base + reg, size, val);
|
ret = dw_pcie_write(pci->dbi_base + reg, size, val);
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(pci->dev, "Write DBI address failed\n");
|
dev_err(pci->dev, "Write DBI address failed\n");
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dw_pcie_write_dbi);
|
||||||
|
|
||||||
u32 __dw_pcie_read_dbi2(struct dw_pcie *pci, void __iomem *base, u32 reg,
|
u32 dw_pcie_read_dbi2(struct dw_pcie *pci, u32 reg, size_t size)
|
||||||
size_t size)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
if (pci->ops->read_dbi2)
|
if (pci->ops->read_dbi2)
|
||||||
return pci->ops->read_dbi2(pci, base, reg, size);
|
return pci->ops->read_dbi2(pci, pci->dbi_base2, reg, size);
|
||||||
|
|
||||||
ret = dw_pcie_read(base + reg, size, &val);
|
ret = dw_pcie_read(pci->dbi_base2 + reg, size, &val);
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(pci->dev, "read DBI address failed\n");
|
dev_err(pci->dev, "read DBI address failed\n");
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __dw_pcie_write_dbi2(struct dw_pcie *pci, void __iomem *base, u32 reg,
|
void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val)
|
||||||
size_t size, u32 val)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (pci->ops->write_dbi2) {
|
if (pci->ops->write_dbi2) {
|
||||||
pci->ops->write_dbi2(pci, base, reg, size, val);
|
pci->ops->write_dbi2(pci, pci->dbi_base2, reg, size, val);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = dw_pcie_write(base + reg, size, val);
|
ret = dw_pcie_write(pci->dbi_base2 + reg, size, val);
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(pci->dev, "write DBI address failed\n");
|
dev_err(pci->dev, "write DBI address failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 dw_pcie_read_atu(struct dw_pcie *pci, u32 reg, size_t size)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
u32 val;
|
||||||
|
|
||||||
|
if (pci->ops->read_dbi)
|
||||||
|
return pci->ops->read_dbi(pci, pci->atu_base, reg, size);
|
||||||
|
|
||||||
|
ret = dw_pcie_read(pci->atu_base + reg, size, &val);
|
||||||
|
if (ret)
|
||||||
|
dev_err(pci->dev, "Read ATU address failed\n");
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dw_pcie_write_atu(struct dw_pcie *pci, u32 reg, size_t size, u32 val)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (pci->ops->write_dbi) {
|
||||||
|
pci->ops->write_dbi(pci, pci->atu_base, reg, size, val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = dw_pcie_write(pci->atu_base + reg, size, val);
|
||||||
|
if (ret)
|
||||||
|
dev_err(pci->dev, "Write ATU address failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
static u32 dw_pcie_readl_ob_unroll(struct dw_pcie *pci, u32 index, u32 reg)
|
static u32 dw_pcie_readl_ob_unroll(struct dw_pcie *pci, u32 index, u32 reg)
|
||||||
{
|
{
|
||||||
u32 offset = PCIE_GET_ATU_OUTB_UNR_REG_OFFSET(index);
|
u32 offset = PCIE_GET_ATU_OUTB_UNR_REG_OFFSET(index);
|
||||||
|
@ -254,14 +254,12 @@ 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_read_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg,
|
u32 dw_pcie_read_dbi(struct dw_pcie *pci, u32 reg, size_t size);
|
||||||
size_t size);
|
void dw_pcie_write_dbi(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
|
||||||
void __dw_pcie_write_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg,
|
u32 dw_pcie_read_dbi2(struct dw_pcie *pci, u32 reg, size_t size);
|
||||||
size_t size, u32 val);
|
void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
|
||||||
u32 __dw_pcie_read_dbi2(struct dw_pcie *pci, void __iomem *base, u32 reg,
|
u32 dw_pcie_read_atu(struct dw_pcie *pci, u32 reg, size_t size);
|
||||||
size_t size);
|
void dw_pcie_write_atu(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
|
||||||
void __dw_pcie_write_dbi2(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,
|
||||||
@ -275,52 +273,52 @@ 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_write_dbi(pci, pci->dbi_base, reg, 0x4, val);
|
dw_pcie_write_dbi(pci, 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_read_dbi(pci, pci->dbi_base, reg, 0x4);
|
return dw_pcie_read_dbi(pci, reg, 0x4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dw_pcie_writew_dbi(struct dw_pcie *pci, u32 reg, u16 val)
|
static inline void dw_pcie_writew_dbi(struct dw_pcie *pci, u32 reg, u16 val)
|
||||||
{
|
{
|
||||||
__dw_pcie_write_dbi(pci, pci->dbi_base, reg, 0x2, val);
|
dw_pcie_write_dbi(pci, reg, 0x2, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u16 dw_pcie_readw_dbi(struct dw_pcie *pci, u32 reg)
|
static inline u16 dw_pcie_readw_dbi(struct dw_pcie *pci, u32 reg)
|
||||||
{
|
{
|
||||||
return __dw_pcie_read_dbi(pci, pci->dbi_base, reg, 0x2);
|
return dw_pcie_read_dbi(pci, reg, 0x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dw_pcie_writeb_dbi(struct dw_pcie *pci, u32 reg, u8 val)
|
static inline void dw_pcie_writeb_dbi(struct dw_pcie *pci, u32 reg, u8 val)
|
||||||
{
|
{
|
||||||
__dw_pcie_write_dbi(pci, pci->dbi_base, reg, 0x1, val);
|
dw_pcie_write_dbi(pci, reg, 0x1, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u8 dw_pcie_readb_dbi(struct dw_pcie *pci, u32 reg)
|
static inline u8 dw_pcie_readb_dbi(struct dw_pcie *pci, u32 reg)
|
||||||
{
|
{
|
||||||
return __dw_pcie_read_dbi(pci, pci->dbi_base, reg, 0x1);
|
return dw_pcie_read_dbi(pci, reg, 0x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dw_pcie_writel_dbi2(struct dw_pcie *pci, u32 reg, u32 val)
|
static inline void dw_pcie_writel_dbi2(struct dw_pcie *pci, u32 reg, u32 val)
|
||||||
{
|
{
|
||||||
__dw_pcie_write_dbi2(pci, pci->dbi_base2, reg, 0x4, val);
|
dw_pcie_write_dbi2(pci, reg, 0x4, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 dw_pcie_readl_dbi2(struct dw_pcie *pci, u32 reg)
|
static inline u32 dw_pcie_readl_dbi2(struct dw_pcie *pci, u32 reg)
|
||||||
{
|
{
|
||||||
return __dw_pcie_read_dbi2(pci, pci->dbi_base2, reg, 0x4);
|
return dw_pcie_read_dbi2(pci, reg, 0x4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dw_pcie_writel_atu(struct dw_pcie *pci, u32 reg, u32 val)
|
static inline void dw_pcie_writel_atu(struct dw_pcie *pci, u32 reg, u32 val)
|
||||||
{
|
{
|
||||||
__dw_pcie_write_dbi(pci, pci->atu_base, reg, 0x4, val);
|
dw_pcie_write_atu(pci, reg, 0x4, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 dw_pcie_readl_atu(struct dw_pcie *pci, u32 reg)
|
static inline u32 dw_pcie_readl_atu(struct dw_pcie *pci, u32 reg)
|
||||||
{
|
{
|
||||||
return __dw_pcie_read_dbi(pci, pci->atu_base, reg, 0x4);
|
return dw_pcie_read_atu(pci, reg, 0x4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dw_pcie_dbi_ro_wr_en(struct dw_pcie *pci)
|
static inline void dw_pcie_dbi_ro_wr_en(struct dw_pcie *pci)
|
||||||
@ -351,6 +349,7 @@ void dw_pcie_msi_init(struct pcie_port *pp);
|
|||||||
void dw_pcie_free_msi(struct pcie_port *pp);
|
void dw_pcie_free_msi(struct pcie_port *pp);
|
||||||
void dw_pcie_setup_rc(struct pcie_port *pp);
|
void dw_pcie_setup_rc(struct pcie_port *pp);
|
||||||
int dw_pcie_host_init(struct pcie_port *pp);
|
int dw_pcie_host_init(struct pcie_port *pp);
|
||||||
|
void dw_pcie_host_deinit(struct pcie_port *pp);
|
||||||
int dw_pcie_allocate_domains(struct pcie_port *pp);
|
int dw_pcie_allocate_domains(struct pcie_port *pp);
|
||||||
#else
|
#else
|
||||||
static inline irqreturn_t dw_handle_msi_irq(struct pcie_port *pp)
|
static inline irqreturn_t dw_handle_msi_irq(struct pcie_port *pp)
|
||||||
@ -375,6 +374,10 @@ static inline int dw_pcie_host_init(struct pcie_port *pp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void dw_pcie_host_deinit(struct pcie_port *pp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static inline int dw_pcie_allocate_domains(struct pcie_port *pp)
|
static inline int dw_pcie_allocate_domains(struct pcie_port *pp)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user