Linux2.6.32.2 mini2440 platform transplantation--Transplantation of DM9000 network card driver

Publisher:清新天空Latest update time:2022-10-18 Source: csdnKeywords:linux2  6  mini2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1.1.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, so the code is initialized on the target platform. , just fill in the corresponding structure table (in mach-mini2440.c), the specific steps are as follows:


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


#include


Then define 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 match it 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 equipment prepared above in 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,


};


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


1.1.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, and add 2410 related configuration definitions to the header file, as follows


#include


#include


#include


#if defined(CONFIG_ARCH_S3C2410)


#include


#endif


#include "dm9000.h"


Add the following red part to the initialization function of the dm9000 device. Here is the timing for configuring the chip select bus used by DM9000. Because mini2440 currently only has one device that can be expanded through the bus, it will be easier to understand if you directly modify the relevant register configuration in this device driver. Some, of course, this part can also be placed in mach-mini2440.c (note that if you put this part in mach-mini2440.c, there will be several constants that you need to find and define yourself). You can experiment by yourself, and I won’t 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);


}


1.1.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 through 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 MAC address from 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);


        }


       //Use "soft" MAC address: 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);


In fact, DM9000 has been transplanted so far.


1.1.4 Configure the kernel to add DM9000, compile and run the test


At this time, the kernel source code directory will be brought, execute:


#make menuconfig


Start configuring the network card driver in the kernel and select the following menu items in sequence


Device Drivers --->Network device support ---> Ethernet (10 or 100Mbit) --->


You can find the configuration items of DM9000, and 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


Finally, generate the arch/arm/boot/zImage file, use the "k" command to burn it to the development board, and start it using the default file system. Run the ifconfig command in the command line terminal to see the following.


[root@FriendlyARM /]# ifconfig


eth0 Link encap:Ethernet HWaddr 08:90:90:90:90:90


          inet addr:192.168.1.230 Bcast:192.168.1.255 Mask:255.255.255.0


          UP BROADCAST MULTICAST MTU:1500 Metric:1


          RX packets:0 errors:0 dropped:0 overruns:0 frame:0


          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0


          collisions:0 txqueuelen:1000


          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


          Interrupt:51 Base address:0x300


lo Link encap:Local Loopback


          inet addr:127.0.0.1 Mask:255.0.0.0


          UP LOOPBACK RUNNING MTU:16436 Metric:1


          RX packets:0 errors:0 dropped:0 overruns:0 frame:0


          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0


          collisions:0 txqueuelen:0


          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


Test network: ping 127.0.0.1. If there is a number after the equal sign, it means that the network card is pinging the gateway address normally. If there is a number after the equal sign, it is connecting to the gateway and pinging the IP of other hosts normally. If there is a number after the equal sign, it is pinging the IP of other hosts. The connection is OK.


Keywords:linux2  6  mini2440 Reference address:Linux2.6.32.2 mini2440 platform transplantation--Transplantation of DM9000 network card driver

Previous article:linux2.6.32.2 mini2440 platform transplantation--activate RTC driver
Next article:Linux 2.6.32.2 mini2440 platform transplantation-kernel transplantation, yaffs2 file system transplantation

Recommended ReadingLatest update time:2024-11-16 13:49

Detailed explanation of 8 modes of GPIO in STM32
1. Push-pull output: can output high and low levels and connect digital devices; push-pull structure generally means that two transistors are controlled by two complementary signals, and one transistor is always turned on while the other is turned off. The high and low levels are determined by the power supply of the I
[Microcontroller]
[Graphic] TDA1514A×2 amplifier production
Regardless of the configuration of the final stage of the tube amplifier, its power amplifier tubes must be strictly paired (even for single-tube single-ended Class A machines, the parameters of the two-channel tubes should be as consistent as possible). This article introduces a dual-tube same-screen and same-grid te
[Analog Electronics]
[Graphic] TDA1514A×2 amplifier production
Analysis and study of mini2440 I2C driver (Part 1)
I spent nearly a week learning the I2C driver, and I describe my experience as follows. I2C is a typical simple subsystem, which is more suitable for learning because the I2C protocol is much simpler than PCI and so on. An EEPROM chip is connected to the mini2440 via I2C. Therefore, when we talk about the I2C driver
[Microcontroller]
[MCU framework][bsp layer][cx32l003][bsp_crc] Hardware CRC configuration and use
The cyclic redundancy check (CRC) calculation unit obtains the CRC calculation result of any byte data based on a fixed generating polynomial. In applications, CRC technology is mainly used to verify the correctness and integrity of data transmission or data storage. This module algorithm complies with the definitio
[Microcontroller]
STM32 FLASH operation
When it comes to STM32's FLSAH, our first reaction is that it is used to install programs. In fact, the STM32's on-chip FLASH is not only used to install programs, but also to install chip configuration, chip ID, bootloader, etc. Of course, FLASH can also be used to store data.      I have collected some information a
[Microcontroller]
STM32F4 clock initialization configuration
The STM32F4 clock system initialization is completed in the SystemInit() function in system_stm32f4xx.c. The key register settings of the system clock are mainly set by calling the SetSysClock() function in the SystemInit function. Let's take a look at the SystemInit() function body: void SystemInit(void) {       #if
[Microcontroller]
Micron’s low-power memory solutions help Qualcomm’s second-generation Snapdragon XR2 platform enhance mixed reality (MR) and virtual reality (VR) experiences
Micron’s LPDDR5X and UFS 3.1 solutions bring high speed and low power to Metaverse applications Shanghai, China, October 31, 2023 - Micron Technology, Inc. (Micron Technology, Inc.) recently announced that its low-power LPDDR5X DRAM and universal flash memory UFS 3.1 embedded solutions have now be
[Embedded]
Micron’s low-power memory solutions help Qualcomm’s second-generation Snapdragon XR2 platform enhance mixed reality (MR) and virtual reality (VR) experiences
DC-DC Converter Using X2Y Technology
Many OEMs have electromagnetic compatibility (EMC) issues due to the inherent internal switching mode of DC-DC converters. The switching noise voltage needs to be filtered out at the output. Traditionally, several discrete components can provide sufficient filtering performance and remain cost-effective in high-volume
[Power Management]
DC-DC Converter Using X2Y Technology
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号