public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Enable port-mapped access to 16550 UART
Date: Thu, 29 Oct 2009 16:42:00 +0100	[thread overview]
Message-ID: <m2aaza2omv.fsf@ohwell.denx.de> (raw)
In-Reply-To: <d66caabb0910281418g28243439q5c9324b991d24b38@mail.gmail.com> (Graeme Russ's message of "Thu, 29 Oct 2009 08:18:27 +1100")

Hi Graeme,


[...]

>>> +#ifdef CONFIG_X86
>>> +#define uart_writeb(x,y)     outb(x,(ulong)y)
>>> +#define uart_readb(y)                inb((ulong)y)
>>> +#else
>>> +#define uart_writeb(x,y) writeb(x,y)
>>> +#define uart_readb(y) readb(y)
>>> +#endif
>>
>> Why do you need a specific variant for X86 instead of implementing
>> writeb and readb correctly in the first place?
>
> For x86 readb and writeb provide volatile accessors to memory - These are
> used for memory-mapped devices (i.e. devices which are attached directly
> to the memory bus such as PCI devices etc). inb and outb provide access to
> I/O Ports. For example:
>
> writeb(0x12, 0x00001000) will generate something like:
>     movb $0x12, al
>     movl $0x00001000, ebx
>     movb al, ebx
>
> outb(0x12, 0x00001000) will generate something like:
>     movb $0x12, al
>     movl $0x00001000, ebx
>     outb al, ebx
>
> Looking at include/asm/asm-ppc/io.h it seems to me that, for PPC, there is
> no differentiation between readb/writeb and inb/outb other than that the
> user may define an optional IOBASE for inb/outb which shifts where in
> memory inb/outb accesses, but they are still memory accesses. So, for PPC,
> if IOBASE is 0, the above two examples will compile to identical code.
>
> (Having a look at the other arches, it appears that x86 is very unique in
> that inb/outb do not access memory)

Ok, I remember this icky in/out stuff from x86 now that you come to
mention it. 

So it seems we have to keep the distinction somehow.  Looking at
drivers/serial/8250.c to see what Linux does, we could start including
something like the "port.iotype" layer from there, although I feel this
is somewhat too heavy currently.  So in the meantime, I'd suggest that
we at least start using the Linux convention and turn all the register
accesses into "serial_{in,out}" and define these for X86 and !X86 like
you did.

This way should be somewhat clearer than defining a "writeb" not to be a
writeb after all, which I find confusing.

What do you think?

Cheers
  Detlev

-- 
Spelling is a lossed art
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de

  reply	other threads:[~2009-10-29 15:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-24  1:27 [U-Boot] [PATCH] Enable port-mapped access to 16550 UART Graeme Russ
2009-10-27 21:11 ` [U-Boot] [PING][PATCH] " Graeme Russ
2009-10-28 16:13 ` [U-Boot] [PATCH] " Detlev Zundel
2009-10-28 21:18   ` Graeme Russ
2009-10-29 15:42     ` Detlev Zundel [this message]
2009-10-29 20:48       ` Graeme Russ
2009-11-02 13:46         ` Detlev Zundel

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=m2aaza2omv.fsf@ohwell.denx.de \
    --to=dzu@denx.de \
    --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