]>
git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/net/ax88796.h
2 * AX88796L(NE2000) support
4 * (c) 2007 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 #ifndef __DRIVERS_AX88796L_H__
24 #define __DRIVERS_AX88796L_H__
26 #define DP_DATA (0x10 << 1)
27 #define START_PG 0x40 /* First page of TX buffer */
28 #define START_PG2 0x48
29 #define STOP_PG 0x80 /* Last page +1 of RX ring */
31 #define RX_START (START_PG+TX_PAGES)
32 #define RX_END STOP_PG
34 #define AX88796L_BASE_ADDRESS CONFIG_DRIVER_NE2000_BASE
35 #define AX88796L_BYTE_ACCESS 0x00001000
36 #define AX88796L_OFFSET 0x00000400
37 #define AX88796L_ADDRESS_BYTE AX88796L_BASE_ADDRESS + \
38 AX88796L_BYTE_ACCESS + AX88796L_OFFSET
39 #define AX88796L_REG_MEMR AX88796L_ADDRESS_BYTE + (0x14<<1)
40 #define AX88796L_REG_CR AX88796L_ADDRESS_BYTE + (0x00<<1)
42 #define AX88796L_CR (*(vu_short *)(AX88796L_REG_CR))
43 #define AX88796L_MEMR (*(vu_short *)(AX88796L_REG_MEMR))
45 #define EECS_HIGH (AX88796L_MEMR |= 0x10)
46 #define EECS_LOW (AX88796L_MEMR &= 0xef)
47 #define EECLK_HIGH (AX88796L_MEMR |= 0x80)
48 #define EECLK_LOW (AX88796L_MEMR &= 0x7f)
49 #define EEDI_HIGH (AX88796L_MEMR |= 0x20)
50 #define EEDI_LOW (AX88796L_MEMR &= 0xdf)
51 #define EEDO ((AX88796L_MEMR & 0x40)>>6)
53 #define PAGE0_SET (AX88796L_CR &= 0x3f)
54 #define PAGE1_SET (AX88796L_CR = (AX88796L_CR & 0x3f) | 0x40)
57 #define MAC_EEP_READ 1
58 #define MAC_EEP_WRITE 2
59 #define MAC_EEP_ERACE 3
60 #define MAC_EEP_EWEN 4
61 #define MAC_EEP_EWDS 5
63 /* R7780MP Specific code */
64 #if defined(CONFIG_R7780MP)
65 #define ISA_OFFSET 0x1400
66 #define DP_IN(_b_, _o_, _d_) (_d_) = \
67 *( (vu_short *) ((_b_) + ((_o_) * 2) + ISA_OFFSET))
68 #define DP_OUT(_b_, _o_, _d_) \
69 *((vu_short *)((_b_) + ((_o_) * 2) + ISA_OFFSET)) = (_d_)
70 #define DP_IN_DATA(_b_, _d_) (_d_) = *( (vu_short *) ((_b_) + ISA_OFFSET))
71 #define DP_OUT_DATA(_b_, _d_) *( (vu_short *) ((_b_)+ISA_OFFSET)) = (_d_)
73 /* Please change for your target boards */
74 #define ISA_OFFSET 0x0000
75 #define DP_IN(_b_, _o_, _d_) (_d_) = *( (vu_short *)((_b_)+(_o_ )+ISA_OFFSET))
76 #define DP_OUT(_b_, _o_, _d_) *((vu_short *)((_b_)+(_o_)+ISA_OFFSET)) = (_d_)
77 #define DP_IN_DATA(_b_, _d_) (_d_) = *( (vu_short *) ((_b_)+ISA_OFFSET))
78 #define DP_OUT_DATA(_b_, _d_) *( (vu_short *) ((_b_)+ISA_OFFSET)) = (_d_)
85 static void ax88796_bitset(u32 bit
)
103 static u8
ax88796_bitget(void)
118 * Send COMMAND to EEPROM
120 static void ax88796_eep_cmd(u8 cmd
)
122 ax88796_bitset(BIT_DUMMY
);
158 static void ax88796_eep_setaddr(u16 addr
)
161 for( i
= 7 ; i
>= 0 ; i
-- )
162 ax88796_bitset(addr
& (1 << i
));
166 * Get data from EEPROM
168 static u16
ax88796_eep_getdata(void)
173 ax88796_bitget(); /* DUMMY */
174 for( i
= 0 ; i
< 16 ; i
++ ){
176 data
|= ax88796_bitget();
181 static void ax88796_mac_read(u8
*buff
)
186 for( i
= 0 ; i
< 3; i
++ )
192 ax88796_eep_cmd(MAC_EEP_READ
);
194 ax88796_eep_setaddr(addr
++);
196 data
= ax88796_eep_getdata();
197 *buff
++ = (uchar
)(data
& 0xff);
198 *buff
++ = (uchar
)((data
>> 8) & 0xff);
205 int get_prom(u8
* mac_addr
)
210 ax88796_mac_read(prom
);
211 for (i
= 0; i
< 6; i
++){
212 mac_addr
[i
] = prom
[i
];
217 #endif /* __DRIVERS_AX88796L_H__ */