20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23 #include <linux/module.h>
24 #include <linux/kernel.h>
25 #include <linux/sched.h>
26 #include <linux/slab.h>
29 #include <linux/errno.h>
34 #include <linux/ethtool.h>
35 #include <linux/mii.h>
38 #include <linux/netdevice.h>
45 #include <linux/types.h>
48 #include <mach/board.h>
49 #include <mach/platform.h>
50 #include <mach/hardware.h>
52 #define MODNAME "lpc-eth"
53 #define DRV_VERSION "1.00"
55 #define ENET_MAXF_SIZE 1536
56 #define ENET_RX_DESC 48
57 #define ENET_TX_DESC 16
59 #define NAPI_WEIGHT 16
64 #define LPC_ENET_MAC1(x) (x + 0x000)
65 #define LPC_ENET_MAC2(x) (x + 0x004)
66 #define LPC_ENET_IPGT(x) (x + 0x008)
67 #define LPC_ENET_IPGR(x) (x + 0x00C)
68 #define LPC_ENET_CLRT(x) (x + 0x010)
69 #define LPC_ENET_MAXF(x) (x + 0x014)
70 #define LPC_ENET_SUPP(x) (x + 0x018)
71 #define LPC_ENET_TEST(x) (x + 0x01C)
72 #define LPC_ENET_MCFG(x) (x + 0x020)
73 #define LPC_ENET_MCMD(x) (x + 0x024)
74 #define LPC_ENET_MADR(x) (x + 0x028)
75 #define LPC_ENET_MWTD(x) (x + 0x02C)
76 #define LPC_ENET_MRDD(x) (x + 0x030)
77 #define LPC_ENET_MIND(x) (x + 0x034)
78 #define LPC_ENET_SA0(x) (x + 0x040)
79 #define LPC_ENET_SA1(x) (x + 0x044)
80 #define LPC_ENET_SA2(x) (x + 0x048)
81 #define LPC_ENET_COMMAND(x) (x + 0x100)
82 #define LPC_ENET_STATUS(x) (x + 0x104)
83 #define LPC_ENET_RXDESCRIPTOR(x) (x + 0x108)
84 #define LPC_ENET_RXSTATUS(x) (x + 0x10C)
85 #define LPC_ENET_RXDESCRIPTORNUMBER(x) (x + 0x110)
86 #define LPC_ENET_RXPRODUCEINDEX(x) (x + 0x114)
87 #define LPC_ENET_RXCONSUMEINDEX(x) (x + 0x118)
88 #define LPC_ENET_TXDESCRIPTOR(x) (x + 0x11C)
89 #define LPC_ENET_TXSTATUS(x) (x + 0x120)
90 #define LPC_ENET_TXDESCRIPTORNUMBER(x) (x + 0x124)
91 #define LPC_ENET_TXPRODUCEINDEX(x) (x + 0x128)
92 #define LPC_ENET_TXCONSUMEINDEX(x) (x + 0x12C)
93 #define LPC_ENET_TSV0(x) (x + 0x158)
94 #define LPC_ENET_TSV1(x) (x + 0x15C)
95 #define LPC_ENET_RSV(x) (x + 0x160)
96 #define LPC_ENET_FLOWCONTROLCOUNTER(x) (x + 0x170)
97 #define LPC_ENET_FLOWCONTROLSTATUS(x) (x + 0x174)
98 #define LPC_ENET_RXFILTER_CTRL(x) (x + 0x200)
99 #define LPC_ENET_RXFILTERWOLSTATUS(x) (x + 0x204)
100 #define LPC_ENET_RXFILTERWOLCLEAR(x) (x + 0x208)
101 #define LPC_ENET_HASHFILTERL(x) (x + 0x210)
102 #define LPC_ENET_HASHFILTERH(x) (x + 0x214)
103 #define LPC_ENET_INTSTATUS(x) (x + 0xFE0)
104 #define LPC_ENET_INTENABLE(x) (x + 0xFE4)
105 #define LPC_ENET_INTCLEAR(x) (x + 0xFE8)
106 #define LPC_ENET_INTSET(x) (x + 0xFEC)
107 #define LPC_ENET_POWERDOWN(x) (x + 0xFF4)
112 #define LPC_MAC1_RECV_ENABLE (1 << 0)
113 #define LPC_MAC1_PASS_ALL_RX_FRAMES (1 << 1)
114 #define LPC_MAC1_RX_FLOW_CONTROL (1 << 2)
115 #define LPC_MAC1_TX_FLOW_CONTROL (1 << 3)
116 #define LPC_MAC1_LOOPBACK (1 << 4)
117 #define LPC_MAC1_RESET_TX (1 << 8)
118 #define LPC_MAC1_RESET_MCS_TX (1 << 9)
119 #define LPC_MAC1_RESET_RX (1 << 10)
120 #define LPC_MAC1_RESET_MCS_RX (1 << 11)
121 #define LPC_MAC1_SIMULATION_RESET (1 << 14)
122 #define LPC_MAC1_SOFT_RESET (1 << 15)
127 #define LPC_MAC2_FULL_DUPLEX (1 << 0)
128 #define LPC_MAC2_FRAME_LENGTH_CHECKING (1 << 1)
129 #define LPC_MAC2_HUGH_LENGTH_CHECKING (1 << 2)
130 #define LPC_MAC2_DELAYED_CRC (1 << 3)
131 #define LPC_MAC2_CRC_ENABLE (1 << 4)
132 #define LPC_MAC2_PAD_CRC_ENABLE (1 << 5)
133 #define LPC_MAC2_VLAN_PAD_ENABLE (1 << 6)
134 #define LPC_MAC2_AUTO_DETECT_PAD_ENABLE (1 << 7)
135 #define LPC_MAC2_PURE_PREAMBLE_ENFORCEMENT (1 << 8)
136 #define LPC_MAC2_LONG_PREAMBLE_ENFORCEMENT (1 << 9)
137 #define LPC_MAC2_NO_BACKOFF (1 << 12)
138 #define LPC_MAC2_BACK_PRESSURE (1 << 13)
139 #define LPC_MAC2_EXCESS_DEFER (1 << 14)
144 #define LPC_IPGT_LOAD(n) ((n) & 0x7F)
149 #define LPC_IPGR_LOAD_PART2(n) ((n) & 0x7F)
150 #define LPC_IPGR_LOAD_PART1(n) (((n) & 0x7F) << 8)
155 #define LPC_CLRT_LOAD_RETRY_MAX(n) ((n) & 0xF)
156 #define LPC_CLRT_LOAD_COLLISION_WINDOW(n) (((n) & 0x3F) << 8)
161 #define LPC_MAXF_LOAD_MAX_FRAME_LEN(n) ((n) & 0xFFFF)
166 #define LPC_SUPP_SPEED (1 << 8)
167 #define LPC_SUPP_RESET_RMII (1 << 11)
172 #define LPC_TEST_SHORTCUT_PAUSE_QUANTA (1 << 0)
173 #define LPC_TEST_PAUSE (1 << 1)
174 #define LPC_TEST_BACKPRESSURE (1 << 2)
179 #define LPC_MCFG_SCAN_INCREMENT (1 << 0)
180 #define LPC_MCFG_SUPPRESS_PREAMBLE (1 << 1)
181 #define LPC_MCFG_CLOCK_SELECT(n) (((n) & 0x7) << 2)
182 #define LPC_MCFG_CLOCK_HOST_DIV_4 0
183 #define LPC_MCFG_CLOCK_HOST_DIV_6 2
184 #define LPC_MCFG_CLOCK_HOST_DIV_8 3
185 #define LPC_MCFG_CLOCK_HOST_DIV_10 4
186 #define LPC_MCFG_CLOCK_HOST_DIV_14 5
187 #define LPC_MCFG_CLOCK_HOST_DIV_20 6
188 #define LPC_MCFG_CLOCK_HOST_DIV_28 7
189 #define LPC_MCFG_RESET_MII_MGMT (1 << 15)
194 #define LPC_MCMD_READ (1 << 0)
195 #define LPC_MCMD_SCAN (1 << 1)
200 #define LPC_MADR_REGISTER_ADDRESS(n) ((n) & 0x1F)
201 #define LPC_MADR_PHY_0ADDRESS(n) (((n) & 0x1F) << 8)
206 #define LPC_MWDT_WRITE(n) ((n) & 0xFFFF)
211 #define LPC_MRDD_READ_MASK 0xFFFF
216 #define LPC_MIND_BUSY (1 << 0)
217 #define LPC_MIND_SCANNING (1 << 1)
218 #define LPC_MIND_NOT_VALID (1 << 2)
219 #define LPC_MIND_MII_LINK_FAIL (1 << 3)
224 #define LPC_COMMAND_RXENABLE (1 << 0)
225 #define LPC_COMMAND_TXENABLE (1 << 1)
226 #define LPC_COMMAND_REG_RESET (1 << 3)
227 #define LPC_COMMAND_TXRESET (1 << 4)
228 #define LPC_COMMAND_RXRESET (1 << 5)
229 #define LPC_COMMAND_PASSRUNTFRAME (1 << 6)
230 #define LPC_COMMAND_PASSRXFILTER (1 << 7)
231 #define LPC_COMMAND_TXFLOWCONTROL (1 << 8)
232 #define LPC_COMMAND_RMII (1 << 9)
233 #define LPC_COMMAND_FULLDUPLEX (1 << 10)
238 #define LPC_STATUS_RXACTIVE (1 << 0)
239 #define LPC_STATUS_TXACTIVE (1 << 1)
244 #define LPC_TSV0_CRC_ERROR (1 << 0)
245 #define LPC_TSV0_LENGTH_CHECK_ERROR (1 << 1)
246 #define LPC_TSV0_LENGTH_OUT_OF_RANGE (1 << 2)
247 #define LPC_TSV0_DONE (1 << 3)
248 #define LPC_TSV0_MULTICAST (1 << 4)
249 #define LPC_TSV0_BROADCAST (1 << 5)
250 #define LPC_TSV0_PACKET_DEFER (1 << 6)
251 #define LPC_TSV0_ESCESSIVE_DEFER (1 << 7)
252 #define LPC_TSV0_ESCESSIVE_COLLISION (1 << 8)
253 #define LPC_TSV0_LATE_COLLISION (1 << 9)
254 #define LPC_TSV0_GIANT (1 << 10)
255 #define LPC_TSV0_UNDERRUN (1 << 11)
256 #define LPC_TSV0_TOTAL_BYTES(n) (((n) >> 12) & 0xFFFF)
257 #define LPC_TSV0_CONTROL_FRAME (1 << 28)
258 #define LPC_TSV0_PAUSE (1 << 29)
259 #define LPC_TSV0_BACKPRESSURE (1 << 30)
260 #define LPC_TSV0_VLAN (1 << 31)
265 #define LPC_TSV1_TRANSMIT_BYTE_COUNT(n) ((n) & 0xFFFF)
266 #define LPC_TSV1_COLLISION_COUNT(n) (((n) >> 16) & 0xF)
271 #define LPC_RSV_RECEIVED_BYTE_COUNT(n) ((n) & 0xFFFF)
272 #define LPC_RSV_RXDV_EVENT_IGNORED (1 << 16)
273 #define LPC_RSV_RXDV_EVENT_PREVIOUSLY_SEEN (1 << 17)
274 #define LPC_RSV_CARRIER_EVNT_PREVIOUS_SEEN (1 << 18)
275 #define LPC_RSV_RECEIVE_CODE_VIOLATION (1 << 19)
276 #define LPC_RSV_CRC_ERROR (1 << 20)
277 #define LPC_RSV_LENGTH_CHECK_ERROR (1 << 21)
278 #define LPC_RSV_LENGTH_OUT_OF_RANGE (1 << 22)
279 #define LPC_RSV_RECEIVE_OK (1 << 23)
280 #define LPC_RSV_MULTICAST (1 << 24)
281 #define LPC_RSV_BROADCAST (1 << 25)
282 #define LPC_RSV_DRIBBLE_NIBBLE (1 << 26)
283 #define LPC_RSV_CONTROL_FRAME (1 << 27)
284 #define LPC_RSV_PAUSE (1 << 28)
285 #define LPC_RSV_UNSUPPORTED_OPCODE (1 << 29)
286 #define LPC_RSV_VLAN (1 << 30)
291 #define LPC_FCCR_MIRRORCOUNTER(n) ((n) & 0xFFFF)
292 #define LPC_FCCR_PAUSETIMER(n) (((n) >> 16) & 0xFFFF)
297 #define LPC_FCCR_MIRRORCOUNTERCURRENT(n) ((n) & 0xFFFF)
303 #define LPC_RXFLTRW_ACCEPTUNICAST (1 << 0)
304 #define LPC_RXFLTRW_ACCEPTUBROADCAST (1 << 1)
305 #define LPC_RXFLTRW_ACCEPTUMULTICAST (1 << 2)
306 #define LPC_RXFLTRW_ACCEPTUNICASTHASH (1 << 3)
307 #define LPC_RXFLTRW_ACCEPTUMULTICASTHASH (1 << 4)
308 #define LPC_RXFLTRW_ACCEPTPERFECT (1 << 5)
313 #define LPC_RXFLTRWSTS_MAGICPACKETENWOL (1 << 12)
314 #define LPC_RXFLTRWSTS_RXFILTERENWOL (1 << 13)
319 #define LPC_RXFLTRWSTS_RXFILTERWOL (1 << 7)
320 #define LPC_RXFLTRWSTS_MAGICPACKETWOL (1 << 8)
326 #define LPC_MACINT_RXOVERRUNINTEN (1 << 0)
327 #define LPC_MACINT_RXERRORONINT (1 << 1)
328 #define LPC_MACINT_RXFINISHEDINTEN (1 << 2)
329 #define LPC_MACINT_RXDONEINTEN (1 << 3)
330 #define LPC_MACINT_TXUNDERRUNINTEN (1 << 4)
331 #define LPC_MACINT_TXERRORINTEN (1 << 5)
332 #define LPC_MACINT_TXFINISHEDINTEN (1 << 6)
333 #define LPC_MACINT_TXDONEINTEN (1 << 7)
334 #define LPC_MACINT_SOFTINTEN (1 << 12)
335 #define LPC_MACINT_WAKEUPINTEN (1 << 13)
340 #define LPC_POWERDOWN_MACAHB (1 << 31)
347 if (mode && !
strcmp(mode,
"mii"))
353 static bool use_iram_for_net(
struct device *
dev)
356 return of_property_read_bool(dev->
of_node,
"use-iram");
361 #define RXSTATUS_SIZE 0x000007FF
362 #define RXSTATUS_CONTROL (1 << 18)
363 #define RXSTATUS_VLAN (1 << 19)
364 #define RXSTATUS_FILTER (1 << 20)
365 #define RXSTATUS_MULTICAST (1 << 21)
366 #define RXSTATUS_BROADCAST (1 << 22)
367 #define RXSTATUS_CRC (1 << 23)
368 #define RXSTATUS_SYMBOL (1 << 24)
369 #define RXSTATUS_LENGTH (1 << 25)
370 #define RXSTATUS_RANGE (1 << 26)
371 #define RXSTATUS_ALIGN (1 << 27)
372 #define RXSTATUS_OVERRUN (1 << 28)
373 #define RXSTATUS_NODESC (1 << 29)
374 #define RXSTATUS_LAST (1 << 30)
375 #define RXSTATUS_ERROR (1 << 31)
377 #define RXSTATUS_STATUS_ERROR \
378 (RXSTATUS_NODESC | RXSTATUS_OVERRUN | RXSTATUS_ALIGN | \
379 RXSTATUS_RANGE | RXSTATUS_LENGTH | RXSTATUS_SYMBOL | RXSTATUS_CRC)
382 #define RXDESC_CONTROL_SIZE 0x000007FF
383 #define RXDESC_CONTROL_INT (1 << 31)
386 #define TXSTATUS_COLLISIONS_GET(x) (((x) >> 21) & 0xF)
387 #define TXSTATUS_DEFER (1 << 25)
388 #define TXSTATUS_EXCESSDEFER (1 << 26)
389 #define TXSTATUS_EXCESSCOLL (1 << 27)
390 #define TXSTATUS_LATECOLL (1 << 28)
391 #define TXSTATUS_UNDERRUN (1 << 29)
392 #define TXSTATUS_NODESC (1 << 30)
393 #define TXSTATUS_ERROR (1 << 31)
396 #define TXDESC_CONTROL_SIZE 0x000007FF
397 #define TXDESC_CONTROL_OVERRIDE (1 << 26)
398 #define TXDESC_CONTROL_HUGE (1 << 27)
399 #define TXDESC_CONTROL_PAD (1 << 28)
400 #define TXDESC_CONTROL_CRC (1 << 29)
401 #define TXDESC_CONTROL_LAST (1 << 30)
402 #define TXDESC_CONTROL_INT (1 << 31)
454 tmp = mac[0] | ((
u32)mac[1] << 8);
456 tmp = mac[2] | ((
u32)mac[3] << 8);
458 tmp = mac[4] | ((
u32)mac[5] << 8);
480 static void __lpc_eth_clock_enable(
struct netdata_local *pldat,
549 static void lpc_eth_enable_int(
void __iomem *regbase)
555 static void lpc_eth_disable_int(
void __iomem *regbase)
561 static void __lpc_txrx_desc_setup(
struct netdata_local *pldat)
576 tbuff +=
sizeof(
u32) * ENET_TX_DESC;
599 ptxrxdesc->
packet = __va_to_pa(
610 ptxrxdesc->
packet = __va_to_pa(
620 writel((ENET_TX_DESC - 1),
626 writel((ENET_RX_DESC - 1),
667 __lpc_params_setup(pldat);
670 __lpc_txrx_desc_setup(pldat);
684 lpc_eth_enable_int(pldat->
net_base);
698 __lpc_eth_reset(pldat);
728 static int lpc_mdio_write(
struct mii_bus *bus,
int phy_id,
int phyreg,
747 static int lpc_mdio_reset(
struct mii_bus *bus)
758 bool status_change =
false;
767 status_change =
true;
778 status_change =
true;
781 spin_unlock_irqrestore(&pldat->
lock, flags);
784 __lpc_params_setup(pldat);
787 static int lpc_mii_probe(
struct net_device *ndev)
793 netdev_err(ndev,
"no PHY found\n");
799 netdev_info(ndev,
"using MII interface\n");
801 netdev_info(ndev,
"using RMII interface\n");
803 &lpc_handle_link_change, 0,
804 lpc_phy_interface_mode(&pldat->
pdev->dev));
806 if (IS_ERR(phydev)) {
807 netdev_err(ndev,
"Could not attach to PHY\n");
808 return PTR_ERR(phydev);
822 "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
823 phydev->
drv->name, dev_name(&phydev->
dev), phydev->
irq);
831 pldat->
mii_bus = mdiobus_alloc();
847 pldat->
mii_bus->name =
"lpc_mii_bus";
848 pldat->
mii_bus->read = &lpc_mdio_read;
849 pldat->
mii_bus->write = &lpc_mdio_write;
850 pldat->
mii_bus->reset = &lpc_mdio_reset;
852 pldat->
pdev->name, pldat->
pdev->id);
868 goto err_out_free_mdio_irq;
870 if (lpc_mii_probe(pldat->
ndev) != 0)
871 goto err_out_unregister_bus;
875 err_out_unregister_bus:
877 err_out_free_mdio_irq:
885 static void __lpc_handle_xmit(
struct net_device *ndev)
888 u32 txcidx, *ptxstat, txstat;
911 ndev->
stats.tx_fifo_errors++;
915 ndev->
stats.tx_aborted_errors++;
919 ndev->
stats.tx_aborted_errors++;
923 ndev->
stats.tx_aborted_errors++;
925 ndev->
stats.tx_errors++;
928 ndev->
stats.tx_packets++;
936 if (netif_queue_stopped(ndev))
937 netif_wake_queue(ndev);
945 u32 rxconsidx,
len, ethst;
952 while (rx_done < budget && rxconsidx !=
969 ndev->
stats.rx_fifo_errors++;
972 ndev->
stats.rx_crc_errors++;
975 ndev->
stats.rx_length_errors++;
976 }
else if (si & RXSTATUS_ERROR) {
978 ndev->
stats.rx_length_errors++;
980 ndev->
stats.rx_errors++;
983 skb = dev_alloc_skb(len);
985 ndev->
stats.rx_dropped++;
996 ndev->
stats.rx_packets++;
997 ndev->
stats.rx_bytes += len;
1002 rxconsidx = rxconsidx + 1;
1003 if (rxconsidx >= ENET_RX_DESC)
1019 struct netdev_queue *txq = netdev_get_tx_queue(ndev, 0);
1022 __lpc_handle_xmit(ndev);
1023 __netif_tx_unlock(txq);
1024 rx_done = __lpc_handle_recv(ndev, budget);
1026 if (rx_done < budget) {
1028 lpc_eth_enable_int(pldat->
net_base);
1040 spin_lock(&pldat->
lock);
1046 lpc_eth_disable_int(pldat->
net_base);
1047 if (
likely(napi_schedule_prep(&pldat->
napi)))
1050 spin_unlock(&pldat->
lock);
1055 static int lpc_eth_close(
struct net_device *ndev)
1057 unsigned long flags;
1063 napi_disable(&pldat->
napi);
1064 netif_stop_queue(ndev);
1070 __lpc_eth_reset(pldat);
1074 spin_unlock_irqrestore(&pldat->
lock, flags);
1076 __lpc_eth_clock_enable(pldat,
false);
1081 static int lpc_eth_hard_start_xmit(
struct sk_buff *skb,
struct net_device *ndev)
1090 spin_lock_irq(&pldat->
lock);
1095 netif_stop_queue(ndev);
1096 spin_unlock_irq(&pldat->
lock);
1097 WARN(1,
"BUG! TX request when no free TX buffers!\n");
1115 pldat->
skblen[txidx] = len;
1120 if (txidx >= ENET_TX_DESC)
1126 netif_stop_queue(ndev);
1128 spin_unlock_irq(&pldat->
lock);
1134 static int lpc_set_mac_address(
struct net_device *ndev,
void *
p)
1138 unsigned long flags;
1140 if (!is_valid_ether_addr(addr->
sa_data))
1147 __lpc_set_mac(pldat, ndev->
dev_addr);
1149 spin_unlock_irqrestore(&pldat->
lock, flags);
1154 static void lpc_eth_set_multicast_list(
struct net_device *ndev)
1159 u32 tmp32, hash_val, hashlo, hashhi;
1160 unsigned long flags;
1165 __lpc_set_mac(pldat, ndev->
dev_addr);
1190 hashhi |= 1 << (hash_val - 32);
1192 hashlo |= 1 << hash_val;
1198 spin_unlock_irqrestore(&pldat->
lock, flags);
1206 if (!netif_running(ndev))
1215 static int lpc_eth_open(
struct net_device *ndev)
1222 if (!is_valid_ether_addr(ndev->
dev_addr))
1225 __lpc_eth_clock_enable(pldat,
true);
1228 __lpc_eth_reset(pldat);
1229 __lpc_eth_init(pldat);
1233 netif_start_queue(ndev);
1234 napi_enable(&pldat->
napi);
1242 static void lpc_eth_ethtool_getdrvinfo(
struct net_device *ndev,
1250 static u32 lpc_eth_ethtool_getmsglevel(
struct net_device *ndev)
1264 static int lpc_eth_ethtool_getsettings(
struct net_device *ndev,
1276 static int lpc_eth_ethtool_setsettings(
struct net_device *ndev,
1288 static const struct ethtool_ops lpc_eth_ethtool_ops = {
1289 .get_drvinfo = lpc_eth_ethtool_getdrvinfo,
1290 .get_settings = lpc_eth_ethtool_getsettings,
1291 .set_settings = lpc_eth_ethtool_setsettings,
1292 .get_msglevel = lpc_eth_ethtool_getmsglevel,
1293 .set_msglevel = lpc_eth_ethtool_setmsglevel,
1298 .ndo_open = lpc_eth_open,
1299 .ndo_stop = lpc_eth_close,
1300 .ndo_start_xmit = lpc_eth_hard_start_xmit,
1301 .ndo_set_rx_mode = lpc_eth_set_multicast_list,
1302 .ndo_do_ioctl = lpc_eth_ioctl,
1303 .ndo_set_mac_address = lpc_set_mac_address,
1329 if ((!res) || (irq < 0) || (irq >=
NR_IRQS)) {
1330 dev_err(&pdev->
dev,
"error getting resources.\n");
1338 dev_err(&pdev->
dev,
"could not allocate device.\n");
1345 pldat = netdev_priv(ndev);
1356 if (IS_ERR(pldat->
clk)) {
1357 dev_err(&pdev->
dev,
"error getting clock.\n");
1358 ret = PTR_ERR(pldat->
clk);
1359 goto err_out_free_dev;
1363 __lpc_eth_clock_enable(pldat,
true);
1368 dev_err(&pdev->
dev,
"failed to map registers\n");
1370 goto err_out_disable_clocks;
1375 dev_err(&pdev->
dev,
"error requesting interrupt.\n");
1376 goto err_out_iounmap;
1392 if (use_iram_for_net(&pldat->
pdev->dev)) {
1399 "IRAM not big enough for net buffers, using SDRAM instead.\n");
1403 pldat->
pdev->dev.coherent_dma_mask = 0xFFFFFFFF;
1404 pldat->
pdev->dev.dma_mask = &pldat->
pdev->dev.coherent_dma_mask;
1415 dev_err(&pdev->
dev,
"error getting DMA region.\n");
1417 goto err_out_free_irq;
1422 netdev_dbg(ndev,
"IO address start :0x%08x\n",
1426 netdev_dbg(ndev,
"IO address (mapped) :0x%p\n",
1430 netdev_dbg(ndev,
"DMA buffer P address :0x%08x\n",
1432 netdev_dbg(ndev,
"DMA buffer V address :0x%p\n",
1436 __lpc_get_mac(pldat, ndev->
dev_addr);
1438 #ifdef CONFIG_OF_NET
1439 if (!is_valid_ether_addr(ndev->
dev_addr)) {
1445 if (!is_valid_ether_addr(ndev->
dev_addr))
1446 eth_hw_addr_random(ndev);
1449 __lpc_eth_reset(pldat);
1452 __lpc_eth_shutdown(pldat);
1458 __lpc_mii_mngt_reset(pldat);
1465 __lpc_params_setup(pldat);
1471 dev_err(&pdev->
dev,
"Cannot register net device, aborting.\n");
1472 goto err_out_dma_unmap;
1474 platform_set_drvdata(pdev, ndev);
1476 if (lpc_mii_init(pldat) != 0)
1477 goto err_out_unregister_netdev;
1479 netdev_info(ndev,
"LPC mac at 0x%08x irq %d\n",
1489 err_out_unregister_netdev:
1490 platform_set_drvdata(pdev,
NULL);
1493 if (!use_iram_for_net(&pldat->
pdev->dev) ||
1502 err_out_disable_clocks:
1514 struct net_device *ndev = platform_get_drvdata(pdev);
1518 platform_set_drvdata(pdev,
NULL);
1520 if (!use_iram_for_net(&pldat->
pdev->dev) ||
1540 struct net_device *ndev = platform_get_drvdata(pdev);
1543 if (device_may_wakeup(&pdev->
dev))
1544 enable_irq_wake(ndev->
irq);
1547 if (netif_running(ndev)) {
1549 __lpc_eth_shutdown(pldat);
1556 __lpc_eth_reset(pldat);
1565 struct net_device *ndev = platform_get_drvdata(pdev);
1568 if (device_may_wakeup(&pdev->
dev))
1569 disable_irq_wake(ndev->
irq);
1572 if (netif_running(ndev)) {
1573 pldat = netdev_priv(ndev);
1579 __lpc_eth_reset(pldat);
1580 __lpc_eth_init(pldat);
1599 .probe = lpc_eth_drv_probe,
1602 .suspend = lpc_eth_drv_suspend,
1603 .resume = lpc_eth_drv_resume,