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

Merge branch 'stmmac-cleanups'

Corentin Labbe says:

====================
net: stmmac: misc fix

I am currently working on dwmac-sun8i glue driver for Allwinner H3/A83T/A64.
This series is the result of all minor problem found in the stmmac driver.

All patch are tested on cubieboard2 via dwmac-sunxi and on pine64/orangepis via dwmac-sun8i.

Changes since v1:
- Removed netdev_dbg() in "net: stmmac: print phy information"
- Removed patch "net: stmmac: Implement NAPI for TX", it will be reworked
- Changed error message in "Correct the error message about invalid speed"
- Added some acked-by
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+51 -185
-4
drivers/net/ethernet/stmicro/stmmac/chain_mode.c
··· 16 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17 17 more details. 18 18 19 - You should have received a copy of the GNU General Public License along with 20 - this program; if not, write to the Free Software Foundation, Inc., 21 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 22 - 23 19 The full GNU General Public License is included in this distribution in 24 20 the file called "COPYING". 25 21
+2 -6
drivers/net/ethernet/stmicro/stmmac/common.h
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17 ··· 67 71 unsigned long overflow_error; 68 72 unsigned long ipc_csum_error; 69 73 unsigned long rx_collision; 70 - unsigned long rx_crc; 74 + unsigned long rx_crc_errors; 71 75 unsigned long dribbling_bit; 72 76 unsigned long rx_length; 73 77 unsigned long rx_mii; ··· 339 343 /* Common MAC defines */ 340 344 #define MAC_CTRL_REG 0x00000000 /* MAC Control */ 341 345 #define MAC_ENABLE_TX 0x00000008 /* Transmitter Enable */ 342 - #define MAC_RNABLE_RX 0x00000004 /* Receiver Enable */ 346 + #define MAC_ENABLE_RX 0x00000004 /* Receiver Enable */ 343 347 344 348 /* Default LPI timers */ 345 349 #define STMMAC_DEFAULT_LIT_LS 0x3E8
-4
drivers/net/ethernet/stmicro/stmmac/descs.h
··· 11 11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 12 more details. 13 13 14 - You should have received a copy of the GNU General Public License along with 15 - this program; if not, write to the Free Software Foundation, Inc., 16 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 - 18 14 The full GNU General Public License is included in this distribution in 19 15 the file called "COPYING". 20 16
-4
drivers/net/ethernet/stmicro/stmmac/descs_com.h
··· 17 17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 18 18 more details. 19 19 20 - You should have received a copy of the GNU General Public License along with 21 - this program; if not, write to the Free Software Foundation, Inc., 22 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 23 - 24 20 The full GNU General Public License is included in this distribution in 25 21 the file called "COPYING". 26 22
-4
drivers/net/ethernet/stmicro/stmmac/dwmac100.h
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17
-4
drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
··· 10 10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 11 more details. 12 12 13 - You should have received a copy of the GNU General Public License along with 14 - this program; if not, write to the Free Software Foundation, Inc., 15 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 16 - 17 13 The full GNU General Public License is included in this distribution in 18 14 the file called "COPYING". 19 15
-4
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
··· 16 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17 17 more details. 18 18 19 - You should have received a copy of the GNU General Public License along with 20 - this program; if not, write to the Free Software Foundation, Inc., 21 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 22 - 23 19 The full GNU General Public License is included in this distribution in 24 20 the file called "COPYING". 25 21
-4
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
··· 16 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17 17 more details. 18 18 19 - You should have received a copy of the GNU General Public License along with 20 - this program; if not, write to the Free Software Foundation, Inc., 21 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 22 - 23 19 The full GNU General Public License is included in this distribution in 24 20 the file called "COPYING". 25 21
-4
drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c
··· 18 18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 19 19 more details. 20 20 21 - You should have received a copy of the GNU General Public License along with 22 - this program; if not, write to the Free Software Foundation, Inc., 23 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 24 - 25 21 The full GNU General Public License is included in this distribution in 26 22 the file called "COPYING". 27 23
-4
drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
··· 18 18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 19 19 more details. 20 20 21 - You should have received a copy of the GNU General Public License along with 22 - this program; if not, write to the Free Software Foundation, Inc., 23 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 24 - 25 21 The full GNU General Public License is included in this distribution in 26 22 the file called "COPYING". 27 23
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
··· 103 103 x->rx_mii++; 104 104 105 105 if (unlikely(rdes3 & RDES3_CRC_ERROR)) { 106 - x->rx_crc++; 106 + x->rx_crc_errors++; 107 107 stats->rx_crc_errors++; 108 108 } 109 109
-4
drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17
+11 -17
drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
··· 10 10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 11 more details. 12 12 13 - You should have received a copy of the GNU General Public License along with 14 - this program; if not, write to the Free Software Foundation, Inc., 15 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 16 - 17 13 The full GNU General Public License is included in this distribution in 18 14 the file called "COPYING". 19 15 ··· 17 21 *******************************************************************************/ 18 22 19 23 #include <linux/io.h> 24 + #include <linux/iopoll.h> 20 25 #include "common.h" 21 26 #include "dwmac_dma.h" 22 27 ··· 26 29 int dwmac_dma_reset(void __iomem *ioaddr) 27 30 { 28 31 u32 value = readl(ioaddr + DMA_BUS_MODE); 29 - int limit; 32 + int err; 30 33 31 34 /* DMA SW reset */ 32 35 value |= DMA_BUS_MODE_SFT_RESET; 33 36 writel(value, ioaddr + DMA_BUS_MODE); 34 - limit = 10; 35 - while (limit--) { 36 - if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET)) 37 - break; 38 - mdelay(10); 39 - } 40 37 41 - if (limit < 0) 38 + err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value, 39 + !(value & DMA_BUS_MODE_SFT_RESET), 40 + 100000, 10000); 41 + if (err) 42 42 return -EBUSY; 43 43 44 44 return 0; ··· 96 102 pr_debug("- TX (Stopped): Reset or Stop command\n"); 97 103 break; 98 104 case 1: 99 - pr_debug("- TX (Running):Fetching the Tx desc\n"); 105 + pr_debug("- TX (Running): Fetching the Tx desc\n"); 100 106 break; 101 107 case 2: 102 108 pr_debug("- TX (Running): Waiting for end of tx\n"); ··· 130 136 pr_debug("- RX (Running): Fetching the Rx desc\n"); 131 137 break; 132 138 case 2: 133 - pr_debug("- RX (Running):Checking for end of pkt\n"); 139 + pr_debug("- RX (Running): Checking for end of pkt\n"); 134 140 break; 135 141 case 3: 136 142 pr_debug("- RX (Running): Waiting for Rx pkt\n"); ··· 240 246 unsigned long data; 241 247 242 248 data = (addr[5] << 8) | addr[4]; 243 - /* For MAC Addr registers se have to set the Address Enable (AE) 249 + /* For MAC Addr registers we have to set the Address Enable (AE) 244 250 * bit that has no effect on the High Reg 0 where the bit 31 (MO) 245 251 * is RO. 246 252 */ ··· 255 261 u32 value = readl(ioaddr + MAC_CTRL_REG); 256 262 257 263 if (enable) 258 - value |= MAC_RNABLE_RX | MAC_ENABLE_TX; 264 + value |= MAC_ENABLE_RX | MAC_ENABLE_TX; 259 265 else 260 - value &= ~(MAC_ENABLE_TX | MAC_RNABLE_RX); 266 + value &= ~(MAC_ENABLE_TX | MAC_ENABLE_RX); 261 267 262 268 writel(value, ioaddr + MAC_CTRL_REG); 263 269 }
+1 -5
drivers/net/ethernet/stmicro/stmmac/enh_desc.c
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17 ··· 221 225 x->rx_mii++; 222 226 223 227 if (unlikely(rdes0 & RDES0_CRC_ERROR)) { 224 - x->rx_crc++; 228 + x->rx_crc_errors++; 225 229 stats->rx_crc_errors++; 226 230 } 227 231 ret = discard_frame;
-4
drivers/net/ethernet/stmicro/stmmac/mmc.h
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17
-4
drivers/net/ethernet/stmicro/stmmac/mmc_core.c
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17
+1 -5
drivers/net/ethernet/stmicro/stmmac/norm_desc.c
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17 ··· 111 115 stats->collisions++; 112 116 } 113 117 if (unlikely(rdes0 & RDES0_CRC_ERROR)) { 114 - x->rx_crc++; 118 + x->rx_crc_errors++; 115 119 stats->rx_crc_errors++; 116 120 } 117 121 ret = discard_frame;
-4
drivers/net/ethernet/stmicro/stmmac/ring_mode.c
··· 16 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17 17 more details. 18 18 19 - You should have received a copy of the GNU General Public License along with 20 - this program; if not, write to the Free Software Foundation, Inc., 21 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 22 - 23 19 The full GNU General Public License is included in this distribution in 24 20 the file called "COPYING". 25 21
-4
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 10 10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 11 more details. 12 12 13 - You should have received a copy of the GNU General Public License along with 14 - this program; if not, write to the Free Software Foundation, Inc., 15 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 16 - 17 13 The full GNU General Public License is included in this distribution in 18 14 the file called "COPYING". 19 15
+1 -5
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17 ··· 61 65 STMMAC_STAT(overflow_error), 62 66 STMMAC_STAT(ipc_csum_error), 63 67 STMMAC_STAT(rx_collision), 64 - STMMAC_STAT(rx_crc), 68 + STMMAC_STAT(rx_crc_errors), 65 69 STMMAC_STAT(dribbling_bit), 66 70 STMMAC_STAT(rx_length), 67 71 STMMAC_STAT(rx_mii),
-4
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17
+14 -35
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 13 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 14 more details. 15 15 16 - You should have received a copy of the GNU General Public License along with 17 - this program; if not, write to the Free Software Foundation, Inc., 18 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 19 - 20 16 The full GNU General Public License is included in this distribution in 21 17 the file called "COPYING". 22 18 ··· 187 191 188 192 static inline u32 stmmac_tx_avail(struct stmmac_priv *priv) 189 193 { 190 - unsigned avail; 194 + u32 avail; 191 195 192 196 if (priv->dirty_tx > priv->cur_tx) 193 197 avail = priv->dirty_tx - priv->cur_tx - 1; ··· 199 203 200 204 static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv) 201 205 { 202 - unsigned dirty; 206 + u32 dirty; 203 207 204 208 if (priv->dirty_rx <= priv->cur_rx) 205 209 dirty = priv->cur_rx - priv->dirty_rx; ··· 212 216 /** 213 217 * stmmac_hw_fix_mac_speed - callback for speed selection 214 218 * @priv: driver private structure 215 - * Description: on some platforms (e.g. ST), some HW system configuraton 219 + * Description: on some platforms (e.g. ST), some HW system configuration 216 220 * registers have to be set according to the link speed negotiated. 217 221 */ 218 222 static inline void stmmac_hw_fix_mac_speed(struct stmmac_priv *priv) ··· 412 416 /** 413 417 * stmmac_hwtstamp_ioctl - control hardware timestamping. 414 418 * @dev: device pointer. 415 - * @ifr: An IOCTL specefic structure, that can contain a pointer to 419 + * @ifr: An IOCTL specific structure, that can contain a pointer to 416 420 * a proprietary structure used to pass information to the driver. 417 421 * Description: 418 422 * This function configures the MAC to enable/disable both outgoing(TX) ··· 689 693 int new_state = 0; 690 694 unsigned int fc = priv->flow_ctrl, pause_time = priv->pause; 691 695 692 - if (phydev == NULL) 696 + if (!phydev) 693 697 return; 694 698 695 699 spin_lock_irqsave(&priv->lock, flags); ··· 738 742 break; 739 743 default: 740 744 netif_warn(priv, link, priv->dev, 741 - "Speed (%d) not 10/100\n", 742 - phydev->speed); 745 + "broken speed: %d\n", phydev->speed); 743 746 break; 744 747 } 745 748 ··· 870 875 if (phydev->is_pseudo_fixed_link) 871 876 phydev->irq = PHY_POLL; 872 877 873 - netdev_dbg(priv->dev, "%s: attached to PHY (UID 0x%x) Link = %d\n", 874 - __func__, phydev->phy_id, phydev->link); 875 - 878 + phy_attached_info(phydev); 876 879 return 0; 877 880 } 878 881 ··· 996 1003 * @dev: net device structure 997 1004 * @flags: gfp flag. 998 1005 * Description: this function initializes the DMA RX/TX descriptors 999 - * and allocates the socket buffers. It suppors the chained and ring 1006 + * and allocates the socket buffers. It supports the chained and ring 1000 1007 * modes. 1001 1008 */ 1002 1009 static int init_dma_desc_rings(struct net_device *dev, gfp_t flags) ··· 1109 1116 int i; 1110 1117 1111 1118 for (i = 0; i < DMA_TX_SIZE; i++) { 1112 - struct dma_desc *p; 1113 - 1114 - if (priv->extend_desc) 1115 - p = &((priv->dma_etx + i)->basic); 1116 - else 1117 - p = priv->dma_tx + i; 1118 - 1119 1119 if (priv->tx_skbuff_dma[i].buf) { 1120 1120 if (priv->tx_skbuff_dma[i].map_as_page) 1121 1121 dma_unmap_page(priv->device, ··· 1122 1136 DMA_TO_DEVICE); 1123 1137 } 1124 1138 1125 - if (priv->tx_skbuff[i] != NULL) { 1139 + if (priv->tx_skbuff[i]) { 1126 1140 dev_kfree_skb_any(priv->tx_skbuff[i]); 1127 1141 priv->tx_skbuff[i] = NULL; 1128 1142 priv->tx_skbuff_dma[i].buf = 0; ··· 1667 1681 1668 1682 /* Copy the MAC addr into the HW */ 1669 1683 priv->hw->mac->set_umac_addr(priv->hw, dev->dev_addr, 0); 1670 - 1671 - /* If required, perform hw setup of the bus. */ 1672 - if (priv->plat->bus_setup) 1673 - priv->plat->bus_setup(priv->ioaddr); 1674 1684 1675 1685 /* PS and related bits will be programmed according to the speed */ 1676 1686 if (priv->hw->pcs) { ··· 2518 2536 if (unlikely(status == discard_frame)) { 2519 2537 priv->dev->stats.rx_errors++; 2520 2538 if (priv->hwts_rx_en && !priv->extend_desc) { 2521 - /* DESC2 & DESC3 will be overwitten by device 2539 + /* DESC2 & DESC3 will be overwritten by device 2522 2540 * with timestamp value, hence reinitialize 2523 2541 * them in stmmac_rx_refill() function so that 2524 2542 * device can reuse it. ··· 2541 2559 2542 2560 frame_len = priv->hw->desc->get_rx_frame_len(p, coe); 2543 2561 2544 - /* If frame length is greather than skb buffer size 2562 + /* If frame length is greater than skb buffer size 2545 2563 * (preallocated during init) then the packet is 2546 2564 * ignored 2547 2565 */ ··· 2747 2765 /* Some GMAC devices have a bugged Jumbo frame support that 2748 2766 * needs to have the Tx COE disabled for oversized frames 2749 2767 * (due to limited buffer sizes). In this case we disable 2750 - * the TX csum insertionin the TDES and not use SF. 2768 + * the TX csum insertion in the TDES and not use SF. 2751 2769 */ 2752 2770 if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN)) 2753 2771 features &= ~NETIF_F_CSUM_MASK; ··· 2893 2911 struct dma_desc *p = (struct dma_desc *)head; 2894 2912 2895 2913 for (i = 0; i < size; i++) { 2896 - u64 x; 2897 2914 if (extend_desc) { 2898 - x = *(u64 *) ep; 2899 2915 seq_printf(seq, "%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n", 2900 2916 i, (unsigned int)virt_to_phys(ep), 2901 2917 le32_to_cpu(ep->basic.des0), ··· 2902 2922 le32_to_cpu(ep->basic.des3)); 2903 2923 ep++; 2904 2924 } else { 2905 - x = *(u64 *) p; 2906 2925 seq_printf(seq, "%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n", 2907 2926 i, (unsigned int)virt_to_phys(ep), 2908 2927 le32_to_cpu(p->des0), le32_to_cpu(p->des1), ··· 2971 2992 (priv->dma_cap.hash_filter) ? "Y" : "N"); 2972 2993 seq_printf(seq, "\tMultiple MAC address registers: %s\n", 2973 2994 (priv->dma_cap.multi_addr) ? "Y" : "N"); 2974 - seq_printf(seq, "\tPCS (TBI/SGMII/RTBI PHY interfatces): %s\n", 2995 + seq_printf(seq, "\tPCS (TBI/SGMII/RTBI PHY interfaces): %s\n", 2975 2996 (priv->dma_cap.pcs) ? "Y" : "N"); 2976 2997 seq_printf(seq, "\tSMA (MDIO) Interface: %s\n", 2977 2998 (priv->dma_cap.sma_mdio) ? "Y" : "N"); ··· 3468 3489 priv->irq_wake = 0; 3469 3490 } else { 3470 3491 pinctrl_pm_select_default_state(priv->device); 3471 - /* enable the clk prevously disabled */ 3492 + /* enable the clk previously disabled */ 3472 3493 clk_enable(priv->plat->stmmac_clk); 3473 3494 clk_enable(priv->plat->pclk); 3474 3495 /* reset the phy so that it's ready */
+19 -33
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
··· 13 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 14 more details. 15 15 16 - You should have received a copy of the GNU General Public License along with 17 - this program; if not, write to the Free Software Foundation, Inc., 18 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 19 - 20 16 The full GNU General Public License is included in this distribution in 21 17 the file called "COPYING". 22 18 ··· 20 24 Maintainer: Giuseppe Cavallaro <peppe.cavallaro@st.com> 21 25 *******************************************************************************/ 22 26 27 + #include <linux/io.h> 28 + #include <linux/iopoll.h> 23 29 #include <linux/mii.h> 24 - #include <linux/phy.h> 25 - #include <linux/slab.h> 26 30 #include <linux/of.h> 27 31 #include <linux/of_gpio.h> 28 32 #include <linux/of_mdio.h> 29 - #include <asm/io.h> 33 + #include <linux/phy.h> 34 + #include <linux/slab.h> 30 35 31 36 #include "stmmac.h" 32 37 ··· 38 41 #define MII_GMAC4_GOC_SHIFT 2 39 42 #define MII_GMAC4_WRITE (1 << MII_GMAC4_GOC_SHIFT) 40 43 #define MII_GMAC4_READ (3 << MII_GMAC4_GOC_SHIFT) 41 - 42 - static int stmmac_mdio_busy_wait(void __iomem *ioaddr, unsigned int mii_addr) 43 - { 44 - unsigned long curr; 45 - unsigned long finish = jiffies + 3 * HZ; 46 - 47 - do { 48 - curr = jiffies; 49 - if (readl(ioaddr + mii_addr) & MII_BUSY) 50 - cpu_relax(); 51 - else 52 - return 0; 53 - } while (!time_after_eq(curr, finish)); 54 - 55 - return -EBUSY; 56 - } 57 44 58 45 /** 59 46 * stmmac_mdio_read ··· 55 74 struct stmmac_priv *priv = netdev_priv(ndev); 56 75 unsigned int mii_address = priv->hw->mii.addr; 57 76 unsigned int mii_data = priv->hw->mii.data; 58 - 77 + u32 v; 59 78 int data; 60 79 u32 value = MII_BUSY; 61 80 ··· 67 86 if (priv->plat->has_gmac4) 68 87 value |= MII_GMAC4_READ; 69 88 70 - if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address)) 89 + if (readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY), 90 + 100, 10000)) 71 91 return -EBUSY; 72 92 73 93 writel(value, priv->ioaddr + mii_address); 74 94 75 - if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address)) 95 + if (readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY), 96 + 100, 10000)) 76 97 return -EBUSY; 77 98 78 99 /* Read the data from the MII data register */ ··· 98 115 struct stmmac_priv *priv = netdev_priv(ndev); 99 116 unsigned int mii_address = priv->hw->mii.addr; 100 117 unsigned int mii_data = priv->hw->mii.data; 101 - 118 + u32 v; 102 119 u32 value = MII_BUSY; 103 120 104 121 value |= (phyaddr << priv->hw->mii.addr_shift) ··· 113 130 value |= MII_WRITE; 114 131 115 132 /* Wait until any existing MII operation is complete */ 116 - if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address)) 133 + if (readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY), 134 + 100, 10000)) 117 135 return -EBUSY; 118 136 119 137 /* Set the MII address register to write */ ··· 122 138 writel(value, priv->ioaddr + mii_address); 123 139 124 140 /* Wait until any existing MII operation is complete */ 125 - return stmmac_mdio_busy_wait(priv->ioaddr, mii_address); 141 + return readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY), 142 + 100, 10000); 126 143 } 127 144 128 145 /** ··· 141 156 142 157 #ifdef CONFIG_OF 143 158 if (priv->device->of_node) { 144 - 145 159 if (data->reset_gpio < 0) { 146 160 struct device_node *np = priv->device->of_node; 161 + 147 162 if (!np) 148 163 return 0; 149 164 ··· 183 198 184 199 /* This is a workaround for problems with the STE101P PHY. 185 200 * It doesn't complete its reset until at least one clock cycle 186 - * on MDC, so perform a dummy mdio read. To be upadted for GMAC4 201 + * on MDC, so perform a dummy mdio read. To be updated for GMAC4 187 202 * if needed. 188 203 */ 189 204 if (!priv->plat->has_gmac4) ··· 210 225 return 0; 211 226 212 227 new_bus = mdiobus_alloc(); 213 - if (new_bus == NULL) 228 + if (!new_bus) 214 229 return -ENOMEM; 215 230 216 231 if (mdio_bus_data->irqs) ··· 247 262 found = 0; 248 263 for (addr = 0; addr < PHY_MAX_ADDR; addr++) { 249 264 struct phy_device *phydev = mdiobus_get_phy(new_bus, addr); 265 + 250 266 if (phydev) { 251 267 int act = 0; 252 268 char irq_num[4]; ··· 257 271 * If an IRQ was provided to be assigned after 258 272 * the bus probe, do it here. 259 273 */ 260 - if ((mdio_bus_data->irqs == NULL) && 274 + if ((!mdio_bus_data->irqs) && 261 275 (mdio_bus_data->probed_phy_irq > 0)) { 262 276 new_bus->irq[addr] = 263 277 mdio_bus_data->probed_phy_irq;
-4
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17
+1 -5
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17 ··· 411 415 struct plat_stmmacenet_data * 412 416 stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) 413 417 { 414 - return ERR_PTR(-ENOSYS); 418 + return ERR_PTR(-EINVAL); 415 419 } 416 420 417 421 void stmmac_remove_config_dt(struct platform_device *pdev,
-4
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17
-4
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
··· 12 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 13 more details. 14 14 15 - You should have received a copy of the GNU General Public License along with 16 - this program; if not, write to the Free Software Foundation, Inc., 17 - 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 - 19 15 The full GNU General Public License is included in this distribution in 20 16 the file called "COPYING". 21 17
-1
include/linux/stmmac.h
··· 134 134 int tx_fifo_size; 135 135 int rx_fifo_size; 136 136 void (*fix_mac_speed)(void *priv, unsigned int speed); 137 - void (*bus_setup)(void __iomem *ioaddr); 138 137 int (*init)(struct platform_device *pdev, void *priv); 139 138 void (*exit)(struct platform_device *pdev, void *priv); 140 139 void *bsp_priv;