Mini2440_ LCD _x35 Port

Source: Internet
Author: User

 

 

A new driver management and registration mechanism has been introduced since Linux 2.6: platform_device and piatform_driver. (platform stands for the platform). The device is represented by platform_device and the driver is registered using piatform_driver.

Compared with the traditional devicedriver mechanism (registered through the driver_register function), The linuxplatformdriver mechanism has a significant advantage in that the platform mechanism registers the resources of the device into the kernel and is centrally managed by the kernel, when using these resources in the driver, request and use the standard interface provided by platformdevice. This improves the independence of drivers and resource management, and provides good portability and Security (these standard interfaces are secure ).

The use of the platform mechanism is not complex and consists of two parts: platform_device and platfrom_driver.

The general process for developing the underlying driver through the platform mechanism is: Define Resoure-> define platform_device-> define platform_driver-> Register platform_driver.

The kernel already has a sound LCD driver. We only need to make simple modifications based on the LCD used. The first thing to confirm is the device resource information, such as the device address and interrupt number.

In the 2.6 kernel, the platform device is described by the structure platform_device, which is defined in

Kernel \ include \ Linux \ platform_device.h

.

Struct platform_device {

Const char * Name; u32 ID;

Struct device dev; u32 num_resources;

Struct resource * resource;

};

An important element of this structure is resource, which stores the most important device resource information, which is defined in

In kernel \ include \ Linux \ ioport. h. Struct resource {

Resource_size_tstart; // describes the linear starting physical address of the device entity on the CPU bus;

Resource_size_tend; // the physical address that describes the linear end of a device object on the CPU bus;

Const char * Name; // describes the name of the device entity. developers can enter this name at will;

Unsigned long flags; // a flag that describes some of the common characteristics of the device entity; (the I/O port of the LCD controller, which is referenced in the driver to indicate

Reference IO port)

Struct resource * parent, * sibling, * child; // pointer parent, sibling, and child:

Pointer to father, brother, and sub-resource.

};

For example:

1. Modify linux-2.6.32.2 \ arch \ Arm \ palt-s3c24xx \ Devs. c file: Add platform device LCD occupied resources. Open Devs. c

/* LCD controller */

Static struct resource maid [] = {

[0] = {. Start = s3c24xx_pa_ LCD, // (Controller IO port start address)

. End = s3c24xx_pa_ LCD + s3c24xx_sz_ LCD-1, // (Controller I/O port end address)

. Flags = ioresource_mem, // (marked as the LCD controller I/O port, which is referenced in the driver

The IO port is referenced)

}, [1] = {. Start = irq_ LCD,. End = irq_ LCD,. Flags = ioresource_irq ,}};

With the resource information, you can define platform_device:

2. Modify the linux-2.6.32.2 \ arch \ Arm \ plat-s3c24xx \ Devs. c file: Add platform equipment. As shown in the following figure. If yes, you do not need to add it.

Static u64 maid = 0 xfffffffful;

Struct platform_device initi_device_ LCD = {. name = "s3c2410-lcd ",. id =-1 ,. num_resources = array_size (initi_ LCD _resource ),. resource = maid ,. dev = {. dma_mask = & jx_device_ LCD _dmamask ,. coherent_dma_mask = 0 xfffffffful }};

Here we define some information about a device. After the platform_device struct is defined, you can call the platform_add_devices function to add the device to the system. Then, you can call platform_device_register () to register the device. When the registration is successful, the platform_driver structure element probe function pointer will be called. Here

It is s3c24xx_i2c_probe. When you enter the probe function, you need to obtain the device resource information. The commonly used functions for obtaining resources are as follows:

Struct resource * platform_get_resource (struct platform_device * Dev, unsigned int type, unsigned int num );

Obtain the specified Resource Based on the type specified by the parameter, such as ioresource_mem.

Struct int platform_get_irq (struct platform_device * Dev, unsigned int num); // gets the interrupt number in the resource. (You can not see here) export the definition of the LCD platform device, fortunately, the mach-smdk2440.c of smdk2440_devices [] added to the platform device list.

Export_symbol (initi_device_ LCD );

(Linux is still in/ARCH/ARM/mach-s3c2410/include/Mach/FB. h) defines a s3c2410fb_mach_info struct for the LCD platform device, this struct mainly records the hardware parameter information of the LCD (for example, the s3c2410fb_display member structure of this struct is used to record the screen size, screen information, variable screen parameters, and LCD configuration registers of the LCD), in this way, this struct is used directly when writing the driver. Next, let's take a look


How does a core use this struct. In/ARCH/ARM/mach-s3c2440/mach-smdk2440.c (here look at the file I defined for mach-mini2440.c I will use mini2440 );

3. Modify arch \ Arm \ mach-s3c2440 \ mach-smdk2440.c: configure the s3c2440_devices platform equipment data, register the s3c2440_devices platform equipment.

Static struct platform_device * mini2440_devices [] _ initdata ={& initi_device_usb, & initi_device_ LCD (the struct has been defined in the second step) & initi_device_wdt, & define, & initi_device_iis, & amp; cloud_device_nand, & amp; mini2440_device_eth,

};

4. Modify arch \ Arm \ mach-s3c2440 \ mach-mini2440.c: configure the mini2440_devices_ LCD platform device data. /* LCD Driver info */

Static struct s3c2410fb_display mini2440_ LCD _cfg _ initdata ={# if! Defined (LCD _con5 ). lcdcon5 = s3c2410_lcdcon5_frm565 | s3c2410_lcdcon5_invvline | s3c2410_lcdcon5_invvframe | s3c2410_lcdcon5_pwren | s3c2410_lcdcon5_hwswp, # Else. lcdcon5 = LCD _con5, # endif. type = s3c2410_lcdconw.tft ,. width = LCD _width ,. height = LCD _height ,. pixclock = LCD _pixclock,/* hclk 60 MHz, divisor 10 */. xres = LCD _width ,. yres = LCD _height ,. bpp = 16 ,. left_margin = LCD _left_margin + 1 ,. right_margin = LCD _right_margin + 1 ,. hsync_len = LCD _hsync_len + 1 ,. upper_margin = LCD _upper_margin + 1 ,. lower_margin = LCD _lower_margin + 1 ,. vsync_len = LCD _vsync_len + 1 ,};

5. Modify mach-mini2440.c to add x35 screen support. (This part should be placed in front of Step 4) # define LCD _width 240 // screen width # define LCD _height 320 // screen height

# Define LCD _pixclock 170000 // clock # define LCD _right_margin 25 // left boundary


# Define LCD _left_margin 0 // right boundary # define LCD _hsync_len 4 // row synchronization # define LCD _upper_margin 0 // upper boundary # define LCD _lower_margin 4 // bottom boundary # define limit 9 // Frame Synchronization

# Define LCD _con5 (Bytes | \ s3c2410_lcdcon5_invvframe | \ s3c2410_lcdcon5_invvline | \ s3c2410_lcdcon5_invvframe | \ variable | \ s3c2410_lcdcon5_pwren | \ variable)

6. Modify arch \ Arm \ mach-s3c2440 \ mach-mini2440.c: configure the equipment data of s3c2440_devices platform, register the equipment of s3c2440_devices platform, and add the LCD Backlight

(Because the backlight of the mini2440 3.5 inch LCD screen is controlled by the gpg4 pin of the S3C2440,) Static struct s3c2410fb_mach_info mini2440_fb_info _ initdata = {. displays = & mini2440_ LCD _cfg, // (mini2440_ LCD _cfg has been set in step 1 ). num_displays = 1 ,. default_display = 0, // (Note: default is not executed ). gpccon = 0xaa955699 ,. gpccon_mask = 0xffc003cc ,. gpcup = 0x0000ffff ,. gpcup_mask = 0 xffffffff ,. gpdcon = 0xaa95aaa1 ,. gpdcon_mask = 0xffc0fff0 ,. gpdup = 0x0000faff ,. gpdup_mask = 0 xffffffff ,. lpcsel = 0xf82 ,};

Static void _ init mini2440_machine_init (void ){

S3c24xx_fb_set_platdata (& mini2440_fb_info); (sets the equipment data of the s3c2440_devices platform)

Initi_i2c0_set_platdata (null );

S3c2410_gpio_cfgpin (s3c2410_gpg (4), s3c2410_gpio_output); (configure the LCD pin) (to add # include <Linux/gpio. h>)

S3c2410_gpio_setpin (s3c2410_gpg (4), 1 );

Initi_device_nand.dev.platform_data = & mini2440_nand_info;

// Initiation_device_sdi.dev.platform_data = & s3c2410_mmc_cfg;

Platform_add_devices (mini2440_devices, array_size (mini2440_devices); (register the LCD platform device to the kernel)



// Initi_pm_init ();

// Mini2440_machine_init (); (the unavailable ones can be blocked )}

7. Modify the inux-2.6.32.2/Drivers/Video/kconfig file. config fb_s3c2410_x240320

Boolean "3.5 inch 240x320 Sony LCD (X35-ACX502BMU)" depends on fb_s3c2410 help

3.5 inch 240x320 Sony LCD (X35-ACX502BMU) 8. Make menuconfig Device Driver:

<*> Support for frame buffer devices -? [*] Enable frameware edid

[*] Enable vidoe mode handling helpers <*> s3c24x0 LCD framebuffer support console display driver support --? <*> Framebuffer console support [*] bootup logo --?

<*> Standard 224-color Linux logo can be seen after kernel startup.


Mini2440_ LCD _x35 Port

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.