| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * drivers/net/ethernet/nxp/lpc_eth.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Copyright (C) 2010 NXP Semiconductors |
|---|
| 7 | 8 | * Copyright (C) 2012 Roland Stigge <stigge@antcom.de> |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 11 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | | - * (at your option) any later version. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | - * GNU General Public License for more details. |
|---|
| 18 | 9 | */ |
|---|
| 19 | 10 | |
|---|
| 20 | 11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| 21 | 12 | |
|---|
| 22 | | -#include <linux/module.h> |
|---|
| 23 | | -#include <linux/kernel.h> |
|---|
| 24 | | -#include <linux/sched.h> |
|---|
| 25 | | -#include <linux/slab.h> |
|---|
| 26 | | -#include <linux/delay.h> |
|---|
| 27 | | -#include <linux/interrupt.h> |
|---|
| 28 | | -#include <linux/errno.h> |
|---|
| 29 | | -#include <linux/ioport.h> |
|---|
| 13 | +#include <linux/clk.h> |
|---|
| 30 | 14 | #include <linux/crc32.h> |
|---|
| 15 | +#include <linux/etherdevice.h> |
|---|
| 16 | +#include <linux/module.h> |
|---|
| 17 | +#include <linux/of.h> |
|---|
| 18 | +#include <linux/of_mdio.h> |
|---|
| 19 | +#include <linux/of_net.h> |
|---|
| 20 | +#include <linux/phy.h> |
|---|
| 31 | 21 | #include <linux/platform_device.h> |
|---|
| 32 | 22 | #include <linux/spinlock.h> |
|---|
| 33 | | -#include <linux/ethtool.h> |
|---|
| 34 | | -#include <linux/mii.h> |
|---|
| 35 | | -#include <linux/clk.h> |
|---|
| 36 | | -#include <linux/workqueue.h> |
|---|
| 37 | | -#include <linux/netdevice.h> |
|---|
| 38 | | -#include <linux/etherdevice.h> |
|---|
| 39 | | -#include <linux/skbuff.h> |
|---|
| 40 | | -#include <linux/phy.h> |
|---|
| 41 | | -#include <linux/dma-mapping.h> |
|---|
| 42 | | -#include <linux/of.h> |
|---|
| 43 | | -#include <linux/of_net.h> |
|---|
| 44 | | -#include <linux/types.h> |
|---|
| 45 | | - |
|---|
| 46 | | -#include <linux/io.h> |
|---|
| 47 | | -#include <mach/board.h> |
|---|
| 48 | | -#include <mach/platform.h> |
|---|
| 49 | | -#include <mach/hardware.h> |
|---|
| 23 | +#include <linux/soc/nxp/lpc32xx-misc.h> |
|---|
| 50 | 24 | |
|---|
| 51 | 25 | #define MODNAME "lpc-eth" |
|---|
| 52 | 26 | #define DRV_VERSION "1.00" |
|---|
| .. | .. |
|---|
| 296 | 270 | #define LPC_FCCR_MIRRORCOUNTERCURRENT(n) ((n) & 0xFFFF) |
|---|
| 297 | 271 | |
|---|
| 298 | 272 | /* |
|---|
| 299 | | - * rxfliterctrl, rxfilterwolstatus, and rxfilterwolclear shared |
|---|
| 273 | + * rxfilterctrl, rxfilterwolstatus, and rxfilterwolclear shared |
|---|
| 300 | 274 | * register definitions |
|---|
| 301 | 275 | */ |
|---|
| 302 | 276 | #define LPC_RXFLTRW_ACCEPTUNICAST (1 << 0) |
|---|
| .. | .. |
|---|
| 307 | 281 | #define LPC_RXFLTRW_ACCEPTPERFECT (1 << 5) |
|---|
| 308 | 282 | |
|---|
| 309 | 283 | /* |
|---|
| 310 | | - * rxfliterctrl register definitions |
|---|
| 284 | + * rxfilterctrl register definitions |
|---|
| 311 | 285 | */ |
|---|
| 312 | 286 | #define LPC_RXFLTRWSTS_MAGICPACKETENWOL (1 << 12) |
|---|
| 313 | 287 | #define LPC_RXFLTRWSTS_RXFILTERENWOL (1 << 13) |
|---|
| .. | .. |
|---|
| 418 | 392 | struct netdata_local { |
|---|
| 419 | 393 | struct platform_device *pdev; |
|---|
| 420 | 394 | struct net_device *ndev; |
|---|
| 395 | + struct device_node *phy_node; |
|---|
| 421 | 396 | spinlock_t lock; |
|---|
| 422 | 397 | void __iomem *net_base; |
|---|
| 423 | 398 | u32 msg_enable; |
|---|
| .. | .. |
|---|
| 776 | 751 | static int lpc_mii_probe(struct net_device *ndev) |
|---|
| 777 | 752 | { |
|---|
| 778 | 753 | struct netdata_local *pldat = netdev_priv(ndev); |
|---|
| 779 | | - struct phy_device *phydev = phy_find_first(pldat->mii_bus); |
|---|
| 780 | | - |
|---|
| 781 | | - if (!phydev) { |
|---|
| 782 | | - netdev_err(ndev, "no PHY found\n"); |
|---|
| 783 | | - return -ENODEV; |
|---|
| 784 | | - } |
|---|
| 754 | + struct phy_device *phydev; |
|---|
| 785 | 755 | |
|---|
| 786 | 756 | /* Attach to the PHY */ |
|---|
| 787 | 757 | if (lpc_phy_interface_mode(&pldat->pdev->dev) == PHY_INTERFACE_MODE_MII) |
|---|
| 788 | 758 | netdev_info(ndev, "using MII interface\n"); |
|---|
| 789 | 759 | else |
|---|
| 790 | 760 | netdev_info(ndev, "using RMII interface\n"); |
|---|
| 761 | + |
|---|
| 762 | + if (pldat->phy_node) |
|---|
| 763 | + phydev = of_phy_find_device(pldat->phy_node); |
|---|
| 764 | + else |
|---|
| 765 | + phydev = phy_find_first(pldat->mii_bus); |
|---|
| 766 | + if (!phydev) { |
|---|
| 767 | + netdev_err(ndev, "no PHY found\n"); |
|---|
| 768 | + return -ENODEV; |
|---|
| 769 | + } |
|---|
| 770 | + |
|---|
| 791 | 771 | phydev = phy_connect(ndev, phydev_name(phydev), |
|---|
| 792 | 772 | &lpc_handle_link_change, |
|---|
| 793 | 773 | lpc_phy_interface_mode(&pldat->pdev->dev)); |
|---|
| 794 | | - |
|---|
| 795 | 774 | if (IS_ERR(phydev)) { |
|---|
| 796 | 775 | netdev_err(ndev, "Could not attach to PHY\n"); |
|---|
| 797 | 776 | return PTR_ERR(phydev); |
|---|
| 798 | 777 | } |
|---|
| 799 | 778 | |
|---|
| 800 | | - /* mask with MAC supported features */ |
|---|
| 801 | | - phydev->supported &= PHY_BASIC_FEATURES; |
|---|
| 802 | | - |
|---|
| 803 | | - phydev->advertising = phydev->supported; |
|---|
| 779 | + phy_set_max_speed(phydev, SPEED_100); |
|---|
| 804 | 780 | |
|---|
| 805 | 781 | pldat->link = 0; |
|---|
| 806 | 782 | pldat->speed = 0; |
|---|
| .. | .. |
|---|
| 813 | 789 | |
|---|
| 814 | 790 | static int lpc_mii_init(struct netdata_local *pldat) |
|---|
| 815 | 791 | { |
|---|
| 792 | + struct device_node *node; |
|---|
| 816 | 793 | int err = -ENXIO; |
|---|
| 817 | 794 | |
|---|
| 818 | 795 | pldat->mii_bus = mdiobus_alloc(); |
|---|
| .. | .. |
|---|
| 840 | 817 | pldat->mii_bus->priv = pldat; |
|---|
| 841 | 818 | pldat->mii_bus->parent = &pldat->pdev->dev; |
|---|
| 842 | 819 | |
|---|
| 843 | | - platform_set_drvdata(pldat->pdev, pldat->mii_bus); |
|---|
| 844 | | - |
|---|
| 845 | | - if (mdiobus_register(pldat->mii_bus)) |
|---|
| 820 | + node = of_get_child_by_name(pldat->pdev->dev.of_node, "mdio"); |
|---|
| 821 | + err = of_mdiobus_register(pldat->mii_bus, node); |
|---|
| 822 | + of_node_put(node); |
|---|
| 823 | + if (err) |
|---|
| 846 | 824 | goto err_out_unregister_bus; |
|---|
| 847 | 825 | |
|---|
| 848 | 826 | err = lpc_mii_probe(pldat->ndev); |
|---|
| .. | .. |
|---|
| 1051 | 1029 | return 0; |
|---|
| 1052 | 1030 | } |
|---|
| 1053 | 1031 | |
|---|
| 1054 | | -static int lpc_eth_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) |
|---|
| 1032 | +static netdev_tx_t lpc_eth_hard_start_xmit(struct sk_buff *skb, |
|---|
| 1033 | + struct net_device *ndev) |
|---|
| 1055 | 1034 | { |
|---|
| 1056 | 1035 | struct netdata_local *pldat = netdev_priv(ndev); |
|---|
| 1057 | 1036 | u32 len, txidx; |
|---|
| .. | .. |
|---|
| 1171 | 1150 | spin_unlock_irqrestore(&pldat->lock, flags); |
|---|
| 1172 | 1151 | } |
|---|
| 1173 | 1152 | |
|---|
| 1174 | | -static int lpc_eth_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) |
|---|
| 1175 | | -{ |
|---|
| 1176 | | - struct phy_device *phydev = ndev->phydev; |
|---|
| 1177 | | - |
|---|
| 1178 | | - if (!netif_running(ndev)) |
|---|
| 1179 | | - return -EINVAL; |
|---|
| 1180 | | - |
|---|
| 1181 | | - if (!phydev) |
|---|
| 1182 | | - return -ENODEV; |
|---|
| 1183 | | - |
|---|
| 1184 | | - return phy_mii_ioctl(phydev, req, cmd); |
|---|
| 1185 | | -} |
|---|
| 1186 | | - |
|---|
| 1187 | 1153 | static int lpc_eth_open(struct net_device *ndev) |
|---|
| 1188 | 1154 | { |
|---|
| 1189 | 1155 | struct netdata_local *pldat = netdev_priv(ndev); |
|---|
| .. | .. |
|---|
| 1251 | 1217 | .ndo_stop = lpc_eth_close, |
|---|
| 1252 | 1218 | .ndo_start_xmit = lpc_eth_hard_start_xmit, |
|---|
| 1253 | 1219 | .ndo_set_rx_mode = lpc_eth_set_multicast_list, |
|---|
| 1254 | | - .ndo_do_ioctl = lpc_eth_ioctl, |
|---|
| 1220 | + .ndo_do_ioctl = phy_do_ioctl_running, |
|---|
| 1255 | 1221 | .ndo_set_mac_address = lpc_set_mac_address, |
|---|
| 1256 | 1222 | .ndo_validate_addr = eth_validate_addr, |
|---|
| 1257 | 1223 | }; |
|---|
| 1258 | 1224 | |
|---|
| 1259 | 1225 | static int lpc_eth_drv_probe(struct platform_device *pdev) |
|---|
| 1260 | 1226 | { |
|---|
| 1261 | | - struct resource *res; |
|---|
| 1262 | | - struct net_device *ndev; |
|---|
| 1227 | + struct device *dev = &pdev->dev; |
|---|
| 1228 | + struct device_node *np = dev->of_node; |
|---|
| 1263 | 1229 | struct netdata_local *pldat; |
|---|
| 1264 | | - struct phy_device *phydev; |
|---|
| 1230 | + struct net_device *ndev; |
|---|
| 1265 | 1231 | dma_addr_t dma_handle; |
|---|
| 1232 | + struct resource *res; |
|---|
| 1266 | 1233 | int irq, ret; |
|---|
| 1267 | | - u32 tmp; |
|---|
| 1268 | 1234 | |
|---|
| 1269 | 1235 | /* Setup network interface for RMII or MII mode */ |
|---|
| 1270 | | - tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL); |
|---|
| 1271 | | - tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK; |
|---|
| 1272 | | - if (lpc_phy_interface_mode(&pdev->dev) == PHY_INTERFACE_MODE_MII) |
|---|
| 1273 | | - tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS; |
|---|
| 1274 | | - else |
|---|
| 1275 | | - tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS; |
|---|
| 1276 | | - __raw_writel(tmp, LPC32XX_CLKPWR_MACCLK_CTRL); |
|---|
| 1236 | + lpc32xx_set_phy_interface_mode(lpc_phy_interface_mode(dev)); |
|---|
| 1277 | 1237 | |
|---|
| 1278 | 1238 | /* Get platform resources */ |
|---|
| 1279 | 1239 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 1280 | 1240 | irq = platform_get_irq(pdev, 0); |
|---|
| 1281 | 1241 | if (!res || irq < 0) { |
|---|
| 1282 | | - dev_err(&pdev->dev, "error getting resources.\n"); |
|---|
| 1242 | + dev_err(dev, "error getting resources.\n"); |
|---|
| 1283 | 1243 | ret = -ENXIO; |
|---|
| 1284 | 1244 | goto err_exit; |
|---|
| 1285 | 1245 | } |
|---|
| .. | .. |
|---|
| 1287 | 1247 | /* Allocate net driver data structure */ |
|---|
| 1288 | 1248 | ndev = alloc_etherdev(sizeof(struct netdata_local)); |
|---|
| 1289 | 1249 | if (!ndev) { |
|---|
| 1290 | | - dev_err(&pdev->dev, "could not allocate device.\n"); |
|---|
| 1250 | + dev_err(dev, "could not allocate device.\n"); |
|---|
| 1291 | 1251 | ret = -ENOMEM; |
|---|
| 1292 | 1252 | goto err_exit; |
|---|
| 1293 | 1253 | } |
|---|
| 1294 | 1254 | |
|---|
| 1295 | | - SET_NETDEV_DEV(ndev, &pdev->dev); |
|---|
| 1255 | + SET_NETDEV_DEV(ndev, dev); |
|---|
| 1296 | 1256 | |
|---|
| 1297 | 1257 | pldat = netdev_priv(ndev); |
|---|
| 1298 | 1258 | pldat->pdev = pdev; |
|---|
| .. | .. |
|---|
| 1304 | 1264 | ndev->irq = irq; |
|---|
| 1305 | 1265 | |
|---|
| 1306 | 1266 | /* Get clock for the device */ |
|---|
| 1307 | | - pldat->clk = clk_get(&pdev->dev, NULL); |
|---|
| 1267 | + pldat->clk = clk_get(dev, NULL); |
|---|
| 1308 | 1268 | if (IS_ERR(pldat->clk)) { |
|---|
| 1309 | | - dev_err(&pdev->dev, "error getting clock.\n"); |
|---|
| 1269 | + dev_err(dev, "error getting clock.\n"); |
|---|
| 1310 | 1270 | ret = PTR_ERR(pldat->clk); |
|---|
| 1311 | 1271 | goto err_out_free_dev; |
|---|
| 1312 | 1272 | } |
|---|
| .. | .. |
|---|
| 1319 | 1279 | /* Map IO space */ |
|---|
| 1320 | 1280 | pldat->net_base = ioremap(res->start, resource_size(res)); |
|---|
| 1321 | 1281 | if (!pldat->net_base) { |
|---|
| 1322 | | - dev_err(&pdev->dev, "failed to map registers\n"); |
|---|
| 1282 | + dev_err(dev, "failed to map registers\n"); |
|---|
| 1323 | 1283 | ret = -ENOMEM; |
|---|
| 1324 | 1284 | goto err_out_disable_clocks; |
|---|
| 1325 | 1285 | } |
|---|
| 1326 | 1286 | ret = request_irq(ndev->irq, __lpc_eth_interrupt, 0, |
|---|
| 1327 | 1287 | ndev->name, ndev); |
|---|
| 1328 | 1288 | if (ret) { |
|---|
| 1329 | | - dev_err(&pdev->dev, "error requesting interrupt.\n"); |
|---|
| 1289 | + dev_err(dev, "error requesting interrupt.\n"); |
|---|
| 1330 | 1290 | goto err_out_iounmap; |
|---|
| 1331 | 1291 | } |
|---|
| 1332 | 1292 | |
|---|
| .. | .. |
|---|
| 1338 | 1298 | /* Get size of DMA buffers/descriptors region */ |
|---|
| 1339 | 1299 | pldat->dma_buff_size = (ENET_TX_DESC + ENET_RX_DESC) * (ENET_MAXF_SIZE + |
|---|
| 1340 | 1300 | sizeof(struct txrx_desc_t) + sizeof(struct rx_status_t)); |
|---|
| 1341 | | - pldat->dma_buff_base_v = 0; |
|---|
| 1342 | 1301 | |
|---|
| 1343 | | - if (use_iram_for_net(&pldat->pdev->dev)) { |
|---|
| 1344 | | - dma_handle = LPC32XX_IRAM_BASE; |
|---|
| 1345 | | - if (pldat->dma_buff_size <= lpc32xx_return_iram_size()) |
|---|
| 1346 | | - pldat->dma_buff_base_v = |
|---|
| 1347 | | - io_p2v(LPC32XX_IRAM_BASE); |
|---|
| 1348 | | - else |
|---|
| 1302 | + if (use_iram_for_net(dev)) { |
|---|
| 1303 | + if (pldat->dma_buff_size > |
|---|
| 1304 | + lpc32xx_return_iram(&pldat->dma_buff_base_v, &dma_handle)) { |
|---|
| 1305 | + pldat->dma_buff_base_v = NULL; |
|---|
| 1306 | + pldat->dma_buff_size = 0; |
|---|
| 1349 | 1307 | netdev_err(ndev, |
|---|
| 1350 | 1308 | "IRAM not big enough for net buffers, using SDRAM instead.\n"); |
|---|
| 1309 | + } |
|---|
| 1351 | 1310 | } |
|---|
| 1352 | 1311 | |
|---|
| 1353 | | - if (pldat->dma_buff_base_v == 0) { |
|---|
| 1354 | | - ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); |
|---|
| 1312 | + if (pldat->dma_buff_base_v == NULL) { |
|---|
| 1313 | + ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32)); |
|---|
| 1355 | 1314 | if (ret) |
|---|
| 1356 | 1315 | goto err_out_free_irq; |
|---|
| 1357 | 1316 | |
|---|
| .. | .. |
|---|
| 1360 | 1319 | /* Allocate a chunk of memory for the DMA ethernet buffers |
|---|
| 1361 | 1320 | and descriptors */ |
|---|
| 1362 | 1321 | pldat->dma_buff_base_v = |
|---|
| 1363 | | - dma_alloc_coherent(&pldat->pdev->dev, |
|---|
| 1322 | + dma_alloc_coherent(dev, |
|---|
| 1364 | 1323 | pldat->dma_buff_size, &dma_handle, |
|---|
| 1365 | 1324 | GFP_KERNEL); |
|---|
| 1366 | 1325 | if (pldat->dma_buff_base_v == NULL) { |
|---|
| .. | .. |
|---|
| 1382 | 1341 | netdev_dbg(ndev, "DMA buffer V address :0x%p\n", |
|---|
| 1383 | 1342 | pldat->dma_buff_base_v); |
|---|
| 1384 | 1343 | |
|---|
| 1344 | + pldat->phy_node = of_parse_phandle(np, "phy-handle", 0); |
|---|
| 1345 | + |
|---|
| 1385 | 1346 | /* Get MAC address from current HW setting (POR state is all zeros) */ |
|---|
| 1386 | 1347 | __lpc_get_mac(pldat, ndev->dev_addr); |
|---|
| 1387 | 1348 | |
|---|
| 1388 | 1349 | if (!is_valid_ether_addr(ndev->dev_addr)) { |
|---|
| 1389 | | - const char *macaddr = of_get_mac_address(pdev->dev.of_node); |
|---|
| 1390 | | - if (macaddr) |
|---|
| 1391 | | - memcpy(ndev->dev_addr, macaddr, ETH_ALEN); |
|---|
| 1350 | + const char *macaddr = of_get_mac_address(np); |
|---|
| 1351 | + if (!IS_ERR(macaddr)) |
|---|
| 1352 | + ether_addr_copy(ndev->dev_addr, macaddr); |
|---|
| 1392 | 1353 | } |
|---|
| 1393 | 1354 | if (!is_valid_ether_addr(ndev->dev_addr)) |
|---|
| 1394 | 1355 | eth_hw_addr_random(ndev); |
|---|
| 1395 | | - |
|---|
| 1396 | | - /* Reset the ethernet controller */ |
|---|
| 1397 | | - __lpc_eth_reset(pldat); |
|---|
| 1398 | 1356 | |
|---|
| 1399 | 1357 | /* then shut everything down to save power */ |
|---|
| 1400 | 1358 | __lpc_eth_shutdown(pldat); |
|---|
| .. | .. |
|---|
| 1416 | 1374 | |
|---|
| 1417 | 1375 | ret = register_netdev(ndev); |
|---|
| 1418 | 1376 | if (ret) { |
|---|
| 1419 | | - dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); |
|---|
| 1377 | + dev_err(dev, "Cannot register net device, aborting.\n"); |
|---|
| 1420 | 1378 | goto err_out_dma_unmap; |
|---|
| 1421 | 1379 | } |
|---|
| 1422 | 1380 | platform_set_drvdata(pdev, ndev); |
|---|
| .. | .. |
|---|
| 1428 | 1386 | netdev_info(ndev, "LPC mac at 0x%08lx irq %d\n", |
|---|
| 1429 | 1387 | (unsigned long)res->start, ndev->irq); |
|---|
| 1430 | 1388 | |
|---|
| 1431 | | - phydev = ndev->phydev; |
|---|
| 1432 | | - |
|---|
| 1433 | | - device_init_wakeup(&pdev->dev, 1); |
|---|
| 1434 | | - device_set_wakeup_enable(&pdev->dev, 0); |
|---|
| 1389 | + device_init_wakeup(dev, 1); |
|---|
| 1390 | + device_set_wakeup_enable(dev, 0); |
|---|
| 1435 | 1391 | |
|---|
| 1436 | 1392 | return 0; |
|---|
| 1437 | 1393 | |
|---|
| 1438 | 1394 | err_out_unregister_netdev: |
|---|
| 1439 | 1395 | unregister_netdev(ndev); |
|---|
| 1440 | 1396 | err_out_dma_unmap: |
|---|
| 1441 | | - if (!use_iram_for_net(&pldat->pdev->dev) || |
|---|
| 1442 | | - pldat->dma_buff_size > lpc32xx_return_iram_size()) |
|---|
| 1443 | | - dma_free_coherent(&pldat->pdev->dev, pldat->dma_buff_size, |
|---|
| 1397 | + if (!use_iram_for_net(dev) || |
|---|
| 1398 | + pldat->dma_buff_size > lpc32xx_return_iram(NULL, NULL)) |
|---|
| 1399 | + dma_free_coherent(dev, pldat->dma_buff_size, |
|---|
| 1444 | 1400 | pldat->dma_buff_base_v, |
|---|
| 1445 | 1401 | pldat->dma_buff_base_p); |
|---|
| 1446 | 1402 | err_out_free_irq: |
|---|
| .. | .. |
|---|
| 1466 | 1422 | unregister_netdev(ndev); |
|---|
| 1467 | 1423 | |
|---|
| 1468 | 1424 | if (!use_iram_for_net(&pldat->pdev->dev) || |
|---|
| 1469 | | - pldat->dma_buff_size > lpc32xx_return_iram_size()) |
|---|
| 1425 | + pldat->dma_buff_size > lpc32xx_return_iram(NULL, NULL)) |
|---|
| 1470 | 1426 | dma_free_coherent(&pldat->pdev->dev, pldat->dma_buff_size, |
|---|
| 1471 | 1427 | pldat->dma_buff_base_v, |
|---|
| 1472 | 1428 | pldat->dma_buff_base_p); |
|---|
| .. | .. |
|---|
| 1512 | 1468 | { |
|---|
| 1513 | 1469 | struct net_device *ndev = platform_get_drvdata(pdev); |
|---|
| 1514 | 1470 | struct netdata_local *pldat; |
|---|
| 1471 | + int ret; |
|---|
| 1515 | 1472 | |
|---|
| 1516 | 1473 | if (device_may_wakeup(&pdev->dev)) |
|---|
| 1517 | 1474 | disable_irq_wake(ndev->irq); |
|---|
| .. | .. |
|---|
| 1521 | 1478 | pldat = netdev_priv(ndev); |
|---|
| 1522 | 1479 | |
|---|
| 1523 | 1480 | /* Enable interface clock */ |
|---|
| 1524 | | - clk_enable(pldat->clk); |
|---|
| 1481 | + ret = clk_enable(pldat->clk); |
|---|
| 1482 | + if (ret) |
|---|
| 1483 | + return ret; |
|---|
| 1525 | 1484 | |
|---|
| 1526 | 1485 | /* Reset and initialize */ |
|---|
| 1527 | 1486 | __lpc_eth_reset(pldat); |
|---|
| .. | .. |
|---|
| 1535 | 1494 | } |
|---|
| 1536 | 1495 | #endif |
|---|
| 1537 | 1496 | |
|---|
| 1538 | | -#ifdef CONFIG_OF |
|---|
| 1539 | 1497 | static const struct of_device_id lpc_eth_match[] = { |
|---|
| 1540 | 1498 | { .compatible = "nxp,lpc-eth" }, |
|---|
| 1541 | 1499 | { } |
|---|
| 1542 | 1500 | }; |
|---|
| 1543 | 1501 | MODULE_DEVICE_TABLE(of, lpc_eth_match); |
|---|
| 1544 | | -#endif |
|---|
| 1545 | 1502 | |
|---|
| 1546 | 1503 | static struct platform_driver lpc_eth_driver = { |
|---|
| 1547 | 1504 | .probe = lpc_eth_drv_probe, |
|---|
| .. | .. |
|---|
| 1552 | 1509 | #endif |
|---|
| 1553 | 1510 | .driver = { |
|---|
| 1554 | 1511 | .name = MODNAME, |
|---|
| 1555 | | - .of_match_table = of_match_ptr(lpc_eth_match), |
|---|
| 1512 | + .of_match_table = lpc_eth_match, |
|---|
| 1556 | 1513 | }, |
|---|
| 1557 | 1514 | }; |
|---|
| 1558 | 1515 | |
|---|