Linux-2.6.32 ported on mini2440 development board* Ported DM9000 network card driver

Publisher:RadiantJourneyLatest update time:2024-06-18 Source: elecfansKeywords:linux  DM9000 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Device resource initialization
Linux-2..6.32.2 already comes with a complete DM9000 network card driver (source code location: linux-2.6.32.2/
drivers/net/dm9000.c). It is also a platform device. Therefore, in the target platform initialization code, just fill in the corresponding
structure table. The specific steps are as follows:

First add the header file dm9000.h required by the driver:
#include

Redefine the physical base address of the DM9000 network card device for later use:
/* DM9000AEP 10/100 ethernet controller */
#define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300)
Then fill in the resource settings of the platform device to cooperate with the DM9000 network card driver interface, as follows
static struct resource mini2440_dm9k_resource[] = {
[0] = {
.start = MACH_MINI2440_DM9K_BASE,
.end = MACH_MINI2440_DM9K_BASE + 3,
.flags = IORESOURCE_MEM
},
[1] = {
.start = MACH_MINI2440_DM9K_BASE + 4,
.end = MACH_MINI2440_DM9K_BASE + 7,
.flags = IORESOURCE_MEM
},
[2] = {
.start = IRQ_EINT7,
.end = IRQ_EINT7,
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
}
};
/*
* * * The DM9000 has no eeprom, and it's MAC address is set by
* * * the bootloader before starting the kernel.
* * */
static struct dm9000_plat_data mini2440_dm9k_pdata = {
.flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};
static struct platform_device mini2440_device_eth = {
.name = "dm9000",
.id = -1,
.num_resources = ARRAY_SIZE(mini2440_dm9k_resource),
.resource = mini2440_dm9k_resource,
.dev = {
.platform_data = &mini2440_dm9k_pdata,
},
};
; At the same time, add the network card platform device prepared above to the mini2440 device set, as shown in the red part below

static struct platform_device *mini2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&mini2440_device_eth,
&s3c_device_nand,

&mini2440_device_eth
};

In this way, the interface of the DM9000 platform device is completed.

Note: Regarding this structure struct resource, the resources of the network card are defined here. Looking at the circuit diagram of the board, you can find that the network card is hung on

The bus address is in bank 4, and the interrupt is external interrupt 7.

2 Adjust the bit width register used by DM9000
Because the DM9000 network card driver of Linux-2.6.32.2 is not specially prepared for mini2440, some porting work needs to be done in its source code, as follows.
Open linux-2.6.32.2/ drivers/net/dm9000.c, add 2410 related configuration definitions in the header file, as shown in the red part below:
#include
#include
#include
#if defined(CONFIG_ARCH_S3C2410)
#include
#endif
#include "dm9000.h"
Add the following red part in the initialization function of the dm9000 device. This is the timing for configuring the chip select bus used by DM9000. Because mini2440 currently has only one device that expands through the bus, it will be easier to understand by directly modifying the relevant register configuration in this device driver. Of course, this part can also be placed in mach-mini2440.c. You can experiment on your own and I will not go into details here.
static int __init
dm9000_init(void)
{
#if defined(CONFIG_ARCH_S3C2410)
unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4;
*((volatile unsigned int *)S3C2410_BWSCON) =
(oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW4_16 |
S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;

*((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c;
#endif
printk(KERN_INFO "%s Ethernet Driver, V%sn", CARDNAME, DRV_VERSION);
return platform_driver_register(&dm9000_driver);
}


3 About MAC address
It should be noted that the DM9000 network card used in this development board does not have an external EEPROM to store the MAC address, so the MAC address in the system is a "soft" address, which means it can be modified by software and can be changed to other values ​​at will. It can be seen in the static int __devinit dm9000_probe(struct platform_device *pdev) function: /* try reading the node address from the attached EEPROM */; try to read the MAC address from the EEPROM


for (i = 0; i < 6; i += 2)
dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
mac_src = "platform data";
memcpy(ndev->dev_addr, pdata->dev_addr, 6);
}
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */
mac_src = "chip";
for (i = 0; i < 6; i++)
ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
}
;使用“软”MAC 地址: 08:90:90:90:90:90
memcpy(ndev->dev_addr, "x08x90x90x90x90x90", 6);
if (!is_valid_ether_addr(ndev->dev_addr))
dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please ""set using ifconfign", ndev->name);
实际上到此为止DM9000 就已经移植结束了。

4 Configure the kernel to add DM9000, and compile and run the test. At this time, the kernel source code directory will be included. Execute:
#make menuconfig
to start configuring the network card driver in the kernel. Select the following menu items in sequence:
Device Drivers ---> Network device support ---> Ethernet (10 or 100Mbit) --->
to find the configuration items of DM9000. You can see that DM9000 has been selected. This is because the default kernel configuration of Linux-2.6.32.2 has added support for DM9000.

Then execute:
#make zImage
to generate the arch/arm/boot/zImage file. Use the "k" command to burn it to the development board and boot it using the default file system. Run the ifconfig command in the command line terminal to view the information of eth0.

Note: The above transplant process is mainly based on the manual. Here are some personal additions. About the added lines

unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4;
*((volatile unsigned int *)S3C2410_BWSCON) =
(oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW4_16 |
S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;

*((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c;

What does it mean?

S3C2410_BWSCON, S3C2410_BANKCON4 are actually the addresses of BWSCON and BANKCON4. The former corresponds to the mapped address, and the latter corresponds to the actual physical address. For S3C2440, the virtual-real address mapping relationship is actually very simple, just adding a cheap. Take S3C2410_BWSCON as an example (or track the implementation process of this)

#define S3C2410_BWSCON S3C2410_MEMREG(0x0000)

#define S3C2410_MEMREG(x) (S3C24XX_VA_MEMCTRL + (x))

#define S3C24XX_VA_MEMCTRL S3C_VA_MEM

#define S3C_VA_MEM S3C_ADDR(0x00200000) /* memory control */

#define S3C_ADDR(x) (S3C_ADDR_BASE + (x))

#define S3C_ADDR_BASE (0xF4000000)

In fact, S3C2410_BWSCON is F4200000, which is a mapping of address 0x48000000. This relationship is to add an offset. Everyone should know this.

Let's talk about what the above program does.

Several macro definitions appear in it as follows:

#define S3C2410_BWSCON_ST4 (1<<19)

#define S3C2410_BWSCON_WS4 (1<<18)

#define S3C2410_BWSCON_DW4_16 (1<<16)

Below are bits 16 to 19 of the BWSCON control register

ST4 [19] Determines SRAM for using UB/LB for bank 4.

0 = Not using UB/LB (The pins are dedicated nWBE[3:0])

1 = Using UB/LB (The pins are dedicated nBE[3:0])

0

WS4 [18] Determines WAIT status for bank 4.

0 = WAIT disable 1 = WAIT enable

0

DW4 [17:16] Determine data bus width for bank 4.

00 = 8-bit 01 = 16-bit, 10 = 32-bit 11 = reserved

Below is the meaning of each bit of the BANK4CON register.

Tacs [14:13] Address set-up time before nGCSn

00 = 0 clock 01 = 1 clock

10 = 2 clocks 11 = 4 clocks

00

Tcos [12:11] Chip selection set-up time before nOE

00 = 0 clock 01 = 1 clock

10 = 2 clocks 11 = 4 clocks

00

Tacc [10:8] Access cycle

000 = 1 clock 001 = 2 clocks

010 = 3 clocks 011 = 4 clocks

100 = 6 clocks 101 = 8 clocks

110 = 10 clocks 111 = 14 clocks

Note: When nWAIT signal is used, Tacc ³ 4 clocks.

111

Tcoh [7:6] Chip selection hold time after nOE

00 = 0 clock 01 = 1 clock

10 = 2 clocks 11 = 4 clocks

000

Tcah [5:4] Address hold time after nGCSn

00 = 0 clock 01 = 1 clock

10 = 2 clocks 11 = 4 clocks

00

Tacp [3:2] Page mode access cycle @ Page mode

00 = 2 clocks 01 = 3 clocks

10 = 4 clocks 11 = 6 clocks

00

PMC [1:0] Page mode configuration

00 = normal (1 data) 01 = 4 data

10 = 8 times 11 = 16 times

Convert the data to be assigned above into binary bits, and check one by one to see what function is set. In general, it is to set the timing, so I won't go into details.


Keywords:linux  DM9000 Reference address:Linux-2.6.32 ported on mini2440 development board* Ported DM9000 network card driver

Previous article:Linux-2.6.32 ported to mini2440 development board - ported to yaffs2
Next article:Linux-2.6.32 transplanted on mini2440 development board - RTC transplanted

Recommended ReadingLatest update time:2024-11-15 14:49

ADC driver implementation for ARM Linux S3C2440
Hardware Description: The S3c2440 has a 10-bit CMOS ADC analog-to-digital converter that supports 8 analog channel inputs, 10-bit resolution, and a maximum speed of 500KSPS (500 kilosamples per second). As can be seen from the figure: the analog ADC includes two functions, one is the touch
[Microcontroller]
ADC driver implementation for ARM Linux S3C2440
OK6410A development board (three) 7 u-boot-2021.01 boot analysis u-boot and linux configuration part
U-boot configuration make O=output ok6410a_mini_defconfig // You don't need to specify ARCH (because it's written in defconfig) and CROSS_COMPILE (because it's not needed now, it's needed when building) when configuring // If CROSS_COMPILE is written, CROSS_COMPILE will be checked, and then it still needs to be writte
[Microcontroller]
ARM-LINUX key interrupt driver
driver #include linux/module.h #include linux/kernel.h #include linux/moduleparam.h #include linux/init.h #include linux/kdev_t.h #include linux/fs.h #include linux/cdev.h #include linux/device.h #include asm/arch/regs-gpio.h #include asm/hardware.h #include asm/uaccess.h #include linux
[Microcontroller]
ARM-LINUX key interrupt driver
File descriptors in the Linux kernel (V) -- allocation of fd -- locate_fd
Kernel version: 2.6.14 CPU architecture: ARM920T Author: ce123(http://blog.csdn.net/ce123) Continuing from the previous blog, we will analyze the allocation function locate_fd of another file descriptor fd. The dup system call is used to copy the file corresponding to a file descriptor, and the return value is a f
[Microcontroller]
Software-based and networked Linux-based radar terminal system
The existing radar terminal system is implemented with a large number of high-speed dedicated chips. However, the chip is updated very quickly, and many chips are facing elimination. Even if they have not completely disappeared, the price is already very expensive, which brings great inconvenience to the maintenance an
[Microcontroller]
Software-based and networked Linux-based radar terminal system
Detailed analysis of SWI in the Arm Linux system call process
Unix systems implement most of the interfaces between user-mode processes and hardware devices by issuing system calls to the kernel. System calls are services provided by the operating system. User programs use various system calls to reference various services provided by the kernel. The execution of system call
[Microcontroller]
Detailed analysis of SWI in the Arm Linux system call process
ARM_linux development environment establishment (2)
Install FTP, SSH, and NFS server software - apt-get. Install VMware Tools and share files between the local machine and the virtual machine Installing VMWare Tools has several advantages: .When transferring files between Host OS and Guest OS, you only need to drag the mouse. When switching between Host OS and Guest
[Microcontroller]
Compile a Linux uImage that can load the LCD driver
pc:Centos5.4 Kernel: Linux 3.0.1 Development board: ok6410 Cross compiler: arm-linux-gcc 4.4.1 LCD Driver How to write LCD driver? 1. Allocate an fb_info structure: framebuffer_alloc 2. Setup 3. Registration: register_framebuffer 4. Hardware-related operations test:
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号