Skip to contentSkip to conversation

PCI: designware: Move LTSSM state definitions to pcie-designware.h

PATCH Superseded Fabio Estevam 2 participants 11 messages Oct 9, 2015 – Oct 12, 2015

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v2 1/2 PCI: designware: Move LTSSM state definitions to pcie-designware.h

From: Fabio Estevam <[email protected]>

Move LTSSM state definitions to common pcie-designware.h so that other drivers can make use of them.

Also, in order to avoid name collision define LTSSM_STATE_MASK_KS, as keystone uses a different LTSSM mask.

---
Changes since v1:
- Fix build warning noticed by kbuild robot

 drivers/pci/host/pci-keystone-dw.c |  4 ++--
 drivers/pci/host/pci-layerscape.c  |  1 -
 drivers/pci/host/pcie-designware.h | 34 ++++++++++++++++++++++++++++++++++
 drivers/pci/host/pcie-spear13xx.c  | 33 ---------------------------------
 4 files changed, 36 insertions(+), 36 deletions(-)
drivers/pci/host/pci-keystone-dw.c +2 -2
index 3cf55cd..004b677 100644
@@ -25,7 +25,7 @@
 
 /* Application register defines */
 #define LTSSM_EN_VAL		        1
-#define LTSSM_STATE_MASK		0x1f
+#define LTSSM_STATE_MASK_KS		0x1f
 #define LTSSM_STATE_L0			0x11
 #define DBI_CS2_EN_VAL			0x20
 #define OB_XLAT_EN_VAL		        2
@@ -445,7 +445,7 @@ int ks_dw_pcie_link_up(struct pcie_port *pp)
 {
 	u32 val = readl(pp->dbi_base + DEBUG0);
 
-	return (val & LTSSM_STATE_MASK) == LTSSM_STATE_L0;
+	return (val & LTSSM_STATE_MASK_KS) == LTSSM_STATE_L0;
 }
 
 void ks_dw_pcie_initiate_link_train(struct keystone_pcie *ks_pcie)
drivers/pci/host/pci-layerscape.c +0 -1
index b2328ea1..f02752e 100644
@@ -29,7 +29,6 @@
 /* PEX1/2 Misc Ports Status Register */
 #define SCFG_PEXMSCPORTSR(pex_idx)	(0x94 + (pex_idx) * 4)
 #define LTSSM_STATE_SHIFT	20
-#define LTSSM_STATE_MASK	0x3f
 #define LTSSM_PCIE_L0		0x11 /* L0 state */
 
 /* Symbol Timer Register and Filter Mask Register 1 */
drivers/pci/host/pcie-designware.h +34 -0
index 35123d9..97d6558 100644
@@ -22,6 +22,40 @@
 #define MAX_MSI_IRQS			32
 #define MAX_MSI_CTRLS			(MAX_MSI_IRQS / 32)
 
+#define LTSSM_STATE_DETECT_QUIET	0x00
+#define LTSSM_STATE_DETECT_ACT		0x01
+#define LTSSM_STATE_POLL_ACTIVE		0x02
+#define LTSSM_STATE_POLL_COMPLIANCE	0x03
+#define LTSSM_STATE_POLL_CONFIG		0x04
+#define LTSSM_STATE_PRE_DETECT_QUIET	0x05
+#define LTSSM_STATE_DETECT_WAIT		0x06
+#define LTSSM_STATE_CFG_LINKWD_START	0x07
+#define LTSSM_STATE_CFG_LINKWD_ACEPT	0x08
+#define LTSSM_STATE_CFG_LANENUM_WAIT	0x09
+#define LTSSM_STATE_CFG_LANENUM_ACEPT	0x0A
+#define LTSSM_STATE_CFG_COMPLETE	0x0B
+#define LTSSM_STATE_CFG_IDLE		0x0C
+#define LTSSM_STATE_RCVRY_LOCK		0x0D
+#define LTSSM_STATE_RCVRY_SPEED		0x0E
+#define LTSSM_STATE_RCVRY_RCVRCFG	0x0F
+#define LTSSM_STATE_RCVRY_IDLE		0x10
+#define LTSSM_STATE_L0			0x11
+#define LTSSM_STATE_L0S			0x12
+#define LTSSM_STATE_L123_SEND_EIDLE	0x13
+#define LTSSM_STATE_L1_IDLE		0x14
+#define LTSSM_STATE_L2_IDLE		0x15
+#define LTSSM_STATE_L2_WAKE		0x16
+#define LTSSM_STATE_DISABLED_ENTRY	0x17
+#define LTSSM_STATE_DISABLED_IDLE	0x18
+#define LTSSM_STATE_DISABLED		0x19
+#define LTSSM_STATE_LPBK_ENTRY		0x1A
+#define LTSSM_STATE_LPBK_ACTIVE		0x1B
+#define LTSSM_STATE_LPBK_EXIT		0x1C
+#define LTSSM_STATE_LPBK_EXIT_TIMEOUT	0x1D
+#define LTSSM_STATE_HOT_RESET_ENTRY	0x1E
+#define LTSSM_STATE_HOT_RESET		0x1F
+#define LTSSM_STATE_MASK		0x3F
+
 struct pcie_port {
 	struct device		*dev;
 	u8			root_bus_nr;
drivers/pci/host/pcie-spear13xx.c +0 -33
index 98d2683..920d399 100644
@@ -84,39 +84,6 @@ struct pcie_app_reg {
 #define APPS_PM_XMT_PME_ID			5
 
 /* CR3 ID */
-#define XMLH_LTSSM_STATE_DETECT_QUIET		0x00
-#define XMLH_LTSSM_STATE_DETECT_ACT		0x01
-#define XMLH_LTSSM_STATE_POLL_ACTIVE		0x02
-#define XMLH_LTSSM_STATE_POLL_COMPLIANCE	0x03
-#define XMLH_LTSSM_STATE_POLL_CONFIG		0x04
-#define XMLH_LTSSM_STATE_PRE_DETECT_QUIET	0x05
-#define XMLH_LTSSM_STATE_DETECT_WAIT		0x06
-#define XMLH_LTSSM_STATE_CFG_LINKWD_START	0x07
-#define XMLH_LTSSM_STATE_CFG_LINKWD_ACEPT	0x08
-#define XMLH_LTSSM_STATE_CFG_LANENUM_WAIT	0x09
-#define XMLH_LTSSM_STATE_CFG_LANENUM_ACEPT	0x0A
-#define XMLH_LTSSM_STATE_CFG_COMPLETE		0x0B
-#define XMLH_LTSSM_STATE_CFG_IDLE		0x0C
-#define XMLH_LTSSM_STATE_RCVRY_LOCK		0x0D
-#define XMLH_LTSSM_STATE_RCVRY_SPEED		0x0E
-#define XMLH_LTSSM_STATE_RCVRY_RCVRCFG		0x0F
-#define XMLH_LTSSM_STATE_RCVRY_IDLE		0x10
-#define XMLH_LTSSM_STATE_L0			0x11
-#define XMLH_LTSSM_STATE_L0S			0x12
-#define XMLH_LTSSM_STATE_L123_SEND_EIDLE	0x13
-#define XMLH_LTSSM_STATE_L1_IDLE		0x14
-#define XMLH_LTSSM_STATE_L2_IDLE		0x15
-#define XMLH_LTSSM_STATE_L2_WAKE		0x16
-#define XMLH_LTSSM_STATE_DISABLED_ENTRY		0x17
-#define XMLH_LTSSM_STATE_DISABLED_IDLE		0x18
-#define XMLH_LTSSM_STATE_DISABLED		0x19
-#define XMLH_LTSSM_STATE_LPBK_ENTRY		0x1A
-#define XMLH_LTSSM_STATE_LPBK_ACTIVE		0x1B
-#define XMLH_LTSSM_STATE_LPBK_EXIT		0x1C
-#define XMLH_LTSSM_STATE_LPBK_EXIT_TIMEOUT	0x1D
-#define XMLH_LTSSM_STATE_HOT_RESET_ENTRY	0x1E
-#define XMLH_LTSSM_STATE_HOT_RESET		0x1F
-#define XMLH_LTSSM_STATE_MASK			0x3F
 #define XMLH_LINK_UP				(1 << 6)
 
 /* CR4 ID */
Signature · 1 line
1.9.1
author reviewer
#1 lore raw

PATCH v2 2/2 PCI: imx6: Use define instead of hard coded value

From: Fabio Estevam <[email protected]>

Use LTSSM_STATE_RCVRY_LOCK define instead of hard coded value in order to improve the code readability;

---
Changes since v1:
- None

 drivers/pci/host/pci-imx6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivePCIE_PHY_DEBUG_R0_LTSSM_MASKrs/pci/host/pci-imx6.c renamed from drivers/pci/host/pci-imx6.c +1 -1
index 6f43086..4e7b577 100644
@@ -508,7 +508,7 @@ static int imx6_pcie_link_up(struct pcie_port *pp)
 	if (rx_valid & PCIE_PHY_RX_ASIC_OUT_VALID)
 		return 0;
 
-	if ((debug_r0 & PCIE_PHY_DEBUG_R0_LTSSM_MASK) != 0x0d)
+	if ((debug_r0 & PCIE_PHY_DEBUG_R0_LTSSM_MASK) != LTSSM_STATE_RCVRY_LOCK)
 		return 0;
 
 	dev_err(pp->dev, "transition to gen2 is stuck, reset PHY!\n");
Signature · 1 line
1.9.1
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] PCI: imx6: Use define instead of hard coded value

Am Donnerstag, den 08.10.2015, 22:48 -0300 schrieb Fabio Estevam:

Quoted 5 lines

From: Fabio Estevam <[email protected]>

Use LTSSM_STATE_RCVRY_LOCK define instead of hard coded value in order to improve the code readability;

Normally we end sentences to be parsed by humans with a full stop instead of a semicolon. ;)

Quoted 1 line
Quoted 20 lines

---
Changes since v1:
- None

 drivers/pci/host/pci-imx6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivePCIE_PHY_DEBUG_R0_LTSSM_MASKrs/pci/host/pci-imx6.c renamed from drivers/pci/host/pci-imx6.c +1 -1
index 6f43086..4e7b577 100644
@@ -508,7 +508,7 @@ static int imx6_pcie_link_up(struct pcie_port *pp)
 	if (rx_valid & PCIE_PHY_RX_ASIC_OUT_VALID)
 		return 0;
 
-	if ((debug_r0 & PCIE_PHY_DEBUG_R0_LTSSM_MASK) != 0x0d)
+	if ((debug_r0 & PCIE_PHY_DEBUG_R0_LTSSM_MASK) != LTSSM_STATE_RCVRY_LOCK)
 		return 0;
 
 	dev_err(pp->dev, "transition to gen2 is stuck, reset PHY!\n");
Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |
#3 lore raw
In reply to Fabio Estevam

Am Donnerstag, den 08.10.2015, 22:48 -0300 schrieb Fabio Estevam:

Quoted 8 lines

From: Fabio Estevam <[email protected]>

Move LTSSM state definitions to common pcie-designware.h so that other drivers can make use of them.

Also, in order to avoid name collision define LTSSM_STATE_MASK_KS, as keystone uses a different LTSSM mask.

Why? Is this some kind of difference between the DW PCIe core revisions?

I don't see the other drivers using any LTSSM state value that would not fit inside the KS mask. Can we just use the narrower KS mask, even if the others have one bit more allocated in the register? This would spare us this needless differentiation in the software.

Quoted 78 lines

---
Changes since v1:
- Fix build warning noticed by kbuild robot

 drivers/pci/host/pci-keystone-dw.c |  4 ++--
 drivers/pci/host/pci-layerscape.c  |  1 -
 drivers/pci/host/pcie-designware.h | 34 ++++++++++++++++++++++++++++++++++
 drivers/pci/host/pcie-spear13xx.c  | 33 ---------------------------------
 4 files changed, 36 insertions(+), 36 deletions(-)
drivers/pci/host/pci-keystone-dw.c +2 -2
index 3cf55cd..004b677 100644
@@ -25,7 +25,7 @@
 
 /* Application register defines */
 #define LTSSM_EN_VAL		        1
-#define LTSSM_STATE_MASK		0x1f
+#define LTSSM_STATE_MASK_KS		0x1f
 #define LTSSM_STATE_L0			0x11
 #define DBI_CS2_EN_VAL			0x20
 #define OB_XLAT_EN_VAL		        2
@@ -445,7 +445,7 @@ int ks_dw_pcie_link_up(struct pcie_port *pp)
 {
 	u32 val = readl(pp->dbi_base + DEBUG0);
 
-	return (val & LTSSM_STATE_MASK) == LTSSM_STATE_L0;
+	return (val & LTSSM_STATE_MASK_KS) == LTSSM_STATE_L0;
 }
 
 void ks_dw_pcie_initiate_link_train(struct keystone_pcie *ks_pcie)
drivers/pci/host/pci-layerscape.c +0 -1
index b2328ea1..f02752e 100644
@@ -29,7 +29,6 @@
 /* PEX1/2 Misc Ports Status Register */
 #define SCFG_PEXMSCPORTSR(pex_idx)	(0x94 + (pex_idx) * 4)
 #define LTSSM_STATE_SHIFT	20
-#define LTSSM_STATE_MASK	0x3f
 #define LTSSM_PCIE_L0		0x11 /* L0 state */
 
 /* Symbol Timer Register and Filter Mask Register 1 */
drivers/pci/host/pcie-designware.h +24 -0
index 35123d9..97d6558 100644
@@ -22,6 +22,40 @@
 #define MAX_MSI_IRQS			32
 #define MAX_MSI_CTRLS			(MAX_MSI_IRQS / 32)
 
+#define LTSSM_STATE_DETECT_QUIET	0x00
+#define LTSSM_STATE_DETECT_ACT		0x01
+#define LTSSM_STATE_POLL_ACTIVE		0x02
+#define LTSSM_STATE_POLL_COMPLIANCE	0x03
+#define LTSSM_STATE_POLL_CONFIG		0x04
+#define LTSSM_STATE_PRE_DETECT_QUIET	0x05
+#define LTSSM_STATE_DETECT_WAIT		0x06
+#define LTSSM_STATE_CFG_LINKWD_START	0x07
+#define LTSSM_STATE_CFG_LINKWD_ACEPT	0x08
+#define LTSSM_STATE_CFG_LANENUM_WAIT	0x09
+#define LTSSM_STATE_CFG_LANENUM_ACEPT	0x0A
+#define LTSSM_STATE_CFG_COMPLETE	0x0B
+#define LTSSM_STATE_CFG_IDLE		0x0C
+#define LTSSM_STATE_RCVRY_LOCK		0x0D
+#define LTSSM_STATE_RCVRY_SPEED		0x0E
+#define LTSSM_STATE_RCVRY_RCVRCFG	0x0F
+#define LTSSM_STATE_RCVRY_IDLE		0x10
+#define LTSSM_STATE_L0			0x11
+#define LTSSM_STATE_L0S			0x12
+#define LTSSM_STATE_L123_SEND_EIDLE	0x13
+#define LTSSM_STATE_L1_IDLE		0x14
+#define LTSSM_STATE_L2_IDLE		0x15
+#define LTSSM_STATE_L2_WAKE		0x16
+#define LTSSM_STATE_DISABLED_ENTRY	0x17

drivers/pci/host/pcie-designware.h line 58

Quoted 10 lines
drivers/pci/host/pcie-designware.h +10 -0
+#define LTSSM_STATE_DISABLED_IDLE	0x18
+#define LTSSM_STATE_DISABLED		0x19
+#define LTSSM_STATE_LPBK_ENTRY		0x1A
+#define LTSSM_STATE_LPBK_ACTIVE		0x1B
+#define LTSSM_STATE_LPBK_EXIT		0x1C
+#define LTSSM_STATE_LPBK_EXIT_TIMEOUT	0x1D
+#define LTSSM_STATE_HOT_RESET_ENTRY	0x1E
+#define LTSSM_STATE_HOT_RESET		0x1F
+#define LTSSM_STATE_MASK		0x3F
+

I know this is just copy-and-paste, but can we use lowercase letters for the hex values please? This would make this fit in better with the rest of the header and is much more like any other part of the kernel.

Regards,
Lucas

Quoted 47 lines
drivers/pci/host/pcie-designware.h +0 -0
 struct pcie_port {
 	struct device		*dev;
 	u8			root_bus_nr;
drivers/pci/host/pcie-spear13xx.c +0 -33
index 98d2683..920d399 100644
@@ -84,39 +84,6 @@ struct pcie_app_reg {
 #define APPS_PM_XMT_PME_ID			5
 
 /* CR3 ID */
-#define XMLH_LTSSM_STATE_DETECT_QUIET		0x00
-#define XMLH_LTSSM_STATE_DETECT_ACT		0x01
-#define XMLH_LTSSM_STATE_POLL_ACTIVE		0x02
-#define XMLH_LTSSM_STATE_POLL_COMPLIANCE	0x03
-#define XMLH_LTSSM_STATE_POLL_CONFIG		0x04
-#define XMLH_LTSSM_STATE_PRE_DETECT_QUIET	0x05
-#define XMLH_LTSSM_STATE_DETECT_WAIT		0x06
-#define XMLH_LTSSM_STATE_CFG_LINKWD_START	0x07
-#define XMLH_LTSSM_STATE_CFG_LINKWD_ACEPT	0x08
-#define XMLH_LTSSM_STATE_CFG_LANENUM_WAIT	0x09
-#define XMLH_LTSSM_STATE_CFG_LANENUM_ACEPT	0x0A
-#define XMLH_LTSSM_STATE_CFG_COMPLETE		0x0B
-#define XMLH_LTSSM_STATE_CFG_IDLE		0x0C
-#define XMLH_LTSSM_STATE_RCVRY_LOCK		0x0D
-#define XMLH_LTSSM_STATE_RCVRY_SPEED		0x0E
-#define XMLH_LTSSM_STATE_RCVRY_RCVRCFG		0x0F
-#define XMLH_LTSSM_STATE_RCVRY_IDLE		0x10
-#define XMLH_LTSSM_STATE_L0			0x11
-#define XMLH_LTSSM_STATE_L0S			0x12
-#define XMLH_LTSSM_STATE_L123_SEND_EIDLE	0x13
-#define XMLH_LTSSM_STATE_L1_IDLE		0x14
-#define XMLH_LTSSM_STATE_L2_IDLE		0x15
-#define XMLH_LTSSM_STATE_L2_WAKE		0x16
-#define XMLH_LTSSM_STATE_DISABLED_ENTRY		0x17
-#define XMLH_LTSSM_STATE_DISABLED_IDLE		0x18
-#define XMLH_LTSSM_STATE_DISABLED		0x19
-#define XMLH_LTSSM_STATE_LPBK_ENTRY		0x1A
-#define XMLH_LTSSM_STATE_LPBK_ACTIVE		0x1B
-#define XMLH_LTSSM_STATE_LPBK_EXIT		0x1C
-#define XMLH_LTSSM_STATE_LPBK_EXIT_TIMEOUT	0x1D
-#define XMLH_LTSSM_STATE_HOT_RESET_ENTRY	0x1E
-#define XMLH_LTSSM_STATE_HOT_RESET		0x1F
-#define XMLH_LTSSM_STATE_MASK			0x3F
 #define XMLH_LINK_UP				(1 << 6)
 
 /* CR4 ID */
Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |
#4 lore raw

Am Montag, den 12.10.2015, 12:19 +0200 schrieb Lucas Stach:

Quoted 9 lines

Am Donnerstag, den 08.10.2015, 22:48 -0300 schrieb Fabio Estevam:

Quoted 8 lines

From: Fabio Estevam <[email protected]>

Move LTSSM state definitions to common pcie-designware.h so that other drivers can make use of them.

Also, in order to avoid name collision define LTSSM_STATE_MASK_KS, as keystone uses a different LTSSM mask.

Quoted 7 lines

Why? Is this some kind of difference between the DW PCIe core revisions?

I don't see the other drivers using any LTSSM state value that would not fit inside the KS mask. Can we just use the narrower KS mask, even if the others have one bit more allocated in the register? This would spare us this needless differentiation in the software.

Actually the TRM states that i.MX6 is using the same narrower mask of 0x1f for the LTSSM state, so another reason to just use that.

Quoted 143 lines
Quoted 78 lines

---
Changes since v1:
- Fix build warning noticed by kbuild robot

 drivers/pci/host/pci-keystone-dw.c |  4 ++--
 drivers/pci/host/pci-layerscape.c  |  1 -
 drivers/pci/host/pcie-designware.h | 34 ++++++++++++++++++++++++++++++++++
 drivers/pci/host/pcie-spear13xx.c  | 33 ---------------------------------
 4 files changed, 36 insertions(+), 36 deletions(-)
drivers/pci/host/pci-keystone-dw.c +2 -2
index 3cf55cd..004b677 100644
@@ -25,7 +25,7 @@
 
 /* Application register defines */
 #define LTSSM_EN_VAL		        1
-#define LTSSM_STATE_MASK		0x1f
+#define LTSSM_STATE_MASK_KS		0x1f
 #define LTSSM_STATE_L0			0x11
 #define DBI_CS2_EN_VAL			0x20
 #define OB_XLAT_EN_VAL		        2
@@ -445,7 +445,7 @@ int ks_dw_pcie_link_up(struct pcie_port *pp)
 {
 	u32 val = readl(pp->dbi_base + DEBUG0);
 
-	return (val & LTSSM_STATE_MASK) == LTSSM_STATE_L0;
+	return (val & LTSSM_STATE_MASK_KS) == LTSSM_STATE_L0;
 }
 
 void ks_dw_pcie_initiate_link_train(struct keystone_pcie *ks_pcie)
drivers/pci/host/pci-layerscape.c +0 -1
index b2328ea1..f02752e 100644
@@ -29,7 +29,6 @@
 /* PEX1/2 Misc Ports Status Register */
 #define SCFG_PEXMSCPORTSR(pex_idx)	(0x94 + (pex_idx) * 4)
 #define LTSSM_STATE_SHIFT	20
-#define LTSSM_STATE_MASK	0x3f
 #define LTSSM_PCIE_L0		0x11 /* L0 state */
 
 /* Symbol Timer Register and Filter Mask Register 1 */
drivers/pci/host/pcie-designware.h +24 -0
index 35123d9..97d6558 100644
@@ -22,6 +22,40 @@
 #define MAX_MSI_IRQS			32
 #define MAX_MSI_CTRLS			(MAX_MSI_IRQS / 32)
 
+#define LTSSM_STATE_DETECT_QUIET	0x00
+#define LTSSM_STATE_DETECT_ACT		0x01
+#define LTSSM_STATE_POLL_ACTIVE		0x02
+#define LTSSM_STATE_POLL_COMPLIANCE	0x03
+#define LTSSM_STATE_POLL_CONFIG		0x04
+#define LTSSM_STATE_PRE_DETECT_QUIET	0x05
+#define LTSSM_STATE_DETECT_WAIT		0x06
+#define LTSSM_STATE_CFG_LINKWD_START	0x07
+#define LTSSM_STATE_CFG_LINKWD_ACEPT	0x08
+#define LTSSM_STATE_CFG_LANENUM_WAIT	0x09
+#define LTSSM_STATE_CFG_LANENUM_ACEPT	0x0A
+#define LTSSM_STATE_CFG_COMPLETE	0x0B
+#define LTSSM_STATE_CFG_IDLE		0x0C
+#define LTSSM_STATE_RCVRY_LOCK		0x0D
+#define LTSSM_STATE_RCVRY_SPEED		0x0E
+#define LTSSM_STATE_RCVRY_RCVRCFG	0x0F
+#define LTSSM_STATE_RCVRY_IDLE		0x10
+#define LTSSM_STATE_L0			0x11
+#define LTSSM_STATE_L0S			0x12
+#define LTSSM_STATE_L123_SEND_EIDLE	0x13
+#define LTSSM_STATE_L1_IDLE		0x14
+#define LTSSM_STATE_L2_IDLE		0x15
+#define LTSSM_STATE_L2_WAKE		0x16
+#define LTSSM_STATE_DISABLED_ENTRY	0x17

drivers/pci/host/pcie-designware.h line 58

Quoted 10 lines
drivers/pci/host/pcie-designware.h +10 -0
+#define LTSSM_STATE_DISABLED_IDLE	0x18
+#define LTSSM_STATE_DISABLED		0x19
+#define LTSSM_STATE_LPBK_ENTRY		0x1A
+#define LTSSM_STATE_LPBK_ACTIVE		0x1B
+#define LTSSM_STATE_LPBK_EXIT		0x1C
+#define LTSSM_STATE_LPBK_EXIT_TIMEOUT	0x1D
+#define LTSSM_STATE_HOT_RESET_ENTRY	0x1E
+#define LTSSM_STATE_HOT_RESET		0x1F
+#define LTSSM_STATE_MASK		0x3F
+

I know this is just copy-and-paste, but can we use lowercase letters for the hex values please? This would make this fit in better with the rest of the header and is much more like any other part of the kernel.

Regards,
Lucas

Quoted 47 lines
drivers/pci/host/pcie-designware.h +0 -0
 struct pcie_port {
 	struct device		*dev;
 	u8			root_bus_nr;
drivers/pci/host/pcie-spear13xx.c +0 -33
index 98d2683..920d399 100644
@@ -84,39 +84,6 @@ struct pcie_app_reg {
 #define APPS_PM_XMT_PME_ID			5
 
 /* CR3 ID */
-#define XMLH_LTSSM_STATE_DETECT_QUIET		0x00
-#define XMLH_LTSSM_STATE_DETECT_ACT		0x01
-#define XMLH_LTSSM_STATE_POLL_ACTIVE		0x02
-#define XMLH_LTSSM_STATE_POLL_COMPLIANCE	0x03
-#define XMLH_LTSSM_STATE_POLL_CONFIG		0x04
-#define XMLH_LTSSM_STATE_PRE_DETECT_QUIET	0x05
-#define XMLH_LTSSM_STATE_DETECT_WAIT		0x06
-#define XMLH_LTSSM_STATE_CFG_LINKWD_START	0x07
-#define XMLH_LTSSM_STATE_CFG_LINKWD_ACEPT	0x08
-#define XMLH_LTSSM_STATE_CFG_LANENUM_WAIT	0x09
-#define XMLH_LTSSM_STATE_CFG_LANENUM_ACEPT	0x0A
-#define XMLH_LTSSM_STATE_CFG_COMPLETE		0x0B
-#define XMLH_LTSSM_STATE_CFG_IDLE		0x0C
-#define XMLH_LTSSM_STATE_RCVRY_LOCK		0x0D
-#define XMLH_LTSSM_STATE_RCVRY_SPEED		0x0E
-#define XMLH_LTSSM_STATE_RCVRY_RCVRCFG		0x0F
-#define XMLH_LTSSM_STATE_RCVRY_IDLE		0x10
-#define XMLH_LTSSM_STATE_L0			0x11
-#define XMLH_LTSSM_STATE_L0S			0x12
-#define XMLH_LTSSM_STATE_L123_SEND_EIDLE	0x13
-#define XMLH_LTSSM_STATE_L1_IDLE		0x14
-#define XMLH_LTSSM_STATE_L2_IDLE		0x15
-#define XMLH_LTSSM_STATE_L2_WAKE		0x16
-#define XMLH_LTSSM_STATE_DISABLED_ENTRY		0x17
-#define XMLH_LTSSM_STATE_DISABLED_IDLE		0x18
-#define XMLH_LTSSM_STATE_DISABLED		0x19
-#define XMLH_LTSSM_STATE_LPBK_ENTRY		0x1A
-#define XMLH_LTSSM_STATE_LPBK_ACTIVE		0x1B
-#define XMLH_LTSSM_STATE_LPBK_EXIT		0x1C
-#define XMLH_LTSSM_STATE_LPBK_EXIT_TIMEOUT	0x1D
-#define XMLH_LTSSM_STATE_HOT_RESET_ENTRY	0x1E
-#define XMLH_LTSSM_STATE_HOT_RESET		0x1F
-#define XMLH_LTSSM_STATE_MASK			0x3F
 #define XMLH_LINK_UP				(1 << 6)
 
 /* CR4 ID */
Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |
author reviewer
#5 lore raw
Quoted 2 lines · Lucas Stach

Actually the TRM states that i.MX6 is using the same narrower mask of 0x1f for the LTSSM state, so another reason to just use that.

The manual I have seems to tell a different value :-)

Please check: http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf

"48.12.11
Debug Register 0 (PCIE_PL_DEBUG0)"

says "[5:0]: xmlh_ltssm_state LTSSM current state. See source for encodings"

Regards,

Fabio Estevam

#6 lore raw

Am Montag, den 12.10.2015, 09:31 -0300 schrieb Fabio Estevam:

Quoted 5 lines · Lucas Stach
Quoted 3 lines

Actually the TRM states that i.MX6 is using the same narrower mask of 0x1f for the LTSSM state, so another reason to just use that.

Quoted 9 lines

The manual I have seems to tell a different value :-)

Please check: http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf

"48.12.11
Debug Register 0 (PCIE_PL_DEBUG0)"

says "[5:0]: xmlh_ltssm_state LTSSM current state. See source for encodings"

Urgh. Seems we got confused by all the different defines.

In fact [5:0] is 0x1f, so i.MX6 uses the same mask as Keystone, yet the common and shared header now states a mask of 0x3f with Keystone being the exception. That doesn't reflect reality which isn't nice IMHO. I think it would be better to just use 0x1f as the LTSSM mask in the shared header and use this for all drivers until a need arises for using the extra bit on SPEAR.

Regards,
Lucas

Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |
author reviewer
#7 lore raw
Quoted 10 lines · Lucas Stach

Am Montag, den 12.10.2015, 09:31 -0300 schrieb Fabio Estevam:

Quoted 9 lines · Lucas Stach
Quoted 3 lines

Actually the TRM states that i.MX6 is using the same narrower mask of 0x1f for the LTSSM state, so another reason to just use that.

The manual I have seems to tell a different value :-)

Please check: http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf

Quoted 8 lines
Quoted 5 lines

"48.12.11
Debug Register 0 (PCIE_PL_DEBUG0)"

says "[5:0]: xmlh_ltssm_state LTSSM current state. See source for encodings"

Urgh. Seems we got confused by all the different defines.

In fact [5:0] is 0x1f, so i.MX6 uses the same mask as Keystone, yet the

No, bits [5..0] means 0x3f. What am I missing here?

#8 lore raw

Am Montag, den 12.10.2015, 11:04 -0300 schrieb Fabio Estevam:

Quoted 14 lines · Lucas Stach
Quoted 13 lines

Am Montag, den 12.10.2015, 09:31 -0300 schrieb Fabio Estevam:

Quoted 12 lines · Lucas Stach
Quoted 3 lines

Actually the TRM states that i.MX6 is using the same narrower mask of 0x1f for the LTSSM state, so another reason to just use that.

The manual I have seems to tell a different value :-)

Please check: http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf

"48.12.11
Debug Register 0 (PCIE_PL_DEBUG0)"

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

says "[5:0]: xmlh_ltssm_state LTSSM current state. See source for encodings"

Urgh. Seems we got confused by all the different defines.

In fact [5:0] is 0x1f, so i.MX6 uses the same mask as Keystone, yet the

No, bits [5..0] means 0x3f. What am I missing here?

That you have to deal with people who are apparently unable to count to
5. *me puts on the brown paper bag*

Still I would love to have a definition in the common header that's usable for all drivers. So unless there is a reason to use 0x3f (and we don't have any LTSSM state defines which would use the extra bit) keep it at 0x1f. Simpler, cleaner... IMHO.

Regards,
Lucas

Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |
author reviewer
#9 lore raw
Quoted 4 lines · Lucas Stach

Still I would love to have a definition in the common header that's usable for all drivers. So unless there is a reason to use 0x3f (and we don't have any LTSSM state defines which would use the extra bit) keep it at 0x1f. Simpler, cleaner... IMHO.

Sure, just did as suggested in v3. Thanks

author reviewer
#10 lore raw
In reply to Lucas Stach

Hi Lucas,

Quoted 10 lines · Lucas Stach

Am Donnerstag, den 08.10.2015, 22:48 -0300 schrieb Fabio Estevam:

Quoted 8 lines

From: Fabio Estevam <[email protected]>

Move LTSSM state definitions to common pcie-designware.h so that other drivers can make use of them.

Also, in order to avoid name collision define LTSSM_STATE_MASK_KS, as keystone uses a different LTSSM mask.

Why? Is this some kind of difference between the DW PCIe core revisions?

This patch does not alter the LTSSM masks that are used currently and they match the ones stated in the SoC manuals.

For keystone:
http://www.ti.com/lit/ug/sprugs6d/sprugs6d.pdf

Section "48.9.11 Debug Register 0 (PCIE_PL_DEBUG0)" shows that LTSSM current state has 6 bits.

For i.MX6:

Section "3.9.11 Debug 0 Register (DEBUG0)" shows that LTSSM_STATE field has 5 bits.

Regards,

Fabio Estevam