From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chin Liang See Date: Tue, 1 Sep 2015 04:30:59 -0500 Subject: [U-Boot] [PATCH] spi: cadence_qspi: Ensure spi_calibration is run when sclk change In-Reply-To: <201509011119.18443.marex@denx.de> References: <1441097207-2162-1-git-send-email-clsee@altera.com> <201509011101.55689.marex@denx.de> <1441098818.1901.4.camel@clsee-VirtualBox> <201509011119.18443.marex@denx.de> Message-ID: <1441099859.1872.3.camel@clsee-VirtualBox> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, 2015-09-01 at 11:19 +0200, marex at denx.de wrote: > On Tuesday, September 01, 2015 at 11:13:38 AM, Chin Liang See wrote: > > On Tue, 2015-09-01 at 11:01 +0200, marex at denx.de wrote: > > > On Tuesday, September 01, 2015 at 10:46:47 AM, Chin Liang See wrote: > > > > Ensuring spi_calibration is run when there is a change of sclk > > > > frequency. This will ensure the qspi flash access works for high > > > > sclk frequency > > > > > > > > Signed-off-by: Chin Liang See > > > > Cc: Dinh Nguyen > > > > Cc: Marek Vasut > > > > Cc: Stefan Roese > > > > Cc: Vikas Manocha > > > > Cc: Jagannadh Teki > > > > Cc: Pavel Machek > > > > --- > > > > > > > > drivers/spi/cadence_qspi.c | 3 +++ > > > > 1 files changed, 3 insertions(+), 0 deletions(-) > > > > > > > > diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c > > > > index 34a0f46..512bf2d 100644 > > > > --- a/drivers/spi/cadence_qspi.c > > > > +++ b/drivers/spi/cadence_qspi.c > > > > @@ -128,6 +128,9 @@ static int cadence_spi_set_speed(struct udevice > > > > *bus, uint hz) > > > > > > > > cadence_spi_write_speed(bus, hz); > > > > > > > > + /* to ensure spi_calibration is run when SCLK frequency change */ > > > > + plat->max_hz = hz; > > > > + > > > > > > This looks like a hack, doesn't this change just subvert the condition > > > below to enforce the calibration ? > > > > Nope. I checked through debugger where plat->max_hz is initialized once > > with the value from device tree. When you use sf probe to change > > frequency, the value is not reflected to plat->max_hz. Hence the > > calibration is not run when frequency change. That lead to the sf probe > > fail when running at 80MHz or higher. Note the priv->qspi_calibrated_hz > > is updated after calibration succeed. > > Isn't the purpose of ->max_hz to reflect the maximum frequency of the bus? > I don't think this should thus ever be updated, in particular not by the > user. I also think that setting ->max_hz once from DT is the correct behavior. > Oh, in this case, there are more bug in the code. I saw there is mismatch of the usage of this variable. As example, the line "priv->qspi_calibrated_hz = plat->max_hz;" is wrong as it would be always static. Besides that, there is no check against the requested speed not to exceed the max_hz. Let me fix this all again. Thanks Chin Liang > Best regards, > Marek Vasut