VK3X Multi-Bus UART: Serial Port Expansion and Linux Driver Design in Embedded Handheld Devices
2026-04-06 06:57:10··#1
Abstract: This paper introduces a design scheme for expanding the serial port of an embedded handheld device based on the VK3X chip, and provides the method and programming considerations for driver design under Linux. Keywords: Embedded handheld device, VK3X, UART, serial port expansion, Linux driver. With the increasing functionality of embedded handheld devices, the CPU/DSP needs to connect to more functional modules. Common modules such as Bluetooth, GPS, GSM, infrared, and card reader modules mostly use UART to interface with the CPU. However, most current CPUs only provide 2-3 serial ports, and in the design, one UART is often reserved as a debugging port. In reality, only 1-2 UARTs can be used to connect peripheral modules, thus requiring UART serial port expansion for the CPU. Traditional UART chips cannot fully meet the needs of handheld devices due to size and power consumption limitations. Considering the strict requirements of handheld devices on chip size and power consumption, this design selects the 1.8V low-voltage VK3X series QFN packaged UART product specifically designed for handheld devices as the serial port expansion chip. 1. Introduction to the Functional Characteristics and Principle Architecture of the VK3X Series Low-Voltage UART Devices: The low-voltage VK3X series UART supports operating voltages of 1.8V-3.3V and operating temperatures from -45℃ to +85℃. Each sub-channel supports a maximum transmission rate of 1Mbps, supports sleep and automatic wake-up functions, and has a minimum sleep current of only 90uA. It adopts ultra-small QFN24 (4x4x0.8mm) and QFN32 (5x5x0.8mm) packages, fully meeting the design requirements of handheld devices. The principle block diagram of the VK3X series UART is as follows. The internal structure of the VK3X series includes a host interface, sub-channel section, MODEM control logic, and interrupt control logic. The host interface is the interface for connecting the VK3X to the CPU/DSP. Through the M1 and MO mode selection signal lines, it can select four interface modes for connection to the host: 8-bit parallel bus, SPI bus, UART, and IIC. The MODEM control logic is used for monitoring and controlling the status signal lines when connected to the MODEM. Interrupt control logic is used to generate and control various internal interrupts. The clock generator provides the clock for the chip, and the clock source can be selected from a crystal oscillator or an external clock source using the CLKSEL pin. Multiple master bus interfaces can be configured according to actual design needs. 2. Hardware Design for Expanding Serial Ports in Embedded Handheld Devices Based on VK3X: 2.1 Design for Expanding Low-Speed Serial Ports using UART and IIC Buses (Handheld GPS Devices) The VK3X's UART master interface mode innovatively expands a standard 3-wire asynchronous serial port (UART) into a 2-4 channel serial port (UART), providing a simple solution for embedded systems requiring serial port expansion. It is applicable to applications that expand and upgrade existing solutions to multiple serial ports where speed requirements are not high. The IIC bus master interface mode implements IIC expansion bridging of 2-4 channel UARTs, suitable for applications with low serial port speed requirements and limited MCU I/O (such as GPS). This design uses VK302 to expand two low-speed serial ports, with both IIC and UART interfaces available as the main interface. The DSP/CPU in the embedded platform connects to the VK302 via IIC or UART bus. Two extended sub-serial ports connect to the low-speed GPS module and touchscreen module, respectively. 2.2 SPI Bus Expansion High-Speed Serial Port Design (GPS Smartphone) The SPI bus host interface mode can expand 2-4 channels of high-speed serial UART via a high-speed SPI synchronous serial port, widely used in CPU and DSP designs with SPI synchronous serial interfaces to expand high-speed UART serial ports. In this design, the VK304 host interface operates in SPI bus slave mode with a maximum speed of 5Mbps. The four extended sub-serial ports connect to the Bluetooth module (920kbps), infrared transceiver (115.2kbps), CDMA/GPRS module (230kbps), and GPS module (9.6kbps), respectively. To ensure data transmission reliability, a hardware flow control mechanism is applied between the CDMA/GPRS and VK3X, implemented through RTS1 and CTS1. 2.3 SPI/8-bit Parallel Bus Expansion of High-Speed Serial Port and I/O (Smart Dual-Mode Mobile Phone) The VK3X's 8-bit parallel bus interface mode is designed for embedded products, employing pin multiplexing to reduce pins and simplifying software design through a streamlined register structure. It can replace the 16C55X series products for expanding external serial ports for 8-bit, 16-bit, and 32-bit CPUs. The I/O used for parallel port input can also be multiplexed as GPIO, providing I/O expansion functionality for the system. It is suitable for systems requiring both serial port expansion and I/O expansion. In this design, the VK3368 is used for serial port expansion and I/O expansion. In the dual-mode mobile phone design, both CDMA and GPRS wireless modules need to be connected simultaneously. Between the CPU and the modules, in addition to TX, RX, RTS, and CTS, handshake signals such as DTR and DCD are also required. The DCD signal indicates whether the module is in data transmission or AT command transmission state, and the DTR signal notifies the module that the transmission has ended (hanged up). Here, the GPIO extended from the VK3368 is used to implement the handshake signal connection. 3. VK3X Series UART Serial Port Driver Design under Linux Currently, Linux, with its open nature, is widely used in handheld devices. Linux 2.6 is the most widely used version. Linux 2.6 uses a new `drivers/serial/serial_core.c` basic architecture, making driver development easier and porting to other Linux versions more convenient. The following example uses a Linux (2.6 kernel) platform based on ARM9 (S3C2440) as an example to introduce a serial port driver design example for the VK3X using the SPI bus interface: Header files included in the VK3X driver: #include #include #include #include #include #include #include #include <stdio.h> #include <stdlib.h>; #include "serial_vk32xx.h" SPI initialization function: inline void setup_spi(void) { SPCON0 = SPCON_MSTR | SPCON_ENSCK; SPPRE0 = 0x04; //set bandrate write_gpio_bit(VK32_CS, 1); } SPI transmit function: uint8_t spi_send_byte(uint8_t dat) { write_gpio_bit(VK32_CS, 0); SPTDAT0 = dat; while (!(SPSTA0 & SPSTA_READY)); write_gpio_bit(VK32_CS, 1); return SPRDAT0; } VK3X register write function: void vk3xxx_write_reg(uint8_t port, uint8_t reg, uint8_t dat) { `spi_send_byte(0x80|((port-1)<<5)|(reg<<1)); spi_send_byte(dat); }` VK3X register read function: `uint8_t vk3xxx_read_reg(uint8_t port, uint8_t reg) { spi_send_byte(((port-1)<<5)+(reg<<1)); return spi_send_byte(0x00); }` VK3X initialization function: `static int vk32xx_startup(struct uart_port *port, struct uart_info *info)` Data receiving function: `static void vk32xx_rx_chars(struct uart_info *info, struct pt_regs *regs) { uint8_t ssr; struct tty_struct *tty = info->tty; }` unsigned int ch, flg, ignored = 0; struct uart_port *port = info->port; …… } Data transmission function static void vk32xx_tx_chars(struct uart_info *info) { struct uart_port *port = info->port; uint8_t ssr; …… } VK3X interrupt handler function static void vk32xx_int(int irq, void *dev_id, struct pt_regs *regs) VK3X communication speed change function static void vk32xx_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot) Data transmission and reception related functions: static void vk32xx_stop_tx(struct uart_port *port, u_int from_tty) static void vk32xx_start_tx(struct uart_port *port, u_int nonempty, u_int from_tty) static void vk32xx_stop_rx(struct uart_port *port) Control-related functions: static int vk32xx_startup(struct uart_port *port, struct uart_info *info) static void vk32xx_shutdown(struct uart_port *port, struct uart_info *info) static void vk32xx_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot) Sub-channel operation-related functions: static void vk32xx_config_port(struct uart_port *port, int flags) static int vk32xx_verify_port(struct uart_port *port, struct serial_struct *ser) static void vk32xx_init_ports(void) The driver interface structure is as follows: static struct uart_ops vk32xx_pops = {tx_empty: vk32xx_tx_empty, set_mctrl: vk32xx_set_mctrl, get_mctrl: vk32xx_get_mctrl, stop_tx: vk32xx_stop_tx, start_tx: vk32xx_start_tx, stop_rx: vk32xx_stop_rx, enable_ms: vk32xx_enable_ms, break_ctl: vk32xx_break_ctl, startup: vk32xx_startup, shutdown: vk32xx_shutdown, change_speed: vk32xx_change_speed, type: vk32xx_type, release_port: vk32xx_release_port, request_port: vk32xx_request_port, config_port: vk32xx_config_port, verify_port: vk32xx_verify_port, }; Conclusion Embedded handheld devices require an increasing number of serial port peripherals. When the CPU's built-in UART serial port channels are insufficient, serial port expansion is necessary. Considering the requirements of embedded handheld devices for small chip size, low power consumption, and low voltage, the low-voltage version of VK3X is selected for serial port expansion design. In terms of hardware design, depending on the application, different reference design schemes provided in this paper can be selected, such as low-speed serial port expansion, high-speed serial port expansion, and high-speed serial port and IO expansion. For driver software, the Linux driver design reference provided in this paper can be used for driver design. References: www.vkic.com/DataSheetFiles/ www.vkic.com/DataSheetFiles/vk3x_linux_drv.rar The Serial Driver Layer" by Greg Kroah-Hartman, www.linux.it/~rubini/docs/serial/serial.html