drivers/dm9000x.h
1 /*
2 * dm9000 Ethernet
3 */
4
5 #ifdef CONFIG_DRIVER_DM9000
6
7 #define DM9000_ID 0x90000A46
8 #define DM9000_PKT_MAX 1536 /* Received packet max size */
9 #define DM9000_PKT_RDY 0x01 /* Packet ready to receive */
10
11 /* although the registers are 16 bit, they are 32-bit aligned.
12 */
13
14 #define DM9000_NCR 0x00
15 #define DM9000_NSR 0x01
16 #define DM9000_TCR 0x02
17 #define DM9000_TSR1 0x03
18 #define DM9000_TSR2 0x04
19 #define DM9000_RCR 0x05
20 #define DM9000_RSR 0x06
21 #define DM9000_ROCR 0x07
22 #define DM9000_BPTR 0x08
23 #define DM9000_FCTR 0x09
24 #define DM9000_FCR 0x0A
25 #define DM9000_EPCR 0x0B
26 #define DM9000_EPAR 0x0C
27 #define DM9000_EPDRL 0x0D
28 #define DM9000_EPDRH 0x0E
29 #define DM9000_WCR 0x0F
30
31 #define DM9000_PAR 0x10
32 #define DM9000_MAR 0x16
33
34 #define DM9000_GPCR 0x1e
35 #define DM9000_GPR 0x1f
36 #define DM9000_TRPAL 0x22
37 #define DM9000_TRPAH 0x23
38 #define DM9000_RWPAL 0x24
39 #define DM9000_RWPAH 0x25
40
41 #define DM9000_VIDL 0x28
42 #define DM9000_VIDH 0x29
43 #define DM9000_PIDL 0x2A
44 #define DM9000_PIDH 0x2B
45
46 #define DM9000_CHIPR 0x2C
47 #define DM9000_SMCR 0x2F
48
49 #define DM9000_PHY 0x40 /* PHY address 0x01 */
50
51 #define DM9000_MRCMDX 0xF0
52 #define DM9000_MRCMD 0xF2
53 #define DM9000_MRRL 0xF4
54 #define DM9000_MRRH 0xF5
55 #define DM9000_MWCMDX 0xF6
56 #define DM9000_MWCMD 0xF8
57 #define DM9000_MWRL 0xFA
58 #define DM9000_MWRH 0xFB
59 #define DM9000_TXPLL 0xFC
60 #define DM9000_TXPLH 0xFD
61 #define DM9000_ISR 0xFE
62 #define DM9000_IMR 0xFF
63
64 #define NCR_EXT_PHY (1<<7)
65 #define NCR_WAKEEN (1<<6)
66 #define NCR_FCOL (1<<4)
67 #define NCR_FDX (1<<3)
68 #define NCR_LBK (3<<1)
69 #define NCR_RST (1<<0)
70
71 #define NSR_SPEED (1<<7)
72 #define NSR_LINKST (1<<6)
73 #define NSR_WAKEST (1<<5)
74 #define NSR_TX2END (1<<3)
75 #define NSR_TX1END (1<<2)
76 #define NSR_RXOV (1<<1)
77
78 #define TCR_TJDIS (1<<6)
79 #define TCR_EXCECM (1<<5)
80 #define TCR_PAD_DIS2 (1<<4)
81 #define TCR_CRC_DIS2 (1<<3)
82 #define TCR_PAD_DIS1 (1<<2)
83 #define TCR_CRC_DIS1 (1<<1)
84 #define TCR_TXREQ (1<<0)
85
86 #define TSR_TJTO (1<<7)
87 #define TSR_LC (1<<6)
88 #define TSR_NC (1<<5)
89 #define TSR_LCOL (1<<4)
90 #define TSR_COL (1<<3)
91 #define TSR_EC (1<<2)
92
93 #define RCR_WTDIS (1<<6)
94 #define RCR_DIS_LONG (1<<5)
95 #define RCR_DIS_CRC (1<<4)
96 #define RCR_ALL (1<<3)
97 #define RCR_RUNT (1<<2)
98 #define RCR_PRMSC (1<<1)
99 #define RCR_RXEN (1<<0)
100
101 #define RSR_RF (1<<7)
102 #define RSR_MF (1<<6)
103 #define RSR_LCS (1<<5)
104 #define RSR_RWTO (1<<4)
105 #define RSR_PLE (1<<3)
106 #define RSR_AE (1<<2)
107 #define RSR_CE (1<<1)
108 #define RSR_FOE (1<<0)
109
110 #define FCTR_HWOT(ot) (( ot & 0xf ) << 4 )
111 #define FCTR_LWOT(ot) ( ot & 0xf )
112
113 #define IMR_PAR (1<<7)
114 #define IMR_ROOM (1<<3)
115 #define IMR_ROM (1<<2)
116 #define IMR_PTM (1<<1)
117 #define IMR_PRM (1<<0)
118
119 #endif
//////////
修改drivers/Makefile,加入dm9000x.c的编译,如下
1 #
2 # (C) Copyright 2002
3 # Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 # Marius Groeger <mgroeger@sysgo.de>
5 #
6 # See file CREDITS for list of people who contributed to this
7 # project.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 # MA 02111-1307 USA
23 #
24
25 include $(TOPDIR)/config.mk
26
27 LIB = libdrivers.a
28
29 OBJS = cs8900.o smc91111.o 3c589.o dm9000x.o
# 29行尾追加 dm9000x.o,使得dm9000x.c被编译进来
30
31 all: .depend $(START) $(LIB)
32
33 $(LIB): $(OBJS)
34 $(AR) crv $@ $(OBJS)
35
36 #########################################################################
37
38 .depend: Makefile $(START:.o=.S) $(OBJS:.o=.c)
39 $(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
40
41 sinclude .depend
42
43 #########################################################################
////////////
编译测试:
[root@arm armboot-1.1.0]# make distclean ;make mini2440_config ; make all
通过编译,编译结果:
[root@armdev armboot-1.1.0]# ls -altr
-rwxr-xr-x 1 root root 234740 May 24 22:31 armboot.srec
-rw-r--r-- 1 root root 29063 May 24 22:31 armboot.map
-rw-r--r-- 1 root root 220086 May 24 22:31 armboot.hex
-rwxr-xr-x 1 root root 78224 May 24 22:31 armboot.bin
-rwxr-xr-x 1 root root 95823 May 24 22:31 armboot
将armboot.bin下载到0x31f00000地址处运行(串口参数:115200,n81),输出信息:(/* 中的的内容为加如的说明文字 */)
ARMboot 1.1.0 (May 24 2011 - 22:31:04)
ARMboot code: 31f00000 -> 31f16440
DRAM Configuration:
Bank #0: 30000000 64 MB
Flash: 2 MB
*** Using default environment
Hit any key to stop autoboot: 0
ARMboot@MINI2440 # help /* 看看ARMboot 1.1.0帮助信息,是不是和U-boot很相似:> */
go - start application at address 'addr'
run - run commands in an environment variable
bootm - boot application image from memory
bootp - boot image via network using BootP/TFTP protocol
tftpboot- boot image via network using TFTP protocol
and env variables ipaddr and serverip
rarpboot- boot image via network using RARP/TFTP protocol
bootd - boot default, i.e., run 'bootcmd'
loads - load S-Record file over serial line
loadb - load binary file over serial line (kermit mode)
autoscr - run script from memory
md - memory display
mm - memory modify (auto-incrementing)
nm - memory modify (constant address)
mw - memory write (fill)
cp - memory copy
cmp - memory compare
crc32 - checksum calculation
base - print or set address offset
printenv- print environment variables
setenv - set environment variables
saveenv - save environment variables to persistent storage
protect - enable or disable FLASH write protection
erase - erase FLASH memory
flinfo - print FLASH memory information
bdinfo - print Board Info structure
iminfo - print header information for application image
loop - infinite loop on address range
mtest - simple RAM test
icache - enable or disable instruction cache
dcache - enable or disable data cache
reset - Perform RESET of the CPU
echo - echo args to console
sleep - delay execution for some time
version - print monitor version
help - print online help
? - alias for 'help'
ARMboot@MINI2440 #
ARMboot@MINI2440 # loadb 30000000 /* 串口下载个文本文件看看,存放到RAM 的0x30000000地址处 */
## Ready for binary (kermit) download ...
## Start Addr = 0x30000000
ARMboot@MINI2440 # md 30000000 /* 看看0x30000000地址处的下载内容,应该和你的原始数据相同 */
30000000: 6f6f725b 72464074 646e6569 5241796c [root@FriendlyAR
30000010: 5d2f204d 73752023 2d312062 6e203a31 M /]# usb 1-1: n
30000020: 66207765 206c6c75 65657073 53552064 ew full speed US
30000030: 65642042 65636976 69737520 7320676e B device using s
30000040: 34326333 6f2d3031 20696368 20646e61 3c2410-ohci and
30000050: 72646461 20737365 750a0d32 31206273 address 2..usb 1
30000060: 203a312d 2077654e 20425355 69766564 -1: New USB devi
30000070: 66206563 646e756f 6469202c 646e6556 ce found, idVend
30000080: 353d726f 2c383434 50646920 75646f72 or=5448, idProdu
30000090: 303d7463 0d343030 6273750a 312d3120 ct=0004..usb 1-1
300000a0: 654e203a 53552077 65642042 65636976 : New USB device
300000b0: 72747320 73676e69 664d203a 2c343d72 strings: Mfr=4,
300000c0: 6f725020 74637564 202c333d 69726553 Product=3, Seri
300000d0: 754e6c61 7265626d 0a0d323d 20627375 alNumber=2..usb
300000e0: 3a312d31 6f725020 74637564 5355203a 1-1: Product: US
300000f0: 79654b42 73750a0d 2d312062 4d203a31 BKey..usb 1-1: M
ARMboot@MINI2440 # /* 键入回车继续查看 */
30000100: 66756e61 75746361 3a726572 42535520 anufacturer: USB
30000110: 0d79654b 6273750a 312d3120 6553203a Key..usb 1-1: Se
30000120: 6c616972 626d754e 203a7265 750a0d3f rialNumber: ?..u
30000130: 31206273 203a312d 666e6f63 72756769 sb 1-1: configur
30000140: 6f697461 3123206e 6f686320 206e6573 ation #1 chosen
30000150: 6d6f7266 63203120 63696f68 730a0d65 from 1 choice..s
30000160: 30697363 53203a20 20495343 6c756d65 csi0 : SCSI emul
30000170: 6f697461 6f66206e 53552072 614d2042 ation for USB Ma
30000180: 53207373 61726f74 64206567 63697665 ss Storage devic
30000190: 0a0d7365 69736373 61637320 49203a6e es..scsi scan: I
300001a0: 4955514e 72205952 6c757365 6f742074 NQUIRY result to
300001b0: 6873206f 2074726f 2c293528 69737520 o short (5), usi
300001c0: 3320676e 730a0d36 20697363 3a303a30 ng 36..scsi 0:0:
300001d0: 3a303a30 2d444320 204d4f52 20202020 0:0: CD-ROM
300001e0: 20202020 20202020 20202020 20202020
300001f0: 4f524443 2020204d 20202020 20202020 CDROM
ARMboot@MINI2440 # printenv /* 看看环境变量 */
bootargs=noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200n8
bootcmd=nboot
bootdelay=3
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
ipaddr=192.168.2.2
serverip=192.168.2.1
netmask=255.255.255.0
bootfile="uImage110_2440"
loadaddr=0x30008000
Environment size: 253/65532 bytes
ARMboot@MINI2440 # bdinfo /* 看看板子的配置信息 */
enetaddr = 08:00:3E:26:0A:5B
ip_addr = 192.168.2.2
baudrate = 115200 bps
arch_number = 193
env_t = 31F36448
boot_params = 30000100
DRAM:00.start = 30000000
DRAM:00.size = 04000000
ARMboot@MINI2440 # tftp 0x30008000 uImage110_2440 /* 通过tftp下载个uImage看看,前提是要设定网络环境,你的tftp服务器应没有防火墙,所下载的文件可以被tftp服务器读到 */
dm9000 i/o: 0x20000000, id: 0x90000a46
00008000 00000000 00000000 00000000 00000000 00000000
MAC: 08:00:3e:26:0a:5b
could not establish link
ARP broadcast 1
checksum bad
checksum bad
eth addr: 00:0c:29:9d:30:4b
TFTP from server 192.168.2.1; our IP address is 192.168.2.2
Filename 'uImage110_2440'.
Load address: 0x30008000
Loading: #######################################################################
################################################################################
################################################################################
################################################################################
################################################################################
#####
done
Bytes transferred = 2022412 (1edc0c hex)
ARMboot@MINI2440 # bootm /* 下载的uImage可以通过bootm命令来引导这个内核映像,uImage和zImage内核有区别(多了64字节的头),bootm只能引导uImage */
/////////////
