[U-Boot] serial ifdef mess

Graeme Russ graeme.russ at gmail.com
Tue Sep 20 03:07:48 CEST 2011


Hi Mike,

On Tue, Sep 20, 2011 at 10:52 AM, Mike Frysinger <vapier at gentoo.org> wrote:
> On Monday, September 19, 2011 20:41:20 Graeme Russ wrote:
>> Hi Mike,
>>
>> On Tue, Sep 20, 2011 at 6:57 AM, Mike Frysinger <vapier at gentoo.org> wrote:
>> > On Sunday, September 18, 2011 09:08:35 Graeme Russ wrote:
>> >> I mean, it irks me to no end that /common/serial.c, /drivers/serial.c
>> >> and /include/serial.h are such an ugly mess of #ifdef's - I'm working
>> >> on a new SoC at the moment, and it just plain weird that I have to
>> >> touch these :(
>> >
>> > well, there's two things there.  the init mess which could get fixed in
>> > two diff ways: part of your larger init cleanup, or turn it into board
>> > callbacks like most of the other frameworks we have atm.
>>
>> I don't think the serial mess is related to the init sequence at all (but
>> I could be wrong)
>
> the only way to register a new serial device is to add a call to it in
> common/serial.c:serial_initialize().  and the only thing that func does is
> call all the various register funcs which are simply init calls.

Ah, I see - I think I see an architectural thunk! about to happen ;)

>> > the second thing is the CONFIG_SERIAL_MULTI hell.  that mess i'd like to
>> > gut with a dull blade at some point.
>>
>> Or a sledgehammer!
>>
>> The big question I suppose is where we are at with the _MULTI interfaces.
>> From what I can gather, these should now be the only ones in use and we
>> should start to apply pressure on board maintainers (i.e. break their
>> boards) to fix any depricated usage. I think the same philosophy should
>> be applied to the various boards with 'flash.c' which should all be
>> using CFI by now.
>
> i dont have a problem with non-multi instances since it produces thinner code
>
> i dont think there is anyone driving the serial core atm though ... i dont
> recall seeing any patches there other than new device drivers since ive been
> watching the list ...

Hmmm, so let me ponder (keep in mind I am not familiar with the serial code
and do not have it in front of me)...

I can see two implementations that a board could decide to use

a) Use a particular serial driver directly - perfect if you have only one
   serial port (or don't care about the others)
b) Use the SERIAL_MULTI 'management layer' and 'register' each relavent
   serial port on the board. The board will need to define a (probably
   hard-coded) a default to handle I/O until the environment can be read
   and the hardware initialised to actually make the serial ports
   operational.

So in theory, we should be able to register an arbitrary number of serial
ports, each with potentially different hardware and therefore different
drivers. The board (or SoC) init function should be able to simply call
serial_register() for each serial port with a name and info into how to
talk to the hardware (hardware type, base address etc). The SERIAL_MULTI
framework should then simply manage the list of serial devices and
redirect I/O based on environment settings

Regards,

Graeme


More information about the U-Boot mailing list