针对up-tech 2410LCD和触摸屏、USB,NE2000移植!

来源:互联网 发布:以太坊挖矿软件 编辑:程序博客网 时间:2024/04/30 20:11
一、移植LCD驱动程序
                              

 通过上面的工作,在串口中已经看到了linux2.6.14的启动信息,但是在LCD上没有任何显示,这是因为我们还没有对LCD进行初始化,linux2.6.14已经包含了lcd的驱动程序,驱动程于 /linux2.6.14/drivers/video/目录下,文件名是s3c2410fb.c,头文件是s3c2410fb.h.。我们在这里可以不研究这个文件。只要我们对lcd进行以下初始化就可以了。我们打开/linux-2.6.14/arch/arm/mach-s3c2410/mach-smdk2410.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 <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>
/********************gggggggggggggggggggggg*****/
#include <asm-arm/setup.h>
#include <linux/initrd.h>
#include <linux/kdev_t.h>
#include <linux/major.h>
#include <asm-arm/arch-s3c2410/fb.h>
#include <asm-arm/arch-s3c2410/s3c2410_ts.h>//s3c2410_ts.h这个触摸屏文件可以从http://www.hhcn.com/cgi-bin/forums.cgi?forum=3&topic=153中获得。另外从中也要获得s3c2410_ts.c文件。将这个文件放到/linux-2.6.14/drivers/input/touchscreen/里面。并且修改s3c2410_ts.c,将s3c2410_ts.h头文件包含进来!如:#include<asm-arm/arch-s3c2410/s3c2410_ts.h>
//#include <asm-arm/mach/map.h>
#include <asm-arm/arch-s3c2410/gggggg.h>gggggg.h文件内容在日志最下方

/**********************************************/
#include "devs.h"
#include "cpu.h"

然后增加LCD初始化的代码, 

 

static struct s3c2410fb_mach_info gggggg_lcdcfg
__initdata = {
               .fixed_syncs=       0,
               .regs={
                      .lcdcon1=
S3C2410_LCDCON1_TFT16BPP | /
                                                S3C2410_LCDCON1_TFT | /
                                                S3C2410_LCDCON1_CLKVAL(6),
                       
                     .lcdcon2=  
S3C2410_LCDCON2_VBPD(2) | /
                                                S3C2410_LCDCON2_LINEVAL(319) | /
                                                S3C2410_LCDCON2_VFPD(0) | /
                                                S3C2410_LCDCON2_VSPW(4),
                       
                      .lcdcon3=  
S3C2410_LCDCON3_HBPD(47) | /
                                                S3C2410_LCDCON3_HOZVAL(239) | /
                                                S3C2410_LCDCON3_HFPD(15),
                       
                       .lcdcon4=  

 

S3C2410_LCDCON4_MVAL(1) | /
                                                S3C2410_LCDCON4_HSPW(31),
                       
                        .lcdcon5=  
S3C2410_LCDCON5_FRM565 | /
                                                S3C2410_LCDCON5_INVVLINE | /
                                                S3C2410_LCDCON5_HWSWP,
                        },
                .lpcsel=    0x0,
                .gpccon=    0xaaaaaaaa,
                .gpccon_mask=   0xffffffff,
                .gpcup=     0xffffffff,
                .gpcup_mask=    0xffffffff,
                .gpdcon=    0xaaaaaaaa,
                .gpdcon_mask=   0x0,
 
 .gpdup=     0xffffffff,
                .gpdup_mask=    0xffffffff,
                .width=     240,
                .height=    320,
                .xres=      {240,240,240},
                .yres=      {320,320,320},
                .bpp=       {16,16,16},
                            };
   static void __init sdmk2410_init(void)
{
                                set_s3c2410fb_info(&hfrk_lcdcfg);
}
 
在系统初始化中增加对lcd的初始化。
 MACHINE_START(SMDK2410, "SMDK2410")
/* @TODO:request a new identifier and switch
* to SMDK2410 */
/* Maintainer: Jonas Dietsche */
……
  .map_io     = smdk2410_map_io,
  .init_irq   = smdk2410_init_irq,
  .init_machine   = sdmk2410_init, /*这一句是新增加的*/
  .timer      = &s3c24xx_timer,
  MACHINE_END
 
现在我们重新保存这个文件,现在需要重新进入配置菜单,检查一下LCD的相关选项是否选上,[Device
                        Drivers->Graphics
                        support->]这个配置菜单下面是相关LCD的配置。回到根目录下,输入make编译内核,重现烧写内核到开发板,再次启动 linxu2.6.14以后就可以在lcd上看到一个小的企鹅。我们的lcd驱动已经移植完成了。
 
移植触摸屏驱动
在linux2.6.14中没有提供s3c2410的驱动,所以我们需要驱动文件。
两个文件:
在附件里!
   首先:我们需要修改linux2.6.14/drivers/input/touchscreen目录下的makefile文件,在文件的最后添加:
obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o
第二:我们需要修改linux2.6.14/drivers/input/touchscreen/Kconfig中添加:
     config TOUCHSCREEN_S
     tristate "Samsung S3C2410 touchscreen input driver"
     depends on ARCH_SMDK2410 && INPUT && INPUT_TOUCHSCREEN
     select SERIO
     help
     Say Y here if you have the s3c2410 touchscreen.
 
 If unsure, say N.
     To compile this driver as a module, choose M here: the
     module will be called s3c2410_ts.
    
config TOUCHSCREEN_S3C2410_DEBUG
     boolean "Samsung S3C2410 touchscreen debug messages"
     depends on TOUCHSCREEN_S3C2410
     help
     Select this if you want debug messages
 
修改完成以后,在我们配置内核的时候,就会增加关系s3c2410的触摸屏配置,我们选择上这些配置就可以把驱动增加进去了
Device drivers
       Input device support
           Touchscreens
               <*>Samsung S3C2410 touchscreen input driver
               []Samsung s3c2410 touchscreen debug message
第三:在/linux-2.6.14/arch/arm/mach-s3c2410/mach-smdk2410.c,中增加如下内容:
     static struct s3c2410_ts_mach_info sbc2410_ts_cfg __initdata = {
     .delay = 10000,
     .divsc = 49,
     .oversampling_shift = 2,
     };
     在smdk2410_devices结构中,添加:
     &s3c_device_ts,
     在smdk2410_map_io函数中添加:
 
 set_s3c2410ts_info(&sbc2410_ts_cfg);
第四:在/linux-2.6.14/arch/arm/mach-s3c2410/devs.h文件中添加:
     extern struct platform_device s3c_device_ts;
第五:在arch/arm/mach-s3c2410/devs.c文件中添加如下几行:
    /* Touchscreen */
    static struct s3c2410_ts_mach_info s3c2410ts_info;
    void __init set_s3c2410ts_info(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
{
memcpy(&s3c2410ts_info,hard_s3c2410ts_info,sizeof(struct s3c2410_ts_mach_info));
}
EXPORT_SYMBOL(set_s3c2410ts_info);
struct platform_device s3c_device_ts = {
.name = "s3c2410-ts",
 
.id = -1,
.dev = {
.platform_data = &s3c2410ts_info,
}
};
EXPORT_SYMBOL(s3c_device_ts);
 
另外mach-smdk2410.c里面也要包括s3c2410_ts.h这个头文件!
经过这些修改,我们的触摸屏驱动已经完成,我们编译就可以了。我们的这个触摸屏驱动在内核注册为/dev/input/mouse0
 
Ne2000兼容的网卡移植
1.首先修改arch/arm文件夹下的Kconfig文件的ISA项如下:
config ISA
       bool "gggggg ISA support"
        default y
        help
          Find out whether you have ISA slots on your motherboard.  ISA is thename of a bus system, i.e. the way the CPU talks to the other stuffinside your box.  Other bus systems are PCI, EISA, MicroChannel (MCA)or VESA.  ISA is an older system, now being displaced by PCI; newerboards don't support it.  If you have ISA, say Y, otherwise N.
 只有这样在内核配置菜单
 Network device support->
      Ethernet(10or100Mbit)->
 下才会出现other ISA cards选项。你才可以选上NE2000/NE1000 support。要不然找不到可不要怪我。      
  linux内核中NE2000设备驱动程序是drivers/net/ne.c和8390.c两个文件。你可以参考我的文件贴图修改。其中ne_defethaddr定义了网卡的MAC地址。需要修改的主要有你的网卡地址,就是你接在哪个个bank上了,你使用的外部中断是哪一个。然后就是设置中断方式,等等。你自己看吧。我实在记不清了(
悔恨当初没记下来呀)。
总结一下:

移植过程中需要注意的几个问题:

 1、确定网卡的基地址、中断无误
 2、注意网卡的数据总线宽度,地址是否连续,如果不连续,如何映射
 3、注意网卡的中断的模式和处理对应的外部中断是不是一致
 4、对于IO和RAM统一编址的处理器,注意缓冲区范围的设置
 5、注意ARMv3和ARMv4等一些和处理器结构相关的底层函数库带来的问题
 6、用抓包软件(sniffer)可以帮助分析定位问题所在
 
 
 
s3c2410开发办linux2.6内核下的usb host驱动移植
在linux2.6.14 里面已经包含了 s3c2410 的 usb 驱动,我们只要对 usb 进行必要的初始化就可以使用了,打开/linux-2.6.14/arch/arm/mach-s3c2410/mach-smdk2410.c, 在这个文件里增加包含文件:
       #include <arm/arch/regs-clock.h>
       增加 usb 的初始化,如下:
static struct s3c2410_hcd_info usb_hfrk_info = {
       .port[0]   = {
              .flags      = S3C_HCDFLG_USED
       },
       .port[1]   = {
              .flags      = S3C_HCDFLG_USED
       },
};
int usb_hfrk_init(void)
{
       unsigned long upllvalue = (0x78<<12)|(0x02<<4)|(0x03);
       printk("USB Control, (c) 2006 hfrk/n");
       s3c_device_usb.dev.platform_data = &usb_hfrk_info;
       __raw_writel(upllvalue,S3C2410_UPLLCON);
       return 0;
}
在 smdk2410_map_io 调用 usb 的初始化,如下所示:
       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));
              s3c24xx_set_board(&smdk2410_board);    
              usb_hfrk_init();
       }
       这样我们对 usb 的初始化就完成了,重新编译, usb 接口就可以使用了。
 
gggggg.h文件如下:
#include <asm-arm/arch-s3c2410/map.h>
#define IRQ_RTL8019              IRQ_EINT4
#define EXTINT_OFF (IRQ_EINT4 - 4)
/* RTL8019a, nGCS3 */
#define pRTL8019_BASE         S3C2410_PA_ISA_NET
#define vRTL8019_BASE       S3C2410_VA_ISA_NET




本文地址:http://read.newbooks.com.cn/info/159330.html

原创粉丝点击