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
- static struct uart_ops s3c24xx_serial_ops ={
- .pm =s3c24xx_serial_pm, //Power management function
- .tx_empty = s3c24xx_serial_tx_empty, //Check if the transmit FIFO buffer is empty
- .get_mctrl = s3c24xx_serial_get_mctrl, // Whether serial port flow control
- .set_mctrl = s3c24xx_serial_set_mctrl, //Whether to set serial port flow 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 break signal
- .startup =s3c24xx_serial_startup, //Serial port sending/receiving, and interrupt request initial configuration function
- .shutdown = s3c24xx_serial_shutdown, //Close the serial port
- .set_termios = s3c24xx_serial_set_termios, //Serial port clk, baud rate, data bit and other parameter settings
- .type = s3c24xx_serial_type, // CPU type about serial port
- .release_port =s3c24xx_serial_release_port, //Release serial port
- .request_port =s3c24xx_serial_request_port, //Request 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", //Specific device name
- .nr =CONFIG_SERIAL_SAMSUNG_UARTS, //define how many ports there are
- .cons = S3C24XX_SERIAL_CONSOLE, //console interface
- .driver_name =S3C24XX_SERIAL_NAME, //Serial port name: ttySAC
- .major =S3C24XX_SERIAL_MAJOR, //Major device number
- .minor =S3C24XX_SERIAL_MINOR, //Minor device number
- };
Port configuration structure definition, which includes a structuart_ports structure:
- struct s3c24xx_uart_port {
- unsignedchar rx_claimed;
- unsignedchar tx_claimed;
- unsignedint pm_level;
- unsignedlong baudclk_rate;
- unsignedint rx_irq;
- unsignedint tx_irq;
- structs3c24xx_uart_info *info;
- structs3c24xx_uart_clksrc *clksrc;
- structclk *clk;
- structclk *baudclk;
- structuart_port 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
- .fifosize = 16, //define FIFO buffer size
- .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,
- .fifosize = 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,
- .fifosize = 16,
- .ops =&s3c24xx_serial_ops,
- .flags = UPF_BOOT_AUTOCONF,
- .line = 2,
- }
- },
- #endif
- };
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.
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- EEWORLD University Hall----Live Replay: Smaller, faster, more reliable connectors drive new developments in IoT applications
- How to achieve aperture tuning
- Black Gold's FPGA is really bad
- This amplifier is a bit figurative, isn't it?
- ad19.0.10 3D display problem
- LPC1114 temperature sensor DS18B20 program
- Why is there only one channel with data when using STM32's TIMER to capture DMA?
- Amazing! TI launches smart high-tech clothing to help curb teenage obesity
- EEWORLD University ---- TPS65218D0: User Programming of Multi-Rail Power Management IC (PMIC)
- DAPLink version upgraded to 0254