public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include
@ 2015-03-11 11:09 Minghuan Lian
  2015-03-11 11:09 ` [U-Boot] [PATCH 2/2] pci/layerscape: fix link and class issues to support ls2085a Minghuan Lian
  2015-03-11 14:22 ` [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Minghuan Lian @ 2015-03-11 11:09 UTC (permalink / raw)
  To: u-boot

The patch moves pcie_layerscape.h out of arm include to top
level include folder so that it can be shared on other Socs.

Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
---
 arch/arm/include/asm/pcie_layerscape.h  | 13 -------------
 board/freescale/ls1021atwr/ls1021atwr.c |  3 ++-
 drivers/pci/pcie_layerscape.c           |  2 +-
 include/pcie_layerscape.h               | 13 +++++++++++++
 4 files changed, 16 insertions(+), 15 deletions(-)
 delete mode 100644 arch/arm/include/asm/pcie_layerscape.h
 create mode 100644 include/pcie_layerscape.h

diff --git a/arch/arm/include/asm/pcie_layerscape.h b/arch/arm/include/asm/pcie_layerscape.h
deleted file mode 100644
index fb08578..0000000
--- a/arch/arm/include/asm/pcie_layerscape.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright 2014 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#ifndef __PCIE_LAYERSCAPE_H_
-#define __PCIE_LAYERSCAPE_H_
-
-void pci_init_board(void);
-void ft_pcie_setup(void *blob, bd_t *bd);
-
-#endif
diff --git a/board/freescale/ls1021atwr/ls1021atwr.c b/board/freescale/ls1021atwr/ls1021atwr.c
index fb8525f..2d5c29c 100644
--- a/board/freescale/ls1021atwr/ls1021atwr.c
+++ b/board/freescale/ls1021atwr/ls1021atwr.c
@@ -12,7 +12,6 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/fsl_serdes.h>
 #include <asm/arch/ls102xa_stream_id.h>
-#include <asm/pcie_layerscape.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
 #include <fsl_ifc.h>
@@ -21,6 +20,8 @@
 #include <tsec.h>
 #include <fsl_sec.h>
 #include <spl.h>
+#include <pcie_layerscape.h>
+
 #ifdef CONFIG_U_QE
 #include "../../../drivers/qe/qe.h"
 #endif
diff --git a/drivers/pci/pcie_layerscape.c b/drivers/pci/pcie_layerscape.c
index bcad8f2..15e3546 100644
--- a/drivers/pci/pcie_layerscape.c
+++ b/drivers/pci/pcie_layerscape.c
@@ -11,7 +11,7 @@
 #include <asm/io.h>
 #include <errno.h>
 #include <malloc.h>
-#include <asm/pcie_layerscape.h>
+#include <pcie_layerscape.h>
 
 #ifndef CONFIG_SYS_PCI_MEMORY_BUS
 #define CONFIG_SYS_PCI_MEMORY_BUS CONFIG_SYS_SDRAM_BASE
diff --git a/include/pcie_layerscape.h b/include/pcie_layerscape.h
new file mode 100644
index 0000000..fb08578
--- /dev/null
+++ b/include/pcie_layerscape.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __PCIE_LAYERSCAPE_H_
+#define __PCIE_LAYERSCAPE_H_
+
+void pci_init_board(void);
+void ft_pcie_setup(void *blob, bd_t *bd);
+
+#endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 2/2] pci/layerscape: fix link and class issues to support ls2085a
  2015-03-11 11:09 [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include Minghuan Lian
@ 2015-03-11 11:09 ` Minghuan Lian
  2015-03-11 14:22 ` [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Minghuan Lian @ 2015-03-11 11:09 UTC (permalink / raw)
  To: u-boot

1. LS2085a provides PCIE_LUT_DBG register rather than PCIE_LDBG
   to show the link status, so the patch fixes it.
2. Increase the delay time to make sure that link training
   has finished.
3. Return invalid value when accessing multi-function device
4. For LS2085a DBI_RO_WR_EN bit is cleared as default, so we
   must set this bit before change DBI register value.

Signed-off-by: Roy Zang <tie-fei.zang@freescale.com>
Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
---
 drivers/pci/pcie_layerscape.c | 47 ++++++++++++++++++++++++++++++-------------
 1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/drivers/pci/pcie_layerscape.c b/drivers/pci/pcie_layerscape.c
index 15e3546..8330380 100644
--- a/drivers/pci/pcie_layerscape.c
+++ b/drivers/pci/pcie_layerscape.c
@@ -50,11 +50,20 @@
 #define PCIE_ATU_FUNC(x)		(((x) & 0x7) << 16)
 #define PCIE_ATU_UPPER_TARGET		0x91C
 
+/* LUT registers */
+#define PCIE_LUT_BASE		0x80000
+#define PCIE_LUT_DBG		0x7FC
+
+#define PCIE_DBI_RO_WR_EN	0x8bc
+
 #define PCIE_LINK_CAP		0x7c
 #define PCIE_LINK_SPEED_MASK	0xf
 #define PCIE_LINK_STA		0x82
 
-#define PCIE_DBI_SIZE		(4 * 1024) /* 4K */
+#define LTSSM_STATE_MASK	0x3f
+#define LTSSM_PCIE_L0		0x11 /* L0 state */
+
+#define PCIE_DBI_SIZE		0x100000 /* 1M */
 
 struct ls_pcie {
 	int idx;
@@ -104,8 +113,6 @@ struct ls_pcie_info {
 
 /* PEX1/2 Misc Ports Status Register */
 #define LTSSM_STATE_SHIFT	20
-#define LTSSM_STATE_MASK	0x3f
-#define LTSSM_PCIE_L0		0x11 /* L0 state */
 
 static int ls_pcie_link_state(struct ls_pcie *pcie)
 {
@@ -122,18 +129,18 @@ static int ls_pcie_link_state(struct ls_pcie *pcie)
 	return 1;
 }
 #else
-#define PCIE_LDBG 0x7FC
-
 static int ls_pcie_link_state(struct ls_pcie *pcie)
 {
 	u32 state;
 
-	state = readl(pcie->dbi + PCIE_LDBG);
-	if (state)
-		return 1;
+	state = readl(pcie->dbi + PCIE_LUT_BASE + PCIE_LUT_DBG) &
+		LTSSM_STATE_MASK;
+	if (state < LTSSM_PCIE_L0) {
+		debug("....PCIe link error. LTSSM=0x%02x.\n", state);
+		return 0;
+	}
 
-	debug("....PCIe link error.\n");
-	return 0;
+	return 1;
 }
 #endif
 
@@ -149,7 +156,11 @@ static int ls_pcie_link_up(struct ls_pcie *pcie)
 	/* Try to download speed to gen1 */
 	cap = readl(pcie->dbi + PCIE_LINK_CAP);
 	writel((cap & (~PCIE_LINK_SPEED_MASK)) | 1, pcie->dbi + PCIE_LINK_CAP);
-	udelay(2000);
+	/*
+	 * Notice: the following delay has critical impact on link training
+	 * if too short (<30ms) the link doesn't get up.
+	 */
+	mdelay(100);
 	state = ls_pcie_link_state(pcie);
 	if (state)
 		return state;
@@ -251,6 +262,10 @@ static int ls_pcie_addr_valid(struct pci_controller *hose, pci_dev_t d)
 	if (PCI_DEV(d) > 0)
 		return -EINVAL;
 
+	/* Controller does not support multi-function in RC mode */
+	if ((PCI_BUS(d) == hose->first_busno) && (PCI_FUNC(d) > 0))
+		return -EINVAL;
+
 	return 0;
 }
 
@@ -327,8 +342,12 @@ static void ls_pcie_setup_ctrl(struct ls_pcie *pcie,
 	pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_0, 0);
 
 	/* program correct class for RC */
+	writel(1, pcie->dbi + PCIE_DBI_RO_WR_EN);
 	pci_hose_write_config_word(hose, dev, PCI_CLASS_DEVICE,
 				   PCI_CLASS_BRIDGE_PCI);
+#ifndef CONFIG_LS102XA
+	writel(0, pcie->dbi + PCIE_DBI_RO_WR_EN);
+#endif
 }
 
 int ls_pcie_init_ctrl(int busno, enum srds_prtcl dev, struct ls_pcie_info *info)
@@ -417,9 +436,9 @@ int ls_pcie_init_ctrl(int busno, enum srds_prtcl dev, struct ls_pcie_info *info)
 	}
 
 	/* Print the negotiated PCIe link width */
-	pci_hose_read_config_word(hose, dev, PCIE_LINK_STA, &temp16);
-		printf("x%d gen%d, regs @ 0x%lx\n", (temp16 & 0x3f0) >> 4,
-		       (temp16 & 0xf), info->regs);
+	pci_hose_read_config_word(hose, pdev, PCIE_LINK_STA, &temp16);
+	printf("x%d gen%d, regs @ 0x%lx\n", (temp16 & 0x3f0) >> 4,
+	       (temp16 & 0xf), info->regs);
 
 	if (ep_mode)
 		return busno;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include
  2015-03-11 11:09 [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include Minghuan Lian
  2015-03-11 11:09 ` [U-Boot] [PATCH 2/2] pci/layerscape: fix link and class issues to support ls2085a Minghuan Lian
@ 2015-03-11 14:22 ` Tom Rini
  2015-03-12  2:21   ` Lian Minghuan-B31939
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Rini @ 2015-03-11 14:22 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 11, 2015 at 07:09:33PM +0800, Minghuan Lian wrote:

> The patch moves pcie_layerscape.h out of arm include to top
> level include folder so that it can be shared on other Socs.
> 
> Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>

OK, I see a problem:

> diff --git a/arch/arm/include/asm/pcie_layerscape.h b/arch/arm/include/asm/pcie_layerscape.h
> deleted file mode 100644
> index fb08578..0000000
> --- a/arch/arm/include/asm/pcie_layerscape.h
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -/*
> - * Copyright 2014 Freescale Semiconductor, Inc.
> - *
> - * SPDX-License-Identifier:	GPL-2.0+
> - */
> -
> -#ifndef __PCIE_LAYERSCAPE_H_
> -#define __PCIE_LAYERSCAPE_H_
> -
> -void pci_init_board(void);

This is already in <common.h>

> -void ft_pcie_setup(void *blob, bd_t *bd);

This belongs in <fdt_support.h> near other similar functions and frankly
might be better done as ft_pci_setup(blob, bd) which already exists.  Or
do we have both ft_pci_setup and ft_pcie_setup existing at the same
time?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150311/1f60a19b/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include
  2015-03-11 14:22 ` [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include Tom Rini
@ 2015-03-12  2:21   ` Lian Minghuan-B31939
  0 siblings, 0 replies; 4+ messages in thread
From: Lian Minghuan-B31939 @ 2015-03-12  2:21 UTC (permalink / raw)
  To: u-boot

Hi Tom,

Thanks for your comments.
I will use the common name and remove unnecessary file pcie_layerscape.h

Thanks,
Minghuan


On 2015?03?11? 22:22, Tom Rini wrote:
> On Wed, Mar 11, 2015 at 07:09:33PM +0800, Minghuan Lian wrote:
>
>> The patch moves pcie_layerscape.h out of arm include to top
>> level include folder so that it can be shared on other Socs.
>>
>> Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
> OK, I see a problem:
>
>> diff --git a/arch/arm/include/asm/pcie_layerscape.h b/arch/arm/include/asm/pcie_layerscape.h
>> deleted file mode 100644
>> index fb08578..0000000
>> --- a/arch/arm/include/asm/pcie_layerscape.h
>> +++ /dev/null
>> @@ -1,13 +0,0 @@
>> -/*
>> - * Copyright 2014 Freescale Semiconductor, Inc.
>> - *
>> - * SPDX-License-Identifier:	GPL-2.0+
>> - */
>> -
>> -#ifndef __PCIE_LAYERSCAPE_H_
>> -#define __PCIE_LAYERSCAPE_H_
>> -
>> -void pci_init_board(void);
> This is already in <common.h>
>
>> -void ft_pcie_setup(void *blob, bd_t *bd);
> This belongs in <fdt_support.h> near other similar functions and frankly
> might be better done as ft_pci_setup(blob, bd) which already exists.  Or
> do we have both ft_pci_setup and ft_pcie_setup existing at the same
> time?
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-12  2:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-11 11:09 [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include Minghuan Lian
2015-03-11 11:09 ` [U-Boot] [PATCH 2/2] pci/layerscape: fix link and class issues to support ls2085a Minghuan Lian
2015-03-11 14:22 ` [U-Boot] [PATCH 1/2] pci/layerscape: move pcie_layerscape.h out of arm include Tom Rini
2015-03-12  2:21   ` Lian Minghuan-B31939

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox