forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/net/ethernet/natsemi/macsonic.c
....@@ -51,8 +51,8 @@
5151 #include <linux/dma-mapping.h>
5252 #include <linux/bitrev.h>
5353 #include <linux/slab.h>
54
+#include <linux/pgtable.h>
5455
55
-#include <asm/pgtable.h>
5656 #include <asm/io.h>
5757 #include <asm/hwtest.h>
5858 #include <asm/dma.h>
....@@ -114,17 +114,6 @@
114114 addr[i] = bitrev8(addr[i]);
115115 }
116116
117
-static irqreturn_t macsonic_interrupt(int irq, void *dev_id)
118
-{
119
- irqreturn_t result;
120
- unsigned long flags;
121
-
122
- local_irq_save(flags);
123
- result = sonic_interrupt(irq, dev_id);
124
- local_irq_restore(flags);
125
- return result;
126
-}
127
-
128117 static int macsonic_open(struct net_device* dev)
129118 {
130119 int retval;
....@@ -135,12 +124,12 @@
135124 dev->name, dev->irq);
136125 goto err;
137126 }
138
- /* Under the A/UX interrupt scheme, the onboard SONIC interrupt comes
139
- * in at priority level 3. However, we sometimes get the level 2 inter-
140
- * rupt as well, which must prevent re-entrance of the sonic handler.
127
+ /* Under the A/UX interrupt scheme, the onboard SONIC interrupt gets
128
+ * moved from level 2 to level 3. Unfortunately we still get some
129
+ * level 2 interrupts so register the handler for both.
141130 */
142131 if (dev->irq == IRQ_AUTO_3) {
143
- retval = request_irq(IRQ_NUBUS_9, macsonic_interrupt, 0,
132
+ retval = request_irq(IRQ_NUBUS_9, sonic_interrupt, 0,
144133 "sonic", dev);
145134 if (retval) {
146135 printk(KERN_ERR "%s: unable to get IRQ %d.\n",
....@@ -186,33 +175,10 @@
186175 static int macsonic_init(struct net_device *dev)
187176 {
188177 struct sonic_local* lp = netdev_priv(dev);
178
+ int err = sonic_alloc_descriptors(dev);
189179
190
- /* Allocate the entire chunk of memory for the descriptors.
191
- Note that this cannot cross a 64K boundary. */
192
- lp->descriptors = dma_alloc_coherent(lp->device,
193
- SIZEOF_SONIC_DESC *
194
- SONIC_BUS_SCALE(lp->dma_bitmode),
195
- &lp->descriptors_laddr,
196
- GFP_KERNEL);
197
- if (lp->descriptors == NULL)
198
- return -ENOMEM;
199
-
200
- /* Now set up the pointers to point to the appropriate places */
201
- lp->cda = lp->descriptors;
202
- lp->tda = lp->cda + (SIZEOF_SONIC_CDA
203
- * SONIC_BUS_SCALE(lp->dma_bitmode));
204
- lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
205
- * SONIC_BUS_SCALE(lp->dma_bitmode));
206
- lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
207
- * SONIC_BUS_SCALE(lp->dma_bitmode));
208
-
209
- lp->cda_laddr = lp->descriptors_laddr;
210
- lp->tda_laddr = lp->cda_laddr + (SIZEOF_SONIC_CDA
211
- * SONIC_BUS_SCALE(lp->dma_bitmode));
212
- lp->rda_laddr = lp->tda_laddr + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
213
- * SONIC_BUS_SCALE(lp->dma_bitmode));
214
- lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
215
- * SONIC_BUS_SCALE(lp->dma_bitmode));
180
+ if (err)
181
+ return err;
216182
217183 dev->netdev_ops = &macsonic_netdev_ops;
218184 dev->watchdog_timeo = TX_TIMEOUT;