Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux 程式設計 >> Linux 程式設計

Linaro Android 4.0.4 for FS100:DM9000 網卡移植實錄

下面按步驟記錄在 FS100 開發板上移植 DM9000 網卡驅動的完整過程。

1. 修改平台代碼

vim arch/arm/mach-s5pc100/mach-smdkc100.c

2. 添加所需頭文件

#if defined (CONFIG_DM9000)
#include <linux/dm9000.h>
#include <linux/irq.h>
#endif

3. 添加平台設備

(CMD 為低時讀寫地址寄存器,CMD 為高時讀寫數據寄存器;訪問 dm9000 內部寄存器時,先把 CMD 拉低寫入地址,再拉高讀寫數據。)

#if defined(CONFIG_DM9000)
// MichaelTang add start
static struct resource dm9000_resources[] = {
    [0] = {
            .start  = 0x88000000,                       // 地址線
            .end    = 0x88000000 + 0x4 - 1,
            .flags  = IORESOURCE_MEM,
        },
    [1] = {
            .start  = 0x88000000 + 0x4,                 // 數據線
            .end    = 0x88000000 + 0x8 - 1,
            .flags  = IORESOURCE_MEM,
        },
    [2] = {
            .start  = S5P_IRQ_VIC0(10),
            .end    = S5P_IRQ_VIC0(10),
            .flags  = IORESOURCE_IRQ | IRQ_TYPE_LEVEL_HIGH,   //申請中斷及觸發方式
        },
};

static struct dm9000_plat_data s5pc100_dm9000_platdata = {    // 設置網卡mac物理地址
                    .flags      = DM9000_PLATF_16BITONLY,
                    .dev_addr[0] = 0x0,
                    .dev_addr[1] = 0x0,
                    .dev_addr[2] = 0x11,
                    .dev_addr[3] = 0x22,
                    .dev_addr[4] = 0x33,
                    .dev_addr[5] = 0x44,
};
static struct platform_device s3c_device_dm9ks = {    // 注冊設備結構體
        .name   = "dm9000",
        .id     = -1,
        .num_resources = ARRAY_SIZE(dm9000_resources),
        .resource      = dm9000_resources,
        .dev = {
            .platform_data = &s5pc100_dm9000_platdata,
        }
};
// MichaelTang add end
#endif

4. 把 dm9000 加入平台設備列表

添加位置:smdkc100_devices[] 中。

#if defined (CONFIG_DM9000)

    // Michaeltang add
    &s3c_device_dm9ks,
    // MichaelTang add end

#endif

5. 配置內核

$ make menuconfig

6. 網絡配置與編譯

把 dm9000 配置為編譯進內核,執行 make zImage,再拷貝到 tftp 目錄,透過 tftp 加載即可測試新內核是否能正常驅動網卡。

Copyright © Linux教程網 All Rights Reserved