diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/ABI/testing/sysfs-tty | 19 | ||||
-rw-r--r-- | Documentation/filesystems/proc.txt | 24 | ||||
-rw-r--r-- | Documentation/serial/00-INDEX | 2 | ||||
-rw-r--r-- | Documentation/serial/serial-rs485.txt | 120 |
4 files changed, 165 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-tty b/Documentation/ABI/testing/sysfs-tty new file mode 100644 index 000000000000..b138b663bf54 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-tty | |||
@@ -0,0 +1,19 @@ | |||
1 | What: /sys/class/tty/console/active | ||
2 | Date: Nov 2010 | ||
3 | Contact: Kay Sievers <kay.sievers@vrfy.org> | ||
4 | Description: | ||
5 | Shows the list of currently configured | ||
6 | console devices, like 'tty1 ttyS0'. | ||
7 | The last entry in the file is the active | ||
8 | device connected to /dev/console. | ||
9 | The file supports poll() to detect virtual | ||
10 | console switches. | ||
11 | |||
12 | What: /sys/class/tty/tty0/active | ||
13 | Date: Nov 2010 | ||
14 | Contact: Kay Sievers <kay.sievers@vrfy.org> | ||
15 | Description: | ||
16 | Shows the currently active virtual console | ||
17 | device, like 'tty1'. | ||
18 | The file supports poll() to detect virtual | ||
19 | console switches. | ||
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index e73df2722ff3..9471225212c4 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt | |||
@@ -1181,6 +1181,30 @@ Table 1-12: Files in /proc/fs/ext4/<devname> | |||
1181 | mb_groups details of multiblock allocator buddy cache of free blocks | 1181 | mb_groups details of multiblock allocator buddy cache of free blocks |
1182 | .............................................................................. | 1182 | .............................................................................. |
1183 | 1183 | ||
1184 | 2.0 /proc/consoles | ||
1185 | ------------------ | ||
1186 | Shows registered system console lines. | ||
1187 | |||
1188 | To see which character device lines are currently used for the system console | ||
1189 | /dev/console, you may simply look into the file /proc/consoles: | ||
1190 | |||
1191 | > cat /proc/consoles | ||
1192 | tty0 -WU (ECp) 4:7 | ||
1193 | ttyS0 -W- (Ep) 4:64 | ||
1194 | |||
1195 | The columns are: | ||
1196 | |||
1197 | device name of the device | ||
1198 | operations R = can do read operations | ||
1199 | W = can do write operations | ||
1200 | U = can do unblank | ||
1201 | flags E = it is enabled | ||
1202 | C = it is prefered console | ||
1203 | B = it is primary boot console | ||
1204 | p = it is used for printk buffer | ||
1205 | b = it is not a TTY but a Braille device | ||
1206 | a = it is safe to use when cpu is offline | ||
1207 | major:minor major and minor number of the device separated by a colon | ||
1184 | 1208 | ||
1185 | ------------------------------------------------------------------------------ | 1209 | ------------------------------------------------------------------------------ |
1186 | Summary | 1210 | Summary |
diff --git a/Documentation/serial/00-INDEX b/Documentation/serial/00-INDEX index 07dcdb0d2a36..e09468ad3cb1 100644 --- a/Documentation/serial/00-INDEX +++ b/Documentation/serial/00-INDEX | |||
@@ -14,6 +14,8 @@ riscom8.txt | |||
14 | - notes on using the RISCom/8 multi-port serial driver. | 14 | - notes on using the RISCom/8 multi-port serial driver. |
15 | rocket.txt | 15 | rocket.txt |
16 | - info on the Comtrol RocketPort multiport serial driver. | 16 | - info on the Comtrol RocketPort multiport serial driver. |
17 | serial-rs485.txt | ||
18 | - info about RS485 structures and support in the kernel. | ||
17 | specialix.txt | 19 | specialix.txt |
18 | - info on hardware/driver for specialix IO8+ multiport serial card. | 20 | - info on hardware/driver for specialix IO8+ multiport serial card. |
19 | stallion.txt | 21 | stallion.txt |
diff --git a/Documentation/serial/serial-rs485.txt b/Documentation/serial/serial-rs485.txt new file mode 100644 index 000000000000..a4932387bbfb --- /dev/null +++ b/Documentation/serial/serial-rs485.txt | |||
@@ -0,0 +1,120 @@ | |||
1 | RS485 SERIAL COMMUNICATIONS | ||
2 | |||
3 | 1. INTRODUCTION | ||
4 | |||
5 | EIA-485, also known as TIA/EIA-485 or RS-485, is a standard defining the | ||
6 | electrical characteristics of drivers and receivers for use in balanced | ||
7 | digital multipoint systems. | ||
8 | This standard is widely used for communications in industrial automation | ||
9 | because it can be used effectively over long distances and in electrically | ||
10 | noisy environments. | ||
11 | |||
12 | 2. HARDWARE-RELATED CONSIDERATIONS | ||
13 | |||
14 | Some CPUs/UARTs (e.g., Atmel AT91 or 16C950 UART) contain a built-in | ||
15 | half-duplex mode capable of automatically controlling line direction by | ||
16 | toggling RTS or DTR signals. That can be used to control external | ||
17 | half-duplex hardware like an RS485 transceiver or any RS232-connected | ||
18 | half-duplex devices like some modems. | ||
19 | |||
20 | For these microcontrollers, the Linux driver should be made capable of | ||
21 | working in both modes, and proper ioctls (see later) should be made | ||
22 | available at user-level to allow switching from one mode to the other, and | ||
23 | vice versa. | ||
24 | |||
25 | 3. DATA STRUCTURES ALREADY AVAILABLE IN THE KERNEL | ||
26 | |||
27 | The Linux kernel provides the serial_rs485 structure (see [1]) to handle | ||
28 | RS485 communications. This data structure is used to set and configure RS485 | ||
29 | parameters in the platform data and in ioctls. | ||
30 | |||
31 | Any driver for devices capable of working both as RS232 and RS485 should | ||
32 | provide at least the following ioctls: | ||
33 | |||
34 | - TIOCSRS485 (typically associated with number 0x542F). This ioctl is used | ||
35 | to enable/disable RS485 mode from user-space | ||
36 | |||
37 | - TIOCGRS485 (typically associated with number 0x542E). This ioctl is used | ||
38 | to get RS485 mode from kernel-space (i.e., driver) to user-space. | ||
39 | |||
40 | In other words, the serial driver should contain a code similar to the next | ||
41 | one: | ||
42 | |||
43 | static struct uart_ops atmel_pops = { | ||
44 | /* ... */ | ||
45 | .ioctl = handle_ioctl, | ||
46 | }; | ||
47 | |||
48 | static int handle_ioctl(struct uart_port *port, | ||
49 | unsigned int cmd, | ||
50 | unsigned long arg) | ||
51 | { | ||
52 | struct serial_rs485 rs485conf; | ||
53 | |||
54 | switch (cmd) { | ||
55 | case TIOCSRS485: | ||
56 | if (copy_from_user(&rs485conf, | ||
57 | (struct serial_rs485 *) arg, | ||
58 | sizeof(rs485conf))) | ||
59 | return -EFAULT; | ||
60 | |||
61 | /* ... */ | ||
62 | break; | ||
63 | |||
64 | case TIOCGRS485: | ||
65 | if (copy_to_user((struct serial_rs485 *) arg, | ||
66 | ..., | ||
67 | sizeof(rs485conf))) | ||
68 | return -EFAULT; | ||
69 | /* ... */ | ||
70 | break; | ||
71 | |||
72 | /* ... */ | ||
73 | } | ||
74 | } | ||
75 | |||
76 | |||
77 | 4. USAGE FROM USER-LEVEL | ||
78 | |||
79 | From user-level, RS485 configuration can be get/set using the previous | ||
80 | ioctls. For instance, to set RS485 you can use the following code: | ||
81 | |||
82 | #include <linux/serial.h> | ||
83 | |||
84 | /* Driver-specific ioctls: */ | ||
85 | #define TIOCGRS485 0x542E | ||
86 | #define TIOCSRS485 0x542F | ||
87 | |||
88 | /* Open your specific device (e.g., /dev/mydevice): */ | ||
89 | int fd = open ("/dev/mydevice", O_RDWR); | ||
90 | if (fd < 0) { | ||
91 | /* Error handling. See errno. */ | ||
92 | } | ||
93 | |||
94 | struct serial_rs485 rs485conf; | ||
95 | |||
96 | /* Set RS485 mode: */ | ||
97 | rs485conf.flags |= SER_RS485_ENABLED; | ||
98 | |||
99 | /* Set rts delay before send, if needed: */ | ||
100 | rs485conf.flags |= SER_RS485_RTS_BEFORE_SEND; | ||
101 | rs485conf.delay_rts_before_send = ...; | ||
102 | |||
103 | /* Set rts delay after send, if needed: */ | ||
104 | rs485conf.flags |= SER_RS485_RTS_AFTER_SEND; | ||
105 | rs485conf.delay_rts_after_send = ...; | ||
106 | |||
107 | if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) { | ||
108 | /* Error handling. See errno. */ | ||
109 | } | ||
110 | |||
111 | /* Use read() and write() syscalls here... */ | ||
112 | |||
113 | /* Close the device when finished: */ | ||
114 | if (close (fd) < 0) { | ||
115 | /* Error handling. See errno. */ | ||
116 | } | ||
117 | |||
118 | 5. REFERENCES | ||
119 | |||
120 | [1] include/linux/serial.h | ||