diff options
author | Alan Cox <alan@linux.intel.com> | 2012-10-29 11:20:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-30 17:05:32 -0400 |
commit | 373bac4cf4c3198cc6d6b9aec7c5d576a06f1f1c (patch) | |
tree | c9dce84632a196aa2da66446f62235fe179c03ac | |
parent | 9f1096943a56c35cc85a0729ec759fd8a25e552f (diff) |
uart: add other serial core layer get attributes
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | Documentation/ABI/testing/sysfs-tty | 112 | ||||
-rw-r--r-- | drivers/tty/serial/serial_core.c | 145 |
2 files changed, 257 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-tty b/Documentation/ABI/testing/sysfs-tty index 0c430150d929..ad22fb0ee765 100644 --- a/Documentation/ABI/testing/sysfs-tty +++ b/Documentation/ABI/testing/sysfs-tty | |||
@@ -26,3 +26,115 @@ Description: | |||
26 | UART port in serial_core, that is bound to TTY like ttyS0. | 26 | UART port in serial_core, that is bound to TTY like ttyS0. |
27 | uartclk = 16 * baud_base | 27 | uartclk = 16 * baud_base |
28 | 28 | ||
29 | These sysfs values expose the TIOCGSERIAL interface via | ||
30 | sysfs rather than via ioctls. | ||
31 | |||
32 | What: /sys/class/tty/ttyS0/type | ||
33 | Date: October 2012 | ||
34 | Contact: Alan Cox <alan@linux.intel.com> | ||
35 | Description: | ||
36 | Shows the current tty type for this port. | ||
37 | |||
38 | These sysfs values expose the TIOCGSERIAL interface via | ||
39 | sysfs rather than via ioctls. | ||
40 | |||
41 | What: /sys/class/tty/ttyS0/line | ||
42 | Date: October 2012 | ||
43 | Contact: Alan Cox <alan@linux.intel.com> | ||
44 | Description: | ||
45 | Shows the current tty line number for this port. | ||
46 | |||
47 | These sysfs values expose the TIOCGSERIAL interface via | ||
48 | sysfs rather than via ioctls. | ||
49 | |||
50 | What: /sys/class/tty/ttyS0/port | ||
51 | Date: October 2012 | ||
52 | Contact: Alan Cox <alan@linux.intel.com> | ||
53 | Description: | ||
54 | Shows the current tty port I/O address for this port. | ||
55 | |||
56 | These sysfs values expose the TIOCGSERIAL interface via | ||
57 | sysfs rather than via ioctls. | ||
58 | |||
59 | What: /sys/class/tty/ttyS0/irq | ||
60 | Date: October 2012 | ||
61 | Contact: Alan Cox <alan@linux.intel.com> | ||
62 | Description: | ||
63 | Shows the current primary interrupt for this port. | ||
64 | |||
65 | These sysfs values expose the TIOCGSERIAL interface via | ||
66 | sysfs rather than via ioctls. | ||
67 | |||
68 | What: /sys/class/tty/ttyS0/flags | ||
69 | Date: October 2012 | ||
70 | Contact: Alan Cox <alan@linux.intel.com> | ||
71 | Description: | ||
72 | Show the tty port status flags for this port. | ||
73 | |||
74 | These sysfs values expose the TIOCGSERIAL interface via | ||
75 | sysfs rather than via ioctls. | ||
76 | |||
77 | What: /sys/class/tty/ttyS0/xmit_fifo_size | ||
78 | Date: October 2012 | ||
79 | Contact: Alan Cox <alan@linux.intel.com> | ||
80 | Description: | ||
81 | Show the transmit FIFO size for this port. | ||
82 | |||
83 | These sysfs values expose the TIOCGSERIAL interface via | ||
84 | sysfs rather than via ioctls. | ||
85 | |||
86 | What: /sys/class/tty/ttyS0/close_delay | ||
87 | Date: October 2012 | ||
88 | Contact: Alan Cox <alan@linux.intel.com> | ||
89 | Description: | ||
90 | Show the closing delay time for this port in ms. | ||
91 | |||
92 | These sysfs values expose the TIOCGSERIAL interface via | ||
93 | sysfs rather than via ioctls. | ||
94 | |||
95 | What: /sys/class/tty/ttyS0/closing_wait | ||
96 | Date: October 2012 | ||
97 | Contact: Alan Cox <alan@linux.intel.com> | ||
98 | Description: | ||
99 | Show the close wait time for this port in ms. | ||
100 | |||
101 | These sysfs values expose the TIOCGSERIAL interface via | ||
102 | sysfs rather than via ioctls. | ||
103 | |||
104 | What: /sys/class/tty/ttyS0/custom_divisor | ||
105 | Date: October 2012 | ||
106 | Contact: Alan Cox <alan@linux.intel.com> | ||
107 | Description: | ||
108 | Show the custom divisor if any that is set on this port. | ||
109 | |||
110 | These sysfs values expose the TIOCGSERIAL interface via | ||
111 | sysfs rather than via ioctls. | ||
112 | |||
113 | What: /sys/class/tty/ttyS0/io_type | ||
114 | Date: October 2012 | ||
115 | Contact: Alan Cox <alan@linux.intel.com> | ||
116 | Description: | ||
117 | Show the I/O type that is to be used with the iomem base | ||
118 | address. | ||
119 | |||
120 | These sysfs values expose the TIOCGSERIAL interface via | ||
121 | sysfs rather than via ioctls. | ||
122 | |||
123 | What: /sys/class/tty/ttyS0/iomem_base | ||
124 | Date: October 2012 | ||
125 | Contact: Alan Cox <alan@linux.intel.com> | ||
126 | Description: | ||
127 | The I/O memory base for this port. | ||
128 | |||
129 | These sysfs values expose the TIOCGSERIAL interface via | ||
130 | sysfs rather than via ioctls. | ||
131 | |||
132 | What: /sys/class/tty/ttyS0/iomem_reg_shift | ||
133 | Date: October 2012 | ||
134 | Contact: Alan Cox <alan@linux.intel.com> | ||
135 | Description: | ||
136 | Show the register shift indicating the spacing to be used | ||
137 | for accesses on this iomem address. | ||
138 | |||
139 | These sysfs values expose the TIOCGSERIAL interface via | ||
140 | sysfs rather than via ioctls. | ||
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 0c4304ef66d9..d3dd4ad984f6 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -2340,10 +2340,155 @@ static ssize_t uart_get_attr_uartclk(struct device *dev, | |||
2340 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.baud_base * 16); | 2340 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.baud_base * 16); |
2341 | } | 2341 | } |
2342 | 2342 | ||
2343 | static ssize_t uart_get_attr_type(struct device *dev, | ||
2344 | struct device_attribute *attr, char *buf) | ||
2345 | { | ||
2346 | struct serial_struct tmp; | ||
2347 | struct tty_port *port = dev_get_drvdata(dev); | ||
2348 | |||
2349 | uart_get_info(port, &tmp); | ||
2350 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.type); | ||
2351 | } | ||
2352 | static ssize_t uart_get_attr_line(struct device *dev, | ||
2353 | struct device_attribute *attr, char *buf) | ||
2354 | { | ||
2355 | struct serial_struct tmp; | ||
2356 | struct tty_port *port = dev_get_drvdata(dev); | ||
2357 | |||
2358 | uart_get_info(port, &tmp); | ||
2359 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.line); | ||
2360 | } | ||
2361 | |||
2362 | static ssize_t uart_get_attr_port(struct device *dev, | ||
2363 | struct device_attribute *attr, char *buf) | ||
2364 | { | ||
2365 | struct serial_struct tmp; | ||
2366 | struct tty_port *port = dev_get_drvdata(dev); | ||
2367 | |||
2368 | uart_get_info(port, &tmp); | ||
2369 | return snprintf(buf, PAGE_SIZE, "0x%lX\n", (unsigned long)(tmp.port | (tmp.port_high << HIGH_BITS_OFFSET))); | ||
2370 | } | ||
2371 | |||
2372 | static ssize_t uart_get_attr_irq(struct device *dev, | ||
2373 | struct device_attribute *attr, char *buf) | ||
2374 | { | ||
2375 | struct serial_struct tmp; | ||
2376 | struct tty_port *port = dev_get_drvdata(dev); | ||
2377 | |||
2378 | uart_get_info(port, &tmp); | ||
2379 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.irq); | ||
2380 | } | ||
2381 | |||
2382 | static ssize_t uart_get_attr_flags(struct device *dev, | ||
2383 | struct device_attribute *attr, char *buf) | ||
2384 | { | ||
2385 | struct serial_struct tmp; | ||
2386 | struct tty_port *port = dev_get_drvdata(dev); | ||
2387 | |||
2388 | uart_get_info(port, &tmp); | ||
2389 | return snprintf(buf, PAGE_SIZE, "0x%X\n", tmp.flags); | ||
2390 | } | ||
2391 | |||
2392 | static ssize_t uart_get_attr_xmit_fifo_size(struct device *dev, | ||
2393 | struct device_attribute *attr, char *buf) | ||
2394 | { | ||
2395 | struct serial_struct tmp; | ||
2396 | struct tty_port *port = dev_get_drvdata(dev); | ||
2397 | |||
2398 | uart_get_info(port, &tmp); | ||
2399 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.xmit_fifo_size); | ||
2400 | } | ||
2401 | |||
2402 | |||
2403 | static ssize_t uart_get_attr_close_delay(struct device *dev, | ||
2404 | struct device_attribute *attr, char *buf) | ||
2405 | { | ||
2406 | struct serial_struct tmp; | ||
2407 | struct tty_port *port = dev_get_drvdata(dev); | ||
2408 | |||
2409 | uart_get_info(port, &tmp); | ||
2410 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.close_delay); | ||
2411 | } | ||
2412 | |||
2413 | |||
2414 | static ssize_t uart_get_attr_closing_wait(struct device *dev, | ||
2415 | struct device_attribute *attr, char *buf) | ||
2416 | { | ||
2417 | struct serial_struct tmp; | ||
2418 | struct tty_port *port = dev_get_drvdata(dev); | ||
2419 | |||
2420 | uart_get_info(port, &tmp); | ||
2421 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.closing_wait); | ||
2422 | } | ||
2423 | |||
2424 | static ssize_t uart_get_attr_custom_divisor(struct device *dev, | ||
2425 | struct device_attribute *attr, char *buf) | ||
2426 | { | ||
2427 | struct serial_struct tmp; | ||
2428 | struct tty_port *port = dev_get_drvdata(dev); | ||
2429 | |||
2430 | uart_get_info(port, &tmp); | ||
2431 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.custom_divisor); | ||
2432 | } | ||
2433 | |||
2434 | static ssize_t uart_get_attr_io_type(struct device *dev, | ||
2435 | struct device_attribute *attr, char *buf) | ||
2436 | { | ||
2437 | struct serial_struct tmp; | ||
2438 | struct tty_port *port = dev_get_drvdata(dev); | ||
2439 | |||
2440 | uart_get_info(port, &tmp); | ||
2441 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.io_type); | ||
2442 | } | ||
2443 | |||
2444 | static ssize_t uart_get_attr_iomem_base(struct device *dev, | ||
2445 | struct device_attribute *attr, char *buf) | ||
2446 | { | ||
2447 | struct serial_struct tmp; | ||
2448 | struct tty_port *port = dev_get_drvdata(dev); | ||
2449 | |||
2450 | uart_get_info(port, &tmp); | ||
2451 | return snprintf(buf, PAGE_SIZE, "0x%lX\n", (unsigned long)tmp.iomem_base); | ||
2452 | } | ||
2453 | |||
2454 | static ssize_t uart_get_attr_iomem_reg_shift(struct device *dev, | ||
2455 | struct device_attribute *attr, char *buf) | ||
2456 | { | ||
2457 | struct serial_struct tmp; | ||
2458 | struct tty_port *port = dev_get_drvdata(dev); | ||
2459 | |||
2460 | uart_get_info(port, &tmp); | ||
2461 | return snprintf(buf, PAGE_SIZE, "%d\n", tmp.iomem_reg_shift); | ||
2462 | } | ||
2463 | |||
2464 | static DEVICE_ATTR(type, S_IRUSR | S_IRGRP, uart_get_attr_type, NULL); | ||
2465 | static DEVICE_ATTR(line, S_IRUSR | S_IRGRP, uart_get_attr_line, NULL); | ||
2466 | static DEVICE_ATTR(port, S_IRUSR | S_IRGRP, uart_get_attr_port, NULL); | ||
2467 | static DEVICE_ATTR(irq, S_IRUSR | S_IRGRP, uart_get_attr_irq, NULL); | ||
2468 | static DEVICE_ATTR(flags, S_IRUSR | S_IRGRP, uart_get_attr_flags, NULL); | ||
2469 | static DEVICE_ATTR(xmit_fifo_size, S_IRUSR | S_IRGRP, uart_get_attr_xmit_fifo_size, NULL); | ||
2343 | static DEVICE_ATTR(uartclk, S_IRUSR | S_IRGRP, uart_get_attr_uartclk, NULL); | 2470 | static DEVICE_ATTR(uartclk, S_IRUSR | S_IRGRP, uart_get_attr_uartclk, NULL); |
2471 | static DEVICE_ATTR(close_delay, S_IRUSR | S_IRGRP, uart_get_attr_close_delay, NULL); | ||
2472 | static DEVICE_ATTR(closing_wait, S_IRUSR | S_IRGRP, uart_get_attr_closing_wait, NULL); | ||
2473 | static DEVICE_ATTR(custom_divisor, S_IRUSR | S_IRGRP, uart_get_attr_custom_divisor, NULL); | ||
2474 | static DEVICE_ATTR(io_type, S_IRUSR | S_IRGRP, uart_get_attr_io_type, NULL); | ||
2475 | static DEVICE_ATTR(iomem_base, S_IRUSR | S_IRGRP, uart_get_attr_iomem_base, NULL); | ||
2476 | static DEVICE_ATTR(iomem_reg_shift, S_IRUSR | S_IRGRP, uart_get_attr_iomem_reg_shift, NULL); | ||
2344 | 2477 | ||
2345 | static struct attribute *tty_dev_attrs[] = { | 2478 | static struct attribute *tty_dev_attrs[] = { |
2479 | &dev_attr_type.attr, | ||
2480 | &dev_attr_line.attr, | ||
2481 | &dev_attr_port.attr, | ||
2482 | &dev_attr_irq.attr, | ||
2483 | &dev_attr_flags.attr, | ||
2484 | &dev_attr_xmit_fifo_size.attr, | ||
2346 | &dev_attr_uartclk.attr, | 2485 | &dev_attr_uartclk.attr, |
2486 | &dev_attr_close_delay.attr, | ||
2487 | &dev_attr_closing_wait.attr, | ||
2488 | &dev_attr_custom_divisor.attr, | ||
2489 | &dev_attr_io_type.attr, | ||
2490 | &dev_attr_iomem_base.attr, | ||
2491 | &dev_attr_iomem_reg_shift.attr, | ||
2347 | NULL, | 2492 | NULL, |
2348 | }; | 2493 | }; |
2349 | 2494 | ||