Smart210学习记录------linux串口驱动

转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=27025492&id=327609

一、核心数据结构 串口驱动有3个核心数据结构,它们都定义在<#include linux/serial_core.h> 1、uart_driver uart_driver包含了串口设备名、串口驱动名、主次设备号、串口控制台(可选)等信息,还封装了tty_driver(底层串口驱动无需关心tty_driver)。

 

 

struct uart_driver {    

 struct module     *owner;           /* 拥有该uart_driver的模块,一般为THIS_MODULE */     

const char        *driver_name;     /* 串口驱动名,串口设备文件名以驱动名为基础 */     

const char        *dev_name;        /* 串口设备名 */    

 int                major;           /* 主设备号 */     

int                minor;           /* 次设备号 */     

int                nr;              /* 该uart_driver支持的串口个数(最大) */     

struct console    *cons;            /* 其对应的console.若该uart_driver支持serial console,否则为NULL */
    /*      * these are private; the low level driver should not      * touch these; they should be initialised to NULL      */     

struct uart_state *state;    

 struct tty_driver *tty_driver;

};

 

2、uart_port uart_port用于描述串口端口的I/O端口或I/O内存地址、FIFO大小、端口类型、串口时钟等信息。实际上,一个uart_port实例对应一个串口设备

struct uart_port {     

spinlock_t             lock;           /* 串口端口锁 */     

unsigned int           iobase;         /* IO端口基地址 */     

unsigned char __iomem *membase;        /* IO内存基地址,经映射(如ioremap)后的IO内存虚拟基地址 */    

 unsigned int           irq;            /* 中断号 */    

 unsigned int           uartclk;        /* 串口时钟 */     

unsigned int           fifosize;       /* 串口FIFO缓冲大小 */    

 unsigned char          x_char;         /* xon/xoff字符 */    

 unsigned char          regshift;       /* 寄存器位移 */     

unsigned char          iotype;         /* IO访问方式 */     

unsigned char          unused1;
#define UPIO_PORT        (0)               /* IO端口 */

#define UPIO_HUB6        (1)

#define UPIO_MEM         (2)               /* IO内存 */

#define UPIO_MEM32       (3)

#define UPIO_AU          (4)               /* Au1x00 type IO */

#define UPIO_TSI         (5)               /* Tsi108/109 type IO */

#define UPIO_DWAPB       (6)               /* DesignWare APB UART */

#define UPIO_RM9000      (7)               /* RM9000 type IO */
    unsigned int        read_status_mask;  /* 关心的Rx error status */     

unsigned int        ignore_status_mask;/* 忽略的Rx error status */     

struct uart_info      *info;           /* pointer to parent info */     

struct uart_icount     icount;         /* 计数器 */
    struct console        *cons;           /* console结构体 */

#ifdef CONFIG_SERIAL_CORE_CONSOLE     

unsigned long         sysrq;           /* sysrq timeout */

#endif
    upf_t                 flags;
#define UPF_FOURPORT         ((__force upf_t(1 << 1))

#define UPF_SAK              ((__force upf_t(1 << 2))

#define UPF_SPD_MASK         ((__force upf_t(0x1030))

#define UPF_SPD_HI           ((__force upf_t(0x0010))

#define UPF_SPD_VHI          ((__force upf_t(0x0020))

#define UPF_SPD_CUST         ((__force upf_t(0x0030))

#define UPF_SPD_SHI          ((__force upf_t(0x1000))

#define UPF_SPD_WARP         ((__force upf_t(0x1010))

#define UPF_SKIP_TEST        ((__force upf_t(1 << 6))

#define UPF_AUTO_IRQ         ((__force upf_t(1 << 7))

#define UPF_HARDPPS_CD       ((__force upf_t(1 << 11))

#define UPF_LOW_LATENCY      ((__force upf_t(1 << 13))

#define UPF_BUGGY_UART       ((__force upf_t(1 << 14))

#define UPF_MAGIC_MULTIPLIER ((__force upf_t(1 << 16))

#define UPF_CONS_FLOW        ((__force upf_t

转载于:https://www.cnblogs.com/qigaohua/p/5574345.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值