Chinaunix首页 | 论坛 | 博客
  • 博客访问: 188587
  • 博文数量: 20
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 405
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-19 13:00
文章分类
文章存档

2011年(1)

2009年(18)

2008年(1)

我的朋友

分类: LINUX

2009-03-24 18:55:15


一、代码修改
修改在arch/arm/mach-s3c2410目录下的mach-smdk2410.c,添加如下内容
 

/**********************add by nick******************************
*******/

static struct s3c2410_hcd_info usb_ljd2410_info = {
.port[0] = {
.flags = S3C_HCDFLG_USED
}
};
int usb_ljd2410_init(void)
{
unsigned long upllvalue = (0x78<<12)|(0x02<<4)|(0x03);
printk("USB Control, (c) 2006 sbc2410\n");
s3c_device_usb.dev.platform_data = &usb_ljd2410_info;
while(upllvalue!=__raw_readl(S3C2410_UPLLCON))
{
__raw_writel(upllvalue,S3C2410_UPLLCON);
mdelay(1);
}
return 0;
}
/***************************end add**********************/
同时将usb_ljd2410_init()函数添加到smdk2410_map_io函数里面进行初始化,如下所示:
static void __init smdk2410_map_io(void)
{
 s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
 s3c24xx_init_clocks(0);
 s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
 usb_ljd2410_init();
 
}
//注意,不能忘了添加头文件

#include <asm/arch/regs-clock.h>
#include <asm/arch/usb-control.h>
#include <linux/device.h>
#include <linux/delay.h>
修改后的整个文件如下:
#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 "asm-arm/arch-s3c2410/regs-cs8900.h"
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>
#include <asm/hardware.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/mach-types.h>
#include <asm/arch/regs-serial.h>
#include <asm/arch/fb.h>
#include <asm/plat-s3c24xx/devs.h>
#include <asm/plat-s3c24xx/cpu.h>
#include <asm/plat-s3c24xx/common-smdk.h>
#include <asm/arch/regs-clock.h>
#include <asm/arch/usb-control.h>
#include <linux/device.h>
#include <linux/delay.h>
static struct map_desc smdk2410_iodesc[] __initdata = {
  /* nothing here yet */
 {vSMDK2410_ETH_IO,pSMDK2410_ETH_IO,SZ_1M,MT_DEVICE}
};
#define UCON S3C2410_UCON_DEFAULT
#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
static struct s3c2410_uartcfg smdk2410_uartcfgs[] __initdata = {
 [0] = {
  .hwport = 0,
  .flags = 0,
  .ucon = UCON,
  .ulcon = ULCON,
  .ufcon = UFCON,
 },
 [1] = {
  .hwport = 1,
  .flags = 0,
  .ucon = UCON,
  .ulcon = ULCON,
  .ufcon = UFCON,
 },
 [2] = {
  .hwport = 2,
  .flags = 0,
  .ucon = UCON,
  .ulcon = ULCON,
  .ufcon = UFCON,
 }
};
//nick LCD Driver 2009.3.22

/* LCD driver info */
/* Configuration for 800*480 */
static struct s3c2410fb_mach_info ljd2410_tft_cfg __initdata = {
    .type = S3C2410_LCDCON1_TFT,
    .regs = {
        .lcdcon1 = S3C2410_LCDCON1_TFT16BPP |
                  S3C2410_LCDCON1_TFT |
                  S3C2410_LCDCON1_CLKVAL(0x01),
        .lcdcon2 = S3C2410_LCDCON2_VBPD(39) |
                  S3C2410_LCDCON2_LINEVAL(479) | /*480*/
                  S3C2410_LCDCON2_VFPD(19) |
                  S3C2410_LCDCON2_VSPW(3),
        .lcdcon3 = S3C2410_LCDCON3_HBPD(49) |
                  S3C2410_LCDCON3_HOZVAL(799) | /* 800 */
                  S3C2410_LCDCON3_HFPD(19),
        .lcdcon4 = S3C2410_LCDCON4_MVAL(13) |
                  S3C2410_LCDCON4_HSPW(99),
        .lcdcon5 = S3C2410_LCDCON5_FRM565 |
                  S3C2410_LCDCON5_INVVLINE |
                  S3C2410_LCDCON5_INVVFRAME |
                  S3C2410_LCDCON5_PWREN |
                  S3C2410_LCDCON5_HWSWP,
    },
    .lpcsel = 0x00,
  
    .gpccon= 0xaaaaaaaa,
    .gpccon_mask= 0xffffffff,
    .gpcup= 0xffffffff,
    .gpcup_mask= 0xffffffff,
    .gpdcon= 0xaaaaaaaa,
    .gpdcon_mask= 0xffffffff,
    .gpdup= 0xffffffff,
    .gpdup_mask= 0xffffffff,

    .width =800,
    .height = 480,
    .xres = {
        .min = 800,
        .max = 800,
        .defval = 800,
    },
    .yres = {
        .min = 480,
        .max = 480,
        .defval = 480,
    },
    .bpp = {
        .min = 16,
        .max = 16,
        .defval = 16,
    },
};
//nick LCD

/**********************add by nick******************************
*******/

static struct s3c2410_hcd_info usb_ljd2410_info = {
.port[0] = {
.flags = S3C_HCDFLG_USED
}
};
int usb_ljd2410_init(void)
{
unsigned long upllvalue = (0x78<<12)|(0x02<<4)|(0x03);
printk("USB Control, (c) 2006 sbc2410\n");
s3c_device_usb.dev.platform_data = &usb_ljd2410_info;
while(upllvalue!=__raw_readl(S3C2410_UPLLCON))
{
__raw_writel(upllvalue,S3C2410_UPLLCON);
mdelay(1);
}
return 0;
}
/***************************end add**********************/

static struct platform_device *smdk2410_devices[] __initdata = {
 &s3c_device_usb,
 &s3c_device_lcd,
 &s3c_device_wdt,
 &s3c_device_i2c,
 &s3c_device_iis,
};
static void __init smdk2410_map_io(void)
{
 s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
 s3c24xx_init_clocks(0);
 s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
 usb_ljd2410_init();
 
}
static void __init smdk2410_init(void)
{
        s3c24xx_fb_set_platdata(&ljd2410_tft_cfg);
 platform_add_devices(smdk2410_devices, ARRAY_SIZE(smdk2410_devices));
 smdk_machine_init();
}
MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switch
        * to SMDK2410 */

 /* Maintainer: Jonas Dietsche */
 .phys_io = S3C2410_PA_UART,
 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
 .boot_params = S3C2410_SDRAM_PA + 0x100,
 .map_io = smdk2410_map_io,
 .init_irq = s3c24xx_init_irq,
 .init_machine = smdk2410_init,
 .timer = &s3c24xx_timer,
MACHINE_END

下面这个连接有大虾们对USB驱动移植的讨论 = 要修改的代码已经修改完了,感觉和LCD驱动程序的移植差不多。
二、配置内核
1、让内核支持热插拔
               General setup  --->  
[*] Support for hot-pluggable devices
2、USB驱动设置,可能有些不选也行,不过没时间去试,至于为什么要选这些选项的话可以看一下这个贴(Linux下的硬件驱动——USB设备):
http://www-128.ibm.com/developerworks/cn/linux/l-usb/index1.html
          Device Drivers  --->
             Generic Driver Options  --->          
               <*> Hotplug firmware loading support    
             Block devices  --->  
             <*> Low Performance USB Block driver  
             SCSI device support  --->  
               <*>   SCSI generic support  
               [*]   Probe all LUNs on each SCSI device    
USB support  --->        
<*> Support for Host-side USB    
[*]   USB device filesystem
<*>   OHCI HCD support  
<*>   USB Mass Storage support
[*]   USB Monitor
3、加入了MSDOS fs和VFAT fs的支持。
                File systems  --->      
        DOS/FAT/NT Filesystems  --->  

                    <*> MSDOS fs support                          
                    <*> VFAT (Windows-95) fs support             
                   (936) Default codepage for FAT                 
                   (cp936) Default iocharset for FAT              
                    < > NTFS file system support
4. 加入对中文的支持,就可以显示出中文了
       Native Language Support  --->    
           <*>   Simplified Chinese charset (CP936, GB2312)  
           <*>   NLS UTF8

配置完成后开始编译内核,下载最新的内核到开发板,启动开发板,

插入u盘后,内核可以识别到u盘,以下是我的内核插入u盘后的提示信息:

[root@ /]#usb 1-1: USB disconnect, address 2
usb 1-1: new full speed USB device using s3c2410-ohci and address 3
usb 1-1: configuration #1 chosen from 1 choice
 uba: uba1
表示usb设备已经挂载到/dev/uba1目录下
在开发板上执行挂载命令
[root@ /]mount -t vfat -o iocharset=cp936 /dev/uba1 /mnt/usb
[root@ /mnt/nfs]#ls -l
drwxr-xr-x    3 root     root         4096 Jan 10  2009 1.files
-rwxr-xr-x    1 root     root        38762 Jan 10  2009 1.html
drwxr-xr-x    2 root     root         4096 Jan  9  2009 NiosII范例
-rwxr-xr-x    1 root     root       657408 Mar 11  2009 Screen.ddb
-rwxr-xr-x    1 root     root       200136 May 21  2008 Timer.pdf
-rwxr-xr-x    1 root     root         4629 Jan 10  2009 Timer.txt
-rwxr-xr-x    1 root     root        24946 Jan  9  2009 bootex.log
drwxr-xr-x    9 root     root         4096 Jan 10  2003 clock
drwxr-xr-x    2 root     root         8192 Jan  9  2009 found.000
drwxr-xr-x    9 root     root         4096 Dec 29  2002 quartus60
-rwxr-xr-x    1 root     root      3675011 Apr  3  2008 按键中断.rar
drwxr-xr-x    3 root     root         4096 Dec 29  2008 电子时钟
drwxr-xr-x    2 root     root         4096 Dec 29  2008 王力宏.-.[心·跳].专辑
drwxr-xr-x    4 root     root         4096 Jan 10  2003 新建文件夹
 
现在可以在/mnt/usb目录下看到U盘里面的文件了,哈哈~~~~

本次移植同样能驱动USB鼠标,插入USB鼠标后显示如下:
[root@ /]#usb 1-1: new low speed USB device using s3c2410-ohci and address 3
usb 1-1: configuration #1 chosen from 1 choice
input: A4Tech USB Optical Mouse as /class/input/input1
input: USB HID v1.10 Mouse [A4Tech USB Optical Mouse] on usb-s3c24xx-1
执行[root@ /]#cat /dev/mouse0
   移动鼠标会出现乱码,证明USB鼠标成功驱动。在移植了MiniGUI后,可以控制鼠标的移动。
   忙活了几个小时,总算有收获,我对usb设备并不很了解,主要还是参考网上的帖子
http://www.cnitblog.com/luofuchong/archive/2007/01/24/22265.html
   整个移植的过程出现过很多问题,在网络的帮助下都得到解决,为了总结,现在把整个过程记录下来··
阅读(2466) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~