移植linux2.6.32.2到mini2440

转自 http://blog.sina.com.cn/s/blog_4ed5ebd00100jvmz.html

1.源码准备:
    linux-2.6.32.2.tar.bz2
    yaffs2补丁:
     
2.不使用自带的mach-mini2440.c,重新创建arch/arm/mach-s3c2440/mach-mini2440.c(源自友善)
#include <linux/kernel.h>
#include <linux/types.h>
#include<linux/interrupt.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/init.h>
#include<linux/serial_core.h>
#include<linux/platform_device.h>
#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/sysdev.h>
#include <linux/mtd/mtd.h>
#include<linux/mtd/nand.h>
#include<linux/mtd/nand_ecc.h>
#include<linux/mtd/partitions.h>
#include <linux/dm9000.h>
#include<linux/mmc/host.h>

#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>
#include <asm/irq.h>
#include<asm/mach-types.h>

#include <mach/hardware.h>
#include<mach/regs-gpio.h>
#include <mach/regs-lcd.h>
#include<mach/leds-gpio.h>
#include <mach/idle.h>
#include <mach/fb.h>

#include<plat/regs-serial.h>
#include <plat/iic.h>
#include <plat/s3c2410.h>
#include <plat/s3c2440.h>
#include <plat/clock.h>
#include <plat/devs.h>
#include <plat/cpu.h>
#include <plat/nand.h>
#include <plat/pm.h>
#include <plat/mci.h>

#include<sound/s3c24xx_uda134x.h>

static struct map_desc mini2440_iodesc[] __initdata = {
};

static struct s3c2410_uartcfg mini2440_uartcfgs[] __initdata ={
[0] = {
.hwport     = 0,
.flags     = 0,
.ucon       = 0x3c5,
.ulcon     = 0x03,
.ufcon     = 0x51,
},
[1] = {
.hwport     = 1,
.flags     = 0,
.ucon       = 0x3c5,
.ulcon     = 0x03,
.ufcon     = 0x51,
},
[2] = {
.hwport     = 2,
.flags     = 0,
.ucon       = 0x3c5,
.ulcon     = 0x03,
.ufcon     = 0x51,
}
};

#define LCD_WIDTH 240
#define LCD_HEIGHT 320
#define LCD_PIXCLOCK 170000

#define LCD_RIGHT_MARGIN 25
#define LCD_LEFT_MARGIN 0
#define LCD_HSYNC_LEN 4

#define LCD_UPPER_MARGIN 1
#define LCD_LOWER_MARGIN 4
#define LCD_VSYNC_LEN 1

static struct s3c2410fb_display mini2440_lcd_cfg __initdata ={
.lcdcon5 = S3C2410_LCDCON5_FRM565 |
  S3C2410_LCDCON5_INVVLINE |
  S3C2410_LCDCON5_INVVFRAME |
  S3C2410_LCDCON5_PWREN |
  S3C2410_LCDCON5_HWSWP,

.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,
};

static struct s3c24xx_uda134x_platform_datas3c24xx_uda134x_data = {
.l3_clk = S3C2410_GPB(4),     //IO表示方法,定义在mach/regs-gpio.h->mach/gpio-nrs.h中
.l3_data = S3C2410_GPB(3),
.l3_mode = S3C2410_GPB(2),
.model = UDA134X_UDA1341,
};

static struct platform_device s3c24xx_uda134x = {
.name = "s3c24xx_uda134x",
.dev = {
.platform_data     =&s3c24xx_uda134x_data,
}
};

static struct mtd_partition friendly_arm_default_nand_part[] ={
[0] = {
.name = "supervivi",
.size = 0x00040000,
.offset = 0,
},
[1] = {
.name = "param",
.offset = 0x00040000,
.size = 0x00020000,
},
[2] = {
.name = "Kernel",
.offset = 0x00060000,
.size = 0x00500000,
},
[3] = {
.name = "root",
.offset = 0x00560000,
.size = 1024 * 1024 * 1024, //为以后拓展用
},
[4] = {
.name = "nand",
.offset = 0x00000000,
.size = 1024 * 1024 * 1024, //
}
};

static struct s3c2410_nand_set friendly_arm_nand_sets[] ={
[0] = {
.name = "NAND",
.nr_chips = 1,
.nr_partitions =ARRAY_SIZE(friendly_arm_default_nand_part),
.partitions = friendly_arm_default_nand_part,
},
};


static struct s3c2410_platform_nand friendly_arm_nand_info ={
.tacls = 20, // 建立时间 
.twrph0 = 60, // 等待时间
.twrph1 = 20, // 保持时间
.nr_sets = ARRAY_SIZE(friendly_arm_nand_sets),
.sets = friendly_arm_nand_sets,
.ignore_unset_ecc = 1,
};

#define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300)

static struct resource mini2440_dm9k_resource[] = {
          [0] = {
                  .start =MACH_MINI2440_DM9K_BASE,
                  .end  = MACH_MINI2440_DM9K_BASE + 3,
                  .flags =IORESOURCE_MEM
          },
          [1] = {
                  .start =MACH_MINI2440_DM9K_BASE + 4,
                  .end  = MACH_MINI2440_DM9K_BASE + 7,
                  .flags =IORESOURCE_MEM
          },
          [2] = {
                  .start =IRQ_EINT7,
                  .end  = IRQ_EINT7,
                  .flags =IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
          }
};

static struct dm9000_plat_data mini2440_dm9k_pdata = {
          .flags           = (DM9000_PLATF_16BITONLY |DM9000_PLATF_NO_EEPROM),
};

static struct platform_device mini2440_device_eth = {
          .name           = "dm9000",
          .id             = -1,
          .num_resources  = ARRAY_SIZE(mini2440_dm9k_resource),
          .resource       =mini2440_dm9k_resource,
          .dev             = {
                  .platform_data   =&mini2440_dm9k_pdata,
          },
};


static struct s3c24xx_mci_pdata mini2440_mmc_cfg = {
    .gpio_detect  = S3C2410_GPG(8),
    .gpio_wprotect =S3C2410_GPH(8),
    .set_power    = NULL,
    .ocr_avail    =MMC_VDD_32_33|MMC_VDD_33_34,
};



static struct platform_device *mini2440_devices[] __initdata ={
&s3c_device_usb,
&s3c_device_rtc,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&mini2440_device_eth,
&s3c24xx_uda134x,
&s3c_device_nand,
&s3c_device_sdi,
&s3c_device_usbgadget,
};

static void __init mini2440_map_io(void)
{
s3c24xx_init_io(mini2440_iodesc,ARRAY_SIZE(mini2440_iodesc));
s3c24xx_init_clocks(12000000);   //外部时钟频率为12000000
s3c24xx_init_uarts(mini2440_uartcfgs,ARRAY_SIZE(mini2440_uartcfgs));
}

static void __init mini2440_machine_init(void)
{
s3c24xx_fb_set_platdata(&mini2440_fb_info); //lcd platform device add

s3c_i2c0_set_platdata(NULL); // i2c

s3c2410_gpio_cfgpin(S3C2410_GPC(0), S3C2410_GPC0_LEND); // lcd背光

s3c_device_nand.dev.platform_data =&friendly_arm_nand_info; //nand
s3c_device_sdi.dev.platform_data =&mini2440_mmc_cfg; //SD card
platform_add_devices(mini2440_devices,ARRAY_SIZE(mini2440_devices));
s3c_pm_init();
}

MACHINE_START(MINI2440, "FriendlyARM Mini2440 developmentboard")
.phys_io = S3C2410_PA_UART,
.io_pg_offst = (((u32)S3C24XX_VA_UART)>> 18) &0xfffc,
.boot_params = S3C2410_SDRAM_PA + 0x100,

.init_irq = s3c24xx_init_irq,
.map_io = mini2440_map_io,
.init_machine = mini2440_machine_init,
.timer = &s3c24xx_timer,
MACHINE_END

3.修改arch/arm/mach-s3c2440/Kconfig,在最后加上
config MACH_MINI2440
bool "FriendlyARM Mini2440 development board"
select CPU_S3C2440
select S3C2440_XTAL_12000000
select S3C_DEV_USB_HOST
select S3C_DEV_NAND
help
  Say Y here if you are using the FriendlyARMMini2440/QQ2440 development board.

4.网卡:
    修改drivers/net/dm9000.c
    1)在文件头文件处加入:
      #ifdefined(CONFIG_ARCH_S3C2410)
      #include<mach/regs-mem.h>
      #endif
      mini2440的内核配置是要选中SystemType->CONFIG_ARCH_S3C2410,因为2440cpu的寄存器一般都是从2410继承来的.
      mach/regs-mem.h中包含了2440的存储器控制器和其相应位掩码的定义.
    2)修改DM9000的mac地址
      在dm9000_probe函数里,系统分别尝试从e2prom,platformdata,chip中获取mac地址.
      在这里我都不采用,而是用软件定义了一个:
        memcpy(ndev->dev_addr,"\x08\x90\x90\x90\x90\x90", 6);
      该函数等价于:
        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;
      即mac为08:90:90:90:90:90
      并将mac源:mac_src重新赋值为"soft define".
    3)在dm9000_init函数中重新初始化bank4的存储器控制寄存器
    #ifdefined(CONFIG_ARCH_S3C2410)
      unsigned int oldval_bwscon = *(volatile unsignedint *)S3C2410_BWSCON;
    *((volatile unsigned int*)S3C2410_BWSCON) = (oldval_bwscon &~(0xF<<16)) | S3C2410_BWSCON_DW4_16 |S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;
    *((volatile unsigned int*)S3C2410_BANKCON4) = 0x1f7c;
    #endif
    bank4数据总线宽度16bit,wait使能,usingUB/LB
   
5.补充下去掉10分钟关闭LCD的方法
    按seigpao大侠的做法,注释掉drivers\char\vt.c的blank_screen_t(unsignedlong dummy)的函数内容,否则,lcd会在10分钟左右关掉显示.

6.内核增加yaffs2支持
    到网上下载ysffs2源代码,解压之后进行如下修改:
    进入yaffs2所在的目录执行./patch-ker.sh c/opt/linux-2.6.32.2
    上面命令完成下面三件事情
    (1)修改内核fs/Kconfig
      增加一行:source "fs/yaffs2/Kconfig"
    (2)修改内核fs/Kconfig
      增加一行:ojb-$(CONFIG_YAFFS_FS) +=yaffs2/
    (3)在内核fs/目录下创建yaffs2目录
      将yaffs2源码目录下面的Makefile.kernel文件复制为内核fs/yaffs2/Makefie;
      将yaffs2 源码目录的Kconfig文件复制到内核fs/yaffs2目录下;
      将yaffs2源码目录下的*.c *.h文件复制到内核fs/yaffs2目录下.
    在内核根目录下执行:
      #makemenuconfig 配置yaffs2文件支持
      Filesystems   --->
        Miscellaneous filesystems--->
          <*>YAFFS2 filesystem support
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值