Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
serial_core.c File Reference
#include <linux/module.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/console.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/device.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
#include <linux/delay.h>
#include <linux/mutex.h>
#include <asm/irq.h>
#include <asm/uaccess.h>

Go to the source code of this file.

Data Structures

struct  uart_match
 

Macros

#define HIGH_BITS_OFFSET   ((sizeof(long)-sizeof(int))*8)
 
#define uart_console(port)   (0)
 
#define uart_set_mctrl(port, set)   uart_update_mctrl(port, set, 0)
 
#define uart_clear_mctrl(port, clear)   uart_update_mctrl(port, 0, clear)
 
#define RELEVANT_IFLAG(iflag)   ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
 

Functions

void uart_write_wakeup (struct uart_port *port)
 
void uart_update_timeout (struct uart_port *port, unsigned int cflag, unsigned int baud)
 
 EXPORT_SYMBOL (uart_update_timeout)
 
unsigned int uart_get_baud_rate (struct uart_port *port, struct ktermios *termios, struct ktermios *old, unsigned int min, unsigned int max)
 
 EXPORT_SYMBOL (uart_get_baud_rate)
 
unsigned int uart_get_divisor (struct uart_port *port, unsigned int baud)
 
 EXPORT_SYMBOL (uart_get_divisor)
 
int uart_suspend_port (struct uart_driver *drv, struct uart_port *uport)
 
int uart_resume_port (struct uart_driver *drv, struct uart_port *uport)
 
int uart_register_driver (struct uart_driver *drv)
 
void uart_unregister_driver (struct uart_driver *drv)
 
struct tty_driveruart_console_device (struct console *co, int *index)
 
int uart_add_one_port (struct uart_driver *drv, struct uart_port *uport)
 
int uart_remove_one_port (struct uart_driver *drv, struct uart_port *uport)
 
int uart_match_port (struct uart_port *port1, struct uart_port *port2)
 
 EXPORT_SYMBOL (uart_match_port)
 
void uart_handle_dcd_change (struct uart_port *uport, unsigned int status)
 
 EXPORT_SYMBOL_GPL (uart_handle_dcd_change)
 
void uart_handle_cts_change (struct uart_port *uport, unsigned int status)
 
 EXPORT_SYMBOL_GPL (uart_handle_cts_change)
 
void uart_insert_char (struct uart_port *port, unsigned int status, unsigned int overrun, unsigned int ch, unsigned int flag)
 
 EXPORT_SYMBOL_GPL (uart_insert_char)
 
 EXPORT_SYMBOL (uart_write_wakeup)
 
 EXPORT_SYMBOL (uart_register_driver)
 
 EXPORT_SYMBOL (uart_unregister_driver)
 
 EXPORT_SYMBOL (uart_suspend_port)
 
 EXPORT_SYMBOL (uart_resume_port)
 
 EXPORT_SYMBOL (uart_add_one_port)
 
 EXPORT_SYMBOL (uart_remove_one_port)
 
 MODULE_DESCRIPTION ("Serial driver core")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define HIGH_BITS_OFFSET   ((sizeof(long)-sizeof(int))*8)

Definition at line 51 of file serial_core.c.

#define RELEVANT_IFLAG (   iflag)    ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
#define uart_clear_mctrl (   port,
  clear 
)    uart_update_mctrl(port, 0, clear)

Definition at line 128 of file serial_core.c.

#define uart_console (   port)    (0)

Definition at line 56 of file serial_core.c.

#define uart_set_mctrl (   port,
  set 
)    uart_update_mctrl(port, set, 0)

Definition at line 127 of file serial_core.c.

Function Documentation

EXPORT_SYMBOL ( uart_update_timeout  )
EXPORT_SYMBOL ( uart_get_baud_rate  )
EXPORT_SYMBOL ( uart_get_divisor  )
EXPORT_SYMBOL ( uart_match_port  )
EXPORT_SYMBOL ( uart_write_wakeup  )
EXPORT_SYMBOL ( uart_register_driver  )
EXPORT_SYMBOL ( uart_unregister_driver  )
EXPORT_SYMBOL ( uart_suspend_port  )
EXPORT_SYMBOL ( uart_resume_port  )
EXPORT_SYMBOL ( uart_add_one_port  )
EXPORT_SYMBOL ( uart_remove_one_port  )
EXPORT_SYMBOL_GPL ( uart_handle_dcd_change  )
EXPORT_SYMBOL_GPL ( uart_handle_cts_change  )
EXPORT_SYMBOL_GPL ( uart_insert_char  )
MODULE_DESCRIPTION ( "Serial driver core )
MODULE_LICENSE ( "GPL"  )
int uart_add_one_port ( struct uart_driver drv,
struct uart_port uport 
)

uart_add_one_port - attach a driver-defined port structure : pointer to the uart low level driver structure for this port : uart port structure to use for this port.

This allows the driver to register its own uart_port structure with the core driver. The main purpose is to allow the low level uart drivers to expand uart_port, rather than having yet more levels of structures.

Definition at line 2369 of file serial_core.c.

struct tty_driver* uart_console_device ( struct console co,
int index 
)
read

Definition at line 2322 of file serial_core.c.

unsigned int uart_get_baud_rate ( struct uart_port port,
struct ktermios termios,
struct ktermios old,
unsigned int  min,
unsigned int  max 
)

uart_get_baud_rate - return baud rate for a particular port : uart_port structure describing the port in question. : desired termios settings. : old termios (or NULL) : minimum acceptable baud rate : maximum acceptable baud rate

Decode the termios structure into a numeric baud rate, taking account of the magic 38400 baud rate (with spd_* flags), and mapping the B0 rate to 9600 baud.

If the new baud rate is invalid, try the old termios setting. If it's still invalid, we try 9600 baud.

Update the structure to reflect the baud rate we're actually going to be using. Don't do this for the case where B0 is requested ("hang up").

Definition at line 335 of file serial_core.c.

unsigned int uart_get_divisor ( struct uart_port port,
unsigned int  baud 
)

uart_get_divisor - return uart clock divisor : uart_port structure describing the port. : desired baud rate

Calculate the uart clock divisor for the port.

Definition at line 414 of file serial_core.c.

void uart_handle_cts_change ( struct uart_port uport,
unsigned int  status 
)

uart_handle_cts_change - handle a change of clear-to-send state : uart_port structure for the open port : new clear to send status, nonzero if active

Definition at line 2555 of file serial_core.c.

void uart_handle_dcd_change ( struct uart_port uport,
unsigned int  status 
)

uart_handle_dcd_change - handle a change of carrier detect state : uart_port structure for the open port : new carrier detect status, nonzero if active

Definition at line 2517 of file serial_core.c.

void uart_insert_char ( struct uart_port port,
unsigned int  status,
unsigned int  overrun,
unsigned int  ch,
unsigned int  flag 
)

uart_insert_char - push a char to the uart layer

User is responsible to call tty_flip_buffer_push when they are done with insertion.

: corresponding port : state of the serial port RX buffer (LSR for 8250) : mask of overrun bits in : character to push : flag for the character (see TTY_NORMAL and friends)

Definition at line 2591 of file serial_core.c.

int uart_match_port ( struct uart_port port1,
struct uart_port port2 
)

Definition at line 2491 of file serial_core.c.

int uart_register_driver ( struct uart_driver drv)

uart_register_driver - register a driver with the uart core layer : low level driver structure

Register a uart driver with the core driver. We in turn register with the tty layer, and initialise the core driver per-port state.

We have a proc file in /proc/tty/driver which is named after the normal driver.

drv->port should be NULL, and the per-port structures should be registered using uart_add_one_port after this call has succeeded.

Definition at line 2245 of file serial_core.c.

int uart_remove_one_port ( struct uart_driver drv,
struct uart_port uport 
)

uart_remove_one_port - detach a driver defined port structure : pointer to the uart low level driver structure for this port : uart port structure for this port

This unhooks (and hangs up) the specified port structure from the core driver. No further calls will be made to the low-level code for this port.

Definition at line 2442 of file serial_core.c.

int uart_resume_port ( struct uart_driver drv,
struct uart_port uport 
)

Definition at line 1945 of file serial_core.c.

int uart_suspend_port ( struct uart_driver drv,
struct uart_port uport 
)

Definition at line 1879 of file serial_core.c.

void uart_unregister_driver ( struct uart_driver drv)

uart_unregister_driver - remove a driver from the uart core layer : low level driver structure

Remove all references to a driver from the core driver. The low level driver must have removed all its ports via the uart_remove_one_port() if it registered them with uart_add_one_port(). (ie, drv->port == NULL)

Definition at line 2312 of file serial_core.c.

void uart_update_timeout ( struct uart_port port,
unsigned int  cflag,
unsigned int  baud 
)

uart_update_timeout - update per-port FIFO timeout. : uart_port structure describing the port : termios cflag value : speed of the port

Set the port FIFO timeout value. The value should reflect the actual hardware settings.

Definition at line 275 of file serial_core.c.

void uart_write_wakeup ( struct uart_port port)

Definition at line 70 of file serial_core.c.