GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing docs.kernel.org — Low Level Serial API — The Linux Kernel documentation Low Level Serial API¶This document is meant as a brief overview of some aspects of the new serial driver. It is not complete, any questions you have should be directed to <rmk@arm.linux.org.uk> The reference implementation is contained within amba-pl011.c. Low Level Serial Hardware Driver¶The low level serial hardware driver is responsible for supplying port information (defined by uart_port) and a set of control methods (defined by uart_ops) to the core serial driver. The low level driver is also responsible for handling interrupts for the port, and providing any console support. Console Support¶The serial core provides a few helper functions. This includes
decoding command line arguments ( There is also a helper function ( Locking¶It is the responsibility of the low level hardware driver to perform the
necessary locking using port->lock. There are some exceptions (which
are described in the There are two locks. A per-port spinlock, and an overall semaphore. From the core driver perspective, the port->lock locks the following data: port->mctrl port->icount port->state->xmit.head (circ_buf->head) port->state->xmit.tail (circ_buf->tail) The low level driver is free to use this lock to provide any additional locking. The port_sem semaphore is used to protect against ports being added/ removed or reconfigured at inappropriate times. Since v2.6.27, this semaphore has been the ‘mutex’ member of the tty_port struct, and commonly referred to as the port mutex. uart_ops¶
Definition: struct uart_ops {
unsigned int (*tx_empty)(struct uart_port *);
void (*set_mctrl)(struct uart_port *, unsigned int mctrl);
unsigned int (*get_mctrl)(struct uart_port *);
void (*stop_tx)(struct uart_port *);
void (*start_tx)(struct uart_port *);
void (*throttle)(struct uart_port *);
void (*unthrottle)(struct uart_port *);
void (*send_xchar)(struct uart_port *, char ch);
void (*stop_rx)(struct uart_port *);
void (*start_rx)(struct uart_port *);
void (*enable_ms)(struct uart_port *);
void (*break_ctl)(struct uart_port *, int ctl);
int (*startup)(struct uart_port *);
void (*shutdown)(struct uart_port *);
void (*flush_buffer)(struct uart_port *);
void (*set_termios)(struct uart_port *, struct ktermios *new, const struct ktermios *old);
void (*set_ldisc)(struct uart_port *, struct ktermios *);
void (*pm)(struct uart_port *, unsigned int state, unsigned int oldstate);
const char *(*type)(struct uart_port *);
void (*release_port)(struct uart_port *);
int (*request_port)(struct uart_port *);
void (*config_port)(struct uart_port *, int);
int (*verify_port)(struct uart_port *, struct serial_struct *);
int (*ioctl)(struct uart_port *, unsigned int, unsigned long);
#ifdef CONFIG_CONSOLE_POLL;
int (*poll_init)(struct uart_port *);
void (*poll_put_char)(struct uart_port *, unsigned char);
int (*poll_get_char)(struct uart_port *);
#endif;
};
Members
Description This structure describes all the operations that can be done on the physical hardware.
Other functions¶
Parameters
Description This routine is used by the interrupt handler to schedule processing in the software interrupt portion of the driver. A driver is expected to call this function when the number of characters in the transmit buffer have dropped below a threshold. Locking: port->lock should be held
Parameters
Description Set the port frame timing information from which the FIFO timeout value is derived. The cflag value should reflect the actual hardware settings as number of bits, parity, stop bits and baud rate is taken into account here. Locking: caller is expected to take port->lock
Parameters
Description Decode the termios structure into a numeric baud rate, taking account of the
magic 38400 baud rate (with spd_* flags), and mapping the If the new baud rate is invalid, try the old termios setting. If it’s still invalid, clip to the nearest chip supported rate. The termios structure is updated 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”). Locking: caller dependent
Parameters
Description Calculate the divisor (baud_base / baud) for the specified baud, appropriately rounded. If 38400 baud and custom divisor is selected, return the custom divisor instead. Locking: caller dependent
Parameters
Parameters
Parameters
Description
is also accepted; the returned iotype will be Return 0 on success or -
Parameters
Description
Parameters
Description Locking: Caller must hold console_list_lock in order to serialize early initialization of the serial-console lock.
Parameters
Description 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 Locking: none, Interrupts: enabled
Parameters
Description Remove all references to a driver from the core driver. The low level
driver must have removed all its ports via the Locking: none, Interrupts: enabled
Parameters
Description Caller must hold uport->lock.
Parameters
Description Caller must hold uport->lock.
Parameters
Description Enables magic SysRq when the required sequence is met on port (see CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE). Return
Parameters
Description This helper transmits characters from the xmit buffer to the hardware using
For all of them, port->lock is held, interrupts are locally disabled and the expressions must not sleep. Return the number of characters in the xmit buffer when done.
Parameters
Description See Other notes¶It is intended some day to drop the ‘unused’ entries from uart_port, and allow low level drivers to register their own individual uart_port’s with the core. This will allow drivers to use uart_port as a pointer to a structure containing both the uart_port entry with their own extensions, thus: struct my_port {
struct uart_port port;
int my_stuff;
};
Modem control lines via GPIO¶Some helpers are provided in order to set/get modem control lines via GPIO.
Parameters
Description Set the gpios according to the mctrl state.
Parameters
Return the gpio_desc structure associated to the modem line index
Parameters
Return modified mctrl (the same value as in mctrl) Description Update mctrl with the gpios values.
Parameters
Description This will get the {cts,rts,...}-gpios from device tree if they are present and request them, set direction etc, and return an allocated structure. devm_* functions are used, so there’s no need to explicitly free. As this sets up the irq handling, make sure to not handle changes to the gpio input lines in your driver, too.
Parameters
Parameters
Parameters
| ||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |