Chinaunix首页 | 论坛 | 博客
  • 博客访问: 793811
  • 博文数量: 118
  • 博客积分: 2067
  • 博客等级: 大尉
  • 技术积分: 1751
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-17 14:27
文章存档

2016年(1)

2013年(1)

2012年(3)

2011年(26)

2010年(47)

2009年(40)

分类: LINUX

2009-09-23 14:17:13

1. 下载最新的内核源码linux-2.6.31,位置:ftp://ftp.kernel.org/pub/linux/kernel/v2.6

2. 下载yaffs2文件系统源码,下载地址:

3. 修改根目录下的Makefile文件:
    ARCH ?= arm
    CROSS_COMPILE ?= arm-linux-

4. arch/arm/plat-s3c24xx/common-smdk.c文件:
分区结构改为:static struct mtd_partition smdk_default_nand_part[] = {
    [0] = {
        .name    = "supervivi",
        .size    = 0x00030000,
        .offset    = 0,
    },
    [1] = {
        .name    = "Kernel",
        .offset = 0x00050000,
        .size    = 0x00200000,
    },
    [2] = {
        .name    = "root",
        .offset = 0x00250000,
        .size    = 0x03dac000,
    }
};
这样分区只是为了和FriendlyARM保持一致,并不是必须。
去掉此文件中相关的led相关设备和驱动,在smdk_devs结构体中增加&s3c_device_usbgadget设备,以支持USB网卡设备,否则usb网卡不可使用。

5. 修改晶振为12000000,位置:arch/arm/mach-s3c2440/mach-smdk2440.c

6. 增加yaffs2文件系统,解压后进入yaffs2文件目录,执行./patch-ker.sh c /home/crazytyt/linux-2.6.31/

7. 修改include/asm/mach-types.h中的MACH_TYPE_S3C2440的值为782,主要是为了与supervivi中
的设置一样,也可以修改supervivi为362。 注意此文件系编译后生成,刚开始没有。

8. 增加 DM9000网卡的驱动程序,步骤如下:
-------------A-------------
arch/arm/mach-s3c2440/mach-smdk2440.c文件中:

static struct platform_device *smdk2440_devices[] __initdata = {

  &s3c_device_wdt,

  &s3c_device_i2c,

  &s3c_device_iis,

添加

 &s3c_device_dm9000,

 &s3c_device_rtc, //增加rtc初始化
--------------- A END ---------------
---------------B ------------------

arch/arm/plat-s3c24xx/devs.c中,

 #include 

 #include 

后面添加


/* DM9000  registrations */

#include 

#define    DM9000_BASE 0x20000300

static struct resource s3c_dm9000_resource[] = {

[0] = {

.start = DM9000_BASE,

.end   = DM9000_BASE + 0x03,

.flags = IORESOURCE_MEM,

},

[1] = {

.start = DM9000_BASE + 0x04,

.end   = DM9000_BASE + 0x04 + 0x7c,

.flags = IORESOURCE_MEM,

},

    [2] = {

.start = IRQ_EINT7,

.end   = IRQ_EINT7,

.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,

}

};

static struct dm9000_plat_data s3c_device_dm9000_platdata = { 

   .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,

};

struct platform_device s3c_device_dm9000 = { 

   .name= "dm9000", 

   .id= 0, 

   .num_resources= ARRAY_SIZE(s3c_dm9000_resource), 

   .resource= s3c_dm9000_resource, 

   .dev= { 

   .platform_data = &s3c_device_dm9000_platdata, 

       } 

}; 

EXPORT_SYMBOL(s3c_device_dm9000);     
--------------- B END -----------------------

----------------------------C -------------------------

linux-2.6.29.4arch/arm/plat-s3c24xx/include/plat/include/devs.h

 extern struct s3c24xx_uart_resources s3c2410_uart_resources[];

后面添加:

extern struct platform_device s3c_device_dm9000;
--------------------------------------- C END ------------------------------

------------------------------- D ----------------------------------

修改drivers/net/dm9000.c

添加37

 #include 

 

 #include "dm9000.h" 后面添加:


#include 

#include    // important for s3c2410_gpio_cfgpin...

#include 

#include 

#include 

#include 

#include 

#define DM9000_IRQ    IRQ_EINT7

------------------ END D ---------------

------------------- E -----------------
dm9000_probe函数中
 
int i;

  u32 id_val;

后面添加:


unsigned int value;

//config the bwscon for bank 4

value = __raw_readl(S3C2410_BWSCON);

value &= ~(S3C2410_BWSCON_WS4|

   S3C2410_BWSCON_ST4|

   S3C2410_BWSCON_DW4_32);

value |= (S3C2410_BWSCON_ST4|

  S3C2410_BWSCON_DW4_16);

__raw_writel(value, S3C2410_BWSCON);

//config the bankcon4

value = 0;

value = (S3C2410_BANKCON_Tacs4|

 S3C2410_BANKCON_Tcos4|

 S3C2410_BANKCON_Tacc14|

 S3C2410_BANKCON_Tcoh4|

 S3C2410_BANKCON_Tcah4|

 S3C2410_BANKCON_Tacp6|

 S3C2410_BANKCON_PMCnorm);

__raw_writel(value,S3C2410_BANKCON4);

//config the irq pin (for mini2440)

set_irq_type(DM9000_IRQ,IRQ_TYPE_LEVEL_HIGH);

s3c2410_gpio_cfgpin(S3C2410_GPF7, S3C2410_GPF7_EINT7);

s3c2410_gpio_pullup(S3C2410_GPF7, 0);

-------------- E END-----------------------------
-------------------------- F ----------------------------------
dm9000.c文件中,dm9000_probe函数里,增加 设置MAC地址的代码
在db->mii.mdio_write = dm9000_phy_write后面,用下面代码代替原来else部分的代码
#if defined(CONFIG_ARCH_S3C2410)
        printk("Now use the default MAC address: 08:90:90:90:90:90\n");
        mac_src = "byd2440";
        ndev->dev_addr[0] = 0x08;
        ndev->dev_addr[1] = 0x90;
        ndev->dev_addr[2] = 0x90;
        ndev->dev_addr[3] = 0x90;
        ndev->dev_addr[4] = 0x90;
        ndev->dev_addr[5] = 0x90;
#else
        mac_src = "eeprom";

        /* try reading the node address from the attached EEPROM */
        for (i = 0; i < 6; i += 2)
                dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);

        if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
                mac_src = "platform data";
                memcpy(ndev->dev_addr, pdata->dev_addr, 6);
        }

        if (!is_valid_ether_addr(ndev->dev_addr)) {
                /* try reading from mac */

                mac_src = "chip";
                for (i = 0; i < 6; i++)
                        ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
        }

        if (!is_valid_ether_addr(ndev->dev_addr))
                dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
                         "set using ifconfig\n", ndev->name);
#endif
------------------------------ F END -------------------------
所有dm9000驱动添加完毕

9. 2.6.31增加了MINI2440开发板支持,如果选中这个开发板类型将出现CONFIG_EEPROM_AT24选项,导致编译不过,要去掉此选项

10. 2.6.31版的arch/arm/mach-s3c2410/include/mach/regs-gpio.h与以前版本有较大变化,很多常量未定义,需要自己定义。

11. USB设备口要在bootloader中打开,并做初步初始化,否则linux启动后无法识别usb网卡。

12. 在driver/usb/gadget/s3c2410_udc.c中的s3c2410_udc_enable的最后一句前加上打开USB设备口的代码,如不需要用USB设备,则无需此操作。代码为:
s3c2410_gpio_cfgpin(S3C2410_GPC5, S3C2410_GPC5_OUTP);
s3c2410_gpio_setpin(S3C2410_GPC5, 1);

13. 增加LCD显示驱动部分:
在文件arch/arm/mach-s3c2440/mach-smdk2440.c中,增加LCD相关结构体:
#define LCD_WIDTH 800
#define LCD_HEIGHT 480
#define LCD_PIXCLOCK 40000
#define LCD_RIGHT_MARGIN 67
#define LCD_LEFT_MARGIN 40
#define LCD_HSYNC_LEN 31

#define LCD_UPPER_MARGIN 25
#define LCD_LOWER_MARGIN 5
#define LCD_VSYNC_LEN 1

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_LCDCON1_TFT,

        .width          = LCD_WIDTH,
        .height         = LCD_HEIGHT,

        .pixclock       = LCD_PIXCLOCK,
        .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,
};
static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {
        .displays       = &mini2440_lcd_cfg,
        .num_displays   = 1,
        .default_display = 0,

        .gpccon =       0xaa955699,
        .gpccon_mask =  0xffc003cc,
        .gpcup =        0x0000ffff,
        .gpcup_mask =   0xffffffff,

        .gpdcon =       0xaa95aaa1,
        .gpdcon_mask =  0xffc0fff0,
        .gpdup =        0x0000faff,
        .gpdup_mask =   0xffffffff,


        .lpcsel         = 0xf82,
};
我的显示屏为800×480的,FriendlyARM开发板自带。

14. 增加触摸屏支持,从开发板自带的内核文中复制s3c2410_ts.c文件至driver/input/touchscreen下,由于触摸屏需要adc的支持,还需要复制mini2440_adc.c s3c244xx-adc.h至driver/char/目录下,并相应修改Makerfile和Kconfig文件

阅读(2397) | 评论(1) | 转发(2) |
给主人留下些什么吧!~~

mclovein2009-10-04 19:26:59

不错不错,我也遇到了这个问题,但是对dm9000不太了解,看了你的文章很受启发。