串口驱动分析-初始化
1.串口驱动程序结构
/linux-tq2440/drivers/serial/samsung.c
2.串口驱动中的重要数据结构
在之前一篇中的tty_write,位于:
-
static const struct file_operations tty_fops = {
-
.llseek = no_llseek,
-
.read = tty_read,
-
.write = tty_write,
-
.poll = tty_poll,
-
.unlocked_ioctl = tty_ioctl,
-
.compat_ioctl = tty_compat_ioctl,
-
.open = tty_open,
-
.release = tty_release,
-
.fasync = tty_fasync,
-
};
tty_ldisc_ops线路规程的函数指针:
-
struct tty_ldisc_ops tty_ldisc_N_TTY = {
-
.magic = TTY_LDISC_MAGIC,
-
.name = "n_tty",
-
.open = n_tty_open,
-
.close = n_tty_close,
-
.flush_buffer = n_tty_flush_buffer,
-
.chars_in_buffer = n_tty_chars_in_buffer,
-
.read = n_tty_read,
-
.write = n_tty_write,
-
.ioctl = n_tty_ioctl,
-
.set_termios = n_tty_set_termios,
-
.poll = n_tty_poll,
-
.receive_buf = n_tty_receive_buf,
-
.write_wakeup = n_tty_write_wakeup
-
};
tty_operations的变量:
-
static const struct tty_operations uart_ops = {
-
.open = uart_open,
-
.close = uart_close,
-
.write = uart_write,
-
.put_char = uart_put_char,
-
.flush_chars = uart_flush_chars,
-
.write_room = uart_write_room,
-
.chars_in_buffer= uart_chars_in_buffer,
-
.flush_buffer = uart_flush_buffer,
-
.ioctl = uart_ioctl,
-
.throttle = uart_throttle,
-
.unthrottle = uart_unthrottle,
-
.send_xchar = uart_send_xchar,
-
.set_termios = uart_set_termios,
-
.set_ldisc = uart_set_ldisc,
-
.stop = uart_stop,
-
.start = uart_start,
-
.hangup = uart_hangup,
-
.break_ctl = uart_break_ctl,
-
.wait_until_sent= uart_wait_until_sent,
-
#ifdef CONFIG_PROC_FS
-
.proc_fops = &uart_proc_fops,
-
#endif
-
.tiocmget = uart_tiocmget,
-
.tiocmset = uart_tiocmset,
-
#ifdef CONFIG_CONSOLE_POLL
-
.poll_init = uart_poll_init,
-
.poll_get_char = uart_poll_get_char,
-
.poll_put_char = uart_poll_put_char,
-
#endif
-
};
UART驱动程序结构:struct uart_driver 封装了tty_driver,使得底层的UART驱动无需关心tty_driver
UART端口结构: struct uart_port 用于描述一个UART端口(直接对应于一个串口)的I/O端口或者IO内存地址等信息。
UART相关操作函数结构: struct uart_ops
UART状态结构: struct uart_state 设备私有信息结构体, 在uart_open()中: tty->driver_data = state; 在其他uart_xxx()中: struct uart_state *state = tty->driver_data; 就可以获取设备私有信息结构体。
UART信息结构: struct uart_info
3.分析代码流程
在tq2440中只需要注册uart_register_driver就行了
而在240中初始化uart_port、闯将属性文件、初始化动态频率调节
参考资料:http://www.cnblogs.com/hello2mhb/p/3341291.html
阅读(549) | 评论(0) | 转发(0) |