當(dāng)前位置:首頁 > 嵌入式培訓(xùn) > 嵌入式學(xué)習(xí) > 講師博文 > 基于FS4412內(nèi)核移植之DM9000網(wǎng)卡驅(qū)動添加
網(wǎng)卡是嵌入式產(chǎn)品常用的設(shè)備,這里我們需要完成網(wǎng)卡驅(qū)動的移植。FS4412使用的是DM9000網(wǎng)卡,我們通過這個實驗?zāi)軌蛄私馊绾卧趦?nèi)核中添加網(wǎng)卡驅(qū)動及網(wǎng)絡(luò)功能的基本配置。
由圖中可以看到如下內(nèi)容:
有16根數(shù)據(jù)線,所以總線寬度為16bit
中斷線為DM9000_IRQ對應(yīng)的XEINT6,也就是使用的終端是外部中斷6(EINT6)
片選線為BUF_Xm0cs1,即片選1,對應(yīng)的地址空間為0x05000000 – 0x06000000
所以設(shè)備樹文件中添加如下內(nèi)容:
$ vim arch/arm/boot/dts/exynos4412-fs4412.dts
添加內(nèi)容:
srom-cs1@5000000 {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x5000000 0x1000000>;
ranges;
ethernet@5000000 {
compatible = "davicom,dm9000";
reg = <0x5000000 0x2 0x5000004 0x2>;
interrupt-parent = <&gpx0>;
interrupts = <6 4>;
davicom,no-eeprom;
mac-address = [00 0a 2d a6 55 a2];
};
};
參考文件:Documentation/devicetree/bindings/net/davicom-dm9000.txt
$ vimarch/arm/boot/dts/exynos4x12-pinctrl.dtsi
gpx0: gpx0 {
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
interrupt-parent = <&gic>;
interrupts = <0 16 0>, <0 17 0>, <0 18 0>, <0 19 0>,
<0 20 0>, <0 21 0>, <0 22 0>, <0 23 0>;
#interrupt-cells = <2>;
};
外部中斷6對應(yīng)的GPIO口為GPX0_6,所以:
interrupt-parent = <&gpx0>;
外部中斷6對應(yīng)的是gic中的22所以
interrupts = <6 4>; 6對應(yīng)的是外部中斷6也就是gic中的22,4為高電平觸發(fā)中斷
參考內(nèi)容:Documentation/devicetree/bindings/arm/gic.txt
Documentation/devicetree/bindings/arm/samsung/interrupt-combiner.txt
配置內(nèi)核:
makemenuconfig
//網(wǎng)卡相關(guān)選項
[*] Networking support --->
Networking options --->
<*> Packet socket
<*>Unix domain sockets
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
//DM9000網(wǎng)卡相關(guān)選項
Device Drivers --->
[*] Network device support --->
[*] Ethernet driver support (NEW) --->
<*> DM9000 support
//NFS 相關(guān)選項
File systems --->
[*] Network File Systems (NEW) --->
<*> NFS client support
[*] NFS client support for NFS version 3
[*] NFS client support for the NFSv3 ACL protocol extension
[*] Root file system on NFS
編譯內(nèi)核和設(shè)備樹
$ make uImage
$ make dtbs
設(shè)置系統(tǒng)啟動參數(shù)如果使用NFS啟動的話,則可以通過NFS掛載根文件系統(tǒng)