ARM-Linux s3c2440 UART Analysis (Part 2)

Publisher:创意航海Latest update time:2016-06-12 Source: eefocusKeywords:ARM  Linux  s3c2440  UART Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
This article is original from itspy. Please indicate the original source when copying/reprinting: http://blog.csdn.net/yyplc/article/details/7196290. Thank you!

Software (linux-2.6.30.4):

The serial port driver of the Linux system is different from the general character device. It adopts a hierarchical architecture and is implemented as a serial system.

(1) Focus on the low-level drivers of UART or other low-level serial hardware features.

(2) TTY driver that interfaces with the underlying driver.

(3) Processing the line discipline used to exchange data with the TTY driver.

The following figure describes the hierarchical relationship between serial systems (s3c2440 serial port implementation example), which can be summarized as: user application layer --> line planning layer --> TTY layer --> underlying driver layer --> physical hardware layer

 

Line discipline and TTY driver are independent of hardware platform, and the implementation is already provided in Linux source code, so for a specific platform, we only need to implement the underlying driver, which is what we care about most. In s3c2440a, it is mainly implemented by s3c2440.c and samsung.c in dirivers/serial/.

The Uart driver mainly revolves around 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 see how s3c2440 is connected to the serial port architecture in Linux:

The S3c2440 serial port related operation functions are defined in s3c24xx_serial_ops, which is a structuart_ops structure


 

  1. static struct uart_ops s3c24xx_serial_ops ={  
  2.       .pm =s3c24xx_serial_pm, //Power management function  
  3.       .tx_empty = s3c24xx_serial_tx_empty, //Check if the transmit FIFO buffer is empty  
  4.       .get_mctrl = s3c24xx_serial_get_mctrl, // Whether serial port flow control  
  5.       .set_mctrl = s3c24xx_serial_set_mctrl, //Whether to set serial port flow control cts  
  6.        .stop_tx =s3c24xx_serial_stop_tx, //stop sending  
  7.        .start_tx =s3c24xx_serial_start_tx, //Start sending  
  8.        .stop_rx =s3c24xx_serial_stop_rx, //stop receiving  
  9.       .enable_ms = s3c24xx_serial_enable_ms, //empty function  
  10.       .break_ctl = s3c24xx_serial_break_ctl, //Send break signal  
  11.        .startup =s3c24xx_serial_startup, //Serial port sending/receiving, and interrupt request initial configuration function  
  12.       .shutdown = s3c24xx_serial_shutdown, //Close the serial port  
  13.       .set_termios = s3c24xx_serial_set_termios, //Serial port clk, baud rate, data bit and other parameter settings  
  14.       .type = s3c24xx_serial_type, // CPU type about serial port  
  15.        .release_port =s3c24xx_serial_release_port, //Release serial port  
  16.        .request_port =s3c24xx_serial_request_port, //Request serial port  
  17.       .config_port = s3c24xx_serial_config_port, //Some configuration information of the serial port info  
  18.       .verify_port = s3c24xx_serial_verify_port, //serial port detection  
  19. };  

 

 

Driver structure definition:


 

  1. static struct uart_driver s3c24xx_uart_drv= {  
  2.       .owner           =THIS_MODULE,  
  3.       .dev_name = "s3c2440_serial", //Specific device name  
  4.       .nr =CONFIG_SERIAL_SAMSUNG_UARTS, //define how many ports there are  
  5.       .cons = S3C24XX_SERIAL_CONSOLE, //console interface  
  6.        .driver_name =S3C24XX_SERIAL_NAME, //Serial port name: ttySAC  
  7.       .major =S3C24XX_SERIAL_MAJOR, //Major device number  
  8.       .minor =S3C24XX_SERIAL_MINOR, //Minor device number  
  9. };  

 

 

Port configuration structure definition, which includes a structuart_ports structure:

 

  1. struct s3c24xx_uart_port {  
  2.       unsignedchar               rx_claimed;  
  3.       unsignedchar               tx_claimed;  
  4.       unsignedint                 pm_level;  
  5.       unsignedlong              baudclk_rate;  
  6.    
  7.       unsignedint                 rx_irq;  
  8.       unsignedint                 tx_irq;  
  9.    
  10.       structs3c24xx_uart_info       *info;  
  11.       structs3c24xx_uart_clksrc     *clksrc;  
  12.       structclk              *clk;  
  13.       structclk              *baudclk;  
  14.       structuart_port            port;  
  15.    
  16. #ifdef CONFIG_CPU_FREQ  
  17.       structnotifier_block            freq_transition;  
  18. #endif  
  19. };  
  20. static structs3c24xx_uart_ports3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS] = {  
  21.        [0]= { //Serial port 0  
  22.              .port= {  
  23.                     .lock             =__SPIN_LOCK_UNLOCKED(s3c24xx_serial_ports[0].port.lock),  
  24.                     .iotype =UPIO_MEM, //  
  25.                     .irq =IRQ_S3CUART_RX0, //interrupt number  
  26.                     .uartclk = 0, //clock value  
  27.                     .fifosize = 16, //define FIFO buffer size  
  28.                     .ops = &s3c24xx_serial_ops, //Serial port related operation functions  
  29.                     .flags            = UPF_BOOT_AUTOCONF,  
  30.                     .line = 0, //Line 1  
  31.              }  
  32.        },  
  33.        [1]= {//Serial port 1  
  34.              .port= {  
  35.                     .lock             =__SPIN_LOCK_UNLOCKED(s3c24xx_serial_ports[1].port.lock),  
  36.                     .iotype = UPIO_MEM,  
  37.                     .irq         = IRQ_S3CUART_RX1,  
  38.                     .uartclk   = 0,  
  39.                     .fifosize   = 16,  
  40.                     .ops        = &s3c24xx_serial_ops,  
  41.                     .flags            = UPF_BOOT_AUTOCONF,  
  42.                     .line        = 1,  
  43.              }  
  44.        },  
  45. #if CONFIG_SERIAL_SAMSUNG_UARTS > 2  
  46.    
  47.        [2]= {//Serial port 2  
  48.              .port= {  
  49.                     .lock             =__SPIN_LOCK_UNLOCKED(s3c24xx_serial_ports[2].port.lock),  
  50.                     .iotype = UPIO_MEM,  
  51.                     .irq         = IRQ_S3CUART_RX2,  
  52.                     .uartclk   = 0,  
  53.                     .fifosize   = 16,  
  54.                     .ops        =&s3c24xx_serial_ops,  
  55.                     .flags            = UPF_BOOT_AUTOCONF,  
  56.                     .line        = 2,  
  57.              }  
  58.        },  
  59. #endif  
  60. };  

 

 

To sum up, s3c2440 mainly implements these three data structures: 

s3c24xx_serial_ops,  s3c24xx_uart_drv,  s3c24xx_uart_ports3c24xx_serial_ports

The next article will further explore the implementation of ARM-Linuxs3c2440 in combination with source code.

Keywords:ARM  Linux  s3c2440  UART Reference address:ARM-Linux s3c2440 UART Analysis (Part 2)

Previous article:ARM-Linux s3c2440 UART Analysis (Part 3)
Next article:ARM-Linux s3c2440 UART Analysis (I)

Recommended ReadingLatest update time:2024-11-16 15:29

S3C2440-SDRAM connection analysis
A relatively detailed analysis of the connections between S3C2440 and SDRAM, Nandflash, and Norflash. Analysis of the address connection between S3C2440 and SDRAM S3C2440 has 27 address lines ADDR and 8 chip select signals ngcs0-ngcs7, corresponding to bank0-bank7. When accessing the address space of bankx, the
[Microcontroller]
S3C2440-SDRAM connection analysis
S3C2440 interrupt control register
1. SUBSRCPND register (SUB SOURCE PENDING) The SUBSRCPND register is used to identify whether interrupts such as INT_RXD0, INT_TXD0 (there are 11 such interrupts in S3C2410 and 15 in S3C2440) have occurred, and each bit corresponds to an interrupt. When these interrupts occur and are not masked by the INTSUBMSK regist
[Microcontroller]
S3C2440 interrupt control register
Talk about the use of ARM NEON SIMD architecture extensions in Zynq SoC
Inside all Zynq All Programmable SoCs, you'll find a dual-core ARM Cortex-A9 MPCore processor, and both processors in the Zynq SoC feature the ARM NEON SIMD architecture extensions. So why would you want to use the ARM NEON SIMD extensions? Because you can get a significant performance boost for your software. You may
[Microcontroller]
Talk about the use of ARM NEON SIMD architecture extensions in Zynq SoC
ARM startup and working mode switching
In the ARM system, there are usually three ways to control the execution flow of the program: During normal program execution, the value of the program counter register (PC) increases by 4 bytes for each ARM instruction executed; the value of the program counter register (PC) increases by 2 bytes for each Thumb inst
[Microcontroller]
ARM startup and working mode switching
ARM LCD and LCD controller
Since we mentioned LCD, the first thing we must understand is its types. CD (liquid crystal display) is a display that uses liquid crystal to control transmittance counting to achieve color. Compared with traditional CRT displays, it has many advantages: light and thin, low energy consumption, low radiation, etc., and
[Microcontroller]
ARM LCD and LCD controller
【ARM】s3c2440 gpio button control
Function Through GPIO, key 1 lights up LED 1, key 2 lights up LED 2... illustrate 1) Because the 2440 keys only involve rows, scanning keys is much simpler than the 2410 2) Before performing a shift operation, the data register must be initialized, otherwise an error will occur (hardware characteristics) Source
[Microcontroller]
Design of multifunctional integrated communication control system based on ARM9
    With the rapid development of computer technology, industrial data acquisition has evolved from traditional measurement and control circuits to modern data acquisition and control systems consisting of microcomputers, interface circuits, external general equipment, and industrial production objects. However, data a
[Microcontroller]
Design of multifunctional integrated communication control system based on ARM9
Learn ARM development(14)
Since it is still troublesome to develop under LINUX, is there a more convenient and simple development method under WINDOWS? The answer is yes. Of course, we cannot choose a development tool like ADS, because it is too expensive. Even if we use pirated software, we will not feel at ease, so we have to adopt other s
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号