~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/driver-api/serial/serial-rs485.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/driver-api/serial/serial-rs485.rst (Version linux-6.12-rc7) and /Documentation/driver-api/serial/serial-rs485.rst (Version linux-4.17.19)


  1 ===========================                       
  2 RS485 Serial Communications                       
  3 ===========================                       
  4                                                   
  5 1. Introduction                                   
  6 ===============                                   
  7                                                   
  8    EIA-485, also known as TIA/EIA-485 or RS-48    
  9    electrical characteristics of drivers and r    
 10    digital multipoint systems.                    
 11    This standard is widely used for communicat    
 12    because it can be used effectively over lon    
 13    noisy environments.                            
 14                                                   
 15 2. Hardware-related Considerations                
 16 ==================================                
 17                                                   
 18    Some CPUs/UARTs (e.g., Atmel AT91 or 16C950    
 19    half-duplex mode capable of automatically c    
 20    toggling RTS or DTR signals. That can be us    
 21    half-duplex hardware like an RS485 transcei    
 22    half-duplex devices like some modems.          
 23                                                   
 24    For these microcontrollers, the Linux drive    
 25    working in both modes, and proper ioctls (s    
 26    available at user-level to allow switching     
 27    vice versa.                                    
 28                                                   
 29 3. Data Structures Already Available in the Ke    
 30 ==============================================    
 31                                                   
 32    The Linux kernel provides the struct serial    
 33    communications. This data structure is used    
 34    parameters in the platform data and in ioct    
 35                                                   
 36    The device tree can also provide RS485 boot    
 37    [#DT-bindings]_. The serial core fills the     
 38    values given by the device tree when the dr    
 39    uart_get_rs485_mode().                         
 40                                                   
 41    Any driver for devices capable of working b    
 42    implement the ``rs485_config`` callback and    
 43    in the ``struct uart_port``. The serial cor    
 44    the device specific part in response to TIO    
 45    ``rs485_config`` callback receives a pointe    
 46    serial_rs485. The struct serial_rs485 users    
 47    before calling ``rs485_config`` using ``rs4    
 48    what RS485 features the driver supports for    
 49    TIOCGRS485 ioctl can be used to read back t    
 50    matching to the current configuration.         
 51                                                   
 52 .. kernel-doc:: include/uapi/linux/serial.h       
 53    :identifiers: serial_rs485 uart_get_rs485_m    
 54                                                   
 55 4. Usage from user-level                          
 56 ========================                          
 57                                                   
 58    From user-level, RS485 configuration can be    
 59    ioctls. For instance, to set RS485 you can     
 60                                                   
 61         #include <linux/serial.h>                 
 62                                                   
 63         /* Include definition for RS485 ioctls    
 64         #include <sys/ioctl.h>                    
 65                                                   
 66         /* Open your specific device (e.g., /d    
 67         int fd = open ("/dev/mydevice", O_RDWR    
 68         if (fd < 0) {                             
 69                 /* Error handling. See errno.     
 70         }                                         
 71                                                   
 72         struct serial_rs485 rs485conf;            
 73                                                   
 74         /* Enable RS485 mode: */                  
 75         rs485conf.flags |= SER_RS485_ENABLED;     
 76                                                   
 77         /* Set logical level for RTS pin equal    
 78         rs485conf.flags |= SER_RS485_RTS_ON_SE    
 79         /* or, set logical level for RTS pin e    
 80         rs485conf.flags &= ~(SER_RS485_RTS_ON_    
 81                                                   
 82         /* Set logical level for RTS pin equal    
 83         rs485conf.flags |= SER_RS485_RTS_AFTER    
 84         /* or, set logical level for RTS pin e    
 85         rs485conf.flags &= ~(SER_RS485_RTS_AFT    
 86                                                   
 87         /* Set rts delay before send, if neede    
 88         rs485conf.delay_rts_before_send = ...;    
 89                                                   
 90         /* Set rts delay after send, if needed    
 91         rs485conf.delay_rts_after_send = ...;     
 92                                                   
 93         /* Set this flag if you want to receiv    
 94         rs485conf.flags |= SER_RS485_RX_DURING    
 95                                                   
 96         if (ioctl (fd, TIOCSRS485, &rs485conf)    
 97                 /* Error handling. See errno.     
 98         }                                         
 99                                                   
100         /* Use read() and write() syscalls her    
101                                                   
102         /* Close the device when finished: */     
103         if (close (fd) < 0) {                     
104                 /* Error handling. See errno.     
105         }                                         
106                                                   
107 5. Multipoint Addressing                          
108 ========================                          
109                                                   
110    The Linux kernel provides addressing mode f    
111    communications line. The addressing mode is    
112    ``SER_RS485_ADDRB`` flag in struct serial_r    
113    has two additional flags and fields for ena    
114    addresses.                                     
115                                                   
116    Address mode flags:                            
117         - ``SER_RS485_ADDRB``: Enabled address    
118         - ``SER_RS485_ADDR_RECV``: Receive (fi    
119         - ``SER_RS485_ADDR_DEST``: Set destina    
120                                                   
121    Address fields (enabled with corresponding     
122         - ``addr_recv``: Receive address.         
123         - ``addr_dest``: Destination address.     
124                                                   
125    Once a receive address is set, the communic    
126    particular device and other peers are filte    
127    receiver side to enforce the filtering. Rec    
128    if ``SER_RS485_ADDR_RECV`` is not set.         
129                                                   
130    Note: not all devices supporting RS485 supp    
131                                                   
132 6. References                                     
133 =============                                     
134                                                   
135 .. [#DT-bindings]       Documentation/devicetr    
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php