27.linux-dm9000c Nic porting (detailed)

Source: Internet
Author: User

In the previous section we studied:

Network card driver Introduction and production of virtual network card driver: http://www.cnblogs.com/lifexy/p/7763352.html

Next , learn the NIC Chip dm9000c, how to write the porting dm9000c NIC driver.

1. First look at DM9000C schematic diagram

As shown in the following:

(#: Indicates low active)

    • sd0~15: 16-bit data cable with CMD PIN to determine access type
    • cmd: command line, when CMD is high, indicates that SD is transmitting data, CMD is low for transmission is address
    • INT: interrupt pin, connected to 2440 GPF7 foot
    • ior#: read pin, connected to the Noe foot of 2440
    • iow#: write pin, connected to the 2440 nwe foot
    • cs#: chip selection, placed on the top of the 2440 Bank4

1.1 The BANK4 address range for 2440 of these manuals is as follows:

The Bank4 interval is located at: 0x20000000~0x28000000, when we access the address of this interval, the memory controller will enable the NIC to be able to dm9000c the enable foot, so our dm9000c io base Address = 0X20000000

Where the dm9000c cmd pin is connected to the LADDR2 above the bank4

So when accessing the IO base address =0x2000 0000, it means that the content in the read-write addresses is the dm9000c address.

Access to the IO base address =0x2000 0100, which means that the contents of the read-write addresses are dm9000c data

1.2 DM9000C Transceiver Process

When the dm9000c receives the external data, it is staged into the internal address, and a rising edge interrupt is generated, waiting for 2440 to read the data

When dm9000c forwards 2440 of the data, it also produces a rising edge interrupt to 2440

As shown, the dm9000c interrupt pin is located on the pin34 foot

On the GPF7 pin of 2440, the interrupt used is EINT7

Next, we will modify the dm9000c source code provided by the manufacturer.

2. There is a conditional compilation before discovering its init_module () entry function

So to comment out the "#ifdef MODULE" and "#endif"

3. Modify the entry exit function names and decorate them (modify the function name to avoid duplicate names of other functions of the kernel)

4. Modify the hardware differences of the drive (set base address, register, interrupt, etc.)

4.1 First, find out where the code is. Initialize the dm9000c hardware

Enter Dm9000c_init ()

Dmfe_probe ()

 struct  Net_device * __init dmfe_probe (void   struct  net_device *dev;dev  = Alloc_etherdev (sizeof  (          struct  board_info)); //  assign a net_device struct                                   = dmfe_probe1 (dev); //  call the Dmfe_probe1 () function                              = Register_netdev (dev); //   

Obviously the DMFE_PROBE1 () function is used to initialize the DM9000C hardware and to set the members of the Net_device struct.

4.2 Entering the DMFE_PROBE1 () function

For example, this iobase variable is our dm9000c io base Address 0x20000000

The role of Iobase:

For example, before reading a dm9000c VID low byte, you need to first assign the address to 0x20000000, that is, dm9000c cmd 0, and then write to 0x20000000 to read the dm9ks_vid_l address value

Finally, the address +4, which is assigned to 0X20000100, will cmd 1, and then read out the value of 0x20000100, that is, dm9000c vid low byte

DM9000C Read and Write methods are the same, the first cmd set 0, write the dm9000c address, and then the CMD 1, to read and write data

4.3 So the iobase variable is reset in the init function, where iobase is the INT type

And in the exit Exit function, add iounmp ()

4.4 Continue into the DMFE_PROBE1 () function and look down

As shown, block the red box code, the code used to check the version, our dm9000c version number is not the same, so to block

4.5 in the INIT function, modify the interrupt name to change the IRQ to IRQ_EINT7

4.6 Modifying interrupts

When using Register_netdev () to register the NIC driver Net_device, the use of ifconfig in the kernel will enter the Net_device->open member function request interrupt, activation queue, etc.

So we're going to modify the request interrupt function of the open member function to change the triggering interrupt to "irqt_rising", the rising edge trigger

5. then start setting up the 2440 Storage Control Register

Set 2440 bank4 hardware bit width, timing, because different hardware, involving the data sent and received are different,

5.1 Setting the Bwscon Bus width control register

We only set the contents of BANK4 , so only the following 3 (BANK0 bit width by om[1:0] hardware settings)

Set st4=0, do not use UB/LB (ub/lb: Indicates whether high-byte and low-byte data are transferred separately)

Set ws4=0, where the wait pin is PE4, and we dm9000c no pin access PE4, so disable

Set dw4=0x01, our dm9000c data line is 16-bit

5.2 Setting the BANKCON4 control register

Before setting these timings, first look at the DM9000C chip manual timing diagram and the 2440 timing diagram

Refer to the BANKCON4 register set as follows (hclk=100mhz,1 clock equals 10ns)

Set tacs=0,cs and cmd signals can be performed simultaneously (CMD pin is 2440 address pin)

Set tcos=t1=0(Maintenance time after CS chip select Enable)

Set tacc=t2=0, to >=10ns (read and write signal access maintenance time)

Set the tcoh=t4=1, to >=3ns (the end of the chip to maintain time)

Set tcah=t8=0, CS and cmd signals can be ended simultaneously (address bus end of maintenance time)

code such as, in Init settings in the entry function

The hardware-related parts have been changed, Next Start compiling

6. Compiling tests

Before compiling, first add the kernel header file that the driver needs:

#include <asm/delay.h><asm/irq.h><linux/irq.h><asm/io.h ><asm/arch-s3c2410/regs-mem.h>

Once the compilation is correct, start testing the dm9000c driver:

1) Place the DM9DEV9000C.C in the kernel's drivers/net directory to replace the original kernel dm9000c

2) modify drivers/net/makefile

Put
obj-$ (config_dm9000) + = DM9000.O
Instead (as shown)
obj-$ (config_dm9000) + = DM9DEV9000C.O

3) make Uimage

For example, the new driver has been compiled into the kernel

4) boot with new kernel

Ifconfig eth0 192.168.2.107

Ping 192.168.2.1

For example, you can ping to indicate that the migration succeeded

27.linux-dm9000c Nic porting (detailed)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.