16c554 porting on Linux (AT91)

Source: Internet
Author: User

16c554 on Linux (AT91) Linux version:2.6.30at91sam9263  modify the serial Port extension driver:  1,/drivers/serial/ st16c554.c file Create 8250_at91_xr16v554.c file for template, modify corresponding port and interrupt number, modify platform device ID to plat8250_dev_at91_xr16v554 The initialization of the bus and the interrupt port is added to the INIT function; in the file/include/linux/serial_8250.h ID list, add the id;  /drivers/serial/ Kconfig add: Config serial_8250_at91_xr16v554tristate "support Exar xr16v554/554d Quad UART for AT91" depends on serial_8250 ! = Nhelp my Psmu-c4m11 uses xr16v554d to form Quad UART.  if are using These uarts, say Y here.  to compile this driver as a module, choose M here:th E Module will be called 8250_at91_xr16v554. /drivers/serial/makefile join: obj-$ (CONFIG_SERIAL_8250_AT91_ xr16v554) + = 8250_AT91_XR16V554.O 2,8250.C without modification!!   Places to note: 1, #define PORT (_BASE,_IRQ)    \{       \.mapbase = _base, \.irq = _irq, \.uar TCLK = 7372800, \.iotype = Upio_mem, \        .regshift = 0,       &NBSp    \.flags = upf_boot_autoconf | upf_ioremap,\} macro,. MapBase refers to the 16c554 's physical base address, noting that MEMBASE;.UARTCLK is not the frequency of the 16c554 crystal, and its maximum baud rate is. uartclk/ 16;.iotype refers to the type of access, related to the connection of the hardware, Upio_mem refers to a 8-bit bus connection, and Upio_mem32 is represented as 32-bit bus access mode, that is, access to the 16c554 register, read 32 digits, take 8 bits lower ;. Regshift is also related to the physical connection of the hardware, referring to the offset of each address of the 16c554, that is, the 16c554 of the A0 corresponding to the CPU; Upf_ioremap means the 16c554 register needs to be mapped to virtual address access;  2,.dev = {. Platform_data = Xxx_data,}, xxx_data in device structure declaration because it is a multidimensional array, thus. platform_data = Xxx_data with. Platform_data = &xxx_ The data meaning is the same, can be,  3,platform_device do not need to register in the plate-pole initialization, use the Module_init declaration, the Order of the links, corresponding to the order of execution, and the order of makefile, and registered Platform_ Device and register Platform_driver order regardless of, registration success will match, match success, will call probe function, probe device, only probe success will address map, allocate resources and so on Operation;  4, by reading reference 1 and 8250.c serial_core.c source code, found: in the serial8250_init (void) function will always register an ID of plat8250_dev_legacy platform_device, The device's resources are defined in old_serial_port[], and the array relies on the definition of SERIAL_PORT_DFNS, which does not add port if it is defined as NULL, while other device calls Platform_device_ Register () function, if the matching driver calls Serial8250_probe (), the function reads the data from the device's resources, detects each port, requests an interrupt number if it exists, maps the physical address, and adds port. Thus adding a new device without modifying the 8250.C, the default when initializingThe added device will not be affected as long as it does not define SERIAL_PORT_DFNS.  5, if a gpio interrupt is used, it is important to note that the AT91 normal IO port cannot be set to the rising or falling edge, but can only be defined as an edge trigger, that is, each active level is triggered 2 times, just a waste of the CPU, and will not affect the use, if you want to modify, You can modify the interrupt function in 8250.C, the invalid interrupt is returned directly, refer to the following: + #define at91_gpio_irq_hack++ #ifdef at91_gpio_irq_hack+ #include + #endif  +# Ifdef at91_gpio_irq_hack+ #define Nr_tries + + int ntries = 0;+ int Pin_val1, pin_val2;+ do {+ Pin_val1 = At91_get_gpio_val UE (AT91_PIN_PB20); + Pin_val2 = At91_get_gpio_value (AT91_PIN_PB20); +} while (Pin_val1! = Pin_val2 && ntries++ &lt ; Nr_tries); + + udelay (20); Xxx:this need to is here otherwise IDE layer losts interrups, don ' t know why!!! + if (Pin_val1 = = 0 | | ntries > nr_tries) + return irq_handled;+ #undef nr_tires+ #endif  6, if the boot detection succeeds, the add port succeeds and will print: Seria L8250.11:ttys0 at MMIO 0x30000000 (IRQ = $) is a 16550aserial8250.11:ttys1 at MMIO 0x30000008 (IRQ =-16550Aser) is a Ial8250.11:ttys2 at MMIO 0x30000010 (IRQ = $) is a 16550aserial8250.11:ttys3 at MMIO 0x30000018 (IRQ =) is a 16550a& nbsp; a few useful commands: view the resources of each serial port, if it is not normal to initialize the problem of cat /proc/tty/driver/serial read data from the serial port (baud rate is last set) cat/dev/ttys0  view iomemcat/proc/iomem   Reference: 1, " The UART driver analysis of the Linux device model, http://blog.chinaunix.net/u1/51562/showart.php?id=11109032, I was under the Linux-2.6.32.2 for st16c554 transplant-driven experience, "HTTP://BLOG.CHINAUNIX.NET/U3/106983/SHOWART_2148343.HTML3," linux2.6.14 Core porting 16c554 driver "http://blog.chinaunix.net/u3/92401/showart_2253514.html4,/arch/arm/mach-at91/ BOARD-TMS.C add 16c550 driver definition in this file

16c554 porting on Linux (AT91)

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.