Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/44x: Add more changes for APM821XX EMAC driver

This patch includes:

Configure EMAC PHY clock source (clock from PHY or internal clock).

Do not advertise PHY half duplex capability as APM821XX EMAC does not support half duplex mode.

Add changes to support configuring jumbo frame for APM821XX EMAC.

[ Fix coding style -DaveM ]

Signed-off-by: Duc Dang <dhdang@apm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Duc Dang and committed by
David S. Miller
ae5d3372 8dfc2b45

+41 -3
+28 -1
drivers/net/ethernet/ibm/emac/core.c
··· 434 434 else if (!netdev_mc_empty(ndev)) 435 435 r |= EMAC_RMR_MAE; 436 436 437 + if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) { 438 + r &= ~EMAC4_RMR_MJS_MASK; 439 + r |= EMAC4_RMR_MJS(ndev->mtu); 440 + } 441 + 437 442 return r; 438 443 } 439 444 ··· 970 965 int rx_sync_size = emac_rx_sync_size(new_mtu); 971 966 int rx_skb_size = emac_rx_skb_size(new_mtu); 972 967 int i, ret = 0; 968 + int mr1_jumbo_bit_change = 0; 973 969 974 970 mutex_lock(&dev->link_lock); 975 971 emac_netif_stop(dev); ··· 1019 1013 } 1020 1014 skip: 1021 1015 /* Check if we need to change "Jumbo" bit in MR1 */ 1022 - if ((new_mtu > ETH_DATA_LEN) ^ (dev->ndev->mtu > ETH_DATA_LEN)) { 1016 + if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) { 1017 + mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) || 1018 + (dev->ndev->mtu > ETH_DATA_LEN); 1019 + } else { 1020 + mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ^ 1021 + (dev->ndev->mtu > ETH_DATA_LEN); 1022 + } 1023 + 1024 + if (mr1_jumbo_bit_change) { 1023 1025 /* This is to prevent starting RX channel in emac_rx_enable() */ 1024 1026 set_bit(MAL_COMMAC_RX_STOPPED, &dev->commac.flags); 1025 1027 ··· 2485 2471 2486 2472 /* Disable any PHY features not supported by the platform */ 2487 2473 dev->phy.def->features &= ~dev->phy_feat_exc; 2474 + dev->phy.features &= ~dev->phy_feat_exc; 2488 2475 2489 2476 /* Setup initial link parameters */ 2490 2477 if (dev->phy.features & SUPPORTED_Autoneg) { ··· 2583 2568 if (of_device_is_compatible(np, "ibm,emac-405ex") || 2584 2569 of_device_is_compatible(np, "ibm,emac-405exr")) 2585 2570 dev->features |= EMAC_FTR_440EP_PHY_CLK_FIX; 2571 + if (of_device_is_compatible(np, "ibm,emac-apm821xx")) { 2572 + dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE | 2573 + EMAC_FTR_APM821XX_NO_HALF_DUPLEX | 2574 + EMAC_FTR_460EX_PHY_CLK_FIX); 2575 + } 2586 2576 } else if (of_device_is_compatible(np, "ibm,emac4")) { 2587 2577 dev->features |= EMAC_FTR_EMAC4; 2588 2578 if (of_device_is_compatible(np, "ibm,emac-440gx")) ··· 2835 2815 dev->phy.pause = dev->phy.asym_pause = 0; 2836 2816 dev->stop_timeout = STOP_TIMEOUT_100; 2837 2817 INIT_DELAYED_WORK(&dev->link_work, emac_link_timer); 2818 + 2819 + /* Some SoCs like APM821xx does not support Half Duplex mode. */ 2820 + if (emac_has_feature(dev, EMAC_FTR_APM821XX_NO_HALF_DUPLEX)) { 2821 + dev->phy_feat_exc = (SUPPORTED_1000baseT_Half | 2822 + SUPPORTED_100baseT_Half | 2823 + SUPPORTED_10baseT_Half); 2824 + } 2838 2825 2839 2826 /* Find PHY if any */ 2840 2827 err = emac_init_phy(dev);
+11 -2
drivers/net/ethernet/ibm/emac/core.h
··· 325 325 * Set if we need phy clock workaround for 460ex or 460gt 326 326 */ 327 327 #define EMAC_FTR_460EX_PHY_CLK_FIX 0x00000400 328 - 328 + /* 329 + * APM821xx requires Jumbo frame size set explicitly 330 + */ 331 + #define EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE 0x00000800 332 + /* 333 + * APM821xx does not support Half Duplex mode 334 + */ 335 + #define EMAC_FTR_APM821XX_NO_HALF_DUPLEX 0x00001000 329 336 330 337 /* Right now, we don't quite handle the always/possible masks on the 331 338 * most optimal way as we don't have a way to say something like ··· 360 353 EMAC_FTR_NO_FLOW_CONTROL_40x | 361 354 #endif 362 355 EMAC_FTR_460EX_PHY_CLK_FIX | 363 - EMAC_FTR_440EP_PHY_CLK_FIX, 356 + EMAC_FTR_440EP_PHY_CLK_FIX | 357 + EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE | 358 + EMAC_FTR_APM821XX_NO_HALF_DUPLEX, 364 359 }; 365 360 366 361 static inline int emac_has_feature(struct emac_instance *dev,
+2
drivers/net/ethernet/ibm/emac/emac.h
··· 212 212 #define EMAC4_RMR_RFAF_64_1024 0x00000006 213 213 #define EMAC4_RMR_RFAF_128_2048 0x00000007 214 214 #define EMAC4_RMR_BASE EMAC4_RMR_RFAF_128_2048 215 + #define EMAC4_RMR_MJS_MASK 0x0001fff8 216 + #define EMAC4_RMR_MJS(s) (((s) << 3) & EMAC4_RMR_MJS_MASK) 215 217 216 218 /* EMACx_ISR & EMACx_ISER */ 217 219 #define EMAC4_ISR_TXPE 0x20000000