I need to read from (and write to) a device connected to uart1 in U-Boot to complete board initialization.
For this purpose I'm using the following code (simplified form given):
struct udevice *dev = uclass_get_device_by_name(UCLASS_SERIAL, "serial at 30860000", &dev);
struct dm_serial_ops *ops = serial_get_ops(dev);
ops->setbrg(dev, 115200);
ops->putc(dev, 'f');
Unfortunately this causes a CPU reset in putc() (serial_mxc.c) when performing writel() on the UART TX register (0x30860040):
"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 ...
Via trial-and-error I have found out that the problem occurs with uart1, uart3 and uart4 but not with uart2. In case of the latter there is at least no CPU reset, but given that uart2 is the U-Boot console device I cannot do anything else with it.
It also seems that it's only writing to the TX register causes the issue. Reading from the UART seems to work fine as well as setting the baud rate or reading the TXFULL register.
Any suggestions what I might be doing wrong here? Is UART2 special in any way compared to the others?
Thanks in advance!