Skip to contentSkip to conversation

mvsata_ide: adjust port init sequence

PATCH Superseded Albert Aribaud 2 participants 5 messages Sep 8, 2010 – Oct 12, 2010 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 mvsata_ide: adjust port init sequence

mvsata_ide_initialize_port(): adjust init sequence (SStatus should be checked only after all writes to SControl) and return success/failure to ide_preinit().

Also, as some tests showed init durations in the hundreds of us, raise the time-out to 01 ms to be on the safe side.

---
PATCH HISTORY

V1 Initial patch.
V2 Fixed wrong placement of comment.
Fixed wrong description (was 01 ms, should have been 10). Added Signed-off-by.
V3 Replaced return status values with symbolic names.
Made error status values negative.
Renamed 'tout' to 'timeleft' for clarity. Replaced ternary '?:' operator with '!' and if.

Patch was run through checkscript.pl with 0 errors and warnings.

 drivers/block/mvsata_ide.c |   42 +++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)
drivers/block/mvsata_ide.c +33 -9
index 077b278..3d6993a 100644
@@ -91,29 +91,48 @@ struct mvsata_port_registers {
 #define MVSATA_SSTATUS_DET_DEVCOMM		0x00000003
 
 /*
+ * Status codes to return to client callers. Currently, callers ignore
+ * exact value and only care for zero or nonzero, so no need to make this
+ * public, it is only #define'd for clarity.
+ * If/when standard negative codes are implemented in U-boot, then these
+ * #defines should be moved to, or replaced by ones from, the common list
+ * of status codes.
+ */
+
+#define MVSATA_STATUS_OK	0
+#define MVSATA_STATUS_TIMEOUT	-1
+
+/*
  * Initialize one MVSATAHC port: set SControl's IPM to "always active"
  * and DET to "reset", then wait for SStatus's DET to become "device and
  * comm ok" (or time out after 50 us if no device), then set SControl's
  * DET back to "no action".
  */
 
-static void mvsata_ide_initialize_port(struct mvsata_port_registers *port)
+static int mvsata_ide_initialize_port(struct mvsata_port_registers *port)
 {
 	u32 control;
 	u32 status;
-	u32 tout = 50; /* wait at most 50 us for SATA reset to complete */
+	u32 timeleft = 10000; /* wait at most 10 ms for SATA reset to complete */
 
+	/* 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;
 	writel(control, &port->scontrol);
-	while (--tout) {
+	/* Toggle control DET back to 0 (normal operation) */
+	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_USE;
+	writel(control, &port->scontrol);
+	/* wait for status DET to become 3 (device and communication OK) */
+	while (--timeleft) {
 		status = readl(&port->sstatus) & MVSATA_SSTATUS_DET_MASK;
 		if (status == MVSATA_SSTATUS_DET_DEVCOMM)
 			break;
 		udelay(1);
 	}
-	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_USE;
-	writel(control, &port->scontrol);
+	/* return success or time-out error depending on time left */
+	if (!timeleft)
+		return MVSATA_STATUS_TIMEOUT;
+	return MVSATA_STATUS_OK;
 }
 
 /*
@@ -123,18 +142,23 @@ static void mvsata_ide_initialize_port(struct mvsata_port_registers *port)
 
 int ide_preinit(void)
 {
+	int status;
 	/* Enable ATA port 0 (could be SATA port 0 or 1) if declared */
 #if defined(CONFIG_SYS_ATA_IDE0_OFFSET)
-	mvsata_ide_initialize_port(
+	status = mvsata_ide_initialize_port(
 		(struct mvsata_port_registers *)
 		(CONFIG_SYS_ATA_BASE_ADDR + CONFIG_SYS_ATA_IDE0_OFFSET));
+	if (status)
+		return status;
 #endif
 	/* Enable ATA port 1 (could be SATA port 0 or 1) if declared */
 #if defined(CONFIG_SYS_ATA_IDE1_OFFSET)
-	mvsata_ide_initialize_port(
+	status = mvsata_ide_initialize_port(
 		(struct mvsata_port_registers *)
 		(CONFIG_SYS_ATA_BASE_ADDR + CONFIG_SYS_ATA_IDE1_OFFSET));
+	if (status)
+		return status;
 #endif
-	/* return 0 as we always succeed */
-	return 0;
+	/* return success if all ports initializations succeeded */
+	return MVSATA_STATUS_OK;
 }
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH v3 1/1 mvsata_ide: adjust port init sequence

Quoted 128 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert Aribaud
Sent: Wednesday, September 08, 2010 11:01 PM
To: u-boot at lists.denx.de
Subject: [U-Boot] [PATCH V3] mvsata_ide: adjust port init sequence

mvsata_ide_initialize_port(): adjust init sequence (SStatus should be checked only after all writes to SControl) and return success/failure to ide_preinit().

Also, as some tests showed init durations in the hundreds of us, raise the time-out to 01 ms to be on the safe side.

---
PATCH HISTORY

V1 Initial patch.
V2 Fixed wrong placement of comment.
Fixed wrong description (was 01 ms, should have been 10). Added Signed-off-by.
V3 Replaced return status values with symbolic names.
Made error status values negative.
Renamed 'tout' to 'timeleft' for clarity. Replaced ternary '?:' operator with '!' and if.

Patch was run through checkscript.pl with 0 errors and warnings.

 drivers/block/mvsata_ide.c |   42 
+++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)
drivers/block/mvsata_ide.c +1 -0
index 077b278..3d6993a 100644
@@ -91,29 +91,48 @@ struct mvsata_port_registers {
 #define MVSATA_SSTATUS_DET_DEVCOMM		0x00000003
 
 /*
+ * Status codes to return to client callers. Currently, 

callers ignore
+ * exact value and only care for zero or nonzero, so no need to make this
+ * public, it is only #define'd for clarity.
+ * If/when standard negative codes are implemented in U-boot, then these
+ * #defines should be moved to, or replaced by ones from, the common list
+ * of status codes.
+ */

drivers/block/mvsata_ide.c +5 -0
+
+#define MVSATA_STATUS_OK	0
+#define MVSATA_STATUS_TIMEOUT	-1
+
+/*
  * Initialize one MVSATAHC port: set SControl's IPM to 

"always active"
* and DET to "reset", then wait for SStatus's DET to become
"device and
* comm ok" (or time out after 50 us if no device), then set
SControl's
* DET back to "no action".
*/

-static void mvsata_ide_initialize_port(struct
mvsata_port_registers *port)
+static int mvsata_ide_initialize_port(struct
mvsata_port_registers *port)
{

drivers/block/mvsata_ide.c +0 -1
 	u32 control;
 	u32 status;
-	u32 tout = 50; /* wait at most 50 us for SATA reset to 

complete */

drivers/block/mvsata_ide.c +1 -0
+	u32 timeleft = 10000; /* wait at most 10 ms for SATA 

reset to complete */

drivers/block/mvsata_ide.c +1 -0
+	/* Set control IPM to 3 (no low power) and DET to 1 

(initialize) */

drivers/block/mvsata_ide.c +4 -1
 	control = readl(&port->scontrol);
 	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_INIT;
 	writel(control, &port->scontrol);
-	while (--tout) {
+	/* Toggle control DET back to 0 (normal operation) */
+	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_USE;
+	writel(control, &port->scontrol);
+	/* wait for status DET to become 3 (device and 

communication OK) */

drivers/block/mvsata_ide.c +1 -0
+	while (--timeleft) {
 		status = readl(&port->sstatus) & 

MVSATA_SSTATUS_DET_MASK;

drivers/block/mvsata_ide.c +9 -4
 		if (status == MVSATA_SSTATUS_DET_DEVCOMM)
 			break;
 		udelay(1);
 	}
-	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_USE;
-	writel(control, &port->scontrol);
+	/* return success or time-out error depending on time left */
+	if (!timeleft)
+		return MVSATA_STATUS_TIMEOUT;
+	return MVSATA_STATUS_OK;
 }
 
 /*
@@ -123,18 +142,23 @@ static void 
 mvsata_ide_initialize_port(struct mvsata_port_registers *port)
 
 int ide_preinit(void)
 {
+	int status;
 	/* Enable ATA port 0 (could be SATA port 0 or 1) if declared */
 #if defined(CONFIG_SYS_ATA_IDE0_OFFSET)
-	mvsata_ide_initialize_port(
+	status = mvsata_ide_initialize_port(
 		(struct mvsata_port_registers *)
 		(CONFIG_SYS_ATA_BASE_ADDR + 
 CONFIG_SYS_ATA_IDE0_OFFSET));
+	if (status)
+		return status;
 #endif
 	/* Enable ATA port 1 (could be SATA port 0 or 1) if declared */
 #if defined(CONFIG_SYS_ATA_IDE1_OFFSET)
-	mvsata_ide_initialize_port(
+	status = mvsata_ide_initialize_port(
 		(struct mvsata_port_registers *)

drivers/block/mvsata_ide.c static void · line 164

Quoted 10 lines
drivers/block/mvsata_ide.c +4 -2
 		(CONFIG_SYS_ATA_BASE_ADDR + 
 CONFIG_SYS_ATA_IDE1_OFFSET));
+	if (status)
+		return status;
 #endif
-	/* return 0 as we always succeed */
-	return 0;
+	/* return success if all ports initializations succeeded */
+	return MVSATA_STATUS_OK;
 }

Ack

Regards..
Prafulla . .

#2 lore raw

PATCH v3 1/1 mvsata_ide: adjust port init sequence

In reply to Albert Aribaud
Quoted 128 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert Aribaud
Sent: Wednesday, September 08, 2010 11:01 PM
To: u-boot at lists.denx.de
Subject: [U-Boot] [PATCH V3] mvsata_ide: adjust port init sequence

mvsata_ide_initialize_port(): adjust init sequence (SStatus should be checked only after all writes to SControl) and return success/failure to ide_preinit().

Also, as some tests showed init durations in the hundreds of us, raise the time-out to 01 ms to be on the safe side.

---
PATCH HISTORY

V1 Initial patch.
V2 Fixed wrong placement of comment.
Fixed wrong description (was 01 ms, should have been 10). Added Signed-off-by.
V3 Replaced return status values with symbolic names.
Made error status values negative.
Renamed 'tout' to 'timeleft' for clarity. Replaced ternary '?:' operator with '!' and if.

Patch was run through checkscript.pl with 0 errors and warnings.

 drivers/block/mvsata_ide.c |   42 
+++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)
drivers/block/mvsata_ide.c +1 -0
index 077b278..3d6993a 100644
@@ -91,29 +91,48 @@ struct mvsata_port_registers {
 #define MVSATA_SSTATUS_DET_DEVCOMM		0x00000003
 
 /*
+ * Status codes to return to client callers. Currently, 

callers ignore
+ * exact value and only care for zero or nonzero, so no need to make this
+ * public, it is only #define'd for clarity.
+ * If/when standard negative codes are implemented in U-boot, then these
+ * #defines should be moved to, or replaced by ones from, the common list
+ * of status codes.
+ */

drivers/block/mvsata_ide.c +5 -0
+
+#define MVSATA_STATUS_OK	0
+#define MVSATA_STATUS_TIMEOUT	-1
+
+/*
  * Initialize one MVSATAHC port: set SControl's IPM to 

"always active"
* and DET to "reset", then wait for SStatus's DET to become
"device and
* comm ok" (or time out after 50 us if no device), then set
SControl's
* DET back to "no action".
*/

-static void mvsata_ide_initialize_port(struct
mvsata_port_registers *port)
+static int mvsata_ide_initialize_port(struct
mvsata_port_registers *port)
{

drivers/block/mvsata_ide.c +0 -1
 	u32 control;
 	u32 status;
-	u32 tout = 50; /* wait at most 50 us for SATA reset to 

complete */

drivers/block/mvsata_ide.c +1 -0
+	u32 timeleft = 10000; /* wait at most 10 ms for SATA 

reset to complete */

drivers/block/mvsata_ide.c +1 -0
+	/* Set control IPM to 3 (no low power) and DET to 1 

(initialize) */

drivers/block/mvsata_ide.c +4 -1
 	control = readl(&port->scontrol);
 	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_INIT;
 	writel(control, &port->scontrol);
-	while (--tout) {
+	/* Toggle control DET back to 0 (normal operation) */
+	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_USE;
+	writel(control, &port->scontrol);
+	/* wait for status DET to become 3 (device and 

communication OK) */

drivers/block/mvsata_ide.c +1 -0
+	while (--timeleft) {
 		status = readl(&port->sstatus) & 

MVSATA_SSTATUS_DET_MASK;

drivers/block/mvsata_ide.c +9 -4
 		if (status == MVSATA_SSTATUS_DET_DEVCOMM)
 			break;
 		udelay(1);
 	}
-	control = (control & ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_USE;
-	writel(control, &port->scontrol);
+	/* return success or time-out error depending on time left */
+	if (!timeleft)
+		return MVSATA_STATUS_TIMEOUT;
+	return MVSATA_STATUS_OK;
 }
 
 /*
@@ -123,18 +142,23 @@ static void 
 mvsata_ide_initialize_port(struct mvsata_port_registers *port)
 
 int ide_preinit(void)
 {
+	int status;
 	/* Enable ATA port 0 (could be SATA port 0 or 1) if declared */
 #if defined(CONFIG_SYS_ATA_IDE0_OFFSET)
-	mvsata_ide_initialize_port(
+	status = mvsata_ide_initialize_port(
 		(struct mvsata_port_registers *)
 		(CONFIG_SYS_ATA_BASE_ADDR + 
 CONFIG_SYS_ATA_IDE0_OFFSET));
+	if (status)
+		return status;
 #endif
 	/* Enable ATA port 1 (could be SATA port 0 or 1) if declared */
 #if defined(CONFIG_SYS_ATA_IDE1_OFFSET)
-	mvsata_ide_initialize_port(
+	status = mvsata_ide_initialize_port(
 		(struct mvsata_port_registers *)

drivers/block/mvsata_ide.c static void · line 164

Quoted 10 lines
drivers/block/mvsata_ide.c +4 -2
 		(CONFIG_SYS_ATA_BASE_ADDR + 
 CONFIG_SYS_ATA_IDE1_OFFSET));
+	if (status)
+		return status;
 #endif
-	/* return 0 as we always succeed */
-	return 0;
+	/* return success if all ports initializations succeeded */
+	return MVSATA_STATUS_OK;
 }

Applied to u-boot-marvell.git master branch

Regards..
Prafulla . .

Quoted 8 lines
Signature · 6 lines
1.7.0.4

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
#3 lore raw

PATCH v3 1/1 mvsata_ide: adjust port init sequence

Le 16/09/2010 13:13, Prafulla Wadaskar a ?crit :

Quoted 141 lines
Quoted 128 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert Aribaud
Sent: Wednesday, September 08, 2010 11:01 PM
To: u-boot at lists.denx.de
Subject: [U-Boot] [PATCH V3] mvsata_ide: adjust port init sequence

mvsata_ide_initialize_port(): adjust init sequence (SStatus should be checked only after all writes to SControl) and return success/failure to ide_preinit().

Also, as some tests showed init durations in the hundreds of us, raise the time-out to 01 ms to be on the safe side.

---
PATCH HISTORY

V1 Initial patch.
V2 Fixed wrong placement of comment.
Fixed wrong description (was 01 ms, should have been 10). Added Signed-off-by.
V3 Replaced return status values with symbolic names.
Made error status values negative.
Renamed 'tout' to 'timeleft' for clarity. Replaced ternary '?:' operator with '!' and if.

Patch was run through checkscript.pl with 0 errors and warnings.

  drivers/block/mvsata_ide.c |   42
+++++++++++++++++++++++++++++++++---------
  1 files changed, 33 insertions(+), 9 deletions(-)
drivers/block/mvsata_ide.c +1 -0
index 077b278..3d6993a 100644
@@ -91,29 +91,48 @@ struct mvsata_port_registers {
  #define MVSATA_SSTATUS_DET_DEVCOMM		0x00000003
 
  /*
+ * Status codes to return to client callers. Currently,

callers ignore
+ * exact value and only care for zero or nonzero, so no need to make this
+ * public, it is only #define'd for clarity.
+ * If/when standard negative codes are implemented in U-boot, then these
+ * #defines should be moved to, or replaced by ones from, the common list
+ * of status codes.
+ */

drivers/block/mvsata_ide.c +5 -0
+
+#define MVSATA_STATUS_OK	0
+#define MVSATA_STATUS_TIMEOUT	-1
+
+/*
   * Initialize one MVSATAHC port: set SControl's IPM to

"always active"
* and DET to "reset", then wait for SStatus's DET to become
"device and
* comm ok" (or time out after 50 us if no device), then set
SControl's
* DET back to "no action".
*/

-static void mvsata_ide_initialize_port(struct
mvsata_port_registers *port)
+static int mvsata_ide_initialize_port(struct
mvsata_port_registers *port)
{
u32 control;
u32 status;

drivers/block/mvsata_ide.c +0 -1
-	u32 tout = 50; /* wait at most 50 us for SATA reset to

complete */

drivers/block/mvsata_ide.c +1 -0
+	u32 timeleft = 10000; /* wait at most 10 ms for SATA

reset to complete */

drivers/block/mvsata_ide.c +1 -0
+	/* 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; writel(control,&port->scontrol);

drivers/block/mvsata_ide.c +4 -1
-	while (--tout) {
+	/* Toggle control DET back to 0 (normal operation) */
+	control = (control&  ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_USE;
+	writel(control,&port->scontrol);
+	/* wait for status DET to become 3 (device and

communication OK) */

drivers/block/mvsata_ide.c +1 -0
+	while (--timeleft) {
  		status = readl(&port->sstatus)&

MVSATA_SSTATUS_DET_MASK;
if (status == MVSATA_SSTATUS_DET_DEVCOMM)
break;
udelay(1);
}

drivers/block/mvsata_ide.c +9 -4
-	control = (control&  ~MVSATA_SCONTROL_MASK) | MVSATA_PORT_USE;
-	writel(control,&port->scontrol);
+	/* return success or time-out error depending on time left */
+	if (!timeleft)
+		return MVSATA_STATUS_TIMEOUT;
+	return MVSATA_STATUS_OK;
  }
 
  /*
@@ -123,18 +142,23 @@ static void
 mvsata_ide_initialize_port(struct mvsata_port_registers *port)
 
  int ide_preinit(void)
  {
+	int status;
  	/* Enable ATA port 0 (could be SATA port 0 or 1) if declared */
  #if defined(CONFIG_SYS_ATA_IDE0_OFFSET)
-	mvsata_ide_initialize_port(
+	status = mvsata_ide_initialize_port(
  		(struct mvsata_port_registers *)
  		(CONFIG_SYS_ATA_BASE_ADDR +
 CONFIG_SYS_ATA_IDE0_OFFSET));
+	if (status)
+		return status;
  #endif
  	/* Enable ATA port 1 (could be SATA port 0 or 1) if declared */
  #if defined(CONFIG_SYS_ATA_IDE1_OFFSET)
-	mvsata_ide_initialize_port(
+	status = mvsata_ide_initialize_port(
  		(struct mvsata_port_registers *)

drivers/block/mvsata_ide.c static void · line 164

Quoted 10 lines
drivers/block/mvsata_ide.c +4 -2
  		(CONFIG_SYS_ATA_BASE_ADDR +
 CONFIG_SYS_ATA_IDE1_OFFSET));
+	if (status)
+		return status;
  #endif
-	/* return 0 as we always succeed */
-	return 0;
+	/* return success if all ports initializations succeeded */
+	return MVSATA_STATUS_OK;
  }

Applied to u-boot-marvell.git master branch

Quoted 2 lines

Regards..
Prafulla . .

Prafulla,

Is it possible to ask for a pull of the marvell tree in order to get this bugfix pulled in v2010.09?

Amicalement,

Signature · 1 line
Albert.
#4 lore raw

PATCH v3 1/1 mvsata_ide: adjust port init sequence

In reply to Albert Aribaud
Quoted 29 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert Aribaud
Sent: Wednesday, September 08, 2010 11:01 PM
To: u-boot at lists.denx.de
Subject: [U-Boot] [PATCH V3] mvsata_ide: adjust port init sequence

mvsata_ide_initialize_port(): adjust init sequence (SStatus should be checked only after all writes to SControl) and return success/failure to ide_preinit().

Also, as some tests showed init durations in the hundreds of us, raise the time-out to 01 ms to be on the safe side.

---
PATCH HISTORY

V1 Initial patch.
V2 Fixed wrong placement of comment.
Fixed wrong description (was 01 ms, should have been 10). Added Signed-off-by.
V3 Replaced return status values with symbolic names.
Made error status values negative.
Renamed 'tout' to 'timeleft' for clarity. Replaced ternary '?:' operator with '!' and if.

Quoted 6 lines

Patch was run through checkscript.pl with 0 errors and warnings.

 drivers/block/mvsata_ide.c |   42 
+++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)

Applied to u-boot-marvell.git master branch

Regards.
Prafulla . .