linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* How does the kernel assign ttySn to UARTs?
@ 2016-08-08 19:56 Patrick Doyle
  2016-08-08 21:03 ` Frank Rowand
  2016-08-09 14:55 ` Patrick Doyle
  0 siblings, 2 replies; 3+ messages in thread
From: Patrick Doyle @ 2016-08-08 19:56 UTC (permalink / raw)
  To: linux-arm-kernel

I am playing the the device tree for my (Atmel, SAMA5D2x) device and
find myself confused by the assignment of ttySn devices to UARTs and
FLEXCOM devices.

I started off assuming that the

    alias {
        serial0 = &uart2;
    };

stanza I put in my device tree resulted in ttyS0 being aliased to
uart2 (serial at f8024000).  But when I attempted to change the alias to
uart5 (the label for UART defined in flexcom at fc018000) I was surprised
and confused by the fact that the console continued to spew forth on
UART2.

So I tried removing the "alias" stanza from the device tree.  The
console still showed up on UART2.

I wondered if it might have something to do with the order that
devices show up in the device tree, so I swapped UART2 & UART3, but
the console still showed up on UART2.

Just to make sure I wasn't losing my mind, I decided to comment UART2
out completely... and then the console showed up on FLEXCOM4.  Not
UART3, but FLEXCOM4!

Now I'm really confused.  Now it is time to ask the experts.

FWIW, my kernel command line contains "console=ttyS0", while my device
tree enables UART2, UART3, and FLEXCOM4 (which us configured as a
UART).  Nowhere do I enable UART0, so I am also confused has to how
/dev/ttyS0 gets mapped to UART2 or FLEXCOM4.

Would any experts out there care to point me in the direction of some clues?

Thanks.

--wpd

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

* How does the kernel assign ttySn to UARTs?
  2016-08-08 19:56 How does the kernel assign ttySn to UARTs? Patrick Doyle
@ 2016-08-08 21:03 ` Frank Rowand
  2016-08-09 14:55 ` Patrick Doyle
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Rowand @ 2016-08-08 21:03 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/08/16 12:56, Patrick Doyle wrote:
> I am playing the the device tree for my (Atmel, SAMA5D2x) device and
> find myself confused by the assignment of ttySn devices to UARTs and
> FLEXCOM devices.
> 
> I started off assuming that the
> 
>     alias {
>         serial0 = &uart2;
>     };
> 
> stanza I put in my device tree resulted in ttyS0 being aliased to
> uart2 (serial at f8024000).  But when I attempted to change the alias to
> uart5 (the label for UART defined in flexcom at fc018000) I was surprised
> and confused by the fact that the console continued to spew forth on
> UART2.
> 
> So I tried removing the "alias" stanza from the device tree.  The
> console still showed up on UART2.
> 
> I wondered if it might have something to do with the order that
> devices show up in the device tree, so I swapped UART2 & UART3, but
> the console still showed up on UART2.
> 
> Just to make sure I wasn't losing my mind, I decided to comment UART2
> out completely... and then the console showed up on FLEXCOM4.  Not
> UART3, but FLEXCOM4!
> 
> Now I'm really confused.  Now it is time to ask the experts.
> 
> FWIW, my kernel command line contains "console=ttyS0", while my device
> tree enables UART2, UART3, and FLEXCOM4 (which us configured as a
> UART).  Nowhere do I enable UART0, so I am also confused has to how
> /dev/ttyS0 gets mapped to UART2 or FLEXCOM4.
> 
> Would any experts out there care to point me in the direction of some clues?

Try stdout-path in the device tree chosen node.
See Documentation/devicetree/bindings/chosen.txt

I'm not sure whether "console=ttyS0" will conflict with stdout-path.

> 
> Thanks.
> 
> --wpd
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

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

* How does the kernel assign ttySn to UARTs?
  2016-08-08 19:56 How does the kernel assign ttySn to UARTs? Patrick Doyle
  2016-08-08 21:03 ` Frank Rowand
@ 2016-08-09 14:55 ` Patrick Doyle
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick Doyle @ 2016-08-09 14:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Aug 8, 2016 at 3:56 PM, Patrick Doyle <wpdster@gmail.com> wrote:
> Would any experts out there care to point me in the direction of some clues?


Thank you Frank for your response... I found some clues on my own.
The biggest clue was that I spelled "aliases" incorrectly (having
spelled it "alias" instead of "aliases").

I found my second clue when I found that the Atmel supplied .dtsi file
also defined some aliases for the serial ports.  (And they managed to
spell "aliases" correctly).

And I found my final clue right where I should have started looking...
in the source.  I looked in the Atmel serial driver and saw how it
assigned serial port numbers first by any aliases if they were
defined, and then sequentially.  So, I now have:

    aliases {
        serial0 = &uart2; /* UART2 <=> /dev/ttyS0 (connected to
mobility board) */
        serial1 = &uart5; /* FLEXCOM4 <=> /dev/ttyS1 (console) */
        serial2 = &uart3; /* UART2 <=> /dev/ttyS2 */
    };


which works the want it to, and, more importantly, I understand why it
works that way :-)

Thanks for playing.

--wpd

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

end of thread, other threads:[~2016-08-09 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-08 19:56 How does the kernel assign ttySn to UARTs? Patrick Doyle
2016-08-08 21:03 ` Frank Rowand
2016-08-09 14:55 ` Patrick Doyle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).