Tuesday, November 30, 2010

Linux driver porting kernel2.6.25 CS8900 network adapter

In General, we compile the kernel, the device driver selection in two ways: directly compiled into the kernel, the other is to module hooks.

CS8900 network adapter driver if a module hooks, function init_module is the importers; if you are directly compiled into the kernel, then the function is the importers cs89x0_probe. In this entry function, will complete the network card driver's initialization. If a registered virtual address, device number, interrupt, and various related register initialization. Cs89x0_probe function will call the initialization function cs89x0_probe1 real. Following that the initialization function, you need to complete several important areas: 1, registered virtual address. Registration through the request_region function virtual address. In the inside, our kenel operations register addresses are actually virtual addresses, but each register has a unique virtual addresses and their corresponding physical address because the kernel inside any virtual address flowing through the MMU into physical addresses. So in the kernel, are defined to be used to register, you must use a function ioremap will we have to use the register to the physical address is converted into the kernel, you can manipulate virtual address to be used for specific action, otherwise everything is in vain. Ioaddr = (int) ioremap (BASE_ADDR, 16); net_device structure 2, fill the form. The structure members are and network equipment-related variables. The more important of the two: dev_addr and open. Dev_addr RI to deposit is the host's MAC address, generally is read in from eeproom then hold to that variable, and of course you can also manually according to your needs. for(i=0;i Addr=readreg(dev,PP_IA+i*2); dev->dev_addr[i*2]=Addr&0xF; dev->dev_addr[i*2+1]=Addr>>8;} Open is a function pointer, the function assigned to his net_open. Net_open function is a dedicated to registered network device interrupts, function, enter the ifconfig command, the last will call to this function. In this function to set the interrupt number. Writereg (dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON); request_irq (dev-> irq, & net_interrupt, 0, dev-> name, dev); 3, I/O port interrupt request settings. Network card is not possible to have always been in a break state, the reasonable time interrupt trigger is a necessary condition. Depending on your hardware circuit diagrams of pins, corresponds to the interrupt request registers is GPG1 and EINT9. Inside the GPG1 registers to EINT9 registers function activated, which is inside the EINT9 registers to interrupt set to jump down the trigger. Writel (readl (S3C2410_GPGCON) | 0x8, S3C2410_GPGCON); writel (readl (S3C2410_EXTINT1) | 0x40, S3C2410_EXTINT1); it is also important to note that the CS8900 network adapter registers are 16-bit, so select the read and write functions must select 16-bit registers of read and write functions. staticu16readword(unsignedlongbase_addr,intportno){  returninw(base_addr+portno); }  staticvoidwriteword(unsignedlongbase_addr,intportno,u16value){  outw(value,base_addr+portno);} These are Linuxkernel2.6.25CS8900 NIC drivers porting content required attention. Kernel inside covers and compatible things very much prone to conflict, remove, add your own functionality, you can make porting work smoothly.

No comments:

Post a Comment