public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Chin Liang See <clsee@altera.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/2] nand/denali: Adding Denali NAND driver support
Date: Wed, 5 Mar 2014 11:40:47 -0600	[thread overview]
Message-ID: <1394041247.3307.12.camel@clsee-VirtualBox.altera.com> (raw)
In-Reply-To: <20140304193148.6E7A.AA925319@jp.panasonic.com>

Hi Masahiro,

On Tue, 2014-03-04 at 19:31 +0900, Masahiro Yamada wrote:
> Hello Scott, Chin,
> 
> 
> > > +/* this is a helper macro that allows us to
> > > + * format the bank into the proper bits for the controller */
> > > +#define BANK(x) ((x) << 24)
> > > +
> > > +/* Interrupts are cleared by writing a 1 to the appropriate status bit */
> > > +static inline void clear_interrupt(uint32_t irq_mask)
> > > +{
> > > +	uint32_t intr_status_reg = 0;
> > > +	intr_status_reg = INTR_STATUS(denali.flash_bank);
> > > +	__raw_writel(irq_mask, denali.flash_reg + intr_status_reg);
> > > +}
> > 
> > Why are you using raw I/O accessors?  The Linux driver doesn't do this.
> 
> Add ioread32/iowrite32 to arch/arm/include/asm/io.h
> and use them?
> 


Changed all to use standard writel and readl.

> 
> 
> > > +
> > > +static uint32_t wait_for_irq(uint32_t irq_mask)
> > > +{
> > > +	unsigned long comp_res = 1000;
> > > +	uint32_t intr_status = 0;
> > > +
> > > +	do {
> > > +		intr_status = read_interrupt_status() & DENALI_IRQ_ALL;
> > > +		if (intr_status & irq_mask) {
> > > +			denali.irq_status &= ~irq_mask;
> > > +			/* our interrupt was detected */
> > > +			break;
> > > +		}
> > > +		udelay(1);
> > > +		comp_res--;
> > > +	} while (comp_res != 0);
> > 
> > This looks like a much shorter timeout than Linux uses (1000us versus
> > 1000ms).  Though FWIW the Linux timeout code looks buggy.
> > 
> > Also, comp_res is a very odd name for a timeout variable.
> 
> Right. I think wait time is too short.
> When I tested this code on my board, timeout error always
> occurred on page write command.
> 
> I had to fix it to run write command.
>     s/udelay(1)/udelay(1000)/
> 
> 

Hmmm that is interesting.
Probably I speed up the NAND controller to max.
Anyway, the delay now is 1s.

> 
> 
> There is another problem.
> I think there is a cache coherency problem in this driver code.
> DMA is used in this driver but D-cache is never flushed.
> 
> When D-cache is on (CONFIG_SYS_DCACHE_OFF is not defined),
> ARM processor writes to/reads from the buffer through D-cache.
> On the other hand, Denali NAND controller always wites to/reads from
> the buffer on physical memory.
> So, this driver writes/reads wrong data.
> 
> I had to add flush_dcache_range() function call
> in denali_setup_dma_sequence().
> 
> 
>   @@ -689,6 +689,8 @@ static void denali_setup_dma_sequence(int op)
>           uint32_t mode;
>           uint32_t addr = (uint32_t)denali.buf.dma_buf;
>    
>   +       flush_dcache_range(addr, addr + sizeof(denali.buf.dma_buf));
>   +
>           mode = MODE_10 | BANK(denali.flash_bank);
>    
>           /* DMA is a four step process */
> 
> 


I miss out this as I didn't enable the cache.
Thanks and I will put this into new patches

Chin Liang

> 
> 
> Best Regards
> Masahiro Yamada
> 
> 

  parent reply	other threads:[~2014-03-05 17:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-21 20:51 [U-Boot] [PATCH v2 1/2] nand/denali: Adding Denali NAND driver support Chin Liang See
2014-02-24  7:48 ` Michal Simek
2014-02-24  8:06   ` Masahiro Yamada
2014-02-24  8:16     ` Michal Simek
2014-02-27 17:04   ` Chin Liang See
2014-02-28 10:37     ` Michal Simek
2014-03-04 23:57       ` Chin Liang See
2014-03-05  6:22         ` Michal Simek
2014-02-27 14:35 ` Masahiro Yamada
2014-02-27 21:02   ` Chin Liang See
2014-02-27 22:32     ` Scott Wood
2014-02-27 23:03       ` Chin Liang See
2014-02-28 12:57         ` Masahiro Yamada
2014-03-05  0:24           ` Chin Liang See
2014-03-04  0:03 ` Scott Wood
2014-03-04 10:31   ` Masahiro Yamada
2014-03-04 18:44     ` Scott Wood
2014-03-05 17:40     ` Chin Liang See [this message]
2014-03-05 17:34   ` Chin Liang See
2014-03-05 18:23     ` Scott Wood
2014-03-05 23:01       ` Chin Liang See
2014-03-05 23:04         ` Scott Wood
2014-03-05 23:09           ` Chin Liang See
2014-03-05 23:11             ` Scott Wood
2014-03-05 23:21               ` Chin Liang See
2014-05-30 10:50 ` Rik Smith
2014-05-30 11:36   ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394041247.3307.12.camel@clsee-VirtualBox.altera.com \
    --to=clsee@altera.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox