Old text -16c554 on Linux (AT91)-June 24, 2010 11:29

Source: Internet
Author: User

Linux version: 2.6.30at91sam9263 modify the serial Port extension driver: 1, create a template with 8250_exar_st16c554.c file under/drivers/serial/8250_at91_ xr16v554.c file; Modify the appropriate port and interrupt number, modify the platform device ID to plat8250_dev_at91_xr16v554, add the initialization of the bus to the Init function, and the interrupt port; in the file/ Add the ID to the Include/linux/serial_8250.h ID list;/drivers/serial/kconfig join: Config serial_8250_at91_xr16v554tristate "Support Exar xr16v554/554d Quad UART for AT91"depends on serial_8250! = n HelpMy Psmu-c4m11 uses xr16v554d to form Quad UART. If you areusing these UARTs,say Y here.to compile this driver as a module, choose M here:the ModuleWould be called 8250_at91_xr16v554./drivers/serial/makefile join: obj-$ (config_serial_8250_at91_xr16v554) + = 8250_at91_xr16v554.o 2,8250.c no need to modify!! Places to note: 1, #define PORT (_BASE,_IRQ)     \ {         \. MapBase = _base, \ . IRQ = _IRQ, \ . UARTCLK = 7372800, \ . Iotype = upio_mem, \ . regshift= 0, \. Flags = upf_boot_autoconf | Upf_ioremap,\ }Macro,. MapBase refers to the physical base site of 16c554, noting that MEMBASE;.UARTCLK is not the frequency of the 16c554 crystal, 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, while Upio_mem32 is represented as a 32-bit bus access, which means that when accessing 16c554 registers, 32 digits are read and 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 that the 16c554 register needs to be mapped to virtual address access; 2,.dev = {. Platform_data = xxx_data, },The xxx_data in the device structure declaration is because it is a multidimensional array, thereby. platform_data= Xxx_data with. Platform_data = &xxx_data meaning is the same, can be; 3,platform_device no need to register in the plate-pole initialization, use the Module_init declaration, the Order of the links, corresponding to the order of execution, in accordance with the order of makefile, and registration Platform_device and registration PLATFORM_ Driver order regardless of, registration success will match, match success, will call probe function, probe device, only probe success will address mapping, allocating resources and so on operation; 4, read 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, and the device's resources are defined in old_serial_port[] , and the array relies on the definition of SERIAL_PORT_DFNS, if defined as NULL, the device does not add PORT, while other device calls the Platform_device_register () function, if the driver is matched, Calls Serial8250_probe (), which reads data from the device's resources, detects each port, requests an interrupt number if it exists, maps the physical address, and so on, and adds Port. Thus adding a new device without modifying the 8250.C, the device that was added by default when initializing does not have an effect unless the SERIAL_PORT_DFNS is defined. 5, if the use of Gpio interrupt, you need to note that the AT91 normal IO port can not be set to rise or fall edge trigger, but can only be defined as edge trigger, that is, each effective level trigger 2 times, just wasted 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 <mach/gpio.h >+ #endif + #ifdef at91_gpio_irq_hack+ #define Nr_triesint ntries = 0;+int pin_val1, pin_val2;+Do {+Pin_val1 = At91_get_gpio_value (AT91_PIN_PB20);+Pin_val2 = At91_get_gpio_value (AT91_PIN_PB20);+} while (Pin_val1! = Pin_val2 && ntries++ < nr_tries);++Udelay (+);//Xxx:this need to is here otherwise IDE layer losts interrups, and 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: Serial8250.11:ttys0 at MMIO 0x30000000 (IRQ = $) is a 16550aserial8250.11: TtyS1 at MMIO 0x30000008 (IRQ = up) is a 16550aserial8250.11:ttys2 at MMIO 0x30000010 (IRQ =-) is a 16550aserial8250.1 1:ttys3 at MMIO 0x30000018 (IRQ = 16550A) are a few useful commands: view the resources of each serial port, if not normal initialization has a problem cat/proc/tty/driver/serial read out the data from the serial port (baud rate is on CAT/DEV/TTYS0 View Iomemcat/proc/iomem Reference: 1, "UART driver analysis of the Linux device model" http://blog.chinaunix.net/u1/51562/showart.php id=11109032, "The experience I've been driving for st16c554 transplant under Linux-2.6.32.2," 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

Old text -16c554 on Linux (AT91)-June 24, 2010 11:29

Related Article

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.