mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
PCI: designware: Wait for link to come up with consistent style
All the DesignWare-based host drivers loop waiting for the link to come up, but they do it several ways that are needlessly different. Wait for the link to come up in a consistent style across all the DesignWare drivers. No functional change. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
This commit is contained in:
parent
1d3f9bac71
commit
6cbb247e85
6 changed files with 51 additions and 66 deletions
|
@ -93,9 +93,9 @@ static int dra7xx_pcie_link_up(struct pcie_port *pp)
|
||||||
|
|
||||||
static int dra7xx_pcie_establish_link(struct pcie_port *pp)
|
static int dra7xx_pcie_establish_link(struct pcie_port *pp)
|
||||||
{
|
{
|
||||||
u32 reg;
|
|
||||||
unsigned int retries = 1000;
|
|
||||||
struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
|
struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
|
||||||
|
u32 reg;
|
||||||
|
unsigned int retries;
|
||||||
|
|
||||||
if (dw_pcie_link_up(pp)) {
|
if (dw_pcie_link_up(pp)) {
|
||||||
dev_err(pp->dev, "link is already up\n");
|
dev_err(pp->dev, "link is already up\n");
|
||||||
|
@ -106,18 +106,14 @@ static int dra7xx_pcie_establish_link(struct pcie_port *pp)
|
||||||
reg |= LTSSM_EN;
|
reg |= LTSSM_EN;
|
||||||
dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
|
dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
|
||||||
|
|
||||||
while (retries--) {
|
for (retries = 0; retries < 1000; retries++) {
|
||||||
if (dw_pcie_link_up(pp))
|
if (dw_pcie_link_up(pp))
|
||||||
break;
|
return 0;
|
||||||
usleep_range(10, 20);
|
usleep_range(10, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retries == 0) {
|
|
||||||
dev_err(pp->dev, "link is not up\n");
|
dev_err(pp->dev, "link is not up\n");
|
||||||
return -ETIMEDOUT;
|
return -EINVAL;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dra7xx_pcie_enable_interrupts(struct pcie_port *pp)
|
static void dra7xx_pcie_enable_interrupts(struct pcie_port *pp)
|
||||||
|
|
|
@ -316,9 +316,9 @@ static void exynos_pcie_assert_reset(struct pcie_port *pp)
|
||||||
|
|
||||||
static int exynos_pcie_establish_link(struct pcie_port *pp)
|
static int exynos_pcie_establish_link(struct pcie_port *pp)
|
||||||
{
|
{
|
||||||
u32 val;
|
|
||||||
int count = 0;
|
|
||||||
struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
|
struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
|
||||||
|
u32 val;
|
||||||
|
unsigned int retries;
|
||||||
|
|
||||||
if (dw_pcie_link_up(pp)) {
|
if (dw_pcie_link_up(pp)) {
|
||||||
dev_err(pp->dev, "Link already up\n");
|
dev_err(pp->dev, "Link already up\n");
|
||||||
|
@ -357,14 +357,16 @@ static int exynos_pcie_establish_link(struct pcie_port *pp)
|
||||||
PCIE_APP_LTSSM_ENABLE);
|
PCIE_APP_LTSSM_ENABLE);
|
||||||
|
|
||||||
/* check if the link is up or not */
|
/* check if the link is up or not */
|
||||||
while (!dw_pcie_link_up(pp)) {
|
for (retries = 0; retries < 10; retries++) {
|
||||||
|
if (dw_pcie_link_up(pp)) {
|
||||||
|
dev_info(pp->dev, "Link up\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
mdelay(100);
|
mdelay(100);
|
||||||
count++;
|
}
|
||||||
if (count == 10) {
|
|
||||||
while (exynos_phy_readl(exynos_pcie,
|
while (exynos_phy_readl(exynos_pcie, PCIE_PHY_PLL_LOCKED) == 0) {
|
||||||
PCIE_PHY_PLL_LOCKED) == 0) {
|
val = exynos_blk_readl(exynos_pcie, PCIE_PHY_PLL_LOCKED);
|
||||||
val = exynos_blk_readl(exynos_pcie,
|
|
||||||
PCIE_PHY_PLL_LOCKED);
|
|
||||||
dev_info(pp->dev, "PLL Locked: 0x%x\n", val);
|
dev_info(pp->dev, "PLL Locked: 0x%x\n", val);
|
||||||
}
|
}
|
||||||
/* power off phy */
|
/* power off phy */
|
||||||
|
@ -372,12 +374,6 @@ static int exynos_pcie_establish_link(struct pcie_port *pp)
|
||||||
|
|
||||||
dev_err(pp->dev, "PCIe Link Fail\n");
|
dev_err(pp->dev, "PCIe Link Fail\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_info(pp->dev, "Link up\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void exynos_pcie_clear_irq_pulse(struct pcie_port *pp)
|
static void exynos_pcie_clear_irq_pulse(struct pcie_port *pp)
|
||||||
|
|
|
@ -335,21 +335,19 @@ static void imx6_pcie_init_phy(struct pcie_port *pp)
|
||||||
|
|
||||||
static int imx6_pcie_wait_for_link(struct pcie_port *pp)
|
static int imx6_pcie_wait_for_link(struct pcie_port *pp)
|
||||||
{
|
{
|
||||||
int count = 200;
|
unsigned int retries;
|
||||||
|
|
||||||
while (!dw_pcie_link_up(pp)) {
|
for (retries = 0; retries < 200; retries++) {
|
||||||
|
if (dw_pcie_link_up(pp))
|
||||||
|
return 0;
|
||||||
usleep_range(100, 1000);
|
usleep_range(100, 1000);
|
||||||
if (--count)
|
}
|
||||||
continue;
|
|
||||||
|
|
||||||
dev_err(pp->dev, "phy link never came up\n");
|
dev_err(pp->dev, "phy link never came up\n");
|
||||||
dev_dbg(pp->dev, "DEBUG_R0: 0x%08x, DEBUG_R1: 0x%08x\n",
|
dev_dbg(pp->dev, "DEBUG_R0: 0x%08x, DEBUG_R1: 0x%08x\n",
|
||||||
readl(pp->dbi_base + PCIE_PHY_DEBUG_R0),
|
readl(pp->dbi_base + PCIE_PHY_DEBUG_R0),
|
||||||
readl(pp->dbi_base + PCIE_PHY_DEBUG_R1));
|
readl(pp->dbi_base + PCIE_PHY_DEBUG_R1));
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static irqreturn_t imx6_pcie_msi_handler(int irq, void *arg)
|
static irqreturn_t imx6_pcie_msi_handler(int irq, void *arg)
|
||||||
|
|
|
@ -88,7 +88,7 @@ DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, quirk_limit_mrrs);
|
||||||
static int ks_pcie_establish_link(struct keystone_pcie *ks_pcie)
|
static int ks_pcie_establish_link(struct keystone_pcie *ks_pcie)
|
||||||
{
|
{
|
||||||
struct pcie_port *pp = &ks_pcie->pp;
|
struct pcie_port *pp = &ks_pcie->pp;
|
||||||
int count = 200;
|
unsigned int retries;
|
||||||
|
|
||||||
dw_pcie_setup_rc(pp);
|
dw_pcie_setup_rc(pp);
|
||||||
|
|
||||||
|
@ -99,17 +99,15 @@ static int ks_pcie_establish_link(struct keystone_pcie *ks_pcie)
|
||||||
|
|
||||||
ks_dw_pcie_initiate_link_train(ks_pcie);
|
ks_dw_pcie_initiate_link_train(ks_pcie);
|
||||||
/* check if the link is up or not */
|
/* check if the link is up or not */
|
||||||
while (!dw_pcie_link_up(pp)) {
|
for (retries = 0; retries < 200; retries++) {
|
||||||
|
if (dw_pcie_link_up(pp))
|
||||||
|
return 0;
|
||||||
usleep_range(100, 1000);
|
usleep_range(100, 1000);
|
||||||
if (--count) {
|
|
||||||
ks_dw_pcie_initiate_link_train(ks_pcie);
|
ks_dw_pcie_initiate_link_train(ks_pcie);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
dev_err(pp->dev, "phy link never came up\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
dev_err(pp->dev, "phy link never came up\n");
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ks_pcie_msi_irq_handler(unsigned int irq, struct irq_desc *desc)
|
static void ks_pcie_msi_irq_handler(unsigned int irq, struct irq_desc *desc)
|
||||||
|
|
|
@ -64,18 +64,16 @@ static int ls_pcie_link_up(struct pcie_port *pp)
|
||||||
|
|
||||||
static int ls_pcie_establish_link(struct pcie_port *pp)
|
static int ls_pcie_establish_link(struct pcie_port *pp)
|
||||||
{
|
{
|
||||||
int count = 0;
|
unsigned int retries;
|
||||||
|
|
||||||
while (!dw_pcie_link_up(pp)) {
|
for (retries = 0; retries < 200; retries++) {
|
||||||
|
if (dw_pcie_link_up(pp))
|
||||||
|
return 0;
|
||||||
usleep_range(100, 1000);
|
usleep_range(100, 1000);
|
||||||
count++;
|
}
|
||||||
if (count >= 200) {
|
|
||||||
dev_err(pp->dev, "phy link never came up\n");
|
dev_err(pp->dev, "phy link never came up\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ls_pcie_host_init(struct pcie_port *pp)
|
static void ls_pcie_host_init(struct pcie_port *pp)
|
||||||
|
|
|
@ -146,10 +146,10 @@ struct pcie_app_reg {
|
||||||
static int spear13xx_pcie_establish_link(struct pcie_port *pp)
|
static int spear13xx_pcie_establish_link(struct pcie_port *pp)
|
||||||
{
|
{
|
||||||
u32 val;
|
u32 val;
|
||||||
int count = 0;
|
|
||||||
struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pp);
|
struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pp);
|
||||||
struct pcie_app_reg *app_reg = spear13xx_pcie->app_base;
|
struct pcie_app_reg *app_reg = spear13xx_pcie->app_base;
|
||||||
u32 exp_cap_off = EXP_CAP_ID_OFFSET;
|
u32 exp_cap_off = EXP_CAP_ID_OFFSET;
|
||||||
|
unsigned int retries;
|
||||||
|
|
||||||
if (dw_pcie_link_up(pp)) {
|
if (dw_pcie_link_up(pp)) {
|
||||||
dev_err(pp->dev, "link already up\n");
|
dev_err(pp->dev, "link already up\n");
|
||||||
|
@ -201,17 +201,16 @@ static int spear13xx_pcie_establish_link(struct pcie_port *pp)
|
||||||
&app_reg->app_ctrl_0);
|
&app_reg->app_ctrl_0);
|
||||||
|
|
||||||
/* check if the link is up or not */
|
/* check if the link is up or not */
|
||||||
while (!dw_pcie_link_up(pp)) {
|
for (retries = 0; retries < 10; retries++) {
|
||||||
|
if (dw_pcie_link_up(pp)) {
|
||||||
|
dev_info(pp->dev, "link up\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
mdelay(100);
|
mdelay(100);
|
||||||
count++;
|
}
|
||||||
if (count == 10) {
|
|
||||||
dev_err(pp->dev, "link Fail\n");
|
dev_err(pp->dev, "link Fail\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
}
|
|
||||||
dev_info(pp->dev, "link up\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static irqreturn_t spear13xx_pcie_irq_handler(int irq, void *arg)
|
static irqreturn_t spear13xx_pcie_irq_handler(int irq, void *arg)
|
||||||
|
|
Loading…
Reference in a new issue