Physical address to virtual address mapping

  
 

Mapping from physical address to kernel virtual address—Analyze the driver of the LCD controller that comes with the 9261 chip on the AT91SAM9261EK board

This paper analyzes the LCD controller that comes with the 9261 chip on the AT91SAM9261EK board. How the mapping from the physical address to the kernel virtual address is implemented in the driver. When the system executes atmel_lcdfb_init() in /drivers/video/atmel_lcdfb.c, the platform_driver_probe(&atmel_lcdfb_driver, atmel_lcdfb_probe) function is called, first searching for the system registered device based on the name "atmel_lcdfb" in atmel_lcdfb_driver() Is there any platform_device, if there is this device, the driver of the device is registered with the system. Static struct platform_driver atmel_lcdfb_driver = {.remove =__exit_p(atmel_lcdfb_remove),.driver = {.name ="atmel_lcdfb",.owner = THIS_MODULE,},}; since in /arch/arm/mach-at91/at91sam9261_devices.c The following platform_device at91_lcdc_device, static struct platform_device at91_lcdc_device = {.name ="atmel_lcdfb",.id = 0,.dev = {.dma_mask = &lcdc_dmamask,.coherent_dma_mask = 0xffffffff,.platform_data = &lcdc_data,}, .resource = lcdc_resources,.num_resources =ARRAY_SIZE(lcdc_resources),}; its name is also "atmel_lcdfb", and the device has been registered with the system in the at91_add_device_lcdc() function, so when executing the map in the atmel_lcdfb_probe() function = platform_get_resource(pdev, IORESOURCE_MEM, 1), you can get the lcdc_resources parameter defined below, where AT91SAM9261_LCDC_BASE is the starting address of the LCD User Interface 0x600000, which is the physical address; AT91SAM9261_LCDC_BASE + SZ_4K-1 is the end address. Static struct resource lcdc_resources[] = {[0] = {.start =AT91SAM9261_LCDC_BASE,.end =AT91SAM9261_LCDC_BASE + SZ_4K - 1,.flags =IORESOURCE_MEM,},[1] = {.start = AT91SAM9261_ID_LCDC,.end =AT91SAM9261_ID_LCDC,. Flags=IORESOURCE_IRQ,},#if defined(CONFIG_FB_INTSRAM)[2] = {.start =AT91SAM9261_SRAM_BASE,.end =AT91SAM9261_SRAM_BASE + AT91SAM9261_SRAM_SIZE - 1,.flags =IORESOURCE_MEM,},#endif}; Then implement it from the ioremap() function The mapping of the physical address to the kernel virtual address, ie sinfo->mmio=ioremap(info->fix.mmio_start, info->fix.mmio_len); where info->fix.mmio_start = regs-> Start (ie AT91SAM9261_LCDC_BASE); info->fix.mmio_len = regs->end (ie AT91SAM9261_LCDC_BASE + SZ_4K - 1)- regs->start + 1;

Copyright © Windows knowledge All Rights Reserved