前面已经把内核给跑起来的,现在要做的就是各种驱动的移植了,首先来移植简单的led。

        在linux内核中drivers/leds/leds­gpio.c已经写好了一个与系统结构无关的LED驱动,我们只要修改BSP板极文件将它注册到platform上就行。

在 arch/arm/mach-s3c64xx/目录下打开mach-ok6410.c板级文件

root@ubuntu:/forlinx/linux-3.3.5/arch/arm/mach-s3c64xx# gedit mach-ok6410.c
在板级文件下添加对应的如下信息

static struct gpio_led ok6410_leds[] ={
    [0]= {
        .name = "LED1",
        .gpio = S3C64XX_GPM(0),
        },
    [1]= {
        .name = "LED2",
        .gpio = S3C64XX_GPM(1),
        },
    [2]= {
        .name = "LED3",
        .gpio = S3C64XX_GPM(2),
        },
    [3]= {
        .name = "LED4",
        .gpio = S3C64XX_GPM(3),
        },    
};

static struct gpio_led_platform_data ok6410_gpio_led_pdata ={
    .num_leds    = ARRAY_SIZE(ok6410_leds),
    .leds         =ok6410_leds,
};

static struct platform_device ok6410_device_led ={
    .name    = "leds-gpio",
    .id        = -1,
    .dev    ={
    .platform_data = &ok6410_gpio_led_pdata,
    },
};
在板级文件的设备初始化static struct platform_device *my6410_devices[] __initdata结构体中添加我们的LED配置

&ok6410_device_led,
最后配置内核,使我们的led在启动的时候加载。

Device Drivers --->

    [*] LED Class Support --->    

        <*> LED Support for GPIO connected LEDs

我们再次把内核下载到开发板的时候,当你发现ok6410上4盏led灯全亮的时候证明我们移植的led驱动已经成功了。

################################################################################################################################


Logo

更多推荐