Skip to contentSkip to conversation

armv8: layerscape: Enable EHCI access for LS1012A

PATCH New Ran Wang 2 participants 6 messages Jul 3, 2018 – Jul 26, 2018 Arm (32-bit)

lore
Share & tools
lore

Ran Wang

author
#0 lore raw

PATCH 1/1 armv8: layerscape: Enable EHCI access for LS1012A

Program Central Security Unit (CSU) to grant access permission for USB 2.0 controller, otherwiase EHCI funciton will down.

---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c              | 8 ++++++++
 arch/arm/include/asm/arch-fsl-layerscape/ns_access.h | 1 +
 2 files changed, 9 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +8 -0
index 6a56269..2c4cf7f 100644
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <asm/global_data.h>
 #include <asm/arch-fsl-layerscape/config.h>
+#include <asm/arch-fsl-layerscape/ns_access.h>
 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
 #include <fsl_csu.h>
 #endif
@@ -668,6 +669,13 @@ void fsl_lsch2_early_init_f(void)
 			 CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
 	}
 
+	/*
+	 * Program Central Security Unit (CSU) to grant access
+	 * permission for USB 2.0 controller
+	 */
+#if defined(CONFIG_ARCH_LS1012A) && defined(CONFIG_USB_EHCI_FSL)
+	set_devices_ns_access(CSU_CSLX_USB_2, CSU_ALL_RW);
+#endif
 	/* Erratum */
 	erratum_a008850_early(); /* part 1 of 2 */
 	erratum_a009929();
arch/arm/include/asm/arch-fsl-layerscape/ns_access.h +1 -0
index fe97a93..d1b8efa 100644
@@ -40,6 +40,7 @@ enum csu_cslx_ind {
 	CSU_CSLX_ESDHC,
 	CSU_CSLX_IFC = 45,
 	CSU_CSLX_I2C1,
+	CSU_CSLX_USB_2,
 	CSU_CSLX_I2C3 = 48,
 	CSU_CSLX_I2C2,
 	CSU_CSLX_DUART2 = 50,
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 armv8: layerscape: Enable EHCI access for LS1012A

Quoted 22 lines · Ran Wang

Program Central Security Unit (CSU) to grant access permission for USB 2.0 controller, otherwiase EHCI funciton will down.

---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c              | 8 ++++++++
 arch/arm/include/asm/arch-fsl-layerscape/ns_access.h | 1 +
 2 files changed, 9 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
index 6a56269..2c4cf7f 100644
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <asm/global_data.h>
 #include <asm/arch-fsl-layerscape/config.h>
+#include <asm/arch-fsl-layerscape/ns_access.h>
 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
 #include <fsl_csu.h>
 #endif

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void) · line 678

Quoted 10 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +7 -0
@@ -668,6 +669,13 @@ void fsl_lsch2_early_init_f(void)
 			 CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
 	}
 
+	/*
+	 * Program Central Security Unit (CSU) to grant access
+	 * permission for USB 2.0 controller
+	 */
+#if defined(CONFIG_ARCH_LS1012A) && defined(CONFIG_USB_EHCI_FSL)
+	set_devices_ns_access(CSU_CSLX_USB_2, CSU_ALL_RW);
+#endif

Is this LS1012A specific?

York

author
#2 lore raw

PATCH 1/1 armv8: layerscape: Enable EHCI access for LS1012A

Hi York,

Quoted 36 lines

-----Original Message-----
From: York Sun
Sent: Wednesday, July 11, 2018 05:06
To: Ran Wang <[email protected]>; Albert Aribaud <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: [PATCH] armv8: layerscape: Enable EHCI access for LS1012A

Quoted 23 lines · Ran Wang

Program Central Security Unit (CSU) to grant access permission for USB 2.0 controller, otherwiase EHCI funciton will down.

---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c              | 8 ++++++++
 arch/arm/include/asm/arch-fsl-layerscape/ns_access.h | 1 +
 2 files changed, 9 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
index 6a56269..2c4cf7f 100644
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <asm/global_data.h>
 #include <asm/arch-fsl-layerscape/config.h>
+#include <asm/arch-fsl-layerscape/ns_access.h>
 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
 #include <fsl_csu.h>
 #endif

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void) · line 669

Quoted 1 line
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
@@ -668,6 +669,13 @@ void fsl_lsch2_early_init_f(void)
 			 CCI400_DVM_MESSAGE_REQ_EN |

CCI400_SNOOP_REQ_EN);

Quoted 2 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
 	}
 
Quoted 9 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void)

Quoted 6 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +6 -0
+	/*
+	 * Program Central Security Unit (CSU) to grant access
+	 * permission for USB 2.0 controller
+	 */
+#if defined(CONFIG_ARCH_LS1012A) && defined(CONFIG_USB_EHCI_FSL)
+	set_devices_ns_access(CSU_CSLX_USB_2, CSU_ALL_RW); #endif

Is this LS1012A specific?

For Layerscape platforms, only LS1012A and LS1021A have USB2.0(EHCI) controller, Others have USB3.0 controller only. For now I can only verify on LS1012A, so didn't cover LS1021A yet.

Ran

Quoted 1 line

York

#3 lore raw

PATCH 1/1 armv8: layerscape: Enable EHCI access for LS1012A

Quoted 47 lines · Ran Wang

Hi York,

Quoted 36 lines

-----Original Message-----
From: York Sun
Sent: Wednesday, July 11, 2018 05:06
To: Ran Wang <[email protected]>; Albert Aribaud <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: [PATCH] armv8: layerscape: Enable EHCI access for LS1012A

Quoted 23 lines · Ran Wang

Program Central Security Unit (CSU) to grant access permission for USB 2.0 controller, otherwiase EHCI funciton will down.

---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c              | 8 ++++++++
 arch/arm/include/asm/arch-fsl-layerscape/ns_access.h | 1 +
 2 files changed, 9 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
index 6a56269..2c4cf7f 100644
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <asm/global_data.h>
 #include <asm/arch-fsl-layerscape/config.h>
+#include <asm/arch-fsl-layerscape/ns_access.h>
 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
 #include <fsl_csu.h>
 #endif

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void) · line 669

Quoted 1 line
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
@@ -668,6 +669,13 @@ void fsl_lsch2_early_init_f(void)
 			 CCI400_DVM_MESSAGE_REQ_EN |

CCI400_SNOOP_REQ_EN);

Quoted 2 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
 	}
 
Quoted 9 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void)

Quoted 6 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +6 -0
+	/*
+	 * Program Central Security Unit (CSU) to grant access
+	 * permission for USB 2.0 controller
+	 */
+#if defined(CONFIG_ARCH_LS1012A) && defined(CONFIG_USB_EHCI_FSL)
+	set_devices_ns_access(CSU_CSLX_USB_2, CSU_ALL_RW); #endif

Is this LS1012A specific?

Quoted 4 lines

For Layerscape platforms, only LS1012A and LS1021A have USB2.0(EHCI) controller, Others have USB3.0 controller only. For now I can only verify on LS1012A, so didn't cover LS1021A yet.

Ran,

I think calling function set_devices_ns_access() may have an issue. It is not EL2 safe, is it? Please check enable_layerscape_ns_access(). It detects exception level before accessing EL3-only registers.

York

author
#4 lore raw

PATCH 1/1 armv8: layerscape: Enable EHCI access for LS1012A

Hi York,

Quoted 64 lines

-----Original Message-----
From: York Sun
Sent: Tuesday, July 24, 2018 23:40
To: Ran Wang <[email protected]>; Albert Aribaud <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: [PATCH] armv8: layerscape: Enable EHCI access for LS1012A

Quoted 38 lines · Ran Wang

Hi York,

Quoted 36 lines

-----Original Message-----
From: York Sun
Sent: Wednesday, July 11, 2018 05:06
To: Ran Wang <[email protected]>; Albert Aribaud <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: [PATCH] armv8: layerscape: Enable EHCI access for LS1012A

Quoted 24 lines · Ran Wang

Program Central Security Unit (CSU) to grant access permission for USB
2.0 controller, otherwiase EHCI funciton will down.

---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c              | 8 ++++++++
 arch/arm/include/asm/arch-fsl-layerscape/ns_access.h | 1 +
 2 files changed, 9 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
index 6a56269..2c4cf7f 100644
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <asm/global_data.h>
 #include <asm/arch-fsl-layerscape/config.h>
+#include <asm/arch-fsl-layerscape/ns_access.h>
 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
 #include <fsl_csu.h>
 #endif

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void) · line 669

Quoted 1 line
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
@@ -668,6 +669,13 @@ void fsl_lsch2_early_init_f(void)
 			 CCI400_DVM_MESSAGE_REQ_EN |

CCI400_SNOOP_REQ_EN);

Quoted 7 lines
Quoted 7 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void)

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +5 -0
 	}
 
+	/*
+	 * Program Central Security Unit (CSU) to grant access
+	 * permission for USB 2.0 controller
+	 */
+#if defined(CONFIG_ARCH_LS1012A) &&

defined(CONFIG_USB_EHCI_FSL)

Quoted 8 lines
Quoted 4 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void) · line 677

Quoted 1 line
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
+	set_devices_ns_access(CSU_CSLX_USB_2, CSU_ALL_RW); #endif

Is this LS1012A specific?

For Layerscape platforms, only LS1012A and LS1021A have USB2.0(EHCI) controller, Others have USB3.0 controller only. For now I can only verify on LS1012A, so didn't cover LS1021A yet.

Quoted 6 lines

Ran,

I think calling function set_devices_ns_access() may have an issue. It is not EL2 safe, is it? Please check enable_layerscape_ns_access(). It detects exception level before accessing EL3-only registers.

Yes, I re-checked the code and the experiments prove your point, I will send v2 patch soon. Thanks for reminding.

BTW, I observed that in function board_late_init(), the return value of current_el() will be different:
Case 1: Boot with PPA: return 2

    ...
    Using SERDES1 Protocol: 13576 (0x3508)
    PPA Firmware: Version LSDK-1712-TC1-dirty
    SEC Firmware: 'loadables' present in config
    loadables: 'trustedOS at 1'
    ...
    FPGA: v4 (LS1012QDS_2016_0405_1443), build 100 on Tue Apr 05 09:13:13 2016
    wangran!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    current_el():2

Case 2: without PPA: return 3
...
Using SERDES1 Protocol: 13576 (0x3508)
SEC Firmware: config-1: no such config
SEC Firmware: error (-2)
SEC Firmware: Failed to load image
...
FPGA: v4 (LS1012QDS_2016_0405_1443), build 100 on Tue Apr 05 09:13:13 2016 wangran!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
current_el():3

Do you know the reason?

Ran

#5 lore raw

PATCH 1/1 armv8: layerscape: Enable EHCI access for LS1012A

Quoted 98 lines · Ran Wang

Hi York,

Quoted 64 lines

-----Original Message-----
From: York Sun
Sent: Tuesday, July 24, 2018 23:40
To: Ran Wang <[email protected]>; Albert Aribaud <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: [PATCH] armv8: layerscape: Enable EHCI access for LS1012A

Quoted 38 lines · Ran Wang

Hi York,

Quoted 36 lines

-----Original Message-----
From: York Sun
Sent: Wednesday, July 11, 2018 05:06
To: Ran Wang <[email protected]>; Albert Aribaud <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: [PATCH] armv8: layerscape: Enable EHCI access for LS1012A

Quoted 24 lines · Ran Wang

Program Central Security Unit (CSU) to grant access permission for USB
2.0 controller, otherwiase EHCI funciton will down.

---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c              | 8 ++++++++
 arch/arm/include/asm/arch-fsl-layerscape/ns_access.h | 1 +
 2 files changed, 9 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
index 6a56269..2c4cf7f 100644
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <asm/global_data.h>
 #include <asm/arch-fsl-layerscape/config.h>
+#include <asm/arch-fsl-layerscape/ns_access.h>
 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
 #include <fsl_csu.h>
 #endif

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void) · line 669

Quoted 1 line
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
@@ -668,6 +669,13 @@ void fsl_lsch2_early_init_f(void)
 			 CCI400_DVM_MESSAGE_REQ_EN |

CCI400_SNOOP_REQ_EN);

Quoted 7 lines
Quoted 7 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void)

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +5 -0
 	}
 
+	/*
+	 * Program Central Security Unit (CSU) to grant access
+	 * permission for USB 2.0 controller
+	 */
+#if defined(CONFIG_ARCH_LS1012A) &&

defined(CONFIG_USB_EHCI_FSL)

Quoted 8 lines
Quoted 4 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c void fsl_lsch2_early_init_f(void) · line 677

Quoted 1 line
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
+	set_devices_ns_access(CSU_CSLX_USB_2, CSU_ALL_RW); #endif

Is this LS1012A specific?

For Layerscape platforms, only LS1012A and LS1021A have USB2.0(EHCI) controller, Others have USB3.0 controller only. For now I can only verify on LS1012A, so didn't cover LS1021A yet.

Quoted 6 lines

Ran,

I think calling function set_devices_ns_access() may have an issue. It is not EL2 safe, is it? Please check enable_layerscape_ns_access(). It detects exception level before accessing EL3-only registers.

Yes, I re-checked the code and the experiments prove your point, I will send v2 patch soon. Thanks for reminding.

BTW, I observed that in function board_late_init(), the return value of current_el() will be different:
Case 1: Boot with PPA: return 2

    ...
    Using SERDES1 Protocol: 13576 (0x3508)
    PPA Firmware: Version LSDK-1712-TC1-dirty
    SEC Firmware: 'loadables' present in config
    loadables: 'trustedOS at 1'
    ...
    FPGA: v4 (LS1012QDS_2016_0405_1443), build 100 on Tue Apr 05 09:13:13 2016
    wangran!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    current_el():2

Case 2: without PPA: return 3
...
Using SERDES1 Protocol: 13576 (0x3508)
SEC Firmware: config-1: no such config
SEC Firmware: error (-2)
SEC Firmware: Failed to load image
...
FPGA: v4 (LS1012QDS_2016_0405_1443), build 100 on Tue Apr 05 09:13:13 2016 wangran!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
current_el():3

Quoted 2 lines

Do you know the reason?

That's exactly what PPA does -- drop to EL2.

York