aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sunbmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sunbmac.c')
-rw-r--r--drivers/net/sunbmac.c206
1 files changed, 96 insertions, 110 deletions
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index 0e4a88d16327..018d0fca9422 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -1,7 +1,6 @@
1/* $Id: sunbmac.c,v 1.30 2002/01/15 06:48:55 davem Exp $ 1/* sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters.
2 * sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters.
3 * 2 *
4 * Copyright (C) 1997, 1998, 1999, 2003 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1997, 1998, 1999, 2003, 2008 David S. Miller (davem@davemloft.net)
5 */ 4 */
6 5
7#include <linux/module.h> 6#include <linux/module.h>
@@ -23,6 +22,9 @@
23#include <linux/etherdevice.h> 22#include <linux/etherdevice.h>
24#include <linux/skbuff.h> 23#include <linux/skbuff.h>
25#include <linux/bitops.h> 24#include <linux/bitops.h>
25#include <linux/dma-mapping.h>
26#include <linux/of.h>
27#include <linux/of_device.h>
26 28
27#include <asm/auxio.h> 29#include <asm/auxio.h>
28#include <asm/byteorder.h> 30#include <asm/byteorder.h>
@@ -32,15 +34,14 @@
32#include <asm/openprom.h> 34#include <asm/openprom.h>
33#include <asm/oplib.h> 35#include <asm/oplib.h>
34#include <asm/pgtable.h> 36#include <asm/pgtable.h>
35#include <asm/sbus.h>
36#include <asm/system.h> 37#include <asm/system.h>
37 38
38#include "sunbmac.h" 39#include "sunbmac.h"
39 40
40#define DRV_NAME "sunbmac" 41#define DRV_NAME "sunbmac"
41#define DRV_VERSION "2.0" 42#define DRV_VERSION "2.1"
42#define DRV_RELDATE "11/24/03" 43#define DRV_RELDATE "August 26, 2008"
43#define DRV_AUTHOR "David S. Miller (davem@redhat.com)" 44#define DRV_AUTHOR "David S. Miller (davem@davemloft.net)"
44 45
45static char version[] = 46static char version[] =
46 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; 47 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
@@ -96,8 +97,8 @@ static int qec_global_reset(void __iomem *gregs)
96 97
97static void qec_init(struct bigmac *bp) 98static void qec_init(struct bigmac *bp)
98{ 99{
100 struct of_device *qec_op = bp->qec_op;
99 void __iomem *gregs = bp->gregs; 101 void __iomem *gregs = bp->gregs;
100 struct sbus_dev *qec_sdev = bp->qec_sdev;
101 u8 bsizes = bp->bigmac_bursts; 102 u8 bsizes = bp->bigmac_bursts;
102 u32 regval; 103 u32 regval;
103 104
@@ -112,13 +113,13 @@ static void qec_init(struct bigmac *bp)
112 sbus_writel(GLOB_PSIZE_2048, gregs + GLOB_PSIZE); 113 sbus_writel(GLOB_PSIZE_2048, gregs + GLOB_PSIZE);
113 114
114 /* All of memsize is given to bigmac. */ 115 /* All of memsize is given to bigmac. */
115 sbus_writel(qec_sdev->reg_addrs[1].reg_size, 116 sbus_writel(resource_size(&qec_op->resource[1]),
116 gregs + GLOB_MSIZE); 117 gregs + GLOB_MSIZE);
117 118
118 /* Half to the transmitter, half to the receiver. */ 119 /* Half to the transmitter, half to the receiver. */
119 sbus_writel(qec_sdev->reg_addrs[1].reg_size >> 1, 120 sbus_writel(resource_size(&qec_op->resource[1]) >> 1,
120 gregs + GLOB_TSIZE); 121 gregs + GLOB_TSIZE);
121 sbus_writel(qec_sdev->reg_addrs[1].reg_size >> 1, 122 sbus_writel(resource_size(&qec_op->resource[1]) >> 1,
122 gregs + GLOB_RSIZE); 123 gregs + GLOB_RSIZE);
123} 124}
124 125
@@ -239,9 +240,10 @@ static void bigmac_init_rings(struct bigmac *bp, int from_irq)
239 skb_reserve(skb, 34); 240 skb_reserve(skb, 34);
240 241
241 bb->be_rxd[i].rx_addr = 242 bb->be_rxd[i].rx_addr =
242 sbus_map_single(bp->bigmac_sdev, skb->data, 243 dma_map_single(&bp->bigmac_op->dev,
243 RX_BUF_ALLOC_SIZE - 34, 244 skb->data,
244 SBUS_DMA_FROMDEVICE); 245 RX_BUF_ALLOC_SIZE - 34,
246 DMA_FROM_DEVICE);
245 bb->be_rxd[i].rx_flags = 247 bb->be_rxd[i].rx_flags =
246 (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH)); 248 (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH));
247 } 249 }
@@ -776,9 +778,9 @@ static void bigmac_tx(struct bigmac *bp)
776 skb = bp->tx_skbs[elem]; 778 skb = bp->tx_skbs[elem];
777 bp->enet_stats.tx_packets++; 779 bp->enet_stats.tx_packets++;
778 bp->enet_stats.tx_bytes += skb->len; 780 bp->enet_stats.tx_bytes += skb->len;
779 sbus_unmap_single(bp->bigmac_sdev, 781 dma_unmap_single(&bp->bigmac_op->dev,
780 this->tx_addr, skb->len, 782 this->tx_addr, skb->len,
781 SBUS_DMA_TODEVICE); 783 DMA_TO_DEVICE);
782 784
783 DTX(("skb(%p) ", skb)); 785 DTX(("skb(%p) ", skb));
784 bp->tx_skbs[elem] = NULL; 786 bp->tx_skbs[elem] = NULL;
@@ -831,18 +833,19 @@ static void bigmac_rx(struct bigmac *bp)
831 drops++; 833 drops++;
832 goto drop_it; 834 goto drop_it;
833 } 835 }
834 sbus_unmap_single(bp->bigmac_sdev, 836 dma_unmap_single(&bp->bigmac_op->dev,
835 this->rx_addr, 837 this->rx_addr,
836 RX_BUF_ALLOC_SIZE - 34, 838 RX_BUF_ALLOC_SIZE - 34,
837 SBUS_DMA_FROMDEVICE); 839 DMA_FROM_DEVICE);
838 bp->rx_skbs[elem] = new_skb; 840 bp->rx_skbs[elem] = new_skb;
839 new_skb->dev = bp->dev; 841 new_skb->dev = bp->dev;
840 skb_put(new_skb, ETH_FRAME_LEN); 842 skb_put(new_skb, ETH_FRAME_LEN);
841 skb_reserve(new_skb, 34); 843 skb_reserve(new_skb, 34);
842 this->rx_addr = sbus_map_single(bp->bigmac_sdev, 844 this->rx_addr =
843 new_skb->data, 845 dma_map_single(&bp->bigmac_op->dev,
844 RX_BUF_ALLOC_SIZE - 34, 846 new_skb->data,
845 SBUS_DMA_FROMDEVICE); 847 RX_BUF_ALLOC_SIZE - 34,
848 DMA_FROM_DEVICE);
846 this->rx_flags = 849 this->rx_flags =
847 (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH)); 850 (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH));
848 851
@@ -857,13 +860,13 @@ static void bigmac_rx(struct bigmac *bp)
857 } 860 }
858 skb_reserve(copy_skb, 2); 861 skb_reserve(copy_skb, 2);
859 skb_put(copy_skb, len); 862 skb_put(copy_skb, len);
860 sbus_dma_sync_single_for_cpu(bp->bigmac_sdev, 863 dma_sync_single_for_cpu(&bp->bigmac_op->dev,
861 this->rx_addr, len, 864 this->rx_addr, len,
862 SBUS_DMA_FROMDEVICE); 865 DMA_FROM_DEVICE);
863 skb_copy_to_linear_data(copy_skb, (unsigned char *)skb->data, len); 866 skb_copy_to_linear_data(copy_skb, (unsigned char *)skb->data, len);
864 sbus_dma_sync_single_for_device(bp->bigmac_sdev, 867 dma_sync_single_for_device(&bp->bigmac_op->dev,
865 this->rx_addr, len, 868 this->rx_addr, len,
866 SBUS_DMA_FROMDEVICE); 869 DMA_FROM_DEVICE);
867 870
868 /* Reuse original ring buffer. */ 871 /* Reuse original ring buffer. */
869 this->rx_flags = 872 this->rx_flags =
@@ -959,7 +962,8 @@ static int bigmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
959 u32 mapping; 962 u32 mapping;
960 963
961 len = skb->len; 964 len = skb->len;
962 mapping = sbus_map_single(bp->bigmac_sdev, skb->data, len, SBUS_DMA_TODEVICE); 965 mapping = dma_map_single(&bp->bigmac_op->dev, skb->data,
966 len, DMA_TO_DEVICE);
963 967
964 /* Avoid a race... */ 968 /* Avoid a race... */
965 spin_lock_irq(&bp->lock); 969 spin_lock_irq(&bp->lock);
@@ -1051,12 +1055,8 @@ static void bigmac_set_multicast(struct net_device *dev)
1051/* Ethtool support... */ 1055/* Ethtool support... */
1052static void bigmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1056static void bigmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1053{ 1057{
1054 struct bigmac *bp = dev->priv;
1055
1056 strcpy(info->driver, "sunbmac"); 1058 strcpy(info->driver, "sunbmac");
1057 strcpy(info->version, "2.0"); 1059 strcpy(info->version, "2.0");
1058 sprintf(info->bus_info, "SBUS:%d",
1059 bp->qec_sdev->slot);
1060} 1060}
1061 1061
1062static u32 bigmac_get_link(struct net_device *dev) 1062static u32 bigmac_get_link(struct net_device *dev)
@@ -1075,14 +1075,15 @@ static const struct ethtool_ops bigmac_ethtool_ops = {
1075 .get_link = bigmac_get_link, 1075 .get_link = bigmac_get_link,
1076}; 1076};
1077 1077
1078static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev) 1078static int __devinit bigmac_ether_init(struct of_device *op,
1079 struct of_device *qec_op)
1079{ 1080{
1080 struct net_device *dev;
1081 static int version_printed; 1081 static int version_printed;
1082 struct bigmac *bp; 1082 struct net_device *dev;
1083 u8 bsizes, bsizes_more; 1083 u8 bsizes, bsizes_more;
1084 int i;
1085 DECLARE_MAC_BUF(mac); 1084 DECLARE_MAC_BUF(mac);
1085 struct bigmac *bp;
1086 int i;
1086 1087
1087 /* Get a new device struct for this interface. */ 1088 /* Get a new device struct for this interface. */
1088 dev = alloc_etherdev(sizeof(struct bigmac)); 1089 dev = alloc_etherdev(sizeof(struct bigmac));
@@ -1092,32 +1093,21 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev)
1092 if (version_printed++ == 0) 1093 if (version_printed++ == 0)
1093 printk(KERN_INFO "%s", version); 1094 printk(KERN_INFO "%s", version);
1094 1095
1095 dev->base_addr = (long) qec_sdev;
1096 for (i = 0; i < 6; i++) 1096 for (i = 0; i < 6; i++)
1097 dev->dev_addr[i] = idprom->id_ethaddr[i]; 1097 dev->dev_addr[i] = idprom->id_ethaddr[i];
1098 1098
1099 /* Setup softc, with backpointers to QEC and BigMAC SBUS device structs. */ 1099 /* Setup softc, with backpointers to QEC and BigMAC SBUS device structs. */
1100 bp = dev->priv; 1100 bp = netdev_priv(dev);
1101 bp->qec_sdev = qec_sdev; 1101 bp->qec_op = qec_op;
1102 bp->bigmac_sdev = qec_sdev->child; 1102 bp->bigmac_op = op;
1103 1103
1104 SET_NETDEV_DEV(dev, &bp->bigmac_sdev->ofdev.dev); 1104 SET_NETDEV_DEV(dev, &op->dev);
1105 1105
1106 spin_lock_init(&bp->lock); 1106 spin_lock_init(&bp->lock);
1107 1107
1108 /* Verify the registers we expect, are actually there. */
1109 if ((bp->bigmac_sdev->num_registers != 3) ||
1110 (bp->qec_sdev->num_registers != 2)) {
1111 printk(KERN_ERR "BIGMAC: Device does not have 2 and 3 regs, it has %d and %d.\n",
1112 bp->qec_sdev->num_registers,
1113 bp->bigmac_sdev->num_registers);
1114 printk(KERN_ERR "BIGMAC: Would you like that for here or to go?\n");
1115 goto fail_and_cleanup;
1116 }
1117
1118 /* Map in QEC global control registers. */ 1108 /* Map in QEC global control registers. */
1119 bp->gregs = sbus_ioremap(&bp->qec_sdev->resource[0], 0, 1109 bp->gregs = of_ioremap(&qec_op->resource[0], 0,
1120 GLOB_REG_SIZE, "BigMAC QEC GLobal Regs"); 1110 GLOB_REG_SIZE, "BigMAC QEC GLobal Regs");
1121 if (!bp->gregs) { 1111 if (!bp->gregs) {
1122 printk(KERN_ERR "BIGMAC: Cannot map QEC global registers.\n"); 1112 printk(KERN_ERR "BIGMAC: Cannot map QEC global registers.\n");
1123 goto fail_and_cleanup; 1113 goto fail_and_cleanup;
@@ -1134,13 +1124,8 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev)
1134 goto fail_and_cleanup; 1124 goto fail_and_cleanup;
1135 1125
1136 /* Get supported SBUS burst sizes. */ 1126 /* Get supported SBUS burst sizes. */
1137 bsizes = prom_getintdefault(bp->qec_sdev->prom_node, 1127 bsizes = of_getintprop_default(qec_op->node, "burst-sizes", 0xff);
1138 "burst-sizes", 1128 bsizes_more = of_getintprop_default(qec_op->node, "burst-sizes", 0xff);
1139 0xff);
1140
1141 bsizes_more = prom_getintdefault(bp->qec_sdev->bus->prom_node,
1142 "burst-sizes",
1143 0xff);
1144 1129
1145 bsizes &= 0xff; 1130 bsizes &= 0xff;
1146 if (bsizes_more != 0xff) 1131 if (bsizes_more != 0xff)
@@ -1154,16 +1139,16 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev)
1154 qec_init(bp); 1139 qec_init(bp);
1155 1140
1156 /* Map in the BigMAC channel registers. */ 1141 /* Map in the BigMAC channel registers. */
1157 bp->creg = sbus_ioremap(&bp->bigmac_sdev->resource[0], 0, 1142 bp->creg = of_ioremap(&op->resource[0], 0,
1158 CREG_REG_SIZE, "BigMAC QEC Channel Regs"); 1143 CREG_REG_SIZE, "BigMAC QEC Channel Regs");
1159 if (!bp->creg) { 1144 if (!bp->creg) {
1160 printk(KERN_ERR "BIGMAC: Cannot map QEC channel registers.\n"); 1145 printk(KERN_ERR "BIGMAC: Cannot map QEC channel registers.\n");
1161 goto fail_and_cleanup; 1146 goto fail_and_cleanup;
1162 } 1147 }
1163 1148
1164 /* Map in the BigMAC control registers. */ 1149 /* Map in the BigMAC control registers. */
1165 bp->bregs = sbus_ioremap(&bp->bigmac_sdev->resource[1], 0, 1150 bp->bregs = of_ioremap(&op->resource[1], 0,
1166 BMAC_REG_SIZE, "BigMAC Primary Regs"); 1151 BMAC_REG_SIZE, "BigMAC Primary Regs");
1167 if (!bp->bregs) { 1152 if (!bp->bregs) {
1168 printk(KERN_ERR "BIGMAC: Cannot map BigMAC primary registers.\n"); 1153 printk(KERN_ERR "BIGMAC: Cannot map BigMAC primary registers.\n");
1169 goto fail_and_cleanup; 1154 goto fail_and_cleanup;
@@ -1172,8 +1157,8 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev)
1172 /* Map in the BigMAC transceiver registers, this is how you poke at 1157 /* Map in the BigMAC transceiver registers, this is how you poke at
1173 * the BigMAC's PHY. 1158 * the BigMAC's PHY.
1174 */ 1159 */
1175 bp->tregs = sbus_ioremap(&bp->bigmac_sdev->resource[2], 0, 1160 bp->tregs = of_ioremap(&op->resource[2], 0,
1176 TCVR_REG_SIZE, "BigMAC Transceiver Regs"); 1161 TCVR_REG_SIZE, "BigMAC Transceiver Regs");
1177 if (!bp->tregs) { 1162 if (!bp->tregs) {
1178 printk(KERN_ERR "BIGMAC: Cannot map BigMAC transceiver registers.\n"); 1163 printk(KERN_ERR "BIGMAC: Cannot map BigMAC transceiver registers.\n");
1179 goto fail_and_cleanup; 1164 goto fail_and_cleanup;
@@ -1183,17 +1168,17 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev)
1183 bigmac_stop(bp); 1168 bigmac_stop(bp);
1184 1169
1185 /* Allocate transmit/receive descriptor DVMA block. */ 1170 /* Allocate transmit/receive descriptor DVMA block. */
1186 bp->bmac_block = sbus_alloc_consistent(bp->bigmac_sdev, 1171 bp->bmac_block = dma_alloc_coherent(&bp->bigmac_op->dev,
1187 PAGE_SIZE, 1172 PAGE_SIZE,
1188 &bp->bblock_dvma); 1173 &bp->bblock_dvma, GFP_ATOMIC);
1189 if (bp->bmac_block == NULL || bp->bblock_dvma == 0) { 1174 if (bp->bmac_block == NULL || bp->bblock_dvma == 0) {
1190 printk(KERN_ERR "BIGMAC: Cannot allocate consistent DMA.\n"); 1175 printk(KERN_ERR "BIGMAC: Cannot allocate consistent DMA.\n");
1191 goto fail_and_cleanup; 1176 goto fail_and_cleanup;
1192 } 1177 }
1193 1178
1194 /* Get the board revision of this BigMAC. */ 1179 /* Get the board revision of this BigMAC. */
1195 bp->board_rev = prom_getintdefault(bp->bigmac_sdev->prom_node, 1180 bp->board_rev = of_getintprop_default(bp->bigmac_op->node,
1196 "board-version", 1); 1181 "board-version", 1);
1197 1182
1198 /* Init auto-negotiation timer state. */ 1183 /* Init auto-negotiation timer state. */
1199 init_timer(&bp->bigmac_timer); 1184 init_timer(&bp->bigmac_timer);
@@ -1217,7 +1202,7 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev)
1217 dev->watchdog_timeo = 5*HZ; 1202 dev->watchdog_timeo = 5*HZ;
1218 1203
1219 /* Finish net device registration. */ 1204 /* Finish net device registration. */
1220 dev->irq = bp->bigmac_sdev->irqs[0]; 1205 dev->irq = bp->bigmac_op->irqs[0];
1221 dev->dma = 0; 1206 dev->dma = 0;
1222 1207
1223 if (register_netdev(dev)) { 1208 if (register_netdev(dev)) {
@@ -1225,7 +1210,7 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev)
1225 goto fail_and_cleanup; 1210 goto fail_and_cleanup;
1226 } 1211 }
1227 1212
1228 dev_set_drvdata(&bp->bigmac_sdev->ofdev.dev, bp); 1213 dev_set_drvdata(&bp->bigmac_op->dev, bp);
1229 1214
1230 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet %s\n", 1215 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet %s\n",
1231 dev->name, print_mac(mac, dev->dev_addr)); 1216 dev->name, print_mac(mac, dev->dev_addr));
@@ -1236,66 +1221,67 @@ fail_and_cleanup:
1236 /* Something went wrong, undo whatever we did so far. */ 1221 /* Something went wrong, undo whatever we did so far. */
1237 /* Free register mappings if any. */ 1222 /* Free register mappings if any. */
1238 if (bp->gregs) 1223 if (bp->gregs)
1239 sbus_iounmap(bp->gregs, GLOB_REG_SIZE); 1224 of_iounmap(&qec_op->resource[0], bp->gregs, GLOB_REG_SIZE);
1240 if (bp->creg) 1225 if (bp->creg)
1241 sbus_iounmap(bp->creg, CREG_REG_SIZE); 1226 of_iounmap(&op->resource[0], bp->creg, CREG_REG_SIZE);
1242 if (bp->bregs) 1227 if (bp->bregs)
1243 sbus_iounmap(bp->bregs, BMAC_REG_SIZE); 1228 of_iounmap(&op->resource[1], bp->bregs, BMAC_REG_SIZE);
1244 if (bp->tregs) 1229 if (bp->tregs)
1245 sbus_iounmap(bp->tregs, TCVR_REG_SIZE); 1230 of_iounmap(&op->resource[2], bp->tregs, TCVR_REG_SIZE);
1246 1231
1247 if (bp->bmac_block) 1232 if (bp->bmac_block)
1248 sbus_free_consistent(bp->bigmac_sdev, 1233 dma_free_coherent(&bp->bigmac_op->dev,
1249 PAGE_SIZE, 1234 PAGE_SIZE,
1250 bp->bmac_block, 1235 bp->bmac_block,
1251 bp->bblock_dvma); 1236 bp->bblock_dvma);
1252 1237
1253 /* This also frees the co-located 'dev->priv' */ 1238 /* This also frees the co-located 'dev->priv' */
1254 free_netdev(dev); 1239 free_netdev(dev);
1255 return -ENODEV; 1240 return -ENODEV;
1256} 1241}
1257 1242
1258/* QEC can be the parent of either QuadEthernet or 1243/* QEC can be the parent of either QuadEthernet or a BigMAC. We want
1259 * a BigMAC. We want the latter. 1244 * the latter.
1260 */ 1245 */
1261static int __devinit bigmac_sbus_probe(struct of_device *dev, const struct of_device_id *match) 1246static int __devinit bigmac_sbus_probe(struct of_device *op,
1247 const struct of_device_id *match)
1262{ 1248{
1263 struct sbus_dev *sdev = to_sbus_device(&dev->dev); 1249 struct device *parent = op->dev.parent;
1264 struct device_node *dp = dev->node; 1250 struct of_device *qec_op;
1265 1251
1266 if (!strcmp(dp->name, "be")) 1252 qec_op = to_of_device(parent);
1267 sdev = sdev->parent;
1268 1253
1269 return bigmac_ether_init(sdev); 1254 return bigmac_ether_init(op, qec_op);
1270} 1255}
1271 1256
1272static int __devexit bigmac_sbus_remove(struct of_device *dev) 1257static int __devexit bigmac_sbus_remove(struct of_device *op)
1273{ 1258{
1274 struct bigmac *bp = dev_get_drvdata(&dev->dev); 1259 struct bigmac *bp = dev_get_drvdata(&op->dev);
1260 struct device *parent = op->dev.parent;
1275 struct net_device *net_dev = bp->dev; 1261 struct net_device *net_dev = bp->dev;
1262 struct of_device *qec_op;
1276 1263
1277 unregister_netdevice(net_dev); 1264 qec_op = to_of_device(parent);
1278 1265
1279 sbus_iounmap(bp->gregs, GLOB_REG_SIZE); 1266 unregister_netdev(net_dev);
1280 sbus_iounmap(bp->creg, CREG_REG_SIZE); 1267
1281 sbus_iounmap(bp->bregs, BMAC_REG_SIZE); 1268 of_iounmap(&qec_op->resource[0], bp->gregs, GLOB_REG_SIZE);
1282 sbus_iounmap(bp->tregs, TCVR_REG_SIZE); 1269 of_iounmap(&op->resource[0], bp->creg, CREG_REG_SIZE);
1283 sbus_free_consistent(bp->bigmac_sdev, 1270 of_iounmap(&op->resource[1], bp->bregs, BMAC_REG_SIZE);
1284 PAGE_SIZE, 1271 of_iounmap(&op->resource[2], bp->tregs, TCVR_REG_SIZE);
1285 bp->bmac_block, 1272 dma_free_coherent(&op->dev,
1286 bp->bblock_dvma); 1273 PAGE_SIZE,
1274 bp->bmac_block,
1275 bp->bblock_dvma);
1287 1276
1288 free_netdev(net_dev); 1277 free_netdev(net_dev);
1289 1278
1290 dev_set_drvdata(&dev->dev, NULL); 1279 dev_set_drvdata(&op->dev, NULL);
1291 1280
1292 return 0; 1281 return 0;
1293} 1282}
1294 1283
1295static struct of_device_id bigmac_sbus_match[] = { 1284static const struct of_device_id bigmac_sbus_match[] = {
1296 {
1297 .name = "qec",
1298 },
1299 { 1285 {
1300 .name = "be", 1286 .name = "be",
1301 }, 1287 },
@@ -1313,7 +1299,7 @@ static struct of_platform_driver bigmac_sbus_driver = {
1313 1299
1314static int __init bigmac_init(void) 1300static int __init bigmac_init(void)
1315{ 1301{
1316 return of_register_driver(&bigmac_sbus_driver, &sbus_bus_type); 1302 return of_register_driver(&bigmac_sbus_driver, &of_bus_type);
1317} 1303}
1318 1304
1319static void __exit bigmac_exit(void) 1305static void __exit bigmac_exit(void)