mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* serial_ns16550 driver question
@ 2011-07-20 19:51 Antony Pavlov
  2011-07-20 20:31 ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Antony Pavlov @ 2011-07-20 19:51 UTC (permalink / raw)
  To: barebox

Hi!

In include/ns16550.h we have:

struct NS16550_plat {
        unsigned int clock;
        unsigned char f_caps;
        /**
         * register read access capability
         */
        unsigned int (*reg_read) (unsigned long base, unsigned char reg_offset);
        /**
         * register write access capability
         */
        void (*reg_write) (unsigned int val, unsigned long base,
                                    unsigned char reg_offset);
};

Why reg_read and reg_write's argument base has type unsigned long?
IMHO pointer type (void * or char *)  is more natural.

-- 
Best regards,
  Antony Pavlov

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: serial_ns16550 driver question
  2011-07-20 19:51 serial_ns16550 driver question Antony Pavlov
@ 2011-07-20 20:31 ` Sascha Hauer
  2011-07-21  3:12   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2011-07-20 20:31 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Wed, Jul 20, 2011 at 11:51:04PM +0400, Antony Pavlov wrote:
> Hi!
> 
> In include/ns16550.h we have:
> 
> struct NS16550_plat {
>         unsigned int clock;
>         unsigned char f_caps;
>         /**
>          * register read access capability
>          */
>         unsigned int (*reg_read) (unsigned long base, unsigned char reg_offset);
>         /**
>          * register write access capability
>          */
>         void (*reg_write) (unsigned int val, unsigned long base,
>                                     unsigned char reg_offset);
> };
> 
> Why reg_read and reg_write's argument base has type unsigned long?
> IMHO pointer type (void * or char *)  is more natural.

You're right, I also wondered about this recently when looking at a
patch on the list. I would also rather see void __iomem *. The problem
is that this driver is also used on X86 which uses inb/outb which take
an integer argument.
The Linux driver works around this by having a membase and a iobase
field along with different register accessors. While being cleaner
I'm unsure if we want to go this way.

Ssascha

-- 
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: serial_ns16550 driver question
  2011-07-20 20:31 ` Sascha Hauer
@ 2011-07-21  3:12   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-21  6:28     ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-21  3:12 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 22:31 Wed 20 Jul     , Sascha Hauer wrote:
> On Wed, Jul 20, 2011 at 11:51:04PM +0400, Antony Pavlov wrote:
> > Hi!
> > 
> > In include/ns16550.h we have:
> > 
> > struct NS16550_plat {
> >         unsigned int clock;
> >         unsigned char f_caps;
> >         /**
> >          * register read access capability
> >          */
> >         unsigned int (*reg_read) (unsigned long base, unsigned char reg_offset);
> >         /**
> >          * register write access capability
> >          */
> >         void (*reg_write) (unsigned int val, unsigned long base,
> >                                     unsigned char reg_offset);
> > };
> > 
> > Why reg_read and reg_write's argument base has type unsigned long?
> > IMHO pointer type (void * or char *)  is more natural.
> 
> You're right, I also wondered about this recently when looking at a
> patch on the list. I would also rather see void __iomem *. The problem
> is that this driver is also used on X86 which uses inb/outb which take
> an integer argument.
> The Linux driver works around this by having a membase and a iobase
> field along with different register accessors. While being cleaner
> I'm unsure if we want to go this way.

we can do it via resoure and the flasgs IORESOURCE_MEM_8BIT,
IORESOURCE_MEM_168BITi etc..

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: serial_ns16550 driver question
  2011-07-21  3:12   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-21  6:28     ` Sascha Hauer
  2011-07-21  8:34       ` Juergen Beisert
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2011-07-21  6:28 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Jul 21, 2011 at 05:12:24AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 22:31 Wed 20 Jul     , Sascha Hauer wrote:
> > On Wed, Jul 20, 2011 at 11:51:04PM +0400, Antony Pavlov wrote:
> > > Hi!
> > > 
> > > In include/ns16550.h we have:
> > > 
> > > struct NS16550_plat {
> > >         unsigned int clock;
> > >         unsigned char f_caps;
> > >         /**
> > >          * register read access capability
> > >          */
> > >         unsigned int (*reg_read) (unsigned long base, unsigned char reg_offset);
> > >         /**
> > >          * register write access capability
> > >          */
> > >         void (*reg_write) (unsigned int val, unsigned long base,
> > >                                     unsigned char reg_offset);
> > > };
> > > 
> > > Why reg_read and reg_write's argument base has type unsigned long?
> > > IMHO pointer type (void * or char *)  is more natural.
> > 
> > You're right, I also wondered about this recently when looking at a
> > patch on the list. I would also rather see void __iomem *. The problem
> > is that this driver is also used on X86 which uses inb/outb which take
> > an integer argument.
> > The Linux driver works around this by having a membase and a iobase
> > field along with different register accessors. While being cleaner
> > I'm unsure if we want to go this way.
> 
> we can do it via resoure and the flasgs IORESOURCE_MEM_8BIT,
> IORESOURCE_MEM_168BITi etc..

Yes, but this does not solve the problem with different accessor
functions (and their argument type).

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: serial_ns16550 driver question
  2011-07-21  6:28     ` Sascha Hauer
@ 2011-07-21  8:34       ` Juergen Beisert
  0 siblings, 0 replies; 5+ messages in thread
From: Juergen Beisert @ 2011-07-21  8:34 UTC (permalink / raw)
  To: barebox

Sascha Hauer wrote:
> On Thu, Jul 21, 2011 at 05:12:24AM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> > On 22:31 Wed 20 Jul     , Sascha Hauer wrote:
> > > On Wed, Jul 20, 2011 at 11:51:04PM +0400, Antony Pavlov wrote:
> > > > Hi!
> > > >
> > > > In include/ns16550.h we have:
> > > >
> > > > struct NS16550_plat {
> > > >         unsigned int clock;
> > > >         unsigned char f_caps;
> > > >         /**
> > > >          * register read access capability
> > > >          */
> > > >         unsigned int (*reg_read) (unsigned long base, unsigned char
> > > > reg_offset); /**
> > > >          * register write access capability
> > > >          */
> > > >         void (*reg_write) (unsigned int val, unsigned long base,
> > > >                                     unsigned char reg_offset);
> > > > };
> > > >
> > > > Why reg_read and reg_write's argument base has type unsigned long?
> > > > IMHO pointer type (void * or char *)  is more natural.
> > >
> > > You're right, I also wondered about this recently when looking at a
> > > patch on the list. I would also rather see void __iomem *. The problem
> > > is that this driver is also used on X86 which uses inb/outb which take
> > > an integer argument.
> > > The Linux driver works around this by having a membase and a iobase
> > > field along with different register accessors. While being cleaner
> > > I'm unsure if we want to go this way.
> >
> > we can do it via resoure and the flasgs IORESOURCE_MEM_8BIT,
> > IORESOURCE_MEM_168BITi etc..
>
> Yes, but this does not solve the problem with different accessor
> functions (and their argument type).

Why not adapt the x86 inb/outb function to the same arguments types than other 
archs are using for their memory mapped access? We are in Barebox, not in the 
kernel. I think we can do so, without damaging something in our _small_ x86 
Barebox world.

jbe

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-5121-206917-5128 |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-21  8:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-20 19:51 serial_ns16550 driver question Antony Pavlov
2011-07-20 20:31 ` Sascha Hauer
2011-07-21  3:12   ` Jean-Christophe PLAGNIOL-VILLARD
2011-07-21  6:28     ` Sascha Hauer
2011-07-21  8:34       ` Juergen Beisert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox