All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence
@ 2021-05-03 11:31 Marek Vasut
  2021-05-03 15:29 ` Patrice CHOTARD
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Marek Vasut @ 2021-05-03 11:31 UTC (permalink / raw)
  To: u-boot

Currently the code sets eth1addr only if /ethernet1 alias exists in DT,
the node pointed to by the alias has "micrel,ks8851-mll" compatible
string, and the KSZ8851 CCR register read indicates programmed EEPROM
is not connected.

This is not sufficient to detect cases where the DT still contains the
KSZ8851 nodes, but the chip itself is not present. Extend the detection
to handle these cases.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
---
 board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index 49b12c4c042..ac1af718d4a 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -86,6 +86,8 @@ DECLARE_GLOBAL_DATA_PTR;
 #define KS_CCR_EEPROM	BIT(9)
 #define KS_BE0		BIT(12)
 #define KS_BE1		BIT(13)
+#define KS_CIDER	0xC0
+#define CIDER_ID	0x8870
 
 int setup_mac_address(void)
 {
@@ -123,11 +125,18 @@ int setup_mac_address(void)
 	 * is present. If EEPROM is present, it must contain valid
 	 * MAC address.
 	 */
-	u32 reg, ccr;
+	u32 reg, cider, ccr;
 	reg = fdt_get_base_address(gd->fdt_blob, off);
 	if (!reg)
 		goto out_set_ethaddr;
 
+	writew(KS_BE0 | KS_BE1 | KS_CIDER, reg + 2);
+	cider = readw(reg);
+	if ((cider & 0xfff0) != CIDER_ID) {
+		skip_eth1 = true;
+		goto out_set_ethaddr;
+	}
+
 	writew(KS_BE0 | KS_BE1 | KS_CCR, reg + 2);
 	ccr = readw(reg);
 	if (ccr & KS_CCR_EEPROM) {
-- 
2.30.2

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

* [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence
  2021-05-03 11:31 [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence Marek Vasut
@ 2021-05-03 15:29 ` Patrice CHOTARD
  2021-05-04 14:09 ` Patrick DELAUNAY
  2021-05-28 12:50 ` Patrick DELAUNAY
  2 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2021-05-03 15:29 UTC (permalink / raw)
  To: u-boot

Hi Marek

On 5/3/21 1:31 PM, Marek Vasut wrote:
> Currently the code sets eth1addr only if /ethernet1 alias exists in DT,
> the node pointed to by the alias has "micrel,ks8851-mll" compatible
> string, and the KSZ8851 CCR register read indicates programmed EEPROM
> is not connected.
> 
> This is not sufficient to detect cases where the DT still contains the
> KSZ8851 nodes, but the chip itself is not present. Extend the detection
> to handle these cases.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>  board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
> index 49b12c4c042..ac1af718d4a 100644
> --- a/board/dhelectronics/dh_stm32mp1/board.c
> +++ b/board/dhelectronics/dh_stm32mp1/board.c
> @@ -86,6 +86,8 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define KS_CCR_EEPROM	BIT(9)
>  #define KS_BE0		BIT(12)
>  #define KS_BE1		BIT(13)
> +#define KS_CIDER	0xC0
> +#define CIDER_ID	0x8870
>  
>  int setup_mac_address(void)
>  {
> @@ -123,11 +125,18 @@ int setup_mac_address(void)
>  	 * is present. If EEPROM is present, it must contain valid
>  	 * MAC address.
>  	 */
> -	u32 reg, ccr;
> +	u32 reg, cider, ccr;
>  	reg = fdt_get_base_address(gd->fdt_blob, off);
>  	if (!reg)
>  		goto out_set_ethaddr;
>  
> +	writew(KS_BE0 | KS_BE1 | KS_CIDER, reg + 2);
> +	cider = readw(reg);
> +	if ((cider & 0xfff0) != CIDER_ID) {
> +		skip_eth1 = true;
> +		goto out_set_ethaddr;
> +	}
> +
>  	writew(KS_BE0 | KS_BE1 | KS_CCR, reg + 2);
>  	ccr = readw(reg);
>  	if (ccr & KS_CCR_EEPROM) {
> 

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice

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

* [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence
  2021-05-03 11:31 [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence Marek Vasut
  2021-05-03 15:29 ` Patrice CHOTARD
@ 2021-05-04 14:09 ` Patrick DELAUNAY
  2021-05-28 12:50 ` Patrick DELAUNAY
  2 siblings, 0 replies; 6+ messages in thread
From: Patrick DELAUNAY @ 2021-05-04 14:09 UTC (permalink / raw)
  To: u-boot

Hi,

On 5/3/21 1:31 PM, Marek Vasut wrote:
> Currently the code sets eth1addr only if /ethernet1 alias exists in DT,
> the node pointed to by the alias has "micrel,ks8851-mll" compatible
> string, and the KSZ8851 CCR register read indicates programmed EEPROM
> is not connected.
>
> This is not sufficient to detect cases where the DT still contains the
> KSZ8851 nodes, but the chip itself is not present. Extend the detection
> to handle these cases.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>   board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
> index 49b12c4c042..ac1af718d4a 100644
> --- a/board/dhelectronics/dh_stm32mp1/board.c
> +++ b/board/dhelectronics/dh_stm32mp1/board.c
> @@ -86,6 +86,8 @@ DECLARE_GLOBAL_DATA_PTR;
>   #define KS_CCR_EEPROM	BIT(9)
>   #define KS_BE0		BIT(12)
>   #define KS_BE1		BIT(13)
> +#define KS_CIDER	0xC0
> +#define CIDER_ID	0x8870
>   
>   int setup_mac_address(void)
>   {
> @@ -123,11 +125,18 @@ int setup_mac_address(void)
>   	 * is present. If EEPROM is present, it must contain valid
>   	 * MAC address.
>   	 */
> -	u32 reg, ccr;
> +	u32 reg, cider, ccr;
>   	reg = fdt_get_base_address(gd->fdt_blob, off);
>   	if (!reg)
>   		goto out_set_ethaddr;
>   
> +	writew(KS_BE0 | KS_BE1 | KS_CIDER, reg + 2);
> +	cider = readw(reg);
> +	if ((cider & 0xfff0) != CIDER_ID) {
> +		skip_eth1 = true;
> +		goto out_set_ethaddr;
> +	}
> +
>   	writew(KS_BE0 | KS_BE1 | KS_CCR, reg + 2);
>   	ccr = readw(reg);
>   	if (ccr & KS_CCR_EEPROM) {


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick

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

* Re: [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence
  2021-05-03 11:31 [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence Marek Vasut
  2021-05-03 15:29 ` Patrice CHOTARD
  2021-05-04 14:09 ` Patrick DELAUNAY
@ 2021-05-28 12:50 ` Patrick DELAUNAY
  2 siblings, 0 replies; 6+ messages in thread
From: Patrick DELAUNAY @ 2021-05-28 12:50 UTC (permalink / raw)
  To: Marek Vasut, u-boot; +Cc: Patrice Chotard

Hi,

On 5/3/21 1:31 PM, Marek Vasut wrote:
> Currently the code sets eth1addr only if /ethernet1 alias exists in DT,
> the node pointed to by the alias has "micrel,ks8851-mll" compatible
> string, and the KSZ8851 CCR register read indicates programmed EEPROM
> is not connected.
>
> This is not sufficient to detect cases where the DT still contains the
> KSZ8851 nodes, but the chip itself is not present. Extend the detection
> to handle these cases.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>   board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>


Applied to u-boot-stm/master, thanks!

Regards
Patrick


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

* [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence
  2021-04-30 11:29 Marek Vasut
@ 2021-04-30 15:03 ` Patrice CHOTARD
  0 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2021-04-30 15:03 UTC (permalink / raw)
  To: u-boot

Hi Marek

Can you resend this patch to our @foss.st.com email address please ?

Thanks
Patrice
________________________________
De : Marek Vasut <marex@denx.de>
Envoy? : vendredi 30 avril 2021 13:29
? : u-boot at lists.denx.de <u-boot@lists.denx.de>
Cc : Marek Vasut <marex@denx.de>; Patrice CHOTARD <patrice.chotard@st.com>; Patrick DELAUNAY <patrick.delaunay@st.com>
Objet : [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence

Currently the code sets eth1addr only if /ethernet1 alias exists in DT,
the node pointed to by the alias has "micrel,ks8851-mll" compatible
string, and the KSZ8851 CCR register read indicates programmed EEPROM
is not connected.

This is not sufficient to detect cases where the DT still contains the
KSZ8851 nodes, but the chip itself is not present. Extend the detection
to handle these cases.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
---
 board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index 49b12c4c042..ac1af718d4a 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -86,6 +86,8 @@ DECLARE_GLOBAL_DATA_PTR;
 #define KS_CCR_EEPROM   BIT(9)
 #define KS_BE0          BIT(12)
 #define KS_BE1          BIT(13)
+#define KS_CIDER       0xC0
+#define CIDER_ID       0x8870

 int setup_mac_address(void)
 {
@@ -123,11 +125,18 @@ int setup_mac_address(void)
          * is present. If EEPROM is present, it must contain valid
          * MAC address.
          */
-       u32 reg, ccr;
+       u32 reg, cider, ccr;
         reg = fdt_get_base_address(gd->fdt_blob, off);
         if (!reg)
                 goto out_set_ethaddr;

+       writew(KS_BE0 | KS_BE1 | KS_CIDER, reg + 2);
+       cider = readw(reg);
+       if ((cider & 0xfff0) != CIDER_ID) {
+               skip_eth1 = true;
+               goto out_set_ethaddr;
+       }
+
         writew(KS_BE0 | KS_BE1 | KS_CCR, reg + 2);
         ccr = readw(reg);
         if (ccr & KS_CCR_EEPROM) {
--
2.30.2



ST Restricted

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

* [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence
@ 2021-04-30 11:29 Marek Vasut
  2021-04-30 15:03 ` Patrice CHOTARD
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2021-04-30 11:29 UTC (permalink / raw)
  To: u-boot

Currently the code sets eth1addr only if /ethernet1 alias exists in DT,
the node pointed to by the alias has "micrel,ks8851-mll" compatible
string, and the KSZ8851 CCR register read indicates programmed EEPROM
is not connected.

This is not sufficient to detect cases where the DT still contains the
KSZ8851 nodes, but the chip itself is not present. Extend the detection
to handle these cases.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
---
 board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index 49b12c4c042..ac1af718d4a 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -86,6 +86,8 @@ DECLARE_GLOBAL_DATA_PTR;
 #define KS_CCR_EEPROM	BIT(9)
 #define KS_BE0		BIT(12)
 #define KS_BE1		BIT(13)
+#define KS_CIDER	0xC0
+#define CIDER_ID	0x8870
 
 int setup_mac_address(void)
 {
@@ -123,11 +125,18 @@ int setup_mac_address(void)
 	 * is present. If EEPROM is present, it must contain valid
 	 * MAC address.
 	 */
-	u32 reg, ccr;
+	u32 reg, cider, ccr;
 	reg = fdt_get_base_address(gd->fdt_blob, off);
 	if (!reg)
 		goto out_set_ethaddr;
 
+	writew(KS_BE0 | KS_BE1 | KS_CIDER, reg + 2);
+	cider = readw(reg);
+	if ((cider & 0xfff0) != CIDER_ID) {
+		skip_eth1 = true;
+		goto out_set_ethaddr;
+	}
+
 	writew(KS_BE0 | KS_BE1 | KS_CCR, reg + 2);
 	ccr = readw(reg);
 	if (ccr & KS_CCR_EEPROM) {
-- 
2.30.2

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

end of thread, other threads:[~2021-05-28 12:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 11:31 [PATCH] ARM: stm32: Add additional ID register check for KSZ8851 presence Marek Vasut
2021-05-03 15:29 ` Patrice CHOTARD
2021-05-04 14:09 ` Patrick DELAUNAY
2021-05-28 12:50 ` Patrick DELAUNAY
  -- strict thread matches above, loose matches on Subject: below --
2021-04-30 11:29 Marek Vasut
2021-04-30 15:03 ` Patrice CHOTARD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.