1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * drivers/net/ethernet/ibm/emac/mal.c
5 * Memory Access Layer (MAL) support
7 * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
8 * <benh@kernel.crashing.org>
10 * Based on the arch/ppc version of the driver:
12 * Copyright (c) 2004, 2005 Zultys Technologies.
13 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
15 * Based on original work by
16 * Benjamin Herrenschmidt <benh@kernel.crashing.org>,
17 * David Gibson <hermes@gibson.dropbear.id.au>,
19 * Armin Kuster <akuster@mvista.com>
20 * Copyright 2002 MontaVista Softare Inc.
23 #include <linux/delay.h>
24 #include <linux/slab.h>
25 #include <linux/of_irq.h>
28 #include <asm/dcr-regs.h>
32 int mal_register_commac(struct mal_instance
*mal
, struct mal_commac
*commac
)
36 spin_lock_irqsave(&mal
->lock
, flags
);
38 MAL_DBG(mal
, "reg(%08x, %08x)" NL
,
39 commac
->tx_chan_mask
, commac
->rx_chan_mask
);
41 /* Don't let multiple commacs claim the same channel(s) */
42 if ((mal
->tx_chan_mask
& commac
->tx_chan_mask
) ||
43 (mal
->rx_chan_mask
& commac
->rx_chan_mask
)) {
44 spin_unlock_irqrestore(&mal
->lock
, flags
);
45 printk(KERN_WARNING
"mal%d: COMMAC channels conflict!\n",
50 if (list_empty(&mal
->list
))
51 napi_enable(&mal
->napi
);
52 mal
->tx_chan_mask
|= commac
->tx_chan_mask
;
53 mal
->rx_chan_mask
|= commac
->rx_chan_mask
;
54 list_add(&commac
->list
, &mal
->list
);
56 spin_unlock_irqrestore(&mal
->lock
, flags
);
61 void mal_unregister_commac(struct mal_instance
*mal
,
62 struct mal_commac
*commac
)
66 spin_lock_irqsave(&mal
->lock
, flags
);
68 MAL_DBG(mal
, "unreg(%08x, %08x)" NL
,
69 commac
->tx_chan_mask
, commac
->rx_chan_mask
);
71 mal
->tx_chan_mask
&= ~commac
->tx_chan_mask
;
72 mal
->rx_chan_mask
&= ~commac
->rx_chan_mask
;
73 list_del_init(&commac
->list
);
74 if (list_empty(&mal
->list
))
75 napi_disable(&mal
->napi
);
77 spin_unlock_irqrestore(&mal
->lock
, flags
);
80 int mal_set_rcbs(struct mal_instance
*mal
, int channel
, unsigned long size
)
82 BUG_ON(channel
< 0 || channel
>= mal
->num_rx_chans
||
83 size
> MAL_MAX_RX_SIZE
);
85 MAL_DBG(mal
, "set_rbcs(%d, %lu)" NL
, channel
, size
);
89 "mal%d: incorrect RX size %lu for the channel %d\n",
90 mal
->index
, size
, channel
);
94 set_mal_dcrn(mal
, MAL_RCBS(channel
), size
>> 4);
98 int mal_tx_bd_offset(struct mal_instance
*mal
, int channel
)
100 BUG_ON(channel
< 0 || channel
>= mal
->num_tx_chans
);
102 return channel
* NUM_TX_BUFF
;
105 int mal_rx_bd_offset(struct mal_instance
*mal
, int channel
)
107 BUG_ON(channel
< 0 || channel
>= mal
->num_rx_chans
);
108 return mal
->num_tx_chans
* NUM_TX_BUFF
+ channel
* NUM_RX_BUFF
;
111 void mal_enable_tx_channel(struct mal_instance
*mal
, int channel
)
115 spin_lock_irqsave(&mal
->lock
, flags
);
117 MAL_DBG(mal
, "enable_tx(%d)" NL
, channel
);
119 set_mal_dcrn(mal
, MAL_TXCASR
,
120 get_mal_dcrn(mal
, MAL_TXCASR
) | MAL_CHAN_MASK(channel
));
122 spin_unlock_irqrestore(&mal
->lock
, flags
);
125 void mal_disable_tx_channel(struct mal_instance
*mal
, int channel
)
127 set_mal_dcrn(mal
, MAL_TXCARR
, MAL_CHAN_MASK(channel
));
129 MAL_DBG(mal
, "disable_tx(%d)" NL
, channel
);
132 void mal_enable_rx_channel(struct mal_instance
*mal
, int channel
)
137 * On some 4xx PPC's (e.g. 460EX/GT), the rx channel is a multiple
138 * of 8, but enabling in MAL_RXCASR needs the divided by 8 value
144 spin_lock_irqsave(&mal
->lock
, flags
);
146 MAL_DBG(mal
, "enable_rx(%d)" NL
, channel
);
148 set_mal_dcrn(mal
, MAL_RXCASR
,
149 get_mal_dcrn(mal
, MAL_RXCASR
) | MAL_CHAN_MASK(channel
));
151 spin_unlock_irqrestore(&mal
->lock
, flags
);
154 void mal_disable_rx_channel(struct mal_instance
*mal
, int channel
)
157 * On some 4xx PPC's (e.g. 460EX/GT), the rx channel is a multiple
158 * of 8, but enabling in MAL_RXCASR needs the divided by 8 value
164 set_mal_dcrn(mal
, MAL_RXCARR
, MAL_CHAN_MASK(channel
));
166 MAL_DBG(mal
, "disable_rx(%d)" NL
, channel
);
169 void mal_poll_add(struct mal_instance
*mal
, struct mal_commac
*commac
)
173 spin_lock_irqsave(&mal
->lock
, flags
);
175 MAL_DBG(mal
, "poll_add(%p)" NL
, commac
);
177 /* starts disabled */
178 set_bit(MAL_COMMAC_POLL_DISABLED
, &commac
->flags
);
180 list_add_tail(&commac
->poll_list
, &mal
->poll_list
);
182 spin_unlock_irqrestore(&mal
->lock
, flags
);
185 void mal_poll_del(struct mal_instance
*mal
, struct mal_commac
*commac
)
189 spin_lock_irqsave(&mal
->lock
, flags
);
191 MAL_DBG(mal
, "poll_del(%p)" NL
, commac
);
193 list_del(&commac
->poll_list
);
195 spin_unlock_irqrestore(&mal
->lock
, flags
);
198 /* synchronized by mal_poll() */
199 static inline void mal_enable_eob_irq(struct mal_instance
*mal
)
201 MAL_DBG2(mal
, "enable_irq" NL
);
203 // XXX might want to cache MAL_CFG as the DCR read can be slooooow
204 set_mal_dcrn(mal
, MAL_CFG
, get_mal_dcrn(mal
, MAL_CFG
) | MAL_CFG_EOPIE
);
207 /* synchronized by NAPI state */
208 static inline void mal_disable_eob_irq(struct mal_instance
*mal
)
210 // XXX might want to cache MAL_CFG as the DCR read can be slooooow
211 set_mal_dcrn(mal
, MAL_CFG
, get_mal_dcrn(mal
, MAL_CFG
) & ~MAL_CFG_EOPIE
);
213 MAL_DBG2(mal
, "disable_irq" NL
);
216 static irqreturn_t
mal_serr(int irq
, void *dev_instance
)
218 struct mal_instance
*mal
= dev_instance
;
220 u32 esr
= get_mal_dcrn(mal
, MAL_ESR
);
222 /* Clear the error status register */
223 set_mal_dcrn(mal
, MAL_ESR
, esr
);
225 MAL_DBG(mal
, "SERR %08x" NL
, esr
);
227 if (esr
& MAL_ESR_EVB
) {
228 if (esr
& MAL_ESR_DE
) {
229 /* We ignore Descriptor error,
230 * TXDE or RXDE interrupt will be generated anyway.
235 if (esr
& MAL_ESR_PEIN
) {
236 /* PLB error, it's probably buggy hardware or
237 * incorrect physical address in BD (i.e. bug)
241 "mal%d: system error, "
242 "PLB (ESR = 0x%08x)\n",
247 /* OPB error, it's probably buggy hardware or incorrect
252 "mal%d: system error, OPB (ESR = 0x%08x)\n",
258 static inline void mal_schedule_poll(struct mal_instance
*mal
)
260 if (likely(napi_schedule_prep(&mal
->napi
))) {
261 MAL_DBG2(mal
, "schedule_poll" NL
);
262 spin_lock(&mal
->lock
);
263 mal_disable_eob_irq(mal
);
264 spin_unlock(&mal
->lock
);
265 __napi_schedule(&mal
->napi
);
267 MAL_DBG2(mal
, "already in poll" NL
);
270 static irqreturn_t
mal_txeob(int irq
, void *dev_instance
)
272 struct mal_instance
*mal
= dev_instance
;
274 u32 r
= get_mal_dcrn(mal
, MAL_TXEOBISR
);
276 MAL_DBG2(mal
, "txeob %08x" NL
, r
);
278 mal_schedule_poll(mal
);
279 set_mal_dcrn(mal
, MAL_TXEOBISR
, r
);
281 #ifdef CONFIG_PPC_DCR_NATIVE
282 if (mal_has_feature(mal
, MAL_FTR_CLEAR_ICINTSTAT
))
283 mtdcri(SDR0
, DCRN_SDR_ICINTSTAT
,
284 (mfdcri(SDR0
, DCRN_SDR_ICINTSTAT
) | ICINTSTAT_ICTX
));
290 static irqreturn_t
mal_rxeob(int irq
, void *dev_instance
)
292 struct mal_instance
*mal
= dev_instance
;
294 u32 r
= get_mal_dcrn(mal
, MAL_RXEOBISR
);
296 MAL_DBG2(mal
, "rxeob %08x" NL
, r
);
298 mal_schedule_poll(mal
);
299 set_mal_dcrn(mal
, MAL_RXEOBISR
, r
);
301 #ifdef CONFIG_PPC_DCR_NATIVE
302 if (mal_has_feature(mal
, MAL_FTR_CLEAR_ICINTSTAT
))
303 mtdcri(SDR0
, DCRN_SDR_ICINTSTAT
,
304 (mfdcri(SDR0
, DCRN_SDR_ICINTSTAT
) | ICINTSTAT_ICRX
));
310 static irqreturn_t
mal_txde(int irq
, void *dev_instance
)
312 struct mal_instance
*mal
= dev_instance
;
314 u32 deir
= get_mal_dcrn(mal
, MAL_TXDEIR
);
315 set_mal_dcrn(mal
, MAL_TXDEIR
, deir
);
317 MAL_DBG(mal
, "txde %08x" NL
, deir
);
321 "mal%d: TX descriptor error (TXDEIR = 0x%08x)\n",
327 static irqreturn_t
mal_rxde(int irq
, void *dev_instance
)
329 struct mal_instance
*mal
= dev_instance
;
332 u32 deir
= get_mal_dcrn(mal
, MAL_RXDEIR
);
334 MAL_DBG(mal
, "rxde %08x" NL
, deir
);
336 list_for_each(l
, &mal
->list
) {
337 struct mal_commac
*mc
= list_entry(l
, struct mal_commac
, list
);
338 if (deir
& mc
->rx_chan_mask
) {
339 set_bit(MAL_COMMAC_RX_STOPPED
, &mc
->flags
);
340 mc
->ops
->rxde(mc
->dev
);
344 mal_schedule_poll(mal
);
345 set_mal_dcrn(mal
, MAL_RXDEIR
, deir
);
350 static irqreturn_t
mal_int(int irq
, void *dev_instance
)
352 struct mal_instance
*mal
= dev_instance
;
353 u32 esr
= get_mal_dcrn(mal
, MAL_ESR
);
355 if (esr
& MAL_ESR_EVB
) {
356 /* descriptor error */
357 if (esr
& MAL_ESR_DE
) {
358 if (esr
& MAL_ESR_CIDT
)
359 return mal_rxde(irq
, dev_instance
);
361 return mal_txde(irq
, dev_instance
);
363 return mal_serr(irq
, dev_instance
);
369 void mal_poll_disable(struct mal_instance
*mal
, struct mal_commac
*commac
)
371 /* Spinlock-type semantics: only one caller disable poll at a time */
372 while (test_and_set_bit(MAL_COMMAC_POLL_DISABLED
, &commac
->flags
))
375 /* Synchronize with the MAL NAPI poller */
376 napi_synchronize(&mal
->napi
);
379 void mal_poll_enable(struct mal_instance
*mal
, struct mal_commac
*commac
)
382 clear_bit(MAL_COMMAC_POLL_DISABLED
, &commac
->flags
);
384 /* Feels better to trigger a poll here to catch up with events that
385 * may have happened on this channel while disabled. It will most
386 * probably be delayed until the next interrupt but that's mostly a
387 * non-issue in the context where this is called.
389 napi_schedule(&mal
->napi
);
392 static int mal_poll(struct napi_struct
*napi
, int budget
)
394 struct mal_instance
*mal
= container_of(napi
, struct mal_instance
, napi
);
399 MAL_DBG2(mal
, "poll(%d)" NL
, budget
);
401 /* Process TX skbs */
402 list_for_each(l
, &mal
->poll_list
) {
403 struct mal_commac
*mc
=
404 list_entry(l
, struct mal_commac
, poll_list
);
405 mc
->ops
->poll_tx(mc
->dev
);
410 * We _might_ need something more smart here to enforce polling
413 list_for_each(l
, &mal
->poll_list
) {
414 struct mal_commac
*mc
=
415 list_entry(l
, struct mal_commac
, poll_list
);
417 if (unlikely(test_bit(MAL_COMMAC_POLL_DISABLED
, &mc
->flags
)))
419 n
= mc
->ops
->poll_rx(mc
->dev
, budget
- received
);
422 if (received
>= budget
)
427 if (napi_complete_done(napi
, received
)) {
428 /* We need to disable IRQs to protect from RXDE IRQ here */
429 spin_lock_irqsave(&mal
->lock
, flags
);
430 mal_enable_eob_irq(mal
);
431 spin_unlock_irqrestore(&mal
->lock
, flags
);
434 /* Check for "rotting" packet(s) */
435 list_for_each(l
, &mal
->poll_list
) {
436 struct mal_commac
*mc
=
437 list_entry(l
, struct mal_commac
, poll_list
);
438 if (unlikely(test_bit(MAL_COMMAC_POLL_DISABLED
, &mc
->flags
)))
440 if (unlikely(mc
->ops
->peek_rx(mc
->dev
) ||
441 test_bit(MAL_COMMAC_RX_STOPPED
, &mc
->flags
))) {
442 MAL_DBG2(mal
, "rotting packet" NL
);
443 if (!napi_reschedule(napi
))
446 spin_lock_irqsave(&mal
->lock
, flags
);
447 mal_disable_eob_irq(mal
);
448 spin_unlock_irqrestore(&mal
->lock
, flags
);
450 mc
->ops
->poll_tx(mc
->dev
);
454 MAL_DBG2(mal
, "poll() %d <- %d" NL
, budget
, received
);
458 static void mal_reset(struct mal_instance
*mal
)
462 MAL_DBG(mal
, "reset" NL
);
464 set_mal_dcrn(mal
, MAL_CFG
, MAL_CFG_SR
);
466 /* Wait for reset to complete (1 system clock) */
467 while ((get_mal_dcrn(mal
, MAL_CFG
) & MAL_CFG_SR
) && n
)
471 printk(KERN_ERR
"mal%d: reset timeout\n", mal
->index
);
474 int mal_get_regs_len(struct mal_instance
*mal
)
476 return sizeof(struct emac_ethtool_regs_subhdr
) +
477 sizeof(struct mal_regs
);
480 void *mal_dump_regs(struct mal_instance
*mal
, void *buf
)
482 struct emac_ethtool_regs_subhdr
*hdr
= buf
;
483 struct mal_regs
*regs
= (struct mal_regs
*)(hdr
+ 1);
486 hdr
->version
= mal
->version
;
487 hdr
->index
= mal
->index
;
489 regs
->tx_count
= mal
->num_tx_chans
;
490 regs
->rx_count
= mal
->num_rx_chans
;
492 regs
->cfg
= get_mal_dcrn(mal
, MAL_CFG
);
493 regs
->esr
= get_mal_dcrn(mal
, MAL_ESR
);
494 regs
->ier
= get_mal_dcrn(mal
, MAL_IER
);
495 regs
->tx_casr
= get_mal_dcrn(mal
, MAL_TXCASR
);
496 regs
->tx_carr
= get_mal_dcrn(mal
, MAL_TXCARR
);
497 regs
->tx_eobisr
= get_mal_dcrn(mal
, MAL_TXEOBISR
);
498 regs
->tx_deir
= get_mal_dcrn(mal
, MAL_TXDEIR
);
499 regs
->rx_casr
= get_mal_dcrn(mal
, MAL_RXCASR
);
500 regs
->rx_carr
= get_mal_dcrn(mal
, MAL_RXCARR
);
501 regs
->rx_eobisr
= get_mal_dcrn(mal
, MAL_RXEOBISR
);
502 regs
->rx_deir
= get_mal_dcrn(mal
, MAL_RXDEIR
);
504 for (i
= 0; i
< regs
->tx_count
; ++i
)
505 regs
->tx_ctpr
[i
] = get_mal_dcrn(mal
, MAL_TXCTPR(i
));
507 for (i
= 0; i
< regs
->rx_count
; ++i
) {
508 regs
->rx_ctpr
[i
] = get_mal_dcrn(mal
, MAL_RXCTPR(i
));
509 regs
->rcbs
[i
] = get_mal_dcrn(mal
, MAL_RCBS(i
));
514 static int mal_probe(struct platform_device
*ofdev
)
516 struct mal_instance
*mal
;
517 int err
= 0, i
, bd_size
;
518 int index
= mal_count
++;
519 unsigned int dcr_base
;
522 unsigned long irqflags
;
523 irq_handler_t hdlr_serr
, hdlr_txde
, hdlr_rxde
;
525 mal
= kzalloc(sizeof(struct mal_instance
), GFP_KERNEL
);
531 mal
->version
= of_device_is_compatible(ofdev
->dev
.of_node
, "ibm,mcmal2") ? 2 : 1;
533 MAL_DBG(mal
, "probe" NL
);
535 prop
= of_get_property(ofdev
->dev
.of_node
, "num-tx-chans", NULL
);
538 "mal%d: can't find MAL num-tx-chans property!\n",
543 mal
->num_tx_chans
= prop
[0];
545 prop
= of_get_property(ofdev
->dev
.of_node
, "num-rx-chans", NULL
);
548 "mal%d: can't find MAL num-rx-chans property!\n",
553 mal
->num_rx_chans
= prop
[0];
555 dcr_base
= dcr_resource_start(ofdev
->dev
.of_node
, 0);
558 "mal%d: can't find DCR resource!\n", index
);
562 mal
->dcr_host
= dcr_map(ofdev
->dev
.of_node
, dcr_base
, 0x100);
563 if (!DCR_MAP_OK(mal
->dcr_host
)) {
565 "mal%d: failed to map DCRs !\n", index
);
570 if (of_device_is_compatible(ofdev
->dev
.of_node
, "ibm,mcmal-405ez")) {
571 #if defined(CONFIG_IBM_EMAC_MAL_CLR_ICINTSTAT) && \
572 defined(CONFIG_IBM_EMAC_MAL_COMMON_ERR)
573 mal
->features
|= (MAL_FTR_CLEAR_ICINTSTAT
|
574 MAL_FTR_COMMON_ERR_INT
);
576 printk(KERN_ERR
"%pOF: Support for 405EZ not enabled!\n",
583 mal
->txeob_irq
= irq_of_parse_and_map(ofdev
->dev
.of_node
, 0);
584 mal
->rxeob_irq
= irq_of_parse_and_map(ofdev
->dev
.of_node
, 1);
585 mal
->serr_irq
= irq_of_parse_and_map(ofdev
->dev
.of_node
, 2);
587 if (mal_has_feature(mal
, MAL_FTR_COMMON_ERR_INT
)) {
588 mal
->txde_irq
= mal
->rxde_irq
= mal
->serr_irq
;
590 mal
->txde_irq
= irq_of_parse_and_map(ofdev
->dev
.of_node
, 3);
591 mal
->rxde_irq
= irq_of_parse_and_map(ofdev
->dev
.of_node
, 4);
594 if (!mal
->txeob_irq
|| !mal
->rxeob_irq
|| !mal
->serr_irq
||
595 !mal
->txde_irq
|| !mal
->rxde_irq
) {
597 "mal%d: failed to map interrupts !\n", index
);
602 INIT_LIST_HEAD(&mal
->poll_list
);
603 INIT_LIST_HEAD(&mal
->list
);
604 spin_lock_init(&mal
->lock
);
606 init_dummy_netdev(&mal
->dummy_dev
);
608 netif_napi_add(&mal
->dummy_dev
, &mal
->napi
, mal_poll
,
609 CONFIG_IBM_EMAC_POLL_WEIGHT
);
611 /* Load power-on reset defaults */
614 /* Set the MAL configuration register */
615 cfg
= (mal
->version
== 2) ? MAL2_CFG_DEFAULT
: MAL1_CFG_DEFAULT
;
616 cfg
|= MAL_CFG_PLBB
| MAL_CFG_OPBBL
| MAL_CFG_LEA
;
618 /* Current Axon is not happy with priority being non-0, it can
619 * deadlock, fix it up here
621 if (of_device_is_compatible(ofdev
->dev
.of_node
, "ibm,mcmal-axon"))
622 cfg
&= ~(MAL2_CFG_RPP_10
| MAL2_CFG_WPP_10
);
624 /* Apply configuration */
625 set_mal_dcrn(mal
, MAL_CFG
, cfg
);
627 /* Allocate space for BD rings */
628 BUG_ON(mal
->num_tx_chans
<= 0 || mal
->num_tx_chans
> 32);
629 BUG_ON(mal
->num_rx_chans
<= 0 || mal
->num_rx_chans
> 32);
631 bd_size
= sizeof(struct mal_descriptor
) *
632 (NUM_TX_BUFF
* mal
->num_tx_chans
+
633 NUM_RX_BUFF
* mal
->num_rx_chans
);
634 mal
->bd_virt
= dma_alloc_coherent(&ofdev
->dev
, bd_size
, &mal
->bd_dma
,
636 if (mal
->bd_virt
== NULL
) {
641 for (i
= 0; i
< mal
->num_tx_chans
; ++i
)
642 set_mal_dcrn(mal
, MAL_TXCTPR(i
), mal
->bd_dma
+
643 sizeof(struct mal_descriptor
) *
644 mal_tx_bd_offset(mal
, i
));
646 for (i
= 0; i
< mal
->num_rx_chans
; ++i
)
647 set_mal_dcrn(mal
, MAL_RXCTPR(i
), mal
->bd_dma
+
648 sizeof(struct mal_descriptor
) *
649 mal_rx_bd_offset(mal
, i
));
651 if (mal_has_feature(mal
, MAL_FTR_COMMON_ERR_INT
)) {
652 irqflags
= IRQF_SHARED
;
653 hdlr_serr
= hdlr_txde
= hdlr_rxde
= mal_int
;
656 hdlr_serr
= mal_serr
;
657 hdlr_txde
= mal_txde
;
658 hdlr_rxde
= mal_rxde
;
661 err
= request_irq(mal
->serr_irq
, hdlr_serr
, irqflags
, "MAL SERR", mal
);
664 err
= request_irq(mal
->txde_irq
, hdlr_txde
, irqflags
, "MAL TX DE", mal
);
667 err
= request_irq(mal
->txeob_irq
, mal_txeob
, 0, "MAL TX EOB", mal
);
670 err
= request_irq(mal
->rxde_irq
, hdlr_rxde
, irqflags
, "MAL RX DE", mal
);
673 err
= request_irq(mal
->rxeob_irq
, mal_rxeob
, 0, "MAL RX EOB", mal
);
677 /* Enable all MAL SERR interrupt sources */
678 set_mal_dcrn(mal
, MAL_IER
, MAL_IER_EVENTS
);
680 /* Enable EOB interrupt */
681 mal_enable_eob_irq(mal
);
684 "MAL v%d %pOF, %d TX channels, %d RX channels\n",
685 mal
->version
, ofdev
->dev
.of_node
,
686 mal
->num_tx_chans
, mal
->num_rx_chans
);
688 /* Advertise this instance to the rest of the world */
690 platform_set_drvdata(ofdev
, mal
);
695 free_irq(mal
->rxde_irq
, mal
);
697 free_irq(mal
->txeob_irq
, mal
);
699 free_irq(mal
->txde_irq
, mal
);
701 free_irq(mal
->serr_irq
, mal
);
703 dma_free_coherent(&ofdev
->dev
, bd_size
, mal
->bd_virt
, mal
->bd_dma
);
705 dcr_unmap(mal
->dcr_host
, 0x100);
712 static int mal_remove(struct platform_device
*ofdev
)
714 struct mal_instance
*mal
= platform_get_drvdata(ofdev
);
716 MAL_DBG(mal
, "remove" NL
);
718 /* Synchronize with scheduled polling */
719 napi_disable(&mal
->napi
);
721 if (!list_empty(&mal
->list
))
722 /* This is *very* bad */
724 "mal%d: commac list is not empty on remove!\n",
727 free_irq(mal
->serr_irq
, mal
);
728 free_irq(mal
->txde_irq
, mal
);
729 free_irq(mal
->txeob_irq
, mal
);
730 free_irq(mal
->rxde_irq
, mal
);
731 free_irq(mal
->rxeob_irq
, mal
);
735 dma_free_coherent(&ofdev
->dev
,
736 sizeof(struct mal_descriptor
) *
737 (NUM_TX_BUFF
* mal
->num_tx_chans
+
738 NUM_RX_BUFF
* mal
->num_rx_chans
), mal
->bd_virt
,
745 static const struct of_device_id mal_platform_match
[] =
748 .compatible
= "ibm,mcmal",
751 .compatible
= "ibm,mcmal2",
753 /* Backward compat */
756 .compatible
= "ibm,mcmal",
760 .compatible
= "ibm,mcmal2",
765 static struct platform_driver mal_of_driver
= {
768 .of_match_table
= mal_platform_match
,
771 .remove
= mal_remove
,
774 int __init
mal_init(void)
776 return platform_driver_register(&mal_of_driver
);
781 platform_driver_unregister(&mal_of_driver
);