Patchwork [U-Boot] mvsata: issue hard reset on initialization

login
register
mail settings
Submitter Michael Walle
Date May 1, 2011, 10:04 p.m.
Message ID <1304287496-17497-1-git-send-email-michael@walle.cc>
Download mbox | patch
Permalink /patch/93587/
State Changes Requested
Delegated to: Albert ARIBAUD
Headers show

Comments

Michael Walle - May 1, 2011, 10:04 p.m.
Before the actual initialization do a hard reset of the SATA port and the
connected device.

Signed-off-by: Michael Walle <michael@walle.cc>
Cc: Prafulla Wadaskar <prafulla@marvell.com>
---
 drivers/block/mvsata_ide.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
Prafulla Wadaskar - May 2, 2011, 8:37 a.m.
> -----Original Message-----
> From: Michael Walle [mailto:michael@walle.cc]
> Sent: Monday, May 02, 2011 3:35 AM
> To: u-boot@lists.denx.de
> Cc: Michael Walle; Prafulla Wadaskar
> Subject: [PATCH] mvsata: issue hard reset on initialization
> 
> Before the actual initialization do a hard reset of the SATA port and
> the
> connected device.

Copying Albert for his ack

Regards..
Prafulla . .

> 
> Signed-off-by: Michael Walle <michael@walle.cc>
> Cc: Prafulla Wadaskar <prafulla@marvell.com>
> ---
>  drivers/block/mvsata_ide.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/block/mvsata_ide.c b/drivers/block/mvsata_ide.c
> index 3d6993a..ff880d5 100644
> --- a/drivers/block/mvsata_ide.c
> +++ b/drivers/block/mvsata_ide.c
> @@ -33,7 +33,9 @@
> 
>  /* SATA port registers */
>  struct mvsata_port_registers {
> -	u32 reserved1[192];
> +	u32 reserved0[10];
> +	u32 edma_cmd;
> +	u32 reserved1[181];
>  	/* offset 0x300 : ATA Interface registers */
>  	u32 sstatus;
>  	u32 serror;
> @@ -76,6 +78,7 @@ struct mvsata_port_registers {
>   * and for SStatus DETection.
>   */
> 
> +#define MVSATA_EDMA_CMD_ATA_RST		0x00000004
>  #define MVSATA_SCONTROL_DET_MASK		0x0000000F
>  #define MVSATA_SCONTROL_DET_NONE		0x00000000
>  #define MVSATA_SCONTROL_DET_INIT		0x00000001
> @@ -115,6 +118,11 @@ static int mvsata_ide_initialize_port(struct
> mvsata_port_registers *port)
>  	u32 status;
>  	u32 timeleft = 10000; /* wait at most 10 ms for SATA reset to
> complete */
> 
> +	/* Hard reset */
> +	writel(MVSATA_EDMA_CMD_ATA_RST, &port->edma_cmd);
> +	udelay(25);
> +	writel(0, &port->edma_cmd);
> +
>  	/* Set control IPM to 3 (no low power) and DET to 1 (initialize) */
>  	control = readl(&port->scontrol);
>  	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_INIT;
> --
> 1.7.2.3
Michael Walle - May 9, 2011, 5:49 p.m.
Am Montag 02 Mai 2011, 10:37:41 schrieb Prafulla Wadaskar:
> > -----Original Message-----
> > From: Michael Walle [mailto:michael@walle.cc]
> > Sent: Monday, May 02, 2011 3:35 AM
> > To: u-boot@lists.denx.de
> > Cc: Michael Walle; Prafulla Wadaskar
> > Subject: [PATCH] mvsata: issue hard reset on initialization
> > 
> > Before the actual initialization do a hard reset of the SATA port and
> > the
> > connected device.
> 
> Copying Albert for his ack
any news on this?
Albert ARIBAUD - May 10, 2011, 9:47 p.m.
Hi Michael,

Sorry for the delay. Busy period for me I'm afraid.

Le 09/05/2011 19:49, Michael Walle a écrit :
> Am Montag 02 Mai 2011, 10:37:41 schrieb Prafulla Wadaskar:
>>> -----Original Message-----
>>> From: Michael Walle [mailto:michael@walle.cc]
>>> Sent: Monday, May 02, 2011 3:35 AM
>>> To: u-boot@lists.denx.de
>>> Cc: Michael Walle; Prafulla Wadaskar
>>> Subject: [PATCH] mvsata: issue hard reset on initialization
>>>
>>> Before the actual initialization do a hard reset of the SATA port and
>>> the
>>> connected device.
>>
>> Copying Albert for his ack
> any news on this?
>

What is the reason for issuing the hard reset? Is it in case the board 
was rebooted and we want the disk drives to return to a safe state?

Also, why 25?

Amicalement,
Michael Walle - May 10, 2011, 10:13 p.m.
Hi Albert,

Am Dienstag 10 Mai 2011, 23:47:04 schrieben Sie:
> Hi Michael,
> 
> Sorry for the delay. Busy period for me I'm afraid.
no problem ;)

> Le 09/05/2011 19:49, Michael Walle a écrit :
> > Am Montag 02 Mai 2011, 10:37:41 schrieb Prafulla Wadaskar:
> >>> -----Original Message-----
> >>> From: Michael Walle [mailto:michael@walle.cc]
> >>> Sent: Monday, May 02, 2011 3:35 AM
> >>> To: u-boot@lists.denx.de
> >>> Cc: Michael Walle; Prafulla Wadaskar
> >>> Subject: [PATCH] mvsata: issue hard reset on initialization
> >>> 
> >>> Before the actual initialization do a hard reset of the SATA port and
> >>> the
> >>> connected device.
> >> 
> >> Copying Albert for his ack
> > 
> > any news on this?
> 
> What is the reason for issuing the hard reset? Is it in case the board
> was rebooted and we want the disk drives to return to a safe state?
Right, if i reboot my linkstation (from linux) the ATA probing times out 
without the reset.

Also, the user manual states (FS_88F6180_9x_6281_OpenSource.pdf, Ch 7.6.9):
  Device hard reset (setting the <eAtaRst> field in the EDMA Command Register
  (Table 342 p. 506) and device initialization are required before any attempt
  to access the device.


> Also, why 25?
I took that 25us from the original marvell uboot port (uboot 1.1.4 heavily 
modified by marvell, the gpl sources provided by buffalo) and from the linux 
sata_mv driver, both are using 25us.
Albert ARIBAUD - May 11, 2011, 5:23 a.m.
Hi Michael,

Le 11/05/2011 00:13, Michael Walle a écrit :
>
> Hi Albert,
>
> Am Dienstag 10 Mai 2011, 23:47:04 schrieben Sie:
>> Hi Michael,
>>
>> Sorry for the delay. Busy period for me I'm afraid.
> no problem ;)
>
>> Le 09/05/2011 19:49, Michael Walle a écrit :
>>> Am Montag 02 Mai 2011, 10:37:41 schrieb Prafulla Wadaskar:
>>>>> -----Original Message-----
>>>>> From: Michael Walle [mailto:michael@walle.cc]
>>>>> Sent: Monday, May 02, 2011 3:35 AM
>>>>> To: u-boot@lists.denx.de
>>>>> Cc: Michael Walle; Prafulla Wadaskar
>>>>> Subject: [PATCH] mvsata: issue hard reset on initialization
>>>>>
>>>>> Before the actual initialization do a hard reset of the SATA port and
>>>>> the
>>>>> connected device.
>>>>
>>>> Copying Albert for his ack
>>>
>>> any news on this?
>>
>> What is the reason for issuing the hard reset? Is it in case the board
>> was rebooted and we want the disk drives to return to a safe state?
> Right, if i reboot my linkstation (from linux) the ATA probing times out
> without the reset.
>
> Also, the user manual states (FS_88F6180_9x_6281_OpenSource.pdf, Ch 7.6.9):
>    Device hard reset (setting the<eAtaRst>  field in the EDMA Command Register
>    (Table 342 p. 506) and device initialization are required before any attempt
>    to access the device.

Ok.

>> Also, why 25?
> I took that 25us from the original marvell uboot port (uboot 1.1.4 heavily
> modified by marvell, the gpl sources provided by buffalo) and from the linux
> sata_mv driver, both are using 25us.

Can you just add a comment stating that the value was inspired by 
Marvell use rather than taken from the spec?

Amicalement,

Patch

diff --git a/drivers/block/mvsata_ide.c b/drivers/block/mvsata_ide.c
index 3d6993a..ff880d5 100644
--- a/drivers/block/mvsata_ide.c
+++ b/drivers/block/mvsata_ide.c
@@ -33,7 +33,9 @@ 
 
 /* SATA port registers */
 struct mvsata_port_registers {
-	u32 reserved1[192];
+	u32 reserved0[10];
+	u32 edma_cmd;
+	u32 reserved1[181];
 	/* offset 0x300 : ATA Interface registers */
 	u32 sstatus;
 	u32 serror;
@@ -76,6 +78,7 @@  struct mvsata_port_registers {
  * and for SStatus DETection.
  */
 
+#define MVSATA_EDMA_CMD_ATA_RST		0x00000004
 #define MVSATA_SCONTROL_DET_MASK		0x0000000F
 #define MVSATA_SCONTROL_DET_NONE		0x00000000
 #define MVSATA_SCONTROL_DET_INIT		0x00000001
@@ -115,6 +118,11 @@  static int mvsata_ide_initialize_port(struct mvsata_port_registers *port)
 	u32 status;
 	u32 timeleft = 10000; /* wait at most 10 ms for SATA reset to complete */
 
+	/* Hard reset */
+	writel(MVSATA_EDMA_CMD_ATA_RST, &port->edma_cmd);
+	udelay(25);
+	writel(0, &port->edma_cmd);
+
 	/* Set control IPM to 3 (no low power) and DET to 1 (initialize) */
 	control = readl(&port->scontrol);
 	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_INIT;