mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: barebox@lists.infradead.org
Subject: Re: ARM, MMU and IO space mapping
Date: Mon, 28 Nov 2011 08:43:19 +0100	[thread overview]
Message-ID: <20111128074319.GO27267@pengutronix.de> (raw)
In-Reply-To: <87lir18ag7.fsf@free.fr>

On Sun, Nov 27, 2011 at 11:30:48PM +0100, Robert Jarzmik wrote:
> Sascha Hauer <s.hauer@pengutronix.de> writes:
> 
> > Hmmm...
> >
> > I just made your patches work on my pcm027 board (If you haven't fixed
> > the serial driver already: now I have patches for this). Without MMU
> > everything is fine. With MMU I had to disable the zero page because
> > otherwise the cfi flash driver will bail out with a NULL pointer deref.
> > With this I noticed that when I start barebox from U-Boot that the
> > driver does not recognize the flash.
> 
> I don't understand how that works. As the zero page is remapped onto the vectors
> memory, how can a driver access the NOR chip ?
> 
> My understanding is that barebox makes a flat 1:1 mapping, and then replaces
> the first section with a 2 levels translation, where :
>  - the first 4096 bytes are mapped onto the malloc'd vectors
>  - the remaining 1MBytes-4096Bytes are still in a flat 1:1 mapping
> 
> If that is correct, you loose your ability to access address space 0x00000000 -
> 0x00001000. How can you use the CFI after that ?

That's why I had to disable this mapping. Most other SoCs do not have
flash on 0x0. The i.MX processors for example have their internal ROM
there.

> 
> And as a consequence, I'm a bit afraid that my disk-on-chip, having it's memory
> mapped to 0x0 - 0x2000, will be difficult to convert ... I must think of a way
> in there.

Your options are:

- Add some switch to disable the 0x0 mapping.
- Add ioremap support.

I think we should go for the former for now. Real ioremap support
requires more thinking about how we want to do it. Will all drivers have
to do it or only the cfi driver?

> 
> > 		@ Data cache might be active.
> > 		@ Be sure to flush kernel binary out of the cache,
> > 		@ whatever state it is, before it is turned off.
> > 		@ This is done by fetching through currently executed
> > 		@ memory to be sure we hit the same cache.
> > 		bic	r2, pc, #0x1f
> > 		add	r3, r2, #0x10000	@ 64 kb is quite enough...
> > 1:		ldr	r0, [r2], #32
> > 		teq	r2, r3
> > 		bne	1b
> > 		mcr	p15, 0, r0, c7, c10, 4	@ drain WB
> > 		mcr	p15, 0, r0, c7, c7, 0	@ flush I & D caches
> >
> > 		@ disabling MMU and caches
> > 		mrc	p15, 0, r0, c1, c0, 0	@ read control reg
> > 		bic	r0, r0, #0x05		@ clear DC, MMU
> > 		bic	r0, r0, #0x1000		@ clear Icache
> > 		mcr	p15, 0, r0, c1, c0, 0
> >
> > I don't know what's going on here.
> 
> I don't know either. All I see is that the datacache is filled so that stale
> values are flushed out, and then it's flushed again through normal coproc
> operations.
> Note that there's an erratum in the XScale series that says that turning off the
> cache leaves "dirty bits" set, and reenabling it later might cause havoc. That
> would be a good reason for UBoot the read the 64kb before turning off the MMU,
> wouldn't it ?

Yes, it would. Does your first stage loader use the MMU?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2011-11-28  7:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24 11:24 Robert Jarzmik
2011-11-24 12:04 ` Sascha Hauer
2011-11-24 14:23   ` Marc Kleine-Budde
2011-11-24 20:09   ` Robert Jarzmik
2011-11-24 20:25     ` Marc Kleine-Budde
2011-11-25  0:01     ` Sascha Hauer
2011-11-27 22:30       ` Robert Jarzmik
2011-11-28  7:43         ` Sascha Hauer [this message]
2011-11-28 17:43           ` Robert Jarzmik
2011-11-29  8:15             ` Sascha Hauer
2011-11-30 22:06               ` Robert Jarzmik
2011-12-01 14:26                 ` Sascha Hauer
2011-12-01 14:34                   ` Marc Kleine-Budde
2011-12-11 13:01                   ` Robert Jarzmik

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=20111128074319.GO27267@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=robert.jarzmik@free.fr \
    /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