Arm-Linux S3C2440 UART Analysis (2)

Source: Internet
Author: User

==== This article is the original site. You are welcome to reprint it! Reprinted please indicate the source: http://blog.csdn.net/yyplc====

This article is original in itspy. If you copy or repost it, please indicate the original source at http://blog.csdn.net/yyplc/article/details/7196290. thank you!

Software (linux-2.6.30.4 ):

The serial port driver of Linux is the same as that of general character devices. It adopts a hierarchical architecture and is regarded as a serial system.

(1) underlying drivers that focus on UART or other underlying serial hardware features.

(2) tty driver for the underlying driver interface.

(3) line procedures for processing data exchange with tty drivers.

This section describes the hierarchical relationship between serial systems (implementation example of S3C2440 serial ports), which can be summarized: user Application Layer --> line planning layer --> tty layer --> underlying driver layer --> physical hardware layer

 

Line Rules and tty drivers are irrelevant to the hardware platform. The implementation is provided in the Linux source code. Therefore, for a specific platform, we only need to implement the underlying driver, this is what we are most concerned about. In s3c2440a, it is mainly implemented by S3C2440. C and Samsung. c Under dirivers/serial.

The UART driver is mainly centered on three key data structures (defined in include/Linux/serial_core.h ):

UART-specific driver structure definition: struct uart_driver s3c24xx_uart_drv;

UART port structure definition: struct uart_port s3c24xx_serial_ops;

UART-related operation function structure definition: struct uart_ops s3c24xx_serial_ops;

Based on the above three structures, let's take a look at how the S3C2440 is mounted to the serial port architecture in Linux:

The operation functions related to the S3C2440 serial port are defined in s3c24xx_serial_ops. This is a structuart_ops structure.

Static struct uart_ops s3c24xx_serial_ops = {. PM = s3c24xx_serial_pm, // power management function. tx_empty = s3c24xx_serial_tx_empty, // check whether the FIFO buffer is empty. get_mctrl = s3c24xx_serial_get_mctrl, // whether or not to control the serial port. set_mctrl = s3c24xx_serial_set_mctrl, // whether to set the serial port traffic control CTS. stop_tx = s3c24xx_serial_stop_tx, // stop sending. start_tx = s3c24xx_serial_start_tx, // start sending. stop_rx = s3c24xx_serial_stop_rx, // stop receiving. enable_ms = s3c24xx_serial_enable_ms, // empty function. break_ctl = s3c24xx_serial_break_ctl, // send the break signal. startup = s3c24xx_serial_startup, // serial port sending/receiving, and initial configuration function of interrupt request. shutdown = s3c24xx_serial_shutdown, // close the serial port. set_termios = s3c24xx_serial_set_termios, // set parameters such as serial CLK, baud rate, and data bit. type = s3c24xx_serial_type, // indicates the serial port of the CPU type. release_port = s3c24xx_serial_release_port, // release the serial port. request_port = s3c24xx_serial_request_port, // apply for a serial port. config_port = s3c24xx_serial_config_port, // some configuration information of the serial port info. verify_port = s3c24xx_serial_verify_port, // serial port detection };

Driver structure definition:

Static struct uart_driver s3c24xx_uart_drv = {. owner = this_module ,. dev_name = "s3c2440_serial", // The specific device name. nr = config_serial_samsung_uarts, // defines several ports. cons = s3c24xx_serial_console, // console interface. driver_name = s3c24xx_serial_name, // serial name: ttysac. major = s3c24xx_serial_major, // master device ID. minor = s3c24xx_serial_minor, // device number };

The port configuration structure definition includes a structuart_ports structure:

Struct detail {upper limit; lower pm_level; lower baudclk_rate; lower rx_irq; lower tx_irq; lower * Info; lower * clksrc; structclk * CLK; structclk * baudclk; structuart_port; # ifdef config_cpu_freq structnotifier_block freq_transition; # endif}; static structs3c24xx_uart_ports3c24xx_serial_ports [config_serial_samsung_uarts] = {[0] = {/serial port 0. port = {. lock =__ spin_lock_unlocked (s3c24xx_serial_ports [0]. port. lock ),. iotype = upio_mem ,//. IRQ = irq_s3cuart_rx0, // interrupt number. uartclk = 0, // clock value. required osize = 16, // defines the size of the FIFO cache. ops = & s3c24xx_serial_ops, // serial port related operation functions. flags = upf_boot_autoconf ,. line = 0, // line 1 }}, [1] = {// Serial Port 1. port = {. lock =__ spin_lock_unlocked (s3c24xx_serial_ports [1]. port. lock ),. iotype = upio_mem ,. IRQ = irq_s3cuart_rx1 ,. uartclk = 0 ,. required osize = 16 ,. ops = & s3c24xx_serial_ops ,. flags = upf_boot_autoconf ,. line = 1 ,},# if config_serial_samsung_uarts> 2 [2] = {// Serial Port 2. port = {. lock =__ spin_lock_unlocked (s3c24xx_serial_ports [2]. port. lock ),. iotype = upio_mem ,. IRQ = irq_s3cuart_rx2 ,. uartclk = 0 ,. required osize = 16 ,. ops = & s3c24xx_serial_ops ,. flags = upf_boot_autoconf ,. line = 2 ,},# endif };

To sum up, the S3C2440 mainly implements these three data structures:

S3c24xx_serial_ops, s3c24xx_uart_drv, s3c24xx_uart_ports3c24xx_serial_ports

The next article will further discuss the implementation of ARM-Linuxs3c2440 with the source code.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.