Commit 9afc1af01f2d4b033e0da5df105b399949976a12
Committed by
Albert ARIBAUD
1 parent
8eb0ee6a64
Exists in
master
and in
54 other branches
SPEAr: Add interface information in initialization
Few Designware peripheral registers need to be modified based on the ethernet interface selected by the board. This patch supports interface information in ethernet driver Signed-off-by: Vipin Kumar <vipin.kumar@st.com> Signed-off-by: Amit Virdi <amit.virdi@st.com> Signed-off-by: Stefan Roese <sr@denx.de>
Showing 7 changed files with 61 additions and 22 deletions Side-by-side Diff
board/spear/spear300/spear300.c
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | */ |
23 | 23 | |
24 | 24 | #include <common.h> |
25 | +#include <miiphy.h> | |
25 | 26 | #include <netdev.h> |
26 | 27 | #include <nand.h> |
27 | 28 | #include <asm/io.h> |
28 | 29 | |
29 | 30 | |
... | ... | @@ -64,10 +65,14 @@ |
64 | 65 | |
65 | 66 | int board_eth_init(bd_t *bis) |
66 | 67 | { |
68 | + int ret = 0; | |
69 | + | |
67 | 70 | #if defined(CONFIG_DESIGNWARE_ETH) |
68 | - return designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY); | |
69 | -#else | |
70 | - return -1; | |
71 | + u32 interface = PHY_INTERFACE_MODE_MII; | |
72 | + if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY, | |
73 | + interface) >= 0) | |
74 | + ret++; | |
71 | 75 | #endif |
76 | + return ret; | |
72 | 77 | } |
board/spear/spear310/spear310.c
... | ... | @@ -23,6 +23,7 @@ |
23 | 23 | */ |
24 | 24 | |
25 | 25 | #include <common.h> |
26 | +#include <miiphy.h> | |
26 | 27 | #include <netdev.h> |
27 | 28 | #include <nand.h> |
28 | 29 | #include <asm/io.h> |
29 | 30 | |
30 | 31 | |
31 | 32 | |
32 | 33 | |
... | ... | @@ -68,25 +69,27 @@ |
68 | 69 | int ret = 0; |
69 | 70 | |
70 | 71 | #if defined(CONFIG_DESIGNWARE_ETH) |
71 | - if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY) < 0) | |
72 | - ret += -1; | |
72 | + u32 interface = PHY_INTERFACE_MODE_MII; | |
73 | + if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY, | |
74 | + interface) >= 0) | |
75 | + ret++; | |
73 | 76 | #endif |
74 | 77 | #if defined(CONFIG_MACB) |
75 | 78 | if (macb_eth_initialize(0, (void *)CONFIG_SYS_MACB0_BASE, |
76 | - CONFIG_MACB0_PHY) < 0) | |
77 | - ret += -1; | |
79 | + CONFIG_MACB0_PHY) >= 0) | |
80 | + ret++; | |
78 | 81 | |
79 | 82 | if (macb_eth_initialize(1, (void *)CONFIG_SYS_MACB1_BASE, |
80 | - CONFIG_MACB1_PHY) < 0) | |
81 | - ret += -1; | |
83 | + CONFIG_MACB1_PHY) >= 0) | |
84 | + ret++; | |
82 | 85 | |
83 | 86 | if (macb_eth_initialize(2, (void *)CONFIG_SYS_MACB2_BASE, |
84 | - CONFIG_MACB2_PHY) < 0) | |
85 | - ret += -1; | |
87 | + CONFIG_MACB2_PHY) >= 0) | |
88 | + ret++; | |
86 | 89 | |
87 | 90 | if (macb_eth_initialize(3, (void *)CONFIG_SYS_MACB3_BASE, |
88 | - CONFIG_MACB3_PHY) < 0) | |
89 | - ret += -1; | |
91 | + CONFIG_MACB3_PHY) >= 0) | |
92 | + ret++; | |
90 | 93 | #endif |
91 | 94 | return ret; |
92 | 95 | } |
board/spear/spear320/spear320.c
... | ... | @@ -23,6 +23,7 @@ |
23 | 23 | */ |
24 | 24 | |
25 | 25 | #include <common.h> |
26 | +#include <miiphy.h> | |
26 | 27 | #include <netdev.h> |
27 | 28 | #include <nand.h> |
28 | 29 | #include <asm/io.h> |
29 | 30 | |
30 | 31 | |
... | ... | @@ -31,10 +32,20 @@ |
31 | 32 | #include <asm/arch/spr_defs.h> |
32 | 33 | #include <asm/arch/spr_misc.h> |
33 | 34 | |
35 | +#define PLGPIO_SEL_36 0xb3000028 | |
36 | +#define PLGPIO_IO_36 0xb3000038 | |
37 | + | |
34 | 38 | static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; |
35 | 39 | |
40 | +static void spear_phy_reset(void) | |
41 | +{ | |
42 | + writel(0x10, PLGPIO_IO_36); | |
43 | + writel(0x10, PLGPIO_SEL_36); | |
44 | +} | |
45 | + | |
36 | 46 | int board_init(void) |
37 | 47 | { |
48 | + spear_phy_reset(); | |
38 | 49 | return spear_board_init(MACH_TYPE_SPEAR320); |
39 | 50 | } |
40 | 51 | |
41 | 52 | |
42 | 53 | |
... | ... | @@ -67,14 +78,17 @@ |
67 | 78 | int board_eth_init(bd_t *bis) |
68 | 79 | { |
69 | 80 | int ret = 0; |
81 | + | |
70 | 82 | #if defined(CONFIG_DESIGNWARE_ETH) |
71 | - if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY) < 0) | |
72 | - ret += -1; | |
83 | + u32 interface = PHY_INTERFACE_MODE_MII; | |
84 | + if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY, | |
85 | + interface) >= 0) | |
86 | + ret++; | |
73 | 87 | #endif |
74 | 88 | #if defined(CONFIG_MACB) |
75 | 89 | if (macb_eth_initialize(0, (void *)CONFIG_SYS_MACB0_BASE, |
76 | - CONFIG_MACB0_PHY) < 0) | |
77 | - ret += -1; | |
90 | + CONFIG_MACB0_PHY) >= 0) | |
91 | + ret++; | |
78 | 92 | #endif |
79 | 93 | return ret; |
80 | 94 | } |
board/spear/spear600/spear600.c
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | */ |
23 | 23 | |
24 | 24 | #include <common.h> |
25 | +#include <miiphy.h> | |
25 | 26 | #include <netdev.h> |
26 | 27 | #include <nand.h> |
27 | 28 | #include <asm/io.h> |
28 | 29 | |
29 | 30 | |
... | ... | @@ -59,10 +60,17 @@ |
59 | 60 | |
60 | 61 | int board_eth_init(bd_t *bis) |
61 | 62 | { |
63 | + int ret = 0; | |
64 | + | |
62 | 65 | #if defined(CONFIG_DESIGNWARE_ETH) |
63 | - return designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY); | |
64 | -#else | |
65 | - return -1; | |
66 | + u32 interface = PHY_INTERFACE_MODE_MII; | |
67 | +#if defined(CONFIG_DW_AUTONEG) | |
68 | + interface = PHY_INTERFACE_MODE_GMII; | |
66 | 69 | #endif |
70 | + if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY, | |
71 | + interface) >= 0) | |
72 | + ret++; | |
73 | +#endif | |
74 | + return ret; | |
67 | 75 | } |
drivers/net/designware.c
... | ... | @@ -171,6 +171,13 @@ |
171 | 171 | if (priv->speed != SPEED_1000M) |
172 | 172 | conf |= MII_PORTSELECT; |
173 | 173 | |
174 | + if ((priv->interface != PHY_INTERFACE_MODE_MII) && | |
175 | + (priv->interface != PHY_INTERFACE_MODE_GMII)) { | |
176 | + | |
177 | + if (priv->speed == SPEED_100M) | |
178 | + conf |= FES_100; | |
179 | + } | |
180 | + | |
174 | 181 | if (priv->duplex == FULL_DUPLEX) |
175 | 182 | conf |= FULLDPLXMODE; |
176 | 183 | |
... | ... | @@ -531,7 +538,7 @@ |
531 | 538 | } |
532 | 539 | #endif |
533 | 540 | |
534 | -int designware_initialize(u32 id, ulong base_addr, u32 phy_addr) | |
541 | +int designware_initialize(u32 id, ulong base_addr, u32 phy_addr, u32 interface) | |
535 | 542 | { |
536 | 543 | struct eth_device *dev; |
537 | 544 | struct dw_eth_dev *priv; |
... | ... | @@ -565,6 +572,7 @@ |
565 | 572 | DW_DMA_BASE_OFFSET); |
566 | 573 | priv->address = phy_addr; |
567 | 574 | priv->phy_configured = 0; |
575 | + priv->interface = interface; | |
568 | 576 | |
569 | 577 | if (mac_reset(dev) < 0) |
570 | 578 | return -1; |
drivers/net/designware.h
include/netdev.h
... | ... | @@ -52,7 +52,7 @@ |
52 | 52 | int cs8900_initialize(u8 dev_num, int base_addr); |
53 | 53 | int davinci_emac_initialize(void); |
54 | 54 | int dc21x4x_initialize(bd_t *bis); |
55 | -int designware_initialize(u32 id, ulong base_addr, u32 phy_addr); | |
55 | +int designware_initialize(u32 id, ulong base_addr, u32 phy_addr, u32 interface); | |
56 | 56 | int dm9000_initialize(bd_t *bis); |
57 | 57 | int dnet_eth_initialize(int id, void *regs, unsigned int phy_addr); |
58 | 58 | int e1000_initialize(bd_t *bis); |