294 | | |
295 | | [=#laguna-rs485] |
296 | | === Laguna === |
297 | | The GW16067 IO Expansion module for the GW2380/2/3 supports half-duplex, multi-drop RS485: |
298 | | * CNS3xxx UART2 (/dev/ttyS2) |
299 | | * MAX3485 transceiver |
300 | | * TXEN connected to gpio3 |
301 | | * '''optional on-board termination resistor (R5)''' |
302 | | * '''on-board fail-safe bias resistors (R3/R7) by default are 4.75k pull-up on D+, 4.75k pull-down on D-''' (bus defaults to logic 1 - never idle) |
303 | | |
304 | | By 'optional' this means the baseboard design supports this, but it is not loaded on standard product therefore would be a Gateworks Special. Contact sales@gateworks.com if interested to see if a configuration already exists. |
305 | | |
306 | | Your software must assert/de-assert gpio3 manually (see [#rs485-example] example code) or the uart driver would need to be modified to add TIOCSRS485 ioctl support. |
| 299 | [=#venice-rs485] |
| 300 | === Venice |
| 301 | See #venice below |
| 302 | |
| 303 | [=#newport-rs485] |
| 304 | === Newport |
| 305 | The GW630x / GW640x have 2 CN80XX UART's (UART2/UART3: /dev/ttyAMA2 and /dev/ttyAMA3) going to a [https://www.exar.com/ds/sp335e.pdf SP335E] transceiver which allows selecting a variety of RS232/RS485 configurations: |
| 306 | * 2x RS232 w/o flow control |
| 307 | * 1x RS232 w/ flow control |
| 308 | * 1x RS485 half duplex |
| 309 | * 1x RS485 full duplex |
| 310 | |
| 311 | RS485 modes feature: |
| 312 | * optional half-duplex, multi-drop RS585: |
| 313 | * CN80XX UART2 (/dev/ttyAMA2) |
| 314 | * optional on-board termination (enabled by gpio16) |
| 315 | * in-chip fail-safe protection to default idle inputs to logic-high (no external bias resistors required) |
| 316 | * TXEN connected to CN80XX gpio12 which it typically Linux gpio476 |
| 317 | |
| 318 | The pl011 Linux driver supporting the CN80XX serial ports (SERIAL_AMBA_PL011 drivers/tty/serial/amba-pl011.c) does not look like it supports RS485 directly. While this support could be added to the serial driver in the future you can alternatively manage the TXEN (gpio476) directly in a user application (asserting TXEN prior to calling write() then using tcdrain() to wait for the UART FIFO to be empty before deasserting TXEN). For RS485 half-duplex using (see example below). |
335 | | [=#newport-rs485] |
336 | | === Newport === |
337 | | The GW630x / GW640x have 2 CN80XX UART's (UART2/UART3: /dev/ttyAMA2 and /dev/ttyAMA3) going to a [https://www.exar.com/ds/sp335e.pdf SP335E] transceiver which allows selecting a variety of RS232/RS485 configurations: |
338 | | * 2x RS232 w/o flow control |
339 | | * 1x RS232 w/ flow control |
340 | | * 1x RS485 half duplex |
341 | | * 1x RS485 full duplex |
342 | | |
343 | | RS485 modes feature: |
344 | | * optional half-duplex, multi-drop RS585: |
345 | | * CN80XX UART2 (/dev/ttyAMA2) |
346 | | * optional on-board termination (enabled by gpio16) |
347 | | * in-chip fail-safe protection to default idle inputs to logic-high (no external bias resistors required) |
348 | | * TXEN connected to CN80XX gpio12 which it typically Linux gpio476 |
349 | | |
350 | | The pl011 Linux driver supporting the CN80XX serial ports (SERIAL_AMBA_PL011 drivers/tty/serial/amba-pl011.c) does not look like it supports RS485 directly. While this support could be added to the serial driver in the future you can alternatively manage the TXEN (gpio476) directly in a user application (asserting TXEN prior to calling write() then using tcdrain() to wait for the UART FIFO to be empty before deasserting TXEN). For RS485 half-duplex using (see example below). |
| 347 | |
| 348 | [=#laguna-rs485] |
| 349 | === Laguna |
| 350 | The GW16067 IO Expansion module for the GW2380/2/3 supports half-duplex, multi-drop RS485: |
| 351 | * CNS3xxx UART2 (/dev/ttyS2) |
| 352 | * MAX3485 transceiver |
| 353 | * TXEN connected to gpio3 |
| 354 | * '''optional on-board termination resistor (R5)''' |
| 355 | * '''on-board fail-safe bias resistors (R3/R7) by default are 4.75k pull-up on D+, 4.75k pull-down on D-''' (bus defaults to logic 1 - never idle) |
| 356 | |
| 357 | By 'optional' this means the baseboard design supports this, but it is not loaded on standard product therefore would be a Gateworks Special. Contact sales@gateworks.com if interested to see if a configuration already exists. |
| 358 | |
| 359 | Your software must assert/de-assert gpio3 manually (see [#rs485-example] example code) or the uart driver would need to be modified to add TIOCSRS485 ioctl support. |
627 | | == Specific Product / Model Notes == |
628 | | |
629 | | === Newport === |
| 636 | == Specific Product / Model Notes |
| 637 | |
| 638 | |
| 639 | [=#venice] |
| 640 | === Venice |
| 641 | Most Venice products have a flexible [http://dev.gateworks.com/datasheets/sp335e.pdf MaxLinear SP335E] RS-232/RS-485/RS-422 transceiver which is software configurable. For these boards a device-tree frament is used to configure the kernel appropriately for the mode you desire: |
| 642 | * 2x RS232 TX/RX (default configuration requiring no dt overlay) |
| 643 | * 1x RS232 TX/RX/RTS/CTS (uses rs232-rts dt overlay) |
| 644 | * 1x RS485 (half duplex) (uses rs485 dt overlay) |
| 645 | * 1x RS422 (full duplex) (uses rs422 dt overlay) |
| 646 | |
| 647 | To use dt overlays you specify the appropriate overlay(s) in the U-Boot {{{fdt_overlays}}} environment variable in the U-Boot bootloader. This instructs U-Boot to load and apply those dt overlay fragments to the board dt before booting Linux. Note that you can have more than one dt overlay specified in the {{{fdt_overlays}}} separated by a space: |
| 648 | * imx8mm-venice-gw730x-0x RS485: |
| 649 | {{{#!bash |
| 650 | setenv fdt_overlays "$fdt_overlays imx8mm-venice-gw73xx-0x-rs485.dtbo" |
| 651 | saveenv |
| 652 | }}} |
| 653 | * imx8mm-venice-gw730x-0x RS422: |
| 654 | {{{#!bash |
| 655 | setenv fdt_overlays "imx8mm-venice-gw73xx-0x-rs422.dtbo" |
| 656 | saveenv |
| 657 | }}} |
| 658 | * imx8mm-venice-gw730x-0x RS232-CTSRTS flow control: |
| 659 | {{{#!bash |
| 660 | setenv fdt_overlays "imx8mm-venice-gw73xx-0x-rs232-rts.dtbo" |
| 661 | saveenv |
| 662 | }}} |
| 663 | * imx8mm-venice-gw730x-0x default 2x RS232 TX/RX: |
| 664 | {{{#!bash |
| 665 | setenv fdt_overlays |
| 666 | saveenv |
| 667 | }}} |
| 668 | |
| 669 | For Venice when configured for RS485 or RS422 you do not need to use the TIOCSRS485 as the dt fragments will enable this on bootup as well as configure the UARTs transmit enable pin. |
| 670 | |
| 671 | If you wish to enable the SP335E on-board RS485 termination (which is disabled by default) you can set the GPIO manually: |
| 672 | * GW730x/GW720x: |
| 673 | - U-Boot: |
| 674 | {{{#!bash |
| 675 | u-boot=> gpio status GPIO1_0 |
| 676 | Bank GPIO1_: |
| 677 | GPIO1_0: output: 0 [x] rs485_term.gpio-hog |
| 678 | u-boot=> gpio set GPIO1_0 |
| 679 | gpio: pin GPIO1_0 (gpio 0) value is 1 |
| 680 | }}} |
| 681 | - Linux (sysfs) (deprecated API) |
| 682 | {{{#!bash |
| 683 | root@focal-venice:~# grep rs485_term /sys/kernel/debug/gpio |
| 684 | gpio-0 (rs485_term ) |
| 685 | root@focal-venice:~# echo 0 > /sys/class/gpio/export |
| 686 | root@focal-venice:~# echo out > /sys/class/gpio/gpio0/direction |
| 687 | root@focal-venice:~# echo 1 > /sys/class/gpio/gpio0/value |
| 688 | }}} |
| 689 | - Linux (gpiolib) |
| 690 | {{{#!bash |
| 691 | root@focal-venice:~# gpiofind "rs485_term" |
| 692 | gpiochip0 0 |
| 693 | root@focal-venice:~# gpioset --mode=signal --background gpiochip0 0=1 |
| 694 | }}} |
| 695 | * Note we have to tell {{{gpioset}}} to remaining running until it receives a signal in order to keep the GPIO line from reverting back to its original state when the process exits. If you use the deprecated {{{sysfs}}} API or set it in U-Boot it may be easier |
| 696 | |
| 697 | |
| 698 | [=#newport] |
| 699 | === Newport |