天天看點

基于s3c2410開發闆2.6.25核心的USB驅動的移植 (轉)

http://www.cppblog.com/040410615/archive/2008/05/16/50050.html

因為2.6.25核心源碼中并沒有USB驅動的初始化程式,是以我添加了相應的代碼:

在linux-2.6.25/arch/arm/mach-s3c2410/mach-smdk2410.c檔案中添加:

static struct s3c2410_hcd_info usb_s3c2410_info = {

       .port[0]        = {

               .flags  = S3C_HCDFLG_USED

       },

       .port[1]        = {

               .flags  = S3C_HCDFLG_USED

       }

};

int __init s3c2410_init_usb(void)

{

    unsigned long upllvalue;

    printk("USB Control, (c) 2006 pc104/n");

    s3c_device_usb.dev.platform_data = &usb_s3c2410_info;

    s3c2410_modify_misccr(S3C2410_MISCCR_USBSUSPND0 |

                  S3C2410_MISCCR_USBSUSPND1, 0x8);

    upllvalue = (0x78<<12)|(0x02<<4)|(0x03);

    while(upllvalue!=__raw_readl(S3C2410_UPLLCON))

    {

        __raw_writel(upllvalue,S3C2410_UPLLCON);

        mdelay(1);

    }

    return 0;

}

在此函數中添加了紅色部分:

static void __init smdk2410_init(void)

{

        platform_add_devices(smdk2410_devices, ARRAY_SIZE(smdk2410_devices));

        smdk_machine_init();

       s3c2410_init_usb();

}

其對上面代碼的解釋看下此帖:

http://www.linuxforum.net/forum/showflat.phpCat=&Board=embedded&Number=556915&page=0&view=collapsed&sb=5&o=0&fpart=

拷貝linux-2.6.25/arch/arm/configs/s3c2410_defconfig 預設配置檔案  并命名.config

make  menuconfig  再進行配置

1.裝置驅動部分設定

          General setup  --->  

     [*]Configure standard kernel features (for small systems)  --->

         [*] Support for hot-pluggable devices

              Device Drivers  ---> 

              Generic Driver Options  --->          

<*> Hotplug firmware loading support    

               Block devices  --->    

<*> Low Performance USB Block driver   

           SCSI device support  --->   

      <*>   SCSI generic support  

      <*>   SCSI disk  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

這裡我選擇了SCSI裝置。

2 檔案系統部分設定

           File systems  --->      

         DOS/FAT/NT Filesystems  --->   

                 <*> MSDOS fs support                               

                 <*> VFAT (Windows-95) fs support                  

                 (936) Default codepage for FAT                      

                (cp936) Default iocharset for FAT                   

   File systems  --->

     Partition Types  ---> 

        [*]   PC BIOS (MSDOS partition tables) support

 3 加入一些字型庫

  Native Language Support  --->   

    <*>   Simplified Chinese charset (CP936, GB2312) 

    <*>   NLS UTF8

但我将核心鏡像燒入闆中後,插入U盤  mount  挂載時出現如下錯誤:

Unable to load NLS charset cp437

FAT: codepage cp437 not found

mount: mounting sda1 on /mnt failed: Invalid argument

是以我又重新增加了配置選項在 Native Language Support  --->    中

File systems  --->   

Native Language Support  --->   

  <*>   Codepage 437 (United States, Canada) 

<*>   Simplified Chinese charset (CP936, GB2312) 

然後再編譯

make  zImage

燒入鏡像後插入U盤顯示如下資訊

sd 1:0:0:0: [sda] 129312 512-byte hardware sectors (66 MB)

sd 1:0:0:0: [sda] Write Protect is off

sd 1:0:0:0: [sda] Assuming drive cache: write through

sd 1:0:0:0: [sda] 129312 512-byte hardware sectors (66 MB)

sd 1:0:0:0: [sda] Write Protect is off

sd 1:0:0:0: [sda] Assuming drive cache: write through

sda: sda1

sda: p1 exceeds device capacity

sd 1:0:0:0: [sda] Attached SCSI removable disk

然後mount  -t vfat /dev/sda1  /mnt

其中裝置檔案名是我在安裝檔案系統時生成的

在/dev/中

mknod  sda1  b 8 0

加載成功