Using secondary UART for board initialization
Hi all,
I need to write to (and read from) a UART during board initialization that is not the same UART the U-Boot serial console is running on.
I'm using CONFIG_DM_SERIAL so I've extended my .dts to enable the additional UART (including pinmux registers). In my board init code I can find the serial driver instance of this additional interface via uclass_get_device_by_name() but now I'm stuck finding a way to actually do I/O with this device.
All serial_putc()-like functions that I could find are either static to the actual driver and thus not accessible from board_init() or do not accept a struct udevice * as a parameter and seem to work on the main U-Boot serial console device only.
I could of course copy the functionality of the implementing driver but that seems wrong to me, given we already have the concept of driver instances.
Could somebody give me a quick hint as to how this is supposed to be done?
The target is an i.MX8MM (thus serial_mxc), in case it matters.
Thanks in advance!
Best regards,
Alex
Quoted 4 lines
All
serial_putc()-like functions that I could find are either static to the actual driver and thus not accessible fromboard_init()or do not accept astruct udevice *as a parameter and seem to work on the main U-Boot serial console device only.
Reading other board code I think I have found a supposed-to-be-working sequence of calls:
(simplified code)
struct udevice *dev = uclass_get_device_by_name(UCLASS_SERIAL,
"serial@30860000", &dev);
struct dm_serial_ops *ops = serial_get_ops(dev);
ops->setbrg(dev, 115200);
ops->putc(dev, 'f');Unfortunately this yields a CPU reset:
"Error" handler, esr 0xbf000002
elr: 00000000402605f0 lr : 00000000402610f8 (reloc)
elr: 00000000bff865f0 lr : 00000000bff870f8
x0 : 000000000000006d x1 : 000000000000081a
x2 : 00000000bffabf00 x3 : 00000000bdf1c630
x4 : 00000000bdf1cf20 x5 : 00000000bdf21804
x6 : 000000000000000f x7 : 00000000bdf1cf50
x8 : 00000000bdf1ce80 x9 : 00000000ffffffd0
x10: 0000000000000002 x11: 00000000ffffffff
x12: 00000000bdf1d080 x13: 0000000000004884
x14: 0000000000000000 x15: 00000000bdf1c6a8
x16: 0000000040234dc4 x17: 000000000000aa80
x18: 00000000bdf25d80 x19: 00000000bdf1cf20
x20: 00000000bdf1c670 x21: 00000000ffffffc8
x22: 00000000bdf1ce8a x23: 00000000bdf1cf20
x24: 00000000bdf1c670 x25: 000000000000081a
x26: 00000000bff9c000 x27: 00000000bffabf00
x28: 0000000000000000 x29: 00000000bdf1c560
Code: d00000ba 91263340 f90037e0 39400360 (350001a0)
Resetting CPU ...I traced this down to a writel() call to the UART TXD register in the serial driver (mxc_serial_putc() in 'serial_mxc.c').
The documentation for uclass_get_device_by_name() says the device is 'probed to activate it ready for use' so I think this is not an initialization issue.
Any ideas what I might be missing there?
Best regards,
Alex