27 #include <linux/module.h>
28 #include <linux/sched.h>
29 #include <linux/string.h>
30 #include <linux/errno.h>
32 #include <linux/types.h>
33 #include <linux/pci.h>
37 #include <linux/ethtool.h>
38 #include <linux/mii.h>
39 #include <linux/bitops.h>
43 #include <linux/slab.h>
45 #include <asm/processor.h>
48 #include <asm/uaccess.h>
71 #define DRV_NAME "emac"
72 #define DRV_VERSION "3.54"
73 #define DRV_DESC "PPC 4xx OCP EMAC driver"
84 #define cacheable_memcpy(d,s,n) memcpy((d),(s),(n))
88 #define EMAC_TX_WAKEUP_THRESH (NUM_TX_BUFF / 4)
93 #define EMAC_RX_COPY_THRESH CONFIG_IBM_EMAC_RX_COPY_THRESHOLD
103 static u32 busy_phy_map;
123 #define EMAC_BOOT_LIST_SIZE 4
127 #define EMAC_PROBE_DEP_TIMEOUT (HZ * 5)
138 DBG(dev,
"%s" NL, error);
150 #ifdef CONFIG_PPC_DCR_NATIVE
157 static inline void emac_rx_clk_default(
struct emac_instance *dev)
159 #ifdef CONFIG_PPC_DCR_NATIVE
167 #define PHY_POLL_LINK_ON HZ
168 #define PHY_POLL_LINK_OFF (HZ / 5)
173 #define STOP_TIMEOUT_10 1230
174 #define STOP_TIMEOUT_100 124
175 #define STOP_TIMEOUT_1000 13
176 #define STOP_TIMEOUT_1000_JUMBO 73
178 static unsigned char default_mcast_addr[] = {
179 0x01, 0x80, 0xC2, 0x00, 0x00, 0x01
184 "rx_packets",
"rx_bytes",
"tx_packets",
"tx_bytes",
"rx_packets_csum",
185 "tx_packets_csum",
"tx_undo",
"rx_dropped_stack",
"rx_dropped_oom",
186 "rx_dropped_error",
"rx_dropped_resize",
"rx_dropped_mtu",
187 "rx_stopped",
"rx_bd_errors",
"rx_bd_overrun",
"rx_bd_bad_packet",
188 "rx_bd_runt_packet",
"rx_bd_short_event",
"rx_bd_alignment_error",
189 "rx_bd_bad_fcs",
"rx_bd_packet_too_long",
"rx_bd_out_of_range",
190 "rx_bd_in_range",
"rx_parity",
"rx_fifo_overrun",
"rx_overrun",
191 "rx_bad_packet",
"rx_runt_packet",
"rx_short_event",
192 "rx_alignment_error",
"rx_bad_fcs",
"rx_packet_too_long",
193 "rx_out_of_range",
"rx_in_range",
"tx_dropped",
"tx_bd_errors",
194 "tx_bd_bad_fcs",
"tx_bd_carrier_loss",
"tx_bd_excessive_deferral",
195 "tx_bd_excessive_collisions",
"tx_bd_late_collision",
196 "tx_bd_multple_collisions",
"tx_bd_single_collision",
197 "tx_bd_underrun",
"tx_bd_sqe",
"tx_parity",
"tx_underrun",
"tx_sqe",
201 static irqreturn_t emac_irq(
int irq,
void *dev_instance);
203 static void __emac_set_multicast_list(
struct emac_instance *dev);
205 static inline int emac_phy_supports_gige(
int phy_mode)
214 static inline int emac_phy_gpcs(
int phy_mode)
226 DBG(dev,
"tx_enable" NL);
238 DBG(dev,
"tx_disable" NL);
249 emac_report_timeout_error(dev,
"TX disable timeout");
261 DBG(dev,
"rx_enable" NL);
268 while (!(r =
in_be32(&p->
mr0) & EMAC_MR0_RXI) && n) {
273 emac_report_timeout_error(dev,
274 "RX disable timeout");
287 DBG(dev,
"rx_disable" NL);
290 if (r & EMAC_MR0_RXE) {
293 while (!(
in_be32(&p->
mr0) & EMAC_MR0_RXI) && n) {
298 emac_report_timeout_error(dev,
"RX disable timeout");
302 static inline void emac_netif_stop(
struct emac_instance *dev)
304 netif_tx_lock_bh(dev->
ndev);
305 netif_addr_lock(dev->
ndev);
307 netif_addr_unlock(dev->
ndev);
308 netif_tx_unlock_bh(dev->
ndev);
311 netif_tx_disable(dev->
ndev);
314 static inline void emac_netif_start(
struct emac_instance *dev)
316 netif_tx_lock_bh(dev->
ndev);
317 netif_addr_lock(dev->
ndev);
320 __emac_set_multicast_list(dev);
321 netif_addr_unlock(dev->
ndev);
322 netif_tx_unlock_bh(dev->
ndev);
324 netif_wake_queue(dev->
ndev);
334 static inline void emac_rx_disable_async(
struct emac_instance *dev)
339 DBG(dev,
"rx_disable_async" NL);
342 if (r & EMAC_MR0_RXE)
351 DBG(dev,
"reset" NL);
357 emac_rx_disable(dev);
358 emac_tx_disable(dev);
361 #ifdef CONFIG_PPC_DCR_NATIVE
372 #ifdef CONFIG_PPC_DCR_NATIVE
383 emac_report_timeout_error(dev,
"reset timeout");
392 u32 *gaht_base = emac_gaht_base(dev);
399 memset(gaht_temp, 0,
sizeof (gaht_temp));
413 for (i = 0; i <
regs; i++)
414 out_be32(gaht_base + i, gaht_temp[i]);
445 static u32 __emac_calc_base_mr1(
struct emac_instance *dev,
int tx_size,
int rx_size)
449 DBG2(dev,
"__emac_calc_base_mr1" NL);
457 dev->
ndev->name, tx_size);
469 dev->
ndev->name, rx_size);
475 static u32 __emac4_calc_base_mr1(
struct emac_instance *dev,
int tx_size,
int rx_size)
480 DBG2(dev,
"__emac4_calc_base_mr1" NL);
494 dev->
ndev->name, tx_size);
509 dev->
ndev->name, rx_size);
515 static u32 emac_calc_base_mr1(
struct emac_instance *dev,
int tx_size,
int rx_size)
518 __emac4_calc_base_mr1(dev, tx_size, rx_size) :
519 __emac_calc_base_mr1(dev, tx_size, rx_size);
531 unsigned int low,
unsigned int high)
534 return (low << 22) | ( (high & 0x3ff) << 6);
536 return (low << 23) | ( (high & 0x1ff) << 7);
543 int tx_size, rx_size,
link = netif_carrier_ok(dev->
ndev);
546 DBG(dev,
"configure" NL);
552 }
else if (emac_reset(dev) < 0)
558 DBG(dev,
" link = %d duplex = %d, pause = %d, asym_pause = %d\n",
559 link, dev->
phy.duplex, dev->
phy.pause, dev->
phy.asym_pause);
575 switch (dev->
phy.speed) {
577 if (emac_phy_gpcs(dev->
phy.mode)) {
579 (dev->
phy.gpcs_address != 0xffffffff) ?
580 dev->
phy.gpcs_address : dev->
phy.address);
623 else if (dev->
phy.asym_pause)
628 mr1 |= emac_calc_base_mr1(dev, tx_size, rx_size);
641 r = emac_iff2rmr(ndev);
692 if (emac_phy_gpcs(dev->
phy.mode)) {
693 if (dev->
phy.gpcs_address != 0xffffffff)
704 DBG(dev,
"reinitialize" NL);
706 emac_netif_stop(dev);
707 if (!emac_configure(dev)) {
711 emac_netif_start(dev);
716 DBG(dev,
"full_tx_reset" NL);
718 emac_tx_disable(dev);
720 emac_clean_tx_ring(dev);
734 DBG(dev,
"reset_work" NL);
738 emac_netif_stop(dev);
739 emac_full_tx_reset(dev);
740 emac_netif_start(dev);
745 static void emac_tx_timeout(
struct net_device *ndev)
749 DBG(dev,
"tx_timeout" NL);
773 DBG2(dev,
"mdio_read(%02x,%02x)" NL,
id, reg);
786 DBG2(dev,
" -> timeout wait idle\n");
811 DBG2(dev,
" -> timeout wait complete\n");
817 DBG(dev,
"mdio_read(%02x, %02x) failed" NL,
id, reg);
824 DBG2(dev,
"mdio_read -> %04x" NL, r);
833 return err == 0 ? r :
err;
845 DBG2(dev,
"mdio_write(%02x,%02x,%04x)" NL,
id, reg, val);
858 DBG2(dev,
" -> timeout wait idle\n");
884 DBG2(dev,
" -> timeout wait complete\n");
897 static int emac_mdio_read(
struct net_device *ndev,
int id,
int reg)
903 dev->
phy.gpcs_address !=
id) ?
909 static void emac_mdio_write(
struct net_device *ndev,
int id,
int reg,
int val)
914 dev->
phy.gpcs_address !=
id) ?
920 static void __emac_set_multicast_list(
struct emac_instance *dev)
925 DBG(dev,
"__multicast %08x" NL, rmr);
945 emac_rx_disable(dev);
946 if (rmr & EMAC_RMR_MAE)
953 static void emac_set_multicast_list(
struct net_device *ndev)
957 DBG(dev,
"multicast" NL);
965 __emac_set_multicast_list(dev);
968 static int emac_resize_rx_ring(
struct emac_instance *dev,
int new_mtu)
973 int mr1_jumbo_bit_change = 0;
976 emac_netif_stop(dev);
977 emac_rx_disable(dev);
981 ++dev->
estats.rx_dropped_resize;
992 ++dev->
estats.rx_dropped_resize;
1000 if (rx_skb_size <= dev->rx_skb_size)
1012 dev_kfree_skb(dev->
rx_skb[i]);
1030 if (mr1_jumbo_bit_change) {
1034 dev->
ndev->mtu = new_mtu;
1035 emac_full_tx_reset(dev);
1044 emac_rx_enable(dev);
1045 emac_netif_start(dev);
1052 static int emac_change_mtu(
struct net_device *ndev,
int new_mtu)
1057 if (new_mtu < EMAC_MIN_MTU || new_mtu > dev->
max_mtu)
1060 DBG(dev,
"change_mtu(%d)" NL, new_mtu);
1062 if (netif_running(ndev)) {
1064 if (emac_rx_skb_size(ndev->
mtu) != emac_rx_skb_size(new_mtu))
1065 ret = emac_resize_rx_ring(dev, new_mtu);
1069 ndev->
mtu = new_mtu;
1083 dev_kfree_skb(dev->
tx_skb[i]);
1086 ++dev->
estats.tx_dropped;
1100 dev_kfree_skb(dev->
rx_skb[i]);
1111 static inline int emac_alloc_rx_skb(
struct emac_instance *dev,
int slot,
1132 static void emac_print_link_status(
struct emac_instance *dev)
1134 if (netif_carrier_ok(dev->
ndev))
1136 dev->
ndev->name, dev->
phy.speed,
1138 dev->
phy.pause ?
", pause enabled" :
1139 dev->
phy.asym_pause ?
", asymmetric pause enabled" :
"");
1145 static int emac_open(
struct net_device *ndev)
1150 DBG(dev,
"open" NL);
1177 if (dev->
phy.address >= 0) {
1178 int link_poll_interval;
1179 if (dev->
phy.def->ops->poll_link(&dev->
phy)) {
1180 dev->
phy.def->ops->read_link(&dev->
phy);
1181 emac_rx_clk_default(dev);
1185 emac_rx_clk_tx(dev);
1192 emac_print_link_status(dev);
1199 emac_configure(dev);
1204 emac_tx_enable(dev);
1205 emac_rx_enable(dev);
1206 emac_netif_start(dev);
1212 emac_clean_rx_ring(dev);
1244 pause = asym_pause = 0;
1246 return speed != dev->
phy.speed || duplex != dev->
phy.duplex ||
1247 pause != dev->
phy.pause || asym_pause != dev->
phy.asym_pause;
1251 static void emac_link_timer(
struct work_struct *work)
1256 int link_poll_interval;
1259 DBG2(dev,
"link timer" NL);
1264 if (dev->
phy.def->ops->poll_link(&dev->
phy)) {
1265 if (!netif_carrier_ok(dev->
ndev)) {
1266 emac_rx_clk_default(dev);
1268 dev->
phy.def->ops->read_link(&dev->
phy);
1271 emac_netif_stop(dev);
1272 emac_full_tx_reset(dev);
1273 emac_netif_start(dev);
1274 emac_print_link_status(dev);
1278 if (netif_carrier_ok(dev->
ndev)) {
1279 emac_rx_clk_tx(dev);
1281 netif_tx_disable(dev->
ndev);
1282 emac_reinitialize(dev);
1283 emac_print_link_status(dev);
1292 static void emac_force_link_update(
struct emac_instance *dev)
1304 static int emac_close(
struct net_device *ndev)
1308 DBG(dev,
"close" NL);
1310 if (dev->
phy.address >= 0) {
1315 emac_netif_stop(dev);
1319 emac_rx_disable(dev);
1320 emac_tx_disable(dev);
1325 emac_clean_tx_ring(dev);
1326 emac_clean_rx_ring(dev);
1340 ++dev->
stats.tx_packets_csum;
1346 static inline int emac_xmit_finish(
struct emac_instance *dev,
int len)
1361 netif_stop_queue(ndev);
1362 DBG2(dev,
"stopped TX queue" NL);
1366 ++dev->
stats.tx_packets;
1367 dev->
stats.tx_bytes += len;
1376 unsigned int len = skb->
len;
1383 if (dev->
tx_slot == NUM_TX_BUFF) {
1388 DBG2(dev,
"xmit(%u) %d" NL, len, slot);
1398 return emac_xmit_finish(dev, len);
1401 static inline int emac_xmit_split(
struct emac_instance *dev,
int slot,
1402 u32 pd,
int len,
int last,
u16 base_ctrl)
1405 u16 ctrl = base_ctrl;
1409 slot = (slot + 1) % NUM_TX_BUFF;
1413 if (slot == NUM_TX_BUFF - 1)
1434 int nr_frags = skb_shinfo(skb)->nr_frags;
1442 return emac_start_xmit(skb, ndev);
1450 if (
unlikely(dev->
tx_cnt + nr_frags + mal_tx_chunks(len) > NUM_TX_BUFF))
1454 emac_tx_csum(dev, skb);
1465 slot = emac_xmit_split(dev, slot, pd + chunk, len, !nr_frags,
1468 for (i = 0; i < nr_frags; ++
i) {
1470 len = skb_frag_size(frag);
1475 pd = skb_frag_dma_map(&dev->
ofdev->dev, frag, 0, len,
1478 slot = emac_xmit_split(dev, slot, pd, len, i == nr_frags - 1,
1482 DBG2(dev,
"xmit_sg(%u) %d - %d" NL, skb->
len, dev->
tx_slot, slot);
1488 if (dev->
tx_slot == NUM_TX_BUFF - 1)
1492 dev->
tx_slot = (slot + 1) % NUM_TX_BUFF;
1494 return emac_xmit_finish(dev, skb->
len);
1500 while (slot != dev->
tx_slot) {
1504 slot = NUM_TX_BUFF - 1;
1509 netif_stop_queue(ndev);
1510 DBG2(dev,
"stopped TX queue" NL);
1519 DBG(dev,
"BD TX error %04x" NL, ctrl);
1542 static void emac_poll_tx(
void *
param)
1554 netif_tx_lock_bh(dev->
ndev);
1568 slot = (slot + 1) % NUM_TX_BUFF;
1571 emac_parse_tx_error(dev, ctrl);
1578 if (netif_queue_stopped(dev->
ndev) &&
1580 netif_wake_queue(dev->
ndev);
1582 DBG2(dev,
"tx %d pkts" NL, n);
1585 netif_tx_unlock_bh(dev->
ndev);
1588 static inline void emac_recycle_rx_skb(
struct emac_instance *dev,
int slot,
1593 DBG2(dev,
"recycle %d %d" NL, slot, len);
1609 DBG(dev,
"BD RX error %04x" NL, ctrl);
1635 #ifdef CONFIG_IBM_EMAC_TAH
1638 ++dev->
stats.rx_packets_csum;
1643 static inline int emac_rx_sg_append(
struct emac_instance *dev,
int slot)
1647 int tot_len = dev->
rx_sg_skb->len + len;
1650 ++dev->
estats.rx_dropped_mtu;
1654 cacheable_memcpy(skb_tail_pointer(dev->
rx_sg_skb),
1655 dev->
rx_skb[slot]->data, len);
1657 emac_recycle_rx_skb(dev, slot, len);
1661 emac_recycle_rx_skb(dev, slot, 0);
1666 static int emac_poll_rx(
void *param,
int budget)
1669 int slot = dev->
rx_slot, received = 0;
1671 DBG2(dev,
"poll_rx(%d)" NL, budget);
1674 while (budget > 0) {
1691 emac_parse_rx_error(dev, ctrl);
1692 ++dev->
estats.rx_dropped_error;
1693 emac_recycle_rx_skb(dev, slot, 0);
1699 ++dev->
estats.rx_dropped_stack;
1700 emac_recycle_rx_skb(dev, slot, len);
1711 cacheable_memcpy(copy_skb->
data - 2, skb->
data - 2,
1713 emac_recycle_rx_skb(dev, slot, len);
1721 emac_rx_csum(dev, skb, ctrl);
1724 ++dev->
estats.rx_dropped_stack;
1726 ++dev->
stats.rx_packets;
1729 slot = (slot + 1) % NUM_RX_BUFF;
1737 DBG(dev,
"rx OOM %d" NL, slot);
1738 ++dev->
estats.rx_dropped_oom;
1739 emac_recycle_rx_skb(dev, slot, 0);
1744 }
else if (!emac_rx_sg_append(dev, slot) &&
1752 emac_parse_rx_error(dev, ctrl);
1753 ++dev->
estats.rx_dropped_error;
1761 DBG(dev,
"rx OOM %d" NL, slot);
1763 ++dev->
estats.rx_dropped_oom;
1764 emac_recycle_rx_skb(dev, slot, 0);
1769 DBG2(dev,
"rx %d BDs" NL, received);
1775 if (!(dev->
rx_desc[slot].ctrl & MAL_RX_CTRL_EMPTY)) {
1776 DBG2(dev,
"rx restart" NL);
1782 DBG2(dev,
"dropping partial rx packet" NL);
1783 ++dev->
estats.rx_dropped_error;
1790 emac_rx_enable(dev);
1797 static int emac_peek_rx(
void *param)
1805 static int emac_peek_rx_sg(
void *param)
1812 if (ctrl & MAL_RX_CTRL_EMPTY)
1814 else if (ctrl & MAL_RX_CTRL_LAST)
1817 slot = (slot + 1) % NUM_RX_BUFF;
1826 static void emac_rxde(
void *param)
1830 ++dev->
estats.rx_stopped;
1831 emac_rx_disable_async(dev);
1842 spin_lock(&dev->
lock);
1847 DBG(dev,
"isr = %08x" NL, isr);
1880 spin_unlock(&dev->
lock);
1891 unsigned long flags;
1893 DBG2(dev,
"stats" NL);
1934 spin_unlock_irqrestore(&dev->
lock, flags);
1939 .poll_tx = &emac_poll_tx,
1940 .poll_rx = &emac_poll_rx,
1941 .peek_rx = &emac_peek_rx,
1946 .poll_tx = &emac_poll_tx,
1947 .poll_rx = &emac_poll_rx,
1948 .peek_rx = &emac_peek_rx_sg,
1953 static int emac_ethtool_get_settings(
struct net_device *ndev,
1974 static int emac_ethtool_set_settings(
struct net_device *ndev,
1980 DBG(dev,
"set_settings(%d, %d, %d, 0x%08x)" NL,
1984 if (dev->
phy.address < 0)
1994 switch (cmd->
speed) {
2024 dev->
phy.def->ops->setup_forced(&dev->
phy, cmd->
speed,
2033 dev->
phy.def->ops->setup_aneg(&dev->
phy,
2035 (dev->
phy.advertising &
2040 emac_force_link_update(dev);
2045 static void emac_ethtool_get_ringparam(
struct net_device *ndev,
2052 static void emac_ethtool_get_pauseparam(
struct net_device *ndev,
2065 else if (dev->
phy.asym_pause)
2081 static int emac_ethtool_get_regs_len(
struct net_device *ndev)
2114 static void emac_ethtool_get_regs(
struct net_device *ndev,
2124 buf = emac_dump_regs(dev, buf);
2139 static int emac_ethtool_nway_reset(
struct net_device *ndev)
2144 DBG(dev,
"nway_reset" NL);
2146 if (dev->
phy.address < 0)
2150 if (!dev->
phy.autoneg) {
2155 dev->
phy.def->ops->setup_aneg(&dev->
phy, dev->
phy.advertising);
2158 emac_force_link_update(dev);
2162 static int emac_ethtool_get_sset_count(
struct net_device *ndev,
int stringset)
2170 static void emac_ethtool_get_strings(
struct net_device *ndev,
u32 stringset,
2174 memcpy(buf, &emac_stats_keys,
sizeof(emac_stats_keys));
2177 static void emac_ethtool_get_ethtool_stats(
struct net_device *ndev,
2184 tmp_stats +=
sizeof(dev->
stats) /
sizeof(
u64);
2188 static void emac_ethtool_get_drvinfo(
struct net_device *ndev,
2198 info->
regdump_len = emac_ethtool_get_regs_len(ndev);
2201 static const struct ethtool_ops emac_ethtool_ops = {
2202 .get_settings = emac_ethtool_get_settings,
2203 .set_settings = emac_ethtool_set_settings,
2204 .get_drvinfo = emac_ethtool_get_drvinfo,
2206 .get_regs_len = emac_ethtool_get_regs_len,
2207 .get_regs = emac_ethtool_get_regs,
2209 .nway_reset = emac_ethtool_nway_reset,
2211 .get_ringparam = emac_ethtool_get_ringparam,
2212 .get_pauseparam = emac_ethtool_get_pauseparam,
2214 .get_strings = emac_ethtool_get_strings,
2215 .get_sset_count = emac_ethtool_get_sset_count,
2216 .get_ethtool_stats = emac_ethtool_get_ethtool_stats,
2226 DBG(dev,
"ioctl %08x" NL, cmd);
2228 if (dev->
phy.address < 0)
2236 data->
val_out = emac_mdio_read(ndev, dev->
phy.address,
2241 emac_mdio_write(ndev, dev->
phy.address, data->
reg_num,
2256 #define EMAC_DEP_MAL_IDX 0
2257 #define EMAC_DEP_ZMII_IDX 1
2258 #define EMAC_DEP_RGMII_IDX 2
2259 #define EMAC_DEP_TAH_IDX 3
2260 #define EMAC_DEP_MDIO_IDX 4
2261 #define EMAC_DEP_PREV_IDX 5
2262 #define EMAC_DEP_COUNT 6
2278 np = *(dev->
blist - 1);
2285 deps[
i].
node = of_node_get(np);
2291 if (deps[i].ofdev ==
NULL)
2293 if (deps[i].ofdev ==
NULL)
2318 unsigned long action,
void *data)
2327 .notifier_call = emac_of_bus_notify
2335 memset(&deps, 0,
sizeof(deps));
2344 if (dev->
blist && dev->
blist > emac_boot_list)
2348 emac_check_deps(dev, deps),
2351 err = emac_check_deps(dev, deps) ? 0 : -
ENODEV;
2354 of_node_put(deps[i].node);
2355 if (err && deps[i].
ofdev)
2375 if (prop ==
NULL || len <
sizeof(
u32)) {
2404 dev->
phy.address = -1;
2406 if (emac_phy_supports_gige(dev->
phy_mode))
2416 phy_map = dev->
phy_map | busy_phy_map;
2418 DBG(dev,
"PHY maps %08x %08x" NL, dev->
phy_map, busy_phy_map);
2420 dev->
phy.mdio_read = emac_mdio_read;
2421 dev->
phy.mdio_write = emac_mdio_write;
2424 #ifdef CONFIG_PPC_DCR_NATIVE
2429 emac_rx_clk_tx(dev);
2432 #ifdef CONFIG_PPC_DCR_NATIVE
2439 if (emac_phy_gpcs(dev->
phy.mode)) {
2449 if (dev->
phy.gpcs_address == 0xffffffff)
2453 emac_configure(dev);
2458 for (i = 0; i < 0x20; phy_map >>= 1, ++
i)
2459 if (!(phy_map & 1)) {
2461 busy_phy_map |= 1 <<
i;
2465 if (r == 0xffff || r < 0)
2472 #ifdef CONFIG_PPC_DCR_NATIVE
2483 if (dev->
phy.def->ops->init)
2484 dev->
phy.def->ops->init(&dev->
phy);
2492 adv = dev->
phy.features;
2496 dev->
phy.def->ops->setup_aneg(&dev->
phy, adv);
2498 u32 f = dev->
phy.def->features;
2505 }
else if (f & SUPPORTED_1000baseT_Half)
2507 else if (f & SUPPORTED_100baseT_Full) {
2510 }
else if (f & SUPPORTED_100baseT_Half)
2512 else if (f & SUPPORTED_10baseT_Full)
2516 dev->
phy.def->ops->setup_forced(&dev->
phy, speed, fd);
2527 if (emac_read_uint_prop(np,
"mal-device", &dev->
mal_ph, 1))
2529 if (emac_read_uint_prop(np,
"mal-tx-channel", &dev->
mal_tx_chan, 1))
2531 if (emac_read_uint_prop(np,
"mal-rx-channel", &dev->
mal_rx_chan, 1))
2533 if (emac_read_uint_prop(np,
"cell-index", &dev->
cell_index, 1))
2535 if (emac_read_uint_prop(np,
"max-frame-size", &dev->
max_mtu, 0))
2537 if (emac_read_uint_prop(np,
"rx-fifo-size", &dev->
rx_fifo_size, 0))
2539 if (emac_read_uint_prop(np,
"tx-fifo-size", &dev->
tx_fifo_size, 0))
2545 if (emac_read_uint_prop(np,
"phy-address", &dev->
phy_address, 0))
2547 if (emac_read_uint_prop(np,
"phy-map", &dev->
phy_map, 0))
2549 if (emac_read_uint_prop(np,
"gpcs-address", &dev->
gpcs_address, 0))
2553 if (emac_read_uint_prop(np,
"tah-device", &dev->
tah_ph, 0))
2555 if (emac_read_uint_prop(np,
"tah-channel", &dev->
tah_port, 0))
2557 if (emac_read_uint_prop(np,
"mdio-device", &dev->
mdio_ph, 0))
2559 if (emac_read_uint_prop(np,
"zmii-device", &dev->
zmii_ph, 0))
2561 if (emac_read_uint_prop(np,
"zmii-channel", &dev->
zmii_port, 0))
2563 if (emac_read_uint_prop(np,
"rgmii-device", &dev->
rgmii_ph, 0))
2565 if (emac_read_uint_prop(np,
"rgmii-channel", &dev->
rgmii_port, 0))
2567 if (emac_read_uint_prop(np,
"fifo-entry-size", &dev->
fifo_entry_size, 0))
2569 if (emac_read_uint_prop(np,
"mal-burst-size", &dev->
mal_burst_size, 0))
2600 #ifdef CONFIG_IBM_EMAC_NO_FLOW_CTRL
2624 #ifdef CONFIG_IBM_EMAC_TAH
2634 #ifdef CONFIG_IBM_EMAC_ZMII
2644 #ifdef CONFIG_IBM_EMAC_RGMII
2681 .ndo_open = emac_open,
2682 .ndo_stop = emac_close,
2684 .ndo_set_rx_mode = emac_set_multicast_list,
2685 .ndo_do_ioctl = emac_ioctl,
2686 .ndo_tx_timeout = emac_tx_timeout,
2689 .ndo_start_xmit = emac_start_xmit,
2694 .ndo_open = emac_open,
2695 .ndo_stop = emac_close,
2697 .ndo_set_rx_mode = emac_set_multicast_list,
2698 .ndo_do_ioctl = emac_ioctl,
2699 .ndo_tx_timeout = emac_tx_timeout,
2702 .ndo_start_xmit = emac_start_xmit_sg,
2703 .ndo_change_mtu = emac_change_mtu,
2723 if (emac_boot_list[i] == np)
2724 blist = &emac_boot_list[
i];
2732 dev = netdev_priv(ndev);
2745 err = emac_init_config(dev);
2775 err = emac_wait_deps(dev);
2778 "%s: Timeout waiting for dependent devices\n",
2788 dev->
commac.ops = &emac_commac_ops;
2819 goto err_unreg_commac;
2824 goto err_detach_zmii;
2829 goto err_detach_rgmii;
2835 dev->
phy.pause = dev->
phy.asym_pause = 0;
2842 SUPPORTED_100baseT_Half |
2847 err = emac_init_phy(dev);
2849 goto err_detach_tah;
2856 if (emac_phy_supports_gige(dev->
phy_mode)) {
2858 dev->
commac.ops = &emac_commac_sg_ops;
2869 goto err_detach_tah;
2888 if (dev->
phy.address >= 0)
2889 printk(
"%s: found %s PHY (0x%02x)\n", ndev->
name,
2890 dev->
phy.def->name, dev->
phy.address);
2937 DBG(dev,
"remove" NL);
2952 busy_phy_map &= ~(1 << dev->
phy.address);
2953 DBG(dev,
"busy_phy_map now %#x" NL, busy_phy_map);
2976 .compatible =
"ibm,emac",
2980 .compatible =
"ibm,emac4",
2984 .compatible =
"ibm,emac4sync",
2994 .of_match_table = emac_match,
2996 .probe = emac_probe,
2997 .remove = emac_remove,
3000 static void __init emac_make_bootlist(
void)
3003 int j,
max, i = 0,
k;
3017 cell_indices[
i] = *
idx;
3018 emac_boot_list[i++] = of_node_get(np);
3019 if (i >= EMAC_BOOT_LIST_SIZE) {
3027 for (i = 0; max > 1 && (i < (max - 1)); i++)
3028 for (j = i; j <
max; j++) {
3029 if (cell_indices[i] > cell_indices[j]) {
3030 np = emac_boot_list[
i];
3031 emac_boot_list[
i] = emac_boot_list[
j];
3032 emac_boot_list[
j] = np;
3033 k = cell_indices[
i];
3034 cell_indices[
i] = cell_indices[
j];
3035 cell_indices[
j] =
k;
3040 static int __init emac_init(
void)
3050 emac_make_bootlist();
3083 static void __exit emac_exit(
void)
3097 if (emac_boot_list[i])
3098 of_node_put(emac_boot_list[i]);