|
201 | 201 | # define BOARD_PHY_10BASET(s) (((s) & MII_DP83825I_PHYSTS_SPEED) != 0)
|
202 | 202 | # define BOARD_PHY_100BASET(s) (((s) & MII_DP83825I_PHYSTS_SPEED) == 0)
|
203 | 203 | # define BOARD_PHY_ISDUPLEX(s) (((s) & MII_DP83825I_PHYSTS_DUPLEX) != 0)
|
| 204 | +#elif defined(CONFIG_ETH0_PHY_AR8031) |
| 205 | +# define BOARD_PHY_NAME "AR8031" |
| 206 | +# define BOARD_PHYID1 MII_PHYID1_AR8031 |
| 207 | +# define BOARD_PHYID2 MII_PHYID2_AR8031 |
| 208 | +# define BOARD_PHY_STATUS MII_AR8031_PSSR |
| 209 | +# define BOARD_PHY_ADDR (1) |
| 210 | +# define BOARD_PHY_10BASET(s) (((s) & MII_AR8031_PSSR_10MBPS) == ((s) & MII_AR8031_PSSR_SPEEDMASK)) |
| 211 | +# define BOARD_PHY_100BASET(s) (((s) & MII_AR8031_PSSR_100MBPS) == ((s) & MII_AR8031_PSSR_SPEEDMASK)) |
| 212 | +# define BOARD_PHY_1000BASET(s) (((s) & MII_AR8031_PSSR_1000MBPS) == ((s) & MII_AR8031_PSSR_SPEEDMASK)) |
| 213 | +# define BOARD_PHY_ISDUPLEX(s) (((s) & MII_AR8031_PSSR_DUPLEX) != 0) |
204 | 214 | #else
|
205 | 215 | # error "Unrecognized or missing PHY selection"
|
206 | 216 | #endif
|
|
216 | 226 | * = 23
|
217 | 227 | */
|
218 | 228 |
|
219 |
| -#define IMX_MII_SPEED 0x38 /* 100Mbs. Revisit and remove hardcoded value */ |
| 229 | +#define IMX_MII_SPEED 0xd /* 1000Mbs. Revisit and remove hardcoded value */ |
220 | 230 | #if IMX_MII_SPEED > 63
|
221 | 231 | # error "IMX_MII_SPEED is out-of-range"
|
222 | 232 | #endif
|
@@ -377,7 +387,7 @@ static int imx_phyintenable(struct imx_driver_s *priv);
|
377 | 387 | #endif
|
378 | 388 | static inline void imx_initmii(struct imx_driver_s *priv);
|
379 | 389 |
|
380 |
| -#if 0 /* TODO */ |
| 390 | +#ifndef CONFIG_IMX_ENET_WITH_QEMU |
381 | 391 | static int imx_writemii(struct imx_driver_s *priv, uint8_t phyaddr,
|
382 | 392 | uint8_t regaddr, uint16_t data);
|
383 | 393 | static int imx_readmii(struct imx_driver_s *priv, uint8_t phyaddr,
|
@@ -1327,13 +1337,18 @@ static int imx_ifup_action(struct net_driver_s *dev, bool resetphy)
|
1327 | 1337 | /* And enable the MAC itself */
|
1328 | 1338 |
|
1329 | 1339 | regval = imx_enet_getreg32(priv, IMX_ENET_ECR_OFFSET);
|
1330 |
| - regval |= ENET_ECR_ETHEREN |
| 1340 | + regval |= ENET_ECR_ETHEREN | ENET_ECR_SPEED |
1331 | 1341 | #ifdef IMX_USE_DBSWAP
|
1332 | 1342 | | ENET_ECR_DBSWP
|
1333 | 1343 | #endif
|
1334 | 1344 | ;
|
| 1345 | + |
1335 | 1346 | imx_enet_putreg32(priv, regval, IMX_ENET_ECR_OFFSET);
|
1336 | 1347 |
|
| 1348 | + /* Set TX FIFO write to avoid TX FIFO underrun */ |
| 1349 | + |
| 1350 | + imx_enet_putreg32(priv, 0x3f, IMX_ENET_TFWR_OFFSET); |
| 1351 | + |
1337 | 1352 | /* Indicate that there have been empty receive buffers produced */
|
1338 | 1353 |
|
1339 | 1354 | imx_enet_putreg32(priv, ENET_RDAR, IMX_ENET_RDAR_OFFSET);
|
@@ -1873,7 +1888,7 @@ static void imx_initmii(struct imx_driver_s *priv)
|
1873 | 1888 | *
|
1874 | 1889 | ****************************************************************************/
|
1875 | 1890 |
|
1876 |
| -#if 0 /* TODO */ |
| 1891 | +#ifndef CONFIG_IMX_ENET_WITH_QEMU |
1877 | 1892 | static int imx_writemii(struct imx_driver_s *priv, uint8_t phyaddr,
|
1878 | 1893 | uint8_t regaddr, uint16_t data)
|
1879 | 1894 | {
|
@@ -1935,7 +1950,7 @@ static int imx_writemii(struct imx_driver_s *priv, uint8_t phyaddr,
|
1935 | 1950 | *
|
1936 | 1951 | ****************************************************************************/
|
1937 | 1952 |
|
1938 |
| -#if 0 /* TODO */ |
| 1953 | +#ifndef CONFIG_IMX_ENET_WITH_QEMU |
1939 | 1954 | static int imx_readmii(struct imx_driver_s *priv, uint8_t phyaddr,
|
1940 | 1955 | uint8_t regaddr, uint16_t *data)
|
1941 | 1956 | {
|
@@ -2005,7 +2020,7 @@ static int imx_readmii(struct imx_driver_s *priv, uint8_t phyaddr,
|
2005 | 2020 |
|
2006 | 2021 | static inline int imx_initphy(struct imx_driver_s *priv, bool renogphy)
|
2007 | 2022 | {
|
2008 |
| -#if 0 /* TODO */ |
| 2023 | +#ifndef CONFIG_IMX_ENET_WITH_QEMU |
2009 | 2024 | uint32_t rcr;
|
2010 | 2025 | uint32_t tcr;
|
2011 | 2026 | uint32_t racc;
|
@@ -2160,6 +2175,23 @@ static inline int imx_initphy(struct imx_driver_s *priv, bool renogphy)
|
2160 | 2175 | MII_ADVERTISE_10BASETXHALF |
|
2161 | 2176 | MII_ADVERTISE_CSMA);
|
2162 | 2177 |
|
| 2178 | +#elif defined (CONFIG_ETH0_PHY_AR8031) |
| 2179 | + |
| 2180 | + /* Advertise Gigabit support */ |
| 2181 | + |
| 2182 | + imx_writemii(priv, phyaddr, MII_ADVERTISE, |
| 2183 | + MII_ADVERTISE_1000XFULL | |
| 2184 | + MII_ADVERTISE_1000XHALF | |
| 2185 | + MII_ADVERTISE_100BASETXFULL | |
| 2186 | + MII_ADVERTISE_100BASETXHALF | |
| 2187 | + MII_ADVERTISE_10BASETXFULL | |
| 2188 | + MII_ADVERTISE_10BASETXHALF | |
| 2189 | + MII_ADVERTISE_CSMA); |
| 2190 | + |
| 2191 | + /* Then reset PHY */ |
| 2192 | + |
| 2193 | + ninfo("AR8031: *** reset phy (phyaddr=0x%x) \n", phyaddr); |
| 2194 | + imx_writemii(priv, phyaddr, MII_MCR, MII_MCR_RESET); |
2163 | 2195 | #endif
|
2164 | 2196 |
|
2165 | 2197 | /* Start auto negotiation */
|
@@ -2253,16 +2285,13 @@ static inline int imx_initphy(struct imx_driver_s *priv, bool renogphy)
|
2253 | 2285 | * configuration and the auto negotiation results.
|
2254 | 2286 | */
|
2255 | 2287 |
|
2256 |
| -#ifdef CONFIG_IMX_ENETUSEMII |
2257 | 2288 | rcr = ENET_RCR_CRCFWD |
|
2258 | 2289 | (CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE)
|
2259 | 2290 | << ENET_RCR_MAX_FL_SHIFT |
|
| 2291 | +#ifdef CONFIG_IMX_ENETUSEMII |
2260 | 2292 | ENET_RCR_MII_MODE;
|
2261 | 2293 | #else
|
2262 |
| - rcr = ENET_RCR_RMII_MODE | ENET_RCR_CRCFWD | |
2263 |
| - (CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE) |
2264 |
| - << ENET_RCR_MAX_FL_SHIFT | |
2265 |
| - ENET_RCR_MII_MODE; |
| 2294 | + ENET_RCR_RGMII_EN; |
2266 | 2295 | #endif
|
2267 | 2296 | tcr = 0;
|
2268 | 2297 |
|
@@ -2307,6 +2336,14 @@ static inline int imx_initphy(struct imx_driver_s *priv, bool renogphy)
|
2307 | 2336 |
|
2308 | 2337 | ninfo("%s: 100 Base-T\n", BOARD_PHY_NAME);
|
2309 | 2338 | }
|
| 2339 | +#ifdef CONFIG_ETH0_PHY_AR8031 |
| 2340 | + else if (BOARD_PHY_1000BASET(phydata)) |
| 2341 | + { |
| 2342 | + /* 1000 Mbps */ |
| 2343 | + |
| 2344 | + ninfo("%s: 1000 Base-T\n", BOARD_PHY_NAME); |
| 2345 | + } |
| 2346 | +#endif |
2310 | 2347 | else
|
2311 | 2348 | {
|
2312 | 2349 | /* This might happen if Autonegotiation did not complete(?) */
|
@@ -2488,7 +2525,7 @@ int imx_netinitialize(int intf)
|
2488 | 2525 | #endif
|
2489 | 2526 | priv->dev.d_private = g_enet; /* Used to recover private state from dev */
|
2490 | 2527 |
|
2491 |
| -#if 0 /* TODO */ |
| 2528 | +#if 0 /* NOTE: clock & iomux are set in u-boot */ |
2492 | 2529 | uint32_t regval;
|
2493 | 2530 |
|
2494 | 2531 | /* Configure ENET1_TX_CLK */
|
@@ -2519,7 +2556,7 @@ int imx_netinitialize(int intf)
|
2519 | 2556 | imx_config_gpio(GPIO_ENET_RX_ER);
|
2520 | 2557 | #endif
|
2521 | 2558 |
|
2522 |
| -#endif /* TODO */ |
| 2559 | +#endif /* if 0 */ |
2523 | 2560 |
|
2524 | 2561 | /* Attach the Ethernet MAC IEEE 1588 timer interrupt handler */
|
2525 | 2562 |
|
@@ -2556,16 +2593,16 @@ int imx_netinitialize(int intf)
|
2556 | 2593 |
|
2557 | 2594 | /* hardcoded offset: todo: need proper header file */
|
2558 | 2595 |
|
2559 |
| -#if 0 /* TODO */ |
2560 |
| - uidl = getreg32(IMX_OCOTP_BASE + 0x410); |
2561 |
| - uidml = getreg32(IMX_OCOTP_BASE + 0x420); |
| 2596 | +#ifndef CONFIG_IMX_ENET_WITH_QEMU |
| 2597 | + uidl = getreg32(IMX_OCOTPCTRL_VBASE + 0x620); |
| 2598 | + uidml = getreg32(IMX_OCOTPCTRL_VBASE + 0x630); |
| 2599 | +#else |
| 2600 | + uidml |= 0x00000200; |
| 2601 | + uidml &= 0x0000feff; |
2562 | 2602 | #endif
|
2563 | 2603 |
|
2564 | 2604 | mac = priv->dev.d_mac.ether.ether_addr_octet;
|
2565 | 2605 |
|
2566 |
| - uidml |= 0x00000200; |
2567 |
| - uidml &= 0x0000feff; |
2568 |
| - |
2569 | 2606 | mac[0] = (uidml & 0x0000ff00) >> 8;
|
2570 | 2607 | mac[1] = (uidml & 0x000000ff);
|
2571 | 2608 | mac[2] = (uidl & 0xff000000) >> 24;
|
|
0 commit comments