fl2440内核移植(五)——USB驱动移植

来源:互联网 发布:学java前要学什么 编辑:程序博客网 时间:2024/05/15 05:38

--------------------------------------------------------------------------------------------------------------------------------

   系统环境:Centos 6.5

   板子芯片:s3c2440

   内核版本:linux 3.0

      编译器:arm-linux-gcc 4.5.4

          作者:Lu Zengmeng <1540999272@qq.com>

--------------------------------------------------------------------------------------------------------------------------------


1、修改drivers/usb/serial/Kconfig

找到config USB_SERIAL_WWAN

将下一行的tristate删除,并添加以下两行

boolean

default y if USB_SERIAL_OPTION

2、修改drivers/usb/serial/option.c

添加以下代码

static int vendor = 0;

static int product = 0;

#define OPTION_VENDOR_RESERVED      0XFFFF

#define OPTION_RESERVED_DEVICE       0XFFFF

将static const struct usb_device_id option_ids[]

改为static struct usb_device_id option_ids[]

并在该结构体中添加下面一行

{ USB_DEVICE(OPTION_VENDOR_RESERVED, OPTION_RESERVED_DEVICE) },

找到static int __init option_init(void)

在该函数中int retval;的下一行添加以下几行

if ((vendor>0) && (product>0))
     {
          option_ids[0].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
          option_ids[0].idVendor = vendor;
          option_ids[0].idProduct = product;
          printk("Register option drvier for modem vendor=0x%04x product=0x%04x\n", vendor, product);
     }

找到MODULE_AUTHOR(DRIVER_AUTHOR);

在这行上面添加以下代码

module_param(vendor, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(vendor, "User specified vendor ID");
module_param(product, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(product, "User specified product ID");

3、修改arch/arm/mach-s3c2440/mach-smdk2440.c

添加头文件

#include <mach/regs-clock.h>

#include <linux/delay.h>

添加函数

int usb_s3c2440_init(void)
 {   
     /* Input Frequency is 12.0000MHz, and MDEV=0x38 PDIV=2 SDIV=2, so output frequency 48.00MHz */
     unsigned long upllvalue = (0x38<<12)|(0x02<<4)|(0x02);
     while (upllvalue != __raw_readl(S3C2410_UPLLCON))
     {   
         __raw_writel(upllvalue, S3C2410_UPLLCON);
         mdelay(1);
     }
     
     return 0;
 }

找到smdk2440_map_io(void)

在该函数中添加下面一行

usb_s3c2440_init();

4、修改drivers/usb/host/ohci-s3c2410.c

添加头文件

#include <mach/regs-clock.h>

找到struct s3c2410_hcd_info *info = dev->dev.platform_data;

在该行下面加入

unsigned long upllvalue = (0x38<<12)|(0x02<<4)|(0x02);
while (upllvalue != __raw_readl(S3C2410_UPLLCON))

      __raw_writel(upllvalue, S3C2410_UPLLCON); 
      mdelay(1); 
}
__raw_writel(upllvalue, S3C2410_UPLLCON);

5、配置menuconfig

Device Drivers  ---> 

Generic Driver Options  --->

                 (/sbin/hotplug) path to uevent helper                  

[*] Block devices  --->

                 <*>   Low Performance USB Block driver

SCSI device support  ---> 

                 <*> SCSI device support 

                 <*> SCSI generic support

                  [*] Probe all LUNs on each SCSI device


[*] USB support  --->
              {*}   Support for Host-side USB 
              [*]     USB device filesystem (DEPRECATED) 
              [*]     USB device class-devices (DEPRECATED)
             <*>     OHCI HCD support 
             <*>   USB Mass Storage support 

[*] HID Devices  ---> 
             -*-  Generic HID support
            <*>     USB Human Interface Device (full HID) support

SCSI device support  --->
           <*> SCSI device support
           [*] legacy /proc/scsi/ support
           <*> SCSI disk support 

File systems  --->
         DOS/FAT/NT Filesystems  --->
                     <*> MSDOS fs support
                    <*> VFAT (Windows-95) fs support
                    (437) Default codepage for FAT
                    (iso8859-1) Default iocharset for FAT
                    <*> NTFS file system support
                     [*]   NTFS write support
          Partition Types  --->
                     [*]   PC BIOS (MSDOS partition tables) support
                     [*]   Windows Logical Disk Manager (Dynamic Disk) support
          -*- Native language support  --->
                     <*>   Codepage 437 (United States, Canada)
                     <*>   Simplified Chinese charset (CP936, GB2312)
                     <*>   ASCII (United States)
                     <*>   NLS ISO 8859-1 (Latin 1; Western European Languages)
                     <*>   NLS UTF-8

0 0
原创粉丝点击