From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergei Shtylyov Date: Tue, 07 Sep 2010 13:23:27 +0400 Subject: [U-Boot] [PATCH V2] mvsata_ide: adjust port init sequence In-Reply-To: <1283814151-8440-1-git-send-email-albert.aribaud@free.fr> References: <1283814151-8440-1-git-send-email-albert.aribaud@free.fr> Message-ID: <4C86048F.4020503@mvista.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello. On 07-09-2010 3:02, Albert Aribaud wrote: > 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 [...] > 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); Weren't you going to replace this with '!tout'? And anyway, you omitted space before '?' this time, not only before ':'. WBR, Sergei