> -----Original Message----- > From: u-boot-boun...@lists.denx.de > [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Albert Aribaud > Sent: Tuesday, September 07, 2010 4:33 AM > To: u-boot@lists.denx.de > Subject: [U-Boot] [PATCH V2] 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 10 ms to be on the safe side. > > Signed-off-by: Albert Aribaud <albert.arib...@free.fr> > --- > 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. > > drivers/block/mvsata_ide.c | 22 ++++++++++++++-------- > 1 files changed, 14 insertions(+), 8 deletions(-) > > diff --git a/drivers/block/mvsata_ide.c b/drivers/block/mvsata_ide.c > index 077b278..470659d 100644 > --- a/drivers/block/mvsata_ide.c > +++ b/drivers/block/mvsata_ide.c > @@ -97,23 +97,27 @@ struct mvsata_port_registers { > * 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 tout = 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); > + /* 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 (--tout) { > 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 (tout? 0: 1);
As suggested in earlier review, can you pls use !tout instead. Or please add a space for ":0" > } > > /* > @@ -125,15 +129,17 @@ int ide_preinit(void) > { > /* Enable ATA port 0 (could be SATA port 0 or 1) if declared */ > #if defined(CONFIG_SYS_ATA_IDE0_OFFSET) > - mvsata_ide_initialize_port( > + if (mvsata_ide_initialize_port( > (struct mvsata_port_registers *) > - (CONFIG_SYS_ATA_BASE_ADDR + > CONFIG_SYS_ATA_IDE0_OFFSET)); > + (CONFIG_SYS_ATA_BASE_ADDR + > CONFIG_SYS_ATA_IDE0_OFFSET))) > + return 1; How about returning negative values for errors ? > #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( > + if (mvsata_ide_initialize_port( > (struct mvsata_port_registers *) > - (CONFIG_SYS_ATA_BASE_ADDR + > CONFIG_SYS_ATA_IDE1_OFFSET)); > + (CONFIG_SYS_ATA_BASE_ADDR + > CONFIG_SYS_ATA_IDE1_OFFSET))) > + return 1; Same here Regards.. Prafulla . . > #endif > /* return 0 as we always succeed */ > return 0; > -- > 1.7.0.4 > > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot > _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot