Skip to contentSkip to conversation

at91sam9260/9263: add back up fot the rst(reset controller).

PATCH New Sedji Gaouaou 3 participants 4 messages Jun 23, 2009 – Jun 24, 2009 Arm/Microchip (AT91) SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 at91sam9260/9263: add back up fot the rst(reset controller).

On the boards at91sam9260ek, at91sam9263ek and afed9260, the rstc register was set to 0 after being set to 500 ms for the PHY reset.
Now if back up is enable it will be set to the saved value.

---
 board/afeb9260/afeb9260.c                 |    6 +++++-
 board/atmel/at91sam9260ek/at91sam9260ek.c |    6 +++++-
 board/atmel/at91sam9263ek/at91sam9263ek.c |    6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)
board/afeb9260/afeb9260.c +5 -1
index a247663..1af02e2 100644
@@ -81,6 +81,8 @@ static void afeb9260_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void afeb9260_macb_hw_init(void)
 {
+	unsigned long rstc;
+	
 	/* Enable clock */
 	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_EMAC);
 
@@ -103,6 +105,8 @@ static void afeb9260_macb_hw_init(void)
 	       pin_to_mask(AT91_PIN_PA28),
 	       pin_to_controller(AT91_PIN_PA0) + PIO_PUDR);
 
+	rstc = at91_sys_read(AT91_RSTC_MR);
+	
 	/* Need to reset PHY -> 500ms reset */
 	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
 				     AT91_RSTC_ERSTL | (0x0D << 8) |
@@ -115,7 +119,7 @@ static void afeb9260_macb_hw_init(void)
 
 	/* Restore NRST value */
 	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
-				     AT91_RSTC_ERSTL | (0x0 << 8) |
+				     (rstc) |
 				     AT91_RSTC_URSTEN);
 
 	/* Re-enable pull-up */
board/atmel/at91sam9260ek/at91sam9260ek.c +5 -1
index 6bd3b44..93bc021 100644
@@ -86,6 +86,8 @@ static void at91sam9260ek_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void at91sam9260ek_macb_hw_init(void)
 {
+	unsigned long rstc;
+	
 	/* Enable clock */
 	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_EMAC);
 
@@ -108,6 +110,8 @@ static void at91sam9260ek_macb_hw_init(void)
 	       pin_to_mask(AT91_PIN_PA28),
 	       pin_to_controller(AT91_PIN_PA0) + PIO_PUDR);
 
+	rstc = at91_sys_read(AT91_RSTC_MR);
+	
 	/* Need to reset PHY -> 500ms reset */
 	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
 				     (AT91_RSTC_ERSTL & (0x0D << 8)) |
@@ -120,7 +124,7 @@ static void at91sam9260ek_macb_hw_init(void)
 
 	/* Restore NRST value */
 	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
-				     (AT91_RSTC_ERSTL & (0x0 << 8)) |
+				     (rstc) |
 				     AT91_RSTC_URSTEN);
 
 	/* Re-enable pull-up */
board/atmel/at91sam9263ek/at91sam9263ek.c +5 -1
index 57d5c95..e41b7fa 100644
@@ -91,6 +91,8 @@ static void at91sam9263ek_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void at91sam9263ek_macb_hw_init(void)
 {
+	unsigned long rstc;
+	
 	/* Enable clock */
 	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_EMAC);
 
@@ -108,6 +110,8 @@ static void at91sam9263ek_macb_hw_init(void)
 	       pin_to_mask(AT91_PIN_PE26),
 	       pin_to_controller(AT91_PIN_PE0) + PIO_PUDR);
 
+	rstc = at91_sys_read(AT91_RSTC_MR);
+	
 	/* Need to reset PHY -> 500ms reset */
 	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
 				     (AT91_RSTC_ERSTL & (0x0D << 8)) |
@@ -120,7 +124,7 @@ static void at91sam9263ek_macb_hw_init(void)
 
 	/* Restore NRST value */
 	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
-				     (AT91_RSTC_ERSTL & (0x0 << 8)) |
+				     (rstc) |
 				     AT91_RSTC_URSTEN);
 
 	/* Re-enable pull-up */
Signature · 1 line
1.5.3.7
#1 lore raw

PATCH 1/1 at91sam9260/9263: add back up fot the rst(reset controller).

Quoted 10 lines · Sedji Gaouaou

On the boards at91sam9260ek, at91sam9263ek and afed9260, the rstc register was set to 0 after being set to 500 ms for the PHY reset.
Now if back up is enable it will be set to the saved value.

---
 board/afeb9260/afeb9260.c                 |    6 +++++-
 board/atmel/at91sam9260ek/at91sam9260ek.c |    6 +++++-
 board/atmel/at91sam9263ek/at91sam9263ek.c |    6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

Look fine for me, Stelian & Sergey for you?

Best Regards,
J.

#2 lore raw

PATCH 1/1 at91sam9260/9263: add back up fot the rst(reset controller).

In reply to Sedji Gaouaou
Quoted 3 lines · Sedji Gaouaou

On the boards at91sam9260ek, at91sam9263ek and afed9260, the rstc register was set to 0 after being set to 500 ms for the PHY reset.
Now if back up is enable it will be set to the saved value.

The changelog message is not very clear. What means "if backup is enabled" ? I don't see anything in the patch which can be enabled or disabled...

I think you meant something like: "Do backup the old reset length and restore it after the MACB initialisation".

Quoted 1 line
(quoted diff) +1 -0
+	rstc = at91_sys_read(AT91_RSTC_MR);

[...]

board/afeb9260/afeb9260.c static void afeb9260_macb_hw_init(void) · line 123

Quoted 5 lines
board/afeb9260/afeb9260.c +1 -1
 	/* Restore NRST value */
 	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
-				     AT91_RSTC_ERSTL | (0x0 << 8) |
+				     (rstc) |
 				     AT91_RSTC_URSTEN);

Also, I don't like this: you backup in 'rstc' the _whole_ contents of the MR register (including for example the URSTEN bit), but on restore you still construct a bit mask...

In order to be consistent, I would do either:

rstc = at91_sys_read(AT91_RSTC_MR);
...
at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | rstc);

or

rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL;
...
at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | rstc | AT91_RSTC_URSTEN);

Not sure what version would be best though...

Stelian.

Signature · 1 line
Stelian Pop <[email protected]>
#3 lore raw

PATCH 1/1 at91sam9260/9263: add back up fot the rst(reset controller).

Stelian Pop a ?crit :

Quoted 9 lines · Sedji Gaouaou
Quoted 4 lines

On the boards at91sam9260ek, at91sam9263ek and afed9260, the rstc register was set to 0 after being set to 500 ms for the PHY reset.
Now if back up is enable it will be set to the saved value.

The changelog message is not very clear. What means "if backup is enabled" ? I don't see anything in the patch which can be enabled or disabled...

To enable the back up you need to put a battery, so if there is no battery there is no back up...that is why I said if back up is enable :)

Quoted 3 lines

I think you meant something like: "Do backup the old reset length and restore it after the MACB initialisation".

But you comment is better, so I will change it.

Quoted 18 lines
Quoted 1 line
(quoted diff) +1 -0
+	rstc = at91_sys_read(AT91_RSTC_MR);

[...]

board/afeb9260/afeb9260.c static void afeb9260_macb_hw_init(void) · line 123

Quoted 5 lines
board/afeb9260/afeb9260.c +1 -1
 	/* Restore NRST value */
 	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
-				     AT91_RSTC_ERSTL | (0x0 << 8) |
+				     (rstc) |
 				     AT91_RSTC_URSTEN);

Also, I don't like this: you backup in 'rstc' the _whole_ contents of the MR register (including for example the URSTEN bit), but on restore you still construct a bit mask...

In order to be consistent, I would do either:

rstc = at91_sys_read(AT91_RSTC_MR);
...
at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | rstc);

Quoted 6 lines

or

rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL;
...
at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | rstc | AT91_RSTC_URSTEN);

I will change that to then.

Regards,
Sedji