Port the 16c2550 serial port chip to the Linux driver on the at91sam9263 Board

Source: Internet
Author: User
Tags define definition
The 16c2550 serial port chip can be used to expand two serial ports. Its operation method and register usage are exactly the same as 8250, so we can use the classic 8250 driver in Linux to drive st16c2550.
8250 the driver remains unchanged. You need to add the 16c2550 initialization code. In the initialization code, you need to set the chip selection and IRQ pin for 16c2550, configure the read/write timing for the 16c2550 peripherals (setup, pulse, cycle), and link the driver to the device.
It is very important to configure the read/write timing of the peripheral space. If this parameter is not configured or configured incorrectly, the CPU cannot identify the serial chip or the value is 16450. This step is critical. Many people have made mistakes in this step. For example, cs4 registers are configured when CS3 space is used. For the read/write sequence configuration, see the at91sam9263 SMC section, which corresponds to the read/write Sequence Chart of 16c2550.
16c2550 integrates two asynchronous serial ports into one chip and is independent of each other. In this article, CS2 is selected for port A, at91_pin_pa10 is interrupted, CS3 is selected for port B, and at91_pin_pa8 is interrupted. The main clock frequency is 198 MHz (10.101ns one clock cycle ).
The code added to board_at91sam9263ek.c is as follows:
# Define st16c2550_base0x30000000 // ncs2 // a port # define definition // ncs2 # define definition // irq3 # define definition // ncs3 // B port # define definition // ncs3 # define Definition irq_pin_bat91_pin_pa8 // irq2static struct plat_serial8250_port st16c2550_data [] = {{. mapbase = st16c2550_base ,. IRQ = irq_pin ,. uartclk = 18432000 ,. regshift = 0 ,. iotype = upio_mem ,. flags = upf_boot_autoconf | upf_ioremap | upf_skip_test ,},{. mapbase = st16c2550_base_ B ,. IRQ = irq_pin_ B ,. uartclk = 18432000 ,. regshift = 0 ,. iotype = upio_mem ,. flags = upf_boot_autoconf | upf_ioremap | upf_skip_test, },{}}; static struct platform_device st16c2550_device = {. name = "serial8250 ",. id = plat8250_dev_platform ,. dev = {. dma_mask = & st16c2550_dmamask ,. coherent_dma_mask = dma_bit_mask (32 ),. platform_data = & st16c2550_data,},}; void _ init partition (void) {static void _ iomem * smc_base;/* A ncs2 * // setup ncsx partition (ncsx_pin, 0); // setup IRQ partition (irq_pin, 0); at91_sys_write (at91_smc_mode (2), (at91_smc_readmode | modes | temperature | at91_smc_bat_select | temperature )); at91_sys_write (random (2), 0x000e000f); at91_sys_write (at91_smc_setup (2), 0x03040304); at91_sys_write (at91_smc_pulse (2), 0x07060807 ); /* B ncs3 * // setup ncsx kernel (ncsx_pin_ B, 0); // setup IRQ pinat91_set_gpio_input (irq_pin_ B, 0); at91_sys_write (at91_smc_mode (3 ), (at91_smc_readmode | modes | measures | Measures); at91_sys_write (at91_smc_cycle (3), 0x000e000f); at91_sys_write (at91_smc_setup (3), 0x03040304 ); at91_sys_write (at91_smc_pulse (3), 0x07060807); platform_device_register (& st16c2550_device );}

In the ek_board_init () initialization code, add at91_add_st16c2550.

When porting the driver, pay special attention to whether the CS chip selection space has been used by other peripherals. If you do not pay attention to it, the last configuration overwrites the previous configuration during time series configuration, which leads to incorrect read/write timing.

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.