diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/et131x/Makefile | 1 | ||||
-rw-r--r-- | drivers/staging/et131x/et1310_phy.c | 45 | ||||
-rw-r--r-- | drivers/staging/et131x/et1310_phy.h | 4 | ||||
-rw-r--r-- | drivers/staging/et131x/et131x.h | 6 | ||||
-rw-r--r-- | drivers/staging/et131x/et131x_adapter.h | 3 | ||||
-rw-r--r-- | drivers/staging/et131x/et131x_ethtool.c | 71 | ||||
-rw-r--r-- | drivers/staging/et131x/et131x_initpci.c | 147 | ||||
-rw-r--r-- | drivers/staging/et131x/et131x_netdev.c | 7 |
8 files changed, 254 insertions, 30 deletions
diff --git a/drivers/staging/et131x/Makefile b/drivers/staging/et131x/Makefile index dfcd2bfcb94..5ea0272fc7a 100644 --- a/drivers/staging/et131x/Makefile +++ b/drivers/staging/et131x/Makefile | |||
@@ -11,5 +11,6 @@ et131x-y := et1310_eeprom.o \ | |||
11 | et1310_rx.o \ | 11 | et1310_rx.o \ |
12 | et1310_tx.o \ | 12 | et1310_tx.o \ |
13 | et131x_initpci.o \ | 13 | et131x_initpci.o \ |
14 | et131x_ethtool.o \ | ||
14 | et131x_isr.o \ | 15 | et131x_isr.o \ |
15 | et131x_netdev.o | 16 | et131x_netdev.o |
diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 21e07042795..5e21a180af9 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Agere Systems Inc. | 2 | * Agere Systems Inc. |
3 | * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs | 3 | * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs |
4 | * | 4 | * |
5 | * Copyright * 2005 Agere Systems Inc. | 5 | * Copyright * 2005 Agere Systems Inc. |
6 | * All rights reserved. | 6 | * All rights reserved. |
@@ -82,6 +82,7 @@ | |||
82 | #include <linux/if_arp.h> | 82 | #include <linux/if_arp.h> |
83 | #include <linux/ioport.h> | 83 | #include <linux/ioport.h> |
84 | #include <linux/random.h> | 84 | #include <linux/random.h> |
85 | #include <linux/phy.h> | ||
85 | 86 | ||
86 | #include "et1310_phy.h" | 87 | #include "et1310_phy.h" |
87 | 88 | ||
@@ -93,6 +94,40 @@ | |||
93 | 94 | ||
94 | #include "et131x.h" | 95 | #include "et131x.h" |
95 | 96 | ||
97 | int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg) | ||
98 | { | ||
99 | struct net_device *netdev = bus->priv; | ||
100 | struct et131x_adapter *adapter = netdev_priv(netdev); | ||
101 | u16 value; | ||
102 | int ret; | ||
103 | |||
104 | ret = et131x_phy_mii_read(adapter, phy_addr, reg, &value); | ||
105 | |||
106 | if (ret < 0) | ||
107 | return ret; | ||
108 | else | ||
109 | return value; | ||
110 | } | ||
111 | |||
112 | int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value) | ||
113 | { | ||
114 | struct net_device *netdev = bus->priv; | ||
115 | struct et131x_adapter *adapter = netdev_priv(netdev); | ||
116 | |||
117 | /* mii_write always uses the same phy_addr, xcvr_addr */ | ||
118 | return et131x_mii_write(adapter, reg, value); | ||
119 | } | ||
120 | |||
121 | int et131x_mdio_reset(struct mii_bus *bus) | ||
122 | { | ||
123 | struct net_device *netdev = bus->priv; | ||
124 | struct et131x_adapter *adapter = netdev_priv(netdev); | ||
125 | |||
126 | et1310_phy_reset(adapter); | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
96 | /** | 131 | /** |
97 | * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC | 132 | * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC |
98 | * @adapter: pointer to our private adapter structure | 133 | * @adapter: pointer to our private adapter structure |
@@ -107,7 +142,7 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr, | |||
107 | { | 142 | { |
108 | struct mac_regs __iomem *mac = &adapter->regs->mac; | 143 | struct mac_regs __iomem *mac = &adapter->regs->mac; |
109 | int status = 0; | 144 | int status = 0; |
110 | u32 delay; | 145 | u32 delay = 0; |
111 | u32 mii_addr; | 146 | u32 mii_addr; |
112 | u32 mii_cmd; | 147 | u32 mii_cmd; |
113 | u32 mii_indicator; | 148 | u32 mii_indicator; |
@@ -124,9 +159,6 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr, | |||
124 | /* Set up the register we need to read from on the correct PHY */ | 159 | /* Set up the register we need to read from on the correct PHY */ |
125 | writel(MII_ADDR(xcvr_addr, xcvr_reg), &mac->mii_mgmt_addr); | 160 | writel(MII_ADDR(xcvr_addr, xcvr_reg), &mac->mii_mgmt_addr); |
126 | 161 | ||
127 | /* Kick the read cycle off */ | ||
128 | delay = 0; | ||
129 | |||
130 | writel(0x1, &mac->mii_mgmt_cmd); | 162 | writel(0x1, &mac->mii_mgmt_cmd); |
131 | 163 | ||
132 | do { | 164 | do { |
@@ -176,7 +208,7 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value) | |||
176 | struct mac_regs __iomem *mac = &adapter->regs->mac; | 208 | struct mac_regs __iomem *mac = &adapter->regs->mac; |
177 | int status = 0; | 209 | int status = 0; |
178 | u8 xcvr_addr = adapter->stats.xcvr_addr; | 210 | u8 xcvr_addr = adapter->stats.xcvr_addr; |
179 | u32 delay; | 211 | u32 delay = 0; |
180 | u32 mii_addr; | 212 | u32 mii_addr; |
181 | u32 mii_cmd; | 213 | u32 mii_cmd; |
182 | u32 mii_indicator; | 214 | u32 mii_indicator; |
@@ -195,7 +227,6 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value) | |||
195 | 227 | ||
196 | /* Add the value to write to the registers to the mac */ | 228 | /* Add the value to write to the registers to the mac */ |
197 | writel(value, &mac->mii_mgmt_ctrl); | 229 | writel(value, &mac->mii_mgmt_ctrl); |
198 | delay = 0; | ||
199 | 230 | ||
200 | do { | 231 | do { |
201 | udelay(50); | 232 | udelay(50); |
diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 6b38a3e0cab..8e9404e1473 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h | |||
@@ -121,8 +121,8 @@ struct mi_regs { | |||
121 | u8 imr; /* Interrupt Mask Reg(Reg 0x18) */ | 121 | u8 imr; /* Interrupt Mask Reg(Reg 0x18) */ |
122 | u8 isr; /* Interrupt Status Reg(Reg 0x19) */ | 122 | u8 isr; /* Interrupt Status Reg(Reg 0x19) */ |
123 | u8 psr; /* PHY Status Reg(Reg 0x1A) */ | 123 | u8 psr; /* PHY Status Reg(Reg 0x1A) */ |
124 | u8 lcr1; /* LED Control 1 Reg(Reg 0x1B) */ | 124 | u8 lcr1; /* LED Control 1 Reg(Reg 0x1B) */ |
125 | u8 lcr2; /* LED Control 2 Reg(Reg 0x1C) */ | 125 | u8 lcr2; /* LED Control 2 Reg(Reg 0x1C) */ |
126 | u8 mi_res4[3]; /* Future use by MI working group(Reg 0x1D - 0x1F) */ | 126 | u8 mi_res4[3]; /* Future use by MI working group(Reg 0x1D - 0x1F) */ |
127 | }; | 127 | }; |
128 | 128 | ||
diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 91fafc0331e..9dee7bce073 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h | |||
@@ -116,6 +116,10 @@ int32_t et131x_mii_write(struct et131x_adapter *adapter, | |||
116 | void et131x_mii_check(struct et131x_adapter *pAdapter, | 116 | void et131x_mii_check(struct et131x_adapter *pAdapter, |
117 | u16 bmsr, u16 bmsr_ints); | 117 | u16 bmsr, u16 bmsr_ints); |
118 | 118 | ||
119 | int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg); | ||
120 | int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value); | ||
121 | int et131x_mdio_reset(struct mii_bus *bus); | ||
122 | |||
119 | /* et1310_rx.c */ | 123 | /* et1310_rx.c */ |
120 | int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter); | 124 | int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter); |
121 | void et131x_rx_dma_memory_free(struct et131x_adapter *adapter); | 125 | void et131x_rx_dma_memory_free(struct et131x_adapter *adapter); |
@@ -145,3 +149,5 @@ void et131x_handle_send_interrupt(struct et131x_adapter *adapter); | |||
145 | void et131x_free_busy_send_packets(struct et131x_adapter *adapter); | 149 | void et131x_free_busy_send_packets(struct et131x_adapter *adapter); |
146 | int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev); | 150 | int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev); |
147 | 151 | ||
152 | /* et131x_ethtool.c */ | ||
153 | void et131x_set_ethtool_ops(struct net_device *netdev); | ||
diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index 508cc632ad8..dbb14fed2dd 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h | |||
@@ -144,7 +144,8 @@ struct ce_stats { | |||
144 | struct et131x_adapter { | 144 | struct et131x_adapter { |
145 | struct net_device *netdev; | 145 | struct net_device *netdev; |
146 | struct pci_dev *pdev; | 146 | struct pci_dev *pdev; |
147 | 147 | struct mii_bus *mii_bus; | |
148 | struct phy_device *phydev; | ||
148 | struct work_struct task; | 149 | struct work_struct task; |
149 | 150 | ||
150 | /* Flags that indicate current state of the adapter */ | 151 | /* Flags that indicate current state of the adapter */ |
diff --git a/drivers/staging/et131x/et131x_ethtool.c b/drivers/staging/et131x/et131x_ethtool.c new file mode 100644 index 00000000000..d980ad6c552 --- /dev/null +++ b/drivers/staging/et131x/et131x_ethtool.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Mark Einon | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | * | ||
18 | * Mark Einon <mark.einon@gmail.com> | ||
19 | */ | ||
20 | #include "et131x_version.h" | ||
21 | #include "et131x_defs.h" | ||
22 | |||
23 | #include <linux/types.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/netdevice.h> | ||
26 | #include <linux/ethtool.h> | ||
27 | #include <linux/phy.h> | ||
28 | #include <linux/pci.h> | ||
29 | |||
30 | #include "et131x_adapter.h" | ||
31 | #include "et131x.h" | ||
32 | |||
33 | static int et131x_get_settings(struct net_device *netdev, | ||
34 | struct ethtool_cmd *cmd) | ||
35 | { | ||
36 | struct et131x_adapter *adapter = netdev_priv(netdev); | ||
37 | |||
38 | return phy_ethtool_gset(adapter->phydev, cmd); | ||
39 | } | ||
40 | |||
41 | static int et131x_set_settings(struct net_device *netdev, | ||
42 | struct ethtool_cmd *cmd) | ||
43 | { | ||
44 | struct et131x_adapter *adapter = netdev_priv(netdev); | ||
45 | |||
46 | return phy_ethtool_sset(adapter->phydev, cmd); | ||
47 | } | ||
48 | |||
49 | #define ET131X_DRVINFO_LEN 32 /* value from ethtool.h */ | ||
50 | static void et131x_get_drvinfo(struct net_device *netdev, | ||
51 | struct ethtool_drvinfo *info) | ||
52 | { | ||
53 | struct et131x_adapter *adapter = netdev_priv(netdev); | ||
54 | |||
55 | strncpy(info->driver, DRIVER_NAME, ET131X_DRVINFO_LEN); | ||
56 | strncpy(info->version, DRIVER_VERSION_STRING, ET131X_DRVINFO_LEN); | ||
57 | strncpy(info->bus_info, pci_name(adapter->pdev), ET131X_DRVINFO_LEN); | ||
58 | } | ||
59 | |||
60 | static struct ethtool_ops et131x_ethtool_ops = { | ||
61 | .get_settings = et131x_get_settings, | ||
62 | .set_settings = et131x_set_settings, | ||
63 | .get_drvinfo = et131x_get_drvinfo, | ||
64 | .get_link = ethtool_op_get_link, | ||
65 | }; | ||
66 | |||
67 | void et131x_set_ethtool_ops(struct net_device *netdev) | ||
68 | { | ||
69 | SET_ETHTOOL_OPS(netdev, &et131x_ethtool_ops); | ||
70 | } | ||
71 | |||
diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index a184ac1669e..fbbef7627bc 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c | |||
@@ -80,6 +80,7 @@ | |||
80 | 80 | ||
81 | #include <linux/netdevice.h> | 81 | #include <linux/netdevice.h> |
82 | #include <linux/etherdevice.h> | 82 | #include <linux/etherdevice.h> |
83 | #include <linux/phy.h> | ||
83 | #include <linux/skbuff.h> | 84 | #include <linux/skbuff.h> |
84 | #include <linux/if_arp.h> | 85 | #include <linux/if_arp.h> |
85 | #include <linux/ioport.h> | 86 | #include <linux/ioport.h> |
@@ -329,7 +330,7 @@ void et131x_configure_global_regs(struct et131x_adapter *adapter) | |||
329 | */ | 330 | */ |
330 | int et131x_adapter_setup(struct et131x_adapter *adapter) | 331 | int et131x_adapter_setup(struct et131x_adapter *adapter) |
331 | { | 332 | { |
332 | int status = 0; | 333 | int status; |
333 | 334 | ||
334 | /* Configure the JAGCore */ | 335 | /* Configure the JAGCore */ |
335 | et131x_configure_global_regs(adapter); | 336 | et131x_configure_global_regs(adapter); |
@@ -351,7 +352,7 @@ int et131x_adapter_setup(struct et131x_adapter *adapter) | |||
351 | /* Move the following code to Timer function?? */ | 352 | /* Move the following code to Timer function?? */ |
352 | status = et131x_xcvr_find(adapter); | 353 | status = et131x_xcvr_find(adapter); |
353 | 354 | ||
354 | if (status != 0) | 355 | if (status) |
355 | dev_warn(&adapter->pdev->dev, "Could not find the xcvr\n"); | 356 | dev_warn(&adapter->pdev->dev, "Could not find the xcvr\n"); |
356 | 357 | ||
357 | /* Prepare the TRUEPHY library. */ | 358 | /* Prepare the TRUEPHY library. */ |
@@ -471,6 +472,80 @@ void et131x_adapter_memory_free(struct et131x_adapter *adapter) | |||
471 | et131x_rx_dma_memory_free(adapter); | 472 | et131x_rx_dma_memory_free(adapter); |
472 | } | 473 | } |
473 | 474 | ||
475 | static void et131x_adjust_link(struct net_device *netdev) | ||
476 | { | ||
477 | struct et131x_adapter *adapter = netdev_priv(netdev); | ||
478 | struct phy_device *phydev = adapter->phydev; | ||
479 | struct address_map __iomem *iomem = adapter->regs; | ||
480 | |||
481 | u32 pm_csr; | ||
482 | u16 bmsr_ints; | ||
483 | u16 bmsr_data; | ||
484 | |||
485 | /* If we are in coma mode, we need to disable it. */ | ||
486 | pm_csr = readl(&iomem->global.pm_csr); | ||
487 | if (pm_csr & ET_PM_PHY_SW_COMA) { | ||
488 | /* | ||
489 | * Check to see if we are in coma mode and if | ||
490 | * so, disable it because we will not be able | ||
491 | * to read PHY values until we are out. | ||
492 | */ | ||
493 | et1310_disable_phy_coma(adapter); | ||
494 | } | ||
495 | |||
496 | et131x_mii_read(adapter, | ||
497 | (uint8_t) offsetof(struct mi_regs, bmsr), | ||
498 | &bmsr_data); | ||
499 | |||
500 | bmsr_ints = adapter->bmsr ^ bmsr_data; | ||
501 | adapter->bmsr = bmsr_data; | ||
502 | |||
503 | /* Do all the cable in / cable out stuff */ | ||
504 | et131x_mii_check(adapter, bmsr_data, bmsr_ints); | ||
505 | |||
506 | phy_print_status(phydev); | ||
507 | } | ||
508 | |||
509 | int et131x_mii_probe(struct net_device *netdev) | ||
510 | { | ||
511 | struct et131x_adapter *adapter = netdev_priv(netdev); | ||
512 | struct phy_device *phydev = NULL; | ||
513 | |||
514 | phydev = phy_find_first(adapter->mii_bus); | ||
515 | if (!phydev) { | ||
516 | dev_err(&adapter->pdev->dev, "no PHY found\n"); | ||
517 | return -ENODEV; | ||
518 | } | ||
519 | |||
520 | phydev = phy_connect(netdev, dev_name(&phydev->dev), | ||
521 | &et131x_adjust_link, 0, PHY_INTERFACE_MODE_MII); | ||
522 | |||
523 | if(IS_ERR(phydev)) { | ||
524 | dev_err(&adapter->pdev->dev, "Could not attach to PHY\n"); | ||
525 | return PTR_ERR(phydev); | ||
526 | } | ||
527 | |||
528 | phydev->supported &= (SUPPORTED_10baseT_Half | ||
529 | | SUPPORTED_10baseT_Full | ||
530 | | SUPPORTED_100baseT_Half | ||
531 | | SUPPORTED_100baseT_Full | ||
532 | | SUPPORTED_Autoneg | ||
533 | | SUPPORTED_MII | ||
534 | | SUPPORTED_TP); | ||
535 | |||
536 | if (adapter->pdev->device != ET131X_PCI_DEVICE_ID_FAST) | ||
537 | phydev->supported |= SUPPORTED_1000baseT_Full; | ||
538 | |||
539 | phydev->advertising = phydev->supported; | ||
540 | adapter->phydev = phydev; | ||
541 | |||
542 | dev_info(&adapter->pdev->dev, "attached PHY driver [%s] " | ||
543 | "(mii_bus:phy_addr=%s)\n", | ||
544 | phydev->drv->name, dev_name(&phydev->dev)); | ||
545 | |||
546 | return 0; | ||
547 | } | ||
548 | |||
474 | /** | 549 | /** |
475 | * et131x_adapter_init | 550 | * et131x_adapter_init |
476 | * @adapter: pointer to the private adapter struct | 551 | * @adapter: pointer to the private adapter struct |
@@ -538,8 +613,8 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, | |||
538 | int pm_cap; | 613 | int pm_cap; |
539 | struct net_device *netdev; | 614 | struct net_device *netdev; |
540 | struct et131x_adapter *adapter; | 615 | struct et131x_adapter *adapter; |
616 | int ii; | ||
541 | 617 | ||
542 | /* Enable the device via the PCI subsystem */ | ||
543 | result = pci_enable_device(pdev); | 618 | result = pci_enable_device(pdev); |
544 | if (result) { | 619 | if (result) { |
545 | dev_err(&pdev->dev, "pci_enable_device() failed\n"); | 620 | dev_err(&pdev->dev, "pci_enable_device() failed\n"); |
@@ -602,8 +677,10 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, | |||
602 | } | 677 | } |
603 | 678 | ||
604 | SET_NETDEV_DEV(netdev, &pdev->dev); | 679 | SET_NETDEV_DEV(netdev, &pdev->dev); |
680 | et131x_set_ethtool_ops(netdev); | ||
605 | 681 | ||
606 | adapter = et131x_adapter_init(netdev, pdev); | 682 | adapter = et131x_adapter_init(netdev, pdev); |
683 | |||
607 | /* Initialise the PCI setup for the device */ | 684 | /* Initialise the PCI setup for the device */ |
608 | et131x_pci_init(adapter, pdev); | 685 | et131x_pci_init(adapter, pdev); |
609 | 686 | ||
@@ -650,11 +727,43 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, | |||
650 | adapter->error_timer.function = et131x_error_timer_handler; | 727 | adapter->error_timer.function = et131x_error_timer_handler; |
651 | adapter->error_timer.data = (unsigned long)adapter; | 728 | adapter->error_timer.data = (unsigned long)adapter; |
652 | 729 | ||
653 | /* Initialize link state */ | ||
654 | netif_carrier_off(adapter->netdev); | ||
655 | |||
656 | /* Init variable for counting how long we do not have link status */ | 730 | /* Init variable for counting how long we do not have link status */ |
657 | adapter->boot_coma = 0; | 731 | adapter->boot_coma = 0; |
732 | et1310_disable_phy_coma(adapter); | ||
733 | |||
734 | /* Setup the mii_bus struct */ | ||
735 | adapter->mii_bus = mdiobus_alloc(); | ||
736 | if (!adapter->mii_bus) { | ||
737 | dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n"); | ||
738 | goto err_mem_free; | ||
739 | } | ||
740 | |||
741 | adapter->mii_bus->name = "et131x_eth_mii"; | ||
742 | snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x", | ||
743 | (adapter->pdev->bus->number << 8) | adapter->pdev->devfn); | ||
744 | adapter->mii_bus->priv = netdev; | ||
745 | adapter->mii_bus->read = et131x_mdio_read; | ||
746 | adapter->mii_bus->write = et131x_mdio_write; | ||
747 | adapter->mii_bus->reset = et131x_mdio_reset; | ||
748 | adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); | ||
749 | if (!adapter->mii_bus->irq) { | ||
750 | dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); | ||
751 | goto err_mdio_free; | ||
752 | } | ||
753 | |||
754 | for (ii = 0; ii < PHY_MAX_ADDR; ii++) | ||
755 | adapter->mii_bus->irq[ii] = PHY_POLL; | ||
756 | |||
757 | if (mdiobus_register(adapter->mii_bus)) { | ||
758 | dev_err(&pdev->dev, "failed to register MII bus\n"); | ||
759 | mdiobus_free(adapter->mii_bus); | ||
760 | goto err_mdio_free_irq; | ||
761 | } | ||
762 | |||
763 | if (et131x_mii_probe(netdev)) { | ||
764 | dev_err(&pdev->dev, "failed to probe MII bus\n"); | ||
765 | goto err_mdio_unregister; | ||
766 | } | ||
658 | 767 | ||
659 | /* We can enable interrupts now | 768 | /* We can enable interrupts now |
660 | * | 769 | * |
@@ -667,7 +776,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, | |||
667 | result = register_netdev(netdev); | 776 | result = register_netdev(netdev); |
668 | if (result != 0) { | 777 | if (result != 0) { |
669 | dev_err(&pdev->dev, "register_netdev() failed\n"); | 778 | dev_err(&pdev->dev, "register_netdev() failed\n"); |
670 | goto err_mem_free; | 779 | goto err_mdio_unregister; |
671 | } | 780 | } |
672 | 781 | ||
673 | /* Register the net_device struct with the PCI subsystem. Save a copy | 782 | /* Register the net_device struct with the PCI subsystem. Save a copy |
@@ -679,6 +788,12 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, | |||
679 | 788 | ||
680 | return result; | 789 | return result; |
681 | 790 | ||
791 | err_mdio_unregister: | ||
792 | mdiobus_unregister(adapter->mii_bus); | ||
793 | err_mdio_free_irq: | ||
794 | kfree(adapter->mii_bus->irq); | ||
795 | err_mdio_free: | ||
796 | mdiobus_free(adapter->mii_bus); | ||
682 | err_mem_free: | 797 | err_mem_free: |
683 | et131x_adapter_memory_free(adapter); | 798 | et131x_adapter_memory_free(adapter); |
684 | err_iounmap: | 799 | err_iounmap: |
@@ -704,20 +819,18 @@ err_out: | |||
704 | */ | 819 | */ |
705 | static void __devexit et131x_pci_remove(struct pci_dev *pdev) | 820 | static void __devexit et131x_pci_remove(struct pci_dev *pdev) |
706 | { | 821 | { |
707 | struct net_device *netdev; | 822 | struct net_device *netdev = pci_get_drvdata(pdev); |
708 | struct et131x_adapter *adapter; | 823 | struct et131x_adapter *adapter = netdev_priv(netdev); |
709 | 824 | ||
710 | /* Retrieve the net_device pointer from the pci_dev struct, as well | ||
711 | * as the private adapter struct | ||
712 | */ | ||
713 | netdev = pci_get_drvdata(pdev); | ||
714 | adapter = netdev_priv(netdev); | ||
715 | |||
716 | /* Perform device cleanup */ | ||
717 | unregister_netdev(netdev); | 825 | unregister_netdev(netdev); |
826 | mdiobus_unregister(adapter->mii_bus); | ||
827 | kfree(adapter->mii_bus->irq); | ||
828 | mdiobus_free(adapter->mii_bus); | ||
829 | |||
718 | et131x_adapter_memory_free(adapter); | 830 | et131x_adapter_memory_free(adapter); |
719 | iounmap(adapter->regs); | 831 | iounmap(adapter->regs); |
720 | pci_dev_put(adapter->pdev); | 832 | pci_dev_put(pdev); |
833 | |||
721 | free_netdev(netdev); | 834 | free_netdev(netdev); |
722 | pci_release_regions(pdev); | 835 | pci_release_regions(pdev); |
723 | pci_disable_device(pdev); | 836 | pci_disable_device(pdev); |
diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 20df1454117..ce214339739 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Agere Systems Inc. | 2 | * Agere Systems Inc. |
3 | * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs | 3 | * 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs |
4 | * | 4 | * |
5 | * Copyright © 2005 Agere Systems Inc. | 5 | * Copyright © 2005 Agere Systems Inc. |
6 | * All rights reserved. | 6 | * All rights reserved. |
@@ -82,6 +82,7 @@ | |||
82 | #include <linux/skbuff.h> | 82 | #include <linux/skbuff.h> |
83 | #include <linux/if_arp.h> | 83 | #include <linux/if_arp.h> |
84 | #include <linux/ioport.h> | 84 | #include <linux/ioport.h> |
85 | #include <linux/phy.h> | ||
85 | 86 | ||
86 | #include "et1310_phy.h" | 87 | #include "et1310_phy.h" |
87 | #include "et1310_tx.h" | 88 | #include "et1310_tx.h" |
@@ -167,6 +168,8 @@ int et131x_open(struct net_device *netdev) | |||
167 | 168 | ||
168 | adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; | 169 | adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; |
169 | 170 | ||
171 | phy_start(adapter->phydev); | ||
172 | |||
170 | /* We're ready to move some data, so start the queue */ | 173 | /* We're ready to move some data, so start the queue */ |
171 | netif_start_queue(netdev); | 174 | netif_start_queue(netdev); |
172 | return result; | 175 | return result; |
@@ -699,8 +702,6 @@ struct net_device *et131x_device_alloc(void) | |||
699 | netdev->watchdog_timeo = ET131X_TX_TIMEOUT; | 702 | netdev->watchdog_timeo = ET131X_TX_TIMEOUT; |
700 | netdev->netdev_ops = &et131x_netdev_ops; | 703 | netdev->netdev_ops = &et131x_netdev_ops; |
701 | 704 | ||
702 | /* netdev->ethtool_ops = &et131x_ethtool_ops; */ | ||
703 | |||
704 | /* Poll? */ | 705 | /* Poll? */ |
705 | /* netdev->poll = &et131x_poll; */ | 706 | /* netdev->poll = &et131x_poll; */ |
706 | /* netdev->poll_controller = &et131x_poll_controller; */ | 707 | /* netdev->poll_controller = &et131x_poll_controller; */ |