KlausA20 Posted March 13, 2020 Posted March 13, 2020 Hi folks, I'd like to build a simple rs485 interface onto an A20-OLinuxino-Micro board. Therefore I was looking into utilizing one of the UARTs (6 or 7) on EXT1 or EXT2, add an external driver chip to it and 'fork' the according kernel module to implement support for switching send/receive with the RTS line. While that seemed to be an easy approach, I already got stuck with the basics. :-( dmesg shows me [ 2.822776] printk: console [ttyS0] disabled [ 2.842962] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 53, base_baud = 1500000) is a U6_16550A [ 2.843045] printk: console [ttyS0] enabled [ 2.866650] 1c29800.serial: ttyS1 at MMIO 0x1c29800 (irq = 54, base_baud = 1500000) is a U6_16550A [ 2.889933] 1c29c00.serial: ttyS2 at MMIO 0x1c29c00 (irq = 55, base_baud = 1500000) is a U6_16550A that during the boot process, the kernel seems to 'find' an initialize UART0 (ttyS0 on 0x1c28000), UART6 (ttyS1 on 0x1c29800) and UART7 (ttyS2 on 0x1c29c00). Nevertheless, if I look into sysfs # find /sys/devices/ -name 'ttyS*' /sys/devices/platform/soc/1c28000,serial/tty/ttyS0 /sys/devices/platform/soc/1c29c00,serial/tty/ttyS2 /sys/devices/platform/soc/1c29800,serial/tty/ttyS1 /sys/devices/platform/serial8250/tty/ttyS6 /sys/devices/platform/serial8250/tty/ttyS4 /sys/devices/platform/serial8250/tty/ttyS7 /sys/devices/platform/serial8250/tty/ttyS5 /sys/devices/platform/serial8250/tty/ttyS3 I see that all the other UARTs are also already recognized. How can I find out - which module/driver is loaded/used to access ttyS0, ttyS1 and ttyS2 - if ttyS3 - ttyS7 are 'active' and which module/driver was used - how to prevent the kernel from automatically loading a module for an 'active' ttySx ? Cheers, Klaus
martinayotte Posted March 13, 2020 Posted March 13, 2020 50 minutes ago, KlausA20 said: I see that all the other UARTs are also already recognized. No ! They are not recognised, but defined, due to the following kernel configs : CONFIG_SERIAL_8250_NR_UARTS=8 CONFIG_SERIAL_8250_RUNTIME_UARTS=8 The only ones that are recognised are the one you see in "dmesg", therefore the UART6/UART7 are accessible from /dev/ttyS1 and /dev/ttyS2 respectively ... If you enable some other UARTs using overlays, this order will of course be changed.
KlausA20 Posted March 13, 2020 Author Posted March 13, 2020 Thanks, the first question cleared. If I now 'disable' UART7 to prevent the kernel to initialize/recognize that UART, is there a way to later 'enable' this UART with a different module/driver that the kernel usually (8250 ?) uses.
martinayotte Posted March 13, 2020 Posted March 13, 2020 18 minutes ago, KlausA20 said: If I now 'disable' UART7 to prevent the kernel to initialize/recognize that UART, is there a way to later 'enable' this UART with a different module/driver that the kernel usually (8250 ?) uses. I don't understand your question, all A20 UARTs are always using the 8250dw driver, as well as any other Allwinner SoC. EDIT: If you mean that you simply wish to enable later from userspace, yes, that is possible by loading overlays dynamically ...
KlausA20 Posted March 13, 2020 Author Posted March 13, 2020 Basically I would like to replace the 8250dw driver with a modified version of itself for only UART7 (or UART6).
martinayotte Posted March 13, 2020 Posted March 13, 2020 1 hour ago, KlausA20 said: Basically I would like to replace the 8250dw driver with a modified version of itself for only UART7 (or UART6). Do you mean a custom version of 8250dw with RS485 emulation ? In this case, I've used some patches similar to those one : https://lkml.org/lkml/2018/6/1/344 Doing such custom kernel build applied to all UARTs, enabling RS485 mode is done by an userspace ioctl call.
KlausA20 Posted March 14, 2020 Author Posted March 14, 2020 Exactly that was what I wanted to achieve. Seems I'm a few years to late. ;-) Nevertheless, can you steer me towards some documentation, maybe even regarding A20 APUs?
martinayotte Posted March 14, 2020 Posted March 14, 2020 2 hours ago, KlausA20 said: can you steer me towards some documentation, maybe even regarding A20 APUs? What do you mean ? Documentation about A20 in general ? https://linux-sunxi.org/A20
KlausA20 Posted March 14, 2020 Author Posted March 14, 2020 No, more like custom version of 8250dw with RS485 emulation in regards to the UARTs used in the A20 CPUs .
Recommended Posts