Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Librem5
uboot-imx
Commits
ee924e00
Commit
ee924e00
authored
Feb 01, 2009
by
Wolfgang Denk
Browse files
Merge branch 'master' of
git://git.denx.de/u-boot-net
parents
f4b6f45d
fc01ea1e
Changes
16
Hide whitespace changes
Inline
Side-by-side
board/bf537-stamp/bf537-stamp.c
View file @
ee924e00
...
...
@@ -34,22 +34,6 @@
#include
<asm/mach-common/bits/bootrom.h>
#include
<netdev.h>
/**
* is_valid_ether_addr - Determine if the given Ethernet address is valid
* @addr: Pointer to a six-byte array containing the Ethernet address
*
* Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not
* a multicast address, and is not FF:FF:FF:FF:FF:FF.
*
* Return true if the address is valid.
*/
static
inline
int
is_valid_ether_addr
(
const
u8
*
addr
)
{
/* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to
* explicitly check for it here. */
return
!
is_multicast_ether_addr
(
addr
)
&&
!
is_zero_ether_addr
(
addr
);
}
DECLARE_GLOBAL_DATA_PTR
;
#define POST_WORD_ADDR 0xFF903FFC
...
...
cpu/mpc8260/Makefile
View file @
ee924e00
#
# (C) Copyright 2000-200
6
# (C) Copyright 2000-200
8
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
...
...
@@ -27,9 +27,13 @@ LIB = $(obj)lib$(CPU).a
START
=
start.o kgdb.o
COBJS
=
traps.o serial_smc.o serial_scc.o cpu.o cpu_init.o speed.o
\
interrupts.o
ether_scc.o
ether_fcc.o i2c.o commproc.o
\
interrupts.o ether_fcc.o i2c.o commproc.o
\
bedbug_603e.o pci.o spi.o
COBJS-$(CONFIG_ETHER_ON_SCC)
=
ether_scc.o
COBJS
+=
$
(
COBJS-y
)
SRCS
:=
$(START:.o=.S)
$(SOBJS:.o=.S)
$(COBJS:.o=.c)
OBJS
:=
$(
addprefix
$(obj)
,
$(SOBJS)
$(COBJS)
)
START
:=
$(
addprefix
$(obj)
,
$(START)
)
...
...
cpu/mpc8260/cpu.c
View file @
ee924e00
...
...
@@ -325,6 +325,9 @@ int cpu_eth_init(bd_t *bis)
{
#if defined(CONFIG_ETHER_ON_FCC)
fec_initialize
(
bis
);
#endif
#if defined(CONFIG_ETHER_ON_SCC)
mpc82xx_scc_enet_initialize
(
bd
);
#endif
return
0
;
}
cpu/mpc8260/ether_scc.c
View file @
ee924e00
...
...
@@ -10,6 +10,12 @@
* Advent Networks, Inc. <http://www.adventnetworks.com>
* Jay Monkman <jtm@smoothsmoothie.com>
*
* Modified so that it plays nicely when more than one ETHERNET interface
* is in use a la ether_fcc.c.
* (C) Copyright 2008
* DENX Software Engineerin GmbH
* Gary Jennejohn <garyj@denx.de>
*
* See file CREDITS for list of people who contributed to this
* project.
*
...
...
@@ -32,11 +38,14 @@
#include
<common.h>
#include
<asm/cpm_8260.h>
#include
<mpc8260.h>
#include
<malloc.h>
#include
<net.h>
#include
<command.h>
#include
<config.h>
#if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_CMD_NET)
#ifndef CONFIG_NET_MULTI
#error "CONFIG_NET_MULTI must be defined."
#endif
#if (CONFIG_ETHER_INDEX == 1)
# define PROFF_ENET PROFF_SCC1
...
...
@@ -100,7 +109,7 @@ typedef volatile struct CommonBufferDescriptor {
static
RTXBD
*
rtx
;
int
eth
_send
(
volatile
void
*
packet
,
int
length
)
static
int
sec
_send
(
struct
eth_device
*
dev
,
volatile
void
*
packet
,
int
length
)
{
int
i
;
int
result
=
0
;
...
...
@@ -137,7 +146,7 @@ int eth_send(volatile void *packet, int length)
}
int
eth
_rx
(
void
)
static
int
sec
_rx
(
struct
eth_device
*
dev
)
{
int
length
;
...
...
@@ -184,7 +193,7 @@ int eth_rx(void)
*
*************************************************************/
int
eth
_init
(
bd_t
*
bis
)
static
int
sec
_init
(
struct
eth_device
*
dev
,
bd_t
*
bis
)
{
int
i
;
volatile
immap_t
*
immr
=
(
immap_t
*
)
CONFIG_SYS_IMMR
;
...
...
@@ -194,9 +203,14 @@ int eth_init(bd_t *bis)
rxIdx
=
0
;
txIdx
=
0
;
/* assign static pointer to BD area */
dpaddr
=
m8260_cpm_dpalloc
(
sizeof
(
RTXBD
)
+
2
,
16
);
rtx
=
(
RTXBD
*
)
&
immr
->
im_dprambase
[
dpaddr
];
/*
* Assign static pointer to BD area.
* Avoid exhausting DPRAM, which would cause a panic.
*/
if
(
rtx
==
NULL
)
{
dpaddr
=
m8260_cpm_dpalloc
(
sizeof
(
RTXBD
)
+
2
,
16
);
rtx
=
(
RTXBD
*
)
&
immr
->
im_dprambase
[
dpaddr
];
}
/* 24.21 - (1-3): ioports have been set up already */
...
...
@@ -338,7 +352,7 @@ int eth_init(bd_t *bis)
}
void
eth
_halt
(
void
)
static
void
sec
_halt
(
struct
eth_device
*
dev
)
{
volatile
immap_t
*
immr
=
(
immap_t
*
)
CONFIG_SYS_IMMR
;
immr
->
im_scc
[
CONFIG_ETHER_INDEX
-
1
].
scc_gsmrl
&=
~
(
SCC_GSMRL_ENR
|
...
...
@@ -346,7 +360,7 @@ void eth_halt(void)
}
#if 0
void restart(void)
static
void
sec_
restart(void)
{
volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
immr->im_cpm.cp_scc[CONFIG_ETHER_INDEX-1].scc_gsmrl |= (SCC_GSMRL_ENR |
...
...
@@ -354,4 +368,20 @@ void restart(void)
}
#endif
#endif
int
mpc82xx_scc_enet_initialize
(
bd_t
*
bis
)
{
struct
eth_device
*
dev
;
dev
=
(
struct
eth_device
*
)
malloc
(
sizeof
*
dev
);
memset
(
dev
,
0
,
sizeof
*
dev
);
sprintf
(
dev
->
name
,
"SCC ETHERNET"
);
dev
->
init
=
sec_init
;
dev
->
halt
=
sec_halt
;
dev
->
send
=
sec_send
;
dev
->
recv
=
sec_rx
;
eth_register
(
dev
);
return
1
;
}
cpu/sh4/cpu.c
View file @
ee924e00
...
...
@@ -82,3 +82,11 @@ int dcache_status (void)
{
return
0
;
}
int
cpu_eth_init
(
bd_t
*
bis
)
{
#ifdef CONFIG_SH_ETHER
sh_eth_initialize
(
bis
);
#endif
return
0
;
}
drivers/net/Makefile
View file @
ee924e00
...
...
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk
LIB
:=
$(obj)
libnet.a
COBJS-$(CONFIG_DRIVER_3C589)
+=
3c589.o
COBJS-$(CONFIG_PPC4xx_EMAC)
+=
4xx_enet.o
COBJS-$(CONFIG_DRIVER_AX88180)
+=
ax88180.o
COBJS-$(CONFIG_BCM570x)
+=
bcm570x.o bcm570x_autoneg.o 5701rls.o
COBJS-$(CONFIG_BFIN_MAC)
+=
bfin_mac.o
...
...
@@ -54,11 +55,11 @@ COBJS-$(CONFIG_NS8382X) += ns8382x.o
COBJS-$(CONFIG_DRIVER_NS9750_ETHERNET)
+=
ns9750_eth.o
COBJS-$(CONFIG_PCNET)
+=
pcnet.o
COBJS-$(CONFIG_PLB2800_ETHER)
+=
plb2800_eth.o
COBJS-$(CONFIG_PPC4xx_EMAC)
+=
4xx_enet.o
COBJS-$(CONFIG_DRIVER_RTL8019)
+=
rtl8019.o
COBJS-$(CONFIG_RTL8139)
+=
rtl8139.o
COBJS-$(CONFIG_RTL8169)
+=
rtl8169.o
COBJS-$(CONFIG_DRIVER_S3C4510_ETH)
+=
s3c4510b_eth.o
COBJS-$(CONFIG_SH_ETHER)
+=
sh_eth.o
COBJS-$(CONFIG_DRIVER_SMC91111)
+=
smc91111.o
COBJS-$(CONFIG_DRIVER_SMC911X)
+=
smc911x.o
COBJS-$(CONFIG_TIGON3)
+=
tigon3.o bcm570x_autoneg.o 5701rls.o
...
...
@@ -68,7 +69,6 @@ COBJS-$(CONFIG_ULI526X) += uli526x.o
COBJS-$(CONFIG_VSC7385_ENET)
+=
vsc7385.o
COBJS-$(CONFIG_XILINX_EMAC)
+=
xilinx_emac.o
COBJS-$(CONFIG_XILINX_EMACLITE)
+=
xilinx_emaclite.o
COBJS-$(CONFIG_SH_ETHER)
+=
sh_eth.o
COBJS
:=
$
(
COBJS-y
)
SRCS
:=
$(COBJS:.o=.c)
...
...
drivers/net/macb.c
View file @
ee924e00
...
...
@@ -317,6 +317,30 @@ static void macb_phy_reset(struct macb_device *macb)
netdev
->
name
,
status
);
}
#ifdef CONFIG_MACB_SEARCH_PHY
static
int
macb_phy_find
(
struct
macb_device
*
macb
)
{
int
i
;
u16
phy_id
;
/* Search for PHY... */
for
(
i
=
0
;
i
<
32
;
i
++
)
{
macb
->
phy_addr
=
i
;
phy_id
=
macb_mdio_read
(
macb
,
MII_PHYSID1
);
if
(
phy_id
!=
0xffff
)
{
printf
(
"%s: PHY present at %d
\n
"
,
macb
->
netdev
.
name
,
i
);
return
1
;
}
}
/* PHY isn't up to snuff */
printf
(
"%s: PHY not found"
,
macb
->
netdev
.
name
);
return
0
;
}
#endif
/* CONFIG_MACB_SEARCH_PHY */
static
int
macb_phy_init
(
struct
macb_device
*
macb
)
{
struct
eth_device
*
netdev
=
&
macb
->
netdev
;
...
...
@@ -325,6 +349,13 @@ static int macb_phy_init(struct macb_device *macb)
int
media
,
speed
,
duplex
;
int
i
;
#ifdef CONFIG_MACB_SEARCH_PHY
/* Auto-detect phy_addr */
if
(
!
macb_phy_find
(
macb
))
{
return
0
;
}
#endif
/* CONFIG_MACB_SEARCH_PHY */
/* Check if the PHY is up to snuff... */
phy_id
=
macb_mdio_read
(
macb
,
MII_PHYSID1
);
if
(
phy_id
==
0xffff
)
{
...
...
drivers/net/sh_eth.c
View file @
ee924e00
...
...
@@ -24,6 +24,7 @@
#include
<common.h>
#include
<malloc.h>
#include
<net.h>
#include
<netdev.h>
#include
<asm/errno.h>
#include
<asm/io.h>
...
...
@@ -36,12 +37,7 @@
# error "Please define CONFIG_SH_ETHER_PHY_ADDR"
#endif
extern
int
eth_init
(
bd_t
*
bd
);
extern
void
eth_halt
(
void
);
extern
int
eth_rx
(
void
);
extern
int
eth_send
(
volatile
void
*
packet
,
int
length
);
static
struct
dev_info_s
*
dev
;
#define SH_ETH_PHY_DELAY 50000
/*
* Bits are written to the PHY serially using the
...
...
@@ -89,7 +85,7 @@ static void sh_eth_mii_ind_bus_release(int port)
udelay
(
1
);
}
static
int
sh_eth_mii_read_phy_bits
(
int
port
,
u32
*
val
,
int
len
)
static
void
sh_eth_mii_read_phy_bits
(
int
port
,
u32
*
val
,
int
len
)
{
int
i
;
u32
pir
;
...
...
@@ -106,8 +102,6 @@ static int sh_eth_mii_read_phy_bits(int port, u32 * val, int len)
outl
(
0
,
PIR
(
port
));
udelay
(
1
);
}
return
0
;
}
#define PHY_INIT 0xFFFFFFFF
...
...
@@ -183,26 +177,23 @@ static void sh_eth_mii_write_phy_reg(int port, u8 phy_addr, int reg, u16 val)
sh_eth_mii_ind_bus_release
(
port
);
}
void
eth_halt
(
void
)
{
}
int
eth_send
(
volatile
void
*
packet
,
int
len
)
int
sh_eth_send
(
struct
eth_device
*
dev
,
volatile
void
*
packet
,
int
len
)
{
int
port
=
dev
->
port
;
struct
port_info_s
*
port_info
=
&
dev
->
port_info
[
port
];
int
timeout
;
int
rc
=
0
;
struct
sh_eth_dev
*
eth
=
dev
->
priv
;
int
port
=
eth
->
port
,
ret
=
0
,
timeout
;
struct
sh_eth_info
*
port_info
=
&
eth
->
port_info
[
port
];
if
(
!
packet
||
len
>
0xffff
)
{
printf
(
"eth_send: Invalid argument
\n
"
);
return
-
EINVAL
;
printf
(
SHETHER_NAME
": %s: Invalid argument
\n
"
,
__func__
);
ret
=
-
EINVAL
;
goto
err
;
}
/* packet must be a 4 byte boundary */
if
((
int
)
packet
&
(
4
-
1
))
{
printf
(
"eth_send: packet not 4 byte alligned
\n
"
);
return
-
EFAULT
;
printf
(
SHETHER_NAME
": %s: packet not 4 byte alligned
\n
"
,
__func__
);
ret
=
-
EFAULT
;
goto
err
;
}
/* Update tx descriptor */
...
...
@@ -224,24 +215,25 @@ int eth_send(volatile void *packet, int len)
udelay
(
100
);
if
(
timeout
<
0
)
{
printf
(
"eth_send
: transmit timeout
\n
"
);
r
c
=
-
1
;
printf
(
SHETHER_NAME
"
: transmit timeout
\n
"
);
r
et
=
-
ETIMEDOUT
;
goto
err
;
}
err:
port_info
->
tx_desc_cur
++
;
if
(
port_info
->
tx_desc_cur
>=
port_info
->
tx_desc_base
+
NUM_TX_DESC
)
port_info
->
tx_desc_cur
=
port_info
->
tx_desc_base
;
return
rc
;
return
ret
;
err:
return
ret
;
}
int
eth_r
x
(
void
)
int
sh_
eth_r
ecv
(
struct
eth_device
*
dev
)
{
int
port
=
dev
->
p
ort
;
struct
port_info_s
*
port_info
=
&
dev
->
port_info
[
port
]
;
int
len
=
0
;
struct
sh_eth_dev
*
eth
=
dev
->
p
riv
;
int
port
=
eth
->
port
,
len
=
0
;
struct
sh_eth_info
*
port_info
=
&
eth
->
port_info
[
port
]
;
volatile
u8
*
packet
;
/* Check if the rx descriptor is ready */
...
...
@@ -275,10 +267,10 @@ int eth_rx(void)
}
#define EDMR_INIT_CNT 1000
static
int
sh_eth_reset
(
struct
dev_info_s
*
dev
)
static
int
sh_eth_reset
(
struct
sh_eth_dev
*
eth
)
{
int
port
=
dev
->
port
;
int
i
;
int
port
=
eth
->
port
;
int
ret
=
0
,
i
;
/* Start e-dmac transmitter and receiver */
outl
(
EDSR_ENALL
,
EDSR
(
port
));
...
...
@@ -292,33 +284,36 @@ static int sh_eth_reset(struct dev_info_s *dev)
}
if
(
i
==
EDMR_INIT_CNT
)
{
printf
(
"Error
: Software reset timeout
\n
"
);
ret
urn
-
1
;
printf
(
SHETHER_NAME
"
: Software reset timeout
\n
"
);
ret
=
-
EIO
;
}
return
0
;
return
ret
;
}
static
int
sh_eth_tx_desc_init
(
struct
dev_info_s
*
dev
)
static
int
sh_eth_tx_desc_init
(
struct
sh_eth_dev
*
eth
)
{
int
port
=
dev
->
port
;
struct
port_info_s
*
port_info
=
&
dev
->
port_info
[
port
];
int
port
=
eth
->
port
,
i
,
ret
=
0
;
u32
tmp_addr
;
struct
sh_eth_info
*
port_info
=
&
eth
->
port_info
[
port
];
struct
tx_desc_s
*
cur_tx_desc
;
int
i
;
/* Allocate tx descriptors. They must be TX_DESC_SIZE bytes
aligned */
if
(
!
(
port_info
->
tx_desc_malloc
=
malloc
(
NUM_TX_DESC
*
/*
* Allocate tx descriptors. They must be TX_DESC_SIZE bytes aligned
*/
port_info
->
tx_desc_malloc
=
malloc
(
NUM_TX_DESC
*
sizeof
(
struct
tx_desc_s
)
+
TX_DESC_SIZE
-
1
)))
{
printf
(
"Error: malloc failed
\n
"
);
return
-
ENOMEM
;
TX_DESC_SIZE
-
1
);
if
(
!
port_info
->
tx_desc_malloc
)
{
printf
(
SHETHER_NAME
": malloc failed
\n
"
);
ret
=
-
ENOMEM
;
goto
err
;
}
tmp_addr
=
(
u32
)
(((
int
)
port_info
->
tx_desc_malloc
+
TX_DESC_SIZE
-
1
)
&
~
(
TX_DESC_SIZE
-
1
));
/* Make sure we use a P2 address (non-cacheable) */
port_info
->
tx_desc_base
=
(
struct
tx_desc_s
*
)
ADDR_TO_P2
(
tmp_addr
);
port_info
->
tx_desc_cur
=
port_info
->
tx_desc_base
;
/* Initialize all descriptors */
...
...
@@ -340,26 +335,30 @@ static int sh_eth_tx_desc_init(struct dev_info_s *dev)
outl
(
ADDR_TO_PHY
(
cur_tx_desc
),
TDFXR
(
port
));
outl
(
0x01
,
TDFFR
(
port
));
/* Last discriptor bit */
return
0
;
err:
return
ret
;
}
static
int
sh_eth_rx_desc_init
(
struct
dev_info_s
*
dev
)
static
int
sh_eth_rx_desc_init
(
struct
sh_eth_dev
*
eth
)
{
int
port
=
dev
->
port
;
struct
port_info_s
*
port_info
=
&
dev
->
port_info
[
port
];
u32
tmp_addr
;
int
port
=
eth
->
port
,
i
,
ret
=
0
;
struct
sh_eth_info
*
port_info
=
&
eth
->
port_info
[
port
];
struct
rx_desc_s
*
cur_rx_desc
;
u32
tmp_addr
;
u8
*
rx_buf
;
int
i
;
/* Allocate rx descriptors. They must be RX_DESC_SIZE bytes
aligned */
if
(
!
(
port_info
->
rx_desc_malloc
=
malloc
(
NUM_RX_DESC
*
/*
* Allocate rx descriptors. They must be RX_DESC_SIZE bytes aligned
*/
port_info
->
rx_desc_malloc
=
malloc
(
NUM_RX_DESC
*
sizeof
(
struct
rx_desc_s
)
+
RX_DESC_SIZE
-
1
)))
{
printf
(
"Error: malloc failed
\n
"
);
return
-
ENOMEM
;
RX_DESC_SIZE
-
1
);
if
(
!
port_info
->
rx_desc_malloc
)
{
printf
(
SHETHER_NAME
": malloc failed
\n
"
);
ret
=
-
ENOMEM
;
goto
err
;
}
tmp_addr
=
(
u32
)
(((
int
)
port_info
->
rx_desc_malloc
+
RX_DESC_SIZE
-
1
)
&
~
(
RX_DESC_SIZE
-
1
));
/* Make sure we use a P2 address (non-cacheable) */
...
...
@@ -367,15 +366,17 @@ static int sh_eth_rx_desc_init(struct dev_info_s *dev)
port_info
->
rx_desc_cur
=
port_info
->
rx_desc_base
;
/* Allocate rx data buffers. They must be 32 bytes aligned and in
P2 area */
if
(
!
(
port_info
->
rx_buf_malloc
=
malloc
(
NUM_RX_DESC
*
MAX_BUF_SIZE
+
31
)))
{
printf
(
"Error: malloc failed
\n
"
);
free
(
port_info
->
rx_desc_malloc
);
port_info
->
rx_desc_malloc
=
NULL
;
return
-
ENOMEM
;
/*
* Allocate rx data buffers. They must be 32 bytes aligned and in
* P2 area
*/
port_info
->
rx_buf_malloc
=
malloc
(
NUM_RX_DESC
*
MAX_BUF_SIZE
+
31
);
if
(
!
port_info
->
rx_buf_malloc
)
{
printf
(
SHETHER_NAME
": malloc failed
\n
"
);
ret
=
-
ENOMEM
;
goto
err_buf_malloc
;
}
tmp_addr
=
(
u32
)(((
int
)
port_info
->
rx_buf_malloc
+
(
32
-
1
))
&
~
(
32
-
1
));
port_info
->
rx_buf_base
=
(
u8
*
)
ADDR_TO_P2
(
tmp_addr
);
...
...
@@ -399,18 +400,31 @@ static int sh_eth_rx_desc_init(struct dev_info_s *dev)
outl
(
ADDR_TO_PHY
(
cur_rx_desc
),
RDFXR
(
port
));
outl
(
RDFFR_RDLF
,
RDFFR
(
port
));
return
0
;
return
ret
;
err_buf_malloc:
free
(
port_info
->
rx_desc_malloc
);
port_info
->
rx_desc_malloc
=
NULL
;
err:
return
ret
;
}
static
void
sh_eth_desc_free
(
struct
dev_info_s
*
dev
)
static
void
sh_eth_
tx_
desc_free
(
struct
sh_eth_dev
*
eth
)
{
int
port
=
dev
->
port
;
struct
port
_info
_s
*
port_info
=
&
dev
->
port_info
[
port
];
int
port
=
eth
->
port
;
struct
sh_eth
_info
*
port_info
=
&
eth
->
port_info
[
port
];
if
(
port_info
->
tx_desc_malloc
)
{
free
(
port_info
->
tx_desc_malloc
);
port_info
->
tx_desc_malloc
=
NULL
;
}
}
static
void
sh_eth_rx_desc_free
(
struct
sh_eth_dev
*
eth
)
{
int
port
=
eth
->
port
;
struct
sh_eth_info
*
port_info
=
&
eth
->
port_info
[
port
];
if
(
port_info
->
rx_desc_malloc
)
{
free
(
port_info
->
rx_desc_malloc
);
...
...
@@ -423,36 +437,48 @@ static void sh_eth_desc_free(struct dev_info_s *dev)
}
}
static
int
sh_eth_desc_init
(
struct
dev_info_s
*
dev
)
static
int
sh_eth_desc_init
(
struct
sh_eth_dev
*
eth
)
{
int
r
c
;
int
r
et
=
0
;
if
((
rc
=
sh_eth_tx_desc_init
(
dev
))
||
(
rc
=
sh_eth_rx_desc_init
(
dev
)))
{
sh_eth_desc_free
(
dev
);
return
rc
;
}
ret
=
sh_eth_tx_desc_init
(
eth
);
if
(
ret
)
goto
err_tx_init
;
return
0
;
ret
=
sh_eth_rx_desc_init
(
eth
);
if
(
ret
)
goto
err_rx_init
;
return
ret
;
err_rx_init:
sh_eth_tx_desc_free
(
eth
);
err_tx_init:
return
ret
;
}
static
int
sh_eth_phy_config
(
struct
dev_info_s
*
dev
)
static
int
sh_eth_phy_config
(
struct
sh_eth_dev
*
eth
)
{
int
port
=
dev
->
port
;
struct
port_info_s
*
port_info
=
&
dev
->
port_info
[
port
];
int
timeout
;
int
port
=
eth
->
port
,
timeout
,
ret
=
0
;
struct
sh_eth_info
*
port_info
=
&
eth
->
port_info
[
port
];
u32
val
;
/* Reset phy */
sh_eth_mii_write_phy_reg
(
port
,
port_info
->
phy_addr
,
PHY_CTRL
,
PHY_C_RESET
);
sh_eth_mii_write_phy_reg
(
port
,
port_info
->
phy_addr
,
PHY_CTRL
,
PHY_C_RESET
);
timeout
=
10
;
while
(
timeout
--
)
{
val
=
sh_eth_mii_read_phy_reg
(
port
,
port_info
->
phy_addr
,
PHY_CTRL
);
val
=
sh_eth_mii_read_phy_reg
(
port
,
port_info
->
phy_addr
,
PHY_CTRL
);
if
(
!
(
val
&
PHY_C_RESET
))
break
;
udelay
(
50000
);
udelay
(
SH_ETH_PHY_DELAY
);
}
if
(
timeout
<
0
)
{
printf
(
"%s phy reset timeout
\n
"
,
__func__
);
return
-
1
;
printf
(
SHETHER_NAME
": phy reset timeout
\n
"
);
ret
=
-
EIO
;
goto
err_tout
;
}
/* Advertise 100/10 baseT full/half duplex */
...
...
@@ -467,23 +493,27 @@ static int sh_eth_phy_config(struct dev_info_s *dev)
val
=
sh_eth_mii_read_phy_reg
(
port
,
port_info
->
phy_addr
,
1
);
if
(
val
&
PHY_S_ANEGC
)
break
;
udelay
(
50000
);
udelay
(
SH_ETH_PHY_DELAY
);
}
if
(
timeout
<
0
)
{
printf
(
"sh_eth_phy_config() phy auto-negotiation failed
\n
"
);
return
-
1
;
printf
(
SHETHER_NAME
": phy auto-negotiation failed
\n
"
);
ret
=
-
ETIMEDOUT
;
goto
err_tout
;
}
return
0
;
return
ret
;
err_tout:
return
ret
;
}
static
int
sh_eth_config
(
struct
dev_info_s
*
dev
,
bd_t
*
bd
)
static
int
sh_eth_config
(
struct
sh_eth_dev
*
eth
,
bd_t
*
bd
)
{
int
port
=
dev
->
port
;
struct
port_info_s
*
port_info
=
&
dev
->
port_info
[
port
];
u32
val
;
u32
phy_status
;
int
rc
;
int
port
=
eth
->
port
,
ret
=
0
;
u32
val
,
phy_status
;