^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * jazzsonic.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * (C) 2005 Finn Thain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Converted to DMA API, and (from the mac68k project) introduced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * dhd's support for 16-bit cards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * (C) 1996,1998 by Thomas Bogendoerfer (tsbogend@alpha.franken.de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This driver is based on work from Andreas Busse, but most of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * the code is rewritten.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * A driver for the onboard Sonic ethernet controller on Mips Jazz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * systems (Acer Pica-61, Mips Magnum 4000, Olivetti M700 and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * perhaps others, too)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/pgtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <asm/bootinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <asm/dma.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <asm/jazz.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <asm/jazzdma.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static char jazz_sonic_string[] = "jazzsonic";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define SONIC_MEM_SIZE 0x100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include "sonic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * Macros to access SONIC registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define SONIC_READ(reg) (*((volatile unsigned int *)dev->base_addr+reg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define SONIC_WRITE(reg,val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) *((volatile unsigned int *)dev->base_addr+(reg)) = (val); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * We cannot use station (ethernet) address prefixes to detect the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * sonic controller since these are board manufacturer depended.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * So we check for known Silicon Revision IDs instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static unsigned short known_revisions[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 0x04, /* Mips Magnum 4000 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 0xffff /* end of list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static int jazzsonic_open(struct net_device* dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) retval = request_irq(dev->irq, sonic_interrupt, 0, "sonic", dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) printk(KERN_ERR "%s: unable to get IRQ %d.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) dev->name, dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) retval = sonic_open(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) free_irq(dev->irq, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static int jazzsonic_close(struct net_device* dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) err = sonic_close(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) free_irq(dev->irq, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static const struct net_device_ops sonic_netdev_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .ndo_open = jazzsonic_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .ndo_stop = jazzsonic_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .ndo_start_xmit = sonic_send_packet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .ndo_get_stats = sonic_get_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .ndo_set_rx_mode = sonic_multicast_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .ndo_tx_timeout = sonic_tx_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .ndo_validate_addr = eth_validate_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .ndo_set_mac_address = eth_mac_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static int sonic_probe1(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) unsigned int silicon_revision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) unsigned int val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct sonic_local *lp = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int err = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (!request_mem_region(dev->base_addr, SONIC_MEM_SIZE, jazz_sonic_string))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * get the Silicon Revision ID. If this is one of the known
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * one assume that we found a SONIC ethernet controller at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * the expected location.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) silicon_revision = SONIC_READ(SONIC_SR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) while (known_revisions[i] != 0xffff &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) known_revisions[i] != silicon_revision)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) if (known_revisions[i] == 0xffff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) pr_info("SONIC ethernet controller not found (0x%4x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) silicon_revision);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * Put the sonic into software reset, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * retrieve and print the ethernet address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) SONIC_WRITE(SONIC_CMD,SONIC_CR_RST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) SONIC_WRITE(SONIC_CEP,0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) for (i=0; i<3; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) val = SONIC_READ(SONIC_CAP0-i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) dev->dev_addr[i*2] = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) dev->dev_addr[i*2+1] = val >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) lp->dma_bitmode = SONIC_BITMODE32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) err = sonic_alloc_descriptors(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) dev->netdev_ops = &sonic_netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) dev->watchdog_timeo = TX_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * clear tally counter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) SONIC_WRITE(SONIC_CRCT,0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) SONIC_WRITE(SONIC_FAET,0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) SONIC_WRITE(SONIC_MPT,0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) release_mem_region(dev->base_addr, SONIC_MEM_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * Probe for a SONIC ethernet controller on a Mips Jazz board.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * Actually probing is superfluous but we're paranoid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static int jazz_sonic_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct sonic_local *lp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (!res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) dev = alloc_etherdev(sizeof(struct sonic_local));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (!dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) lp = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) lp->device = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) SET_NETDEV_DEV(dev, &pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) platform_set_drvdata(pdev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) netdev_boot_setup_check(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) dev->base_addr = res->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) dev->irq = platform_get_irq(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) err = sonic_probe1(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) pr_info("SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) dev->base_addr, dev->dev_addr, dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) sonic_msg_init(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) err = register_netdev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) goto undo_probe1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) undo_probe1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) lp->descriptors, lp->descriptors_laddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) release_mem_region(dev->base_addr, SONIC_MEM_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) free_netdev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) MODULE_DESCRIPTION("Jazz SONIC ethernet driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) MODULE_ALIAS("platform:jazzsonic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) #include "sonic.c"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static int jazz_sonic_device_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct net_device *dev = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) struct sonic_local* lp = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) unregister_netdev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) lp->descriptors, lp->descriptors_laddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) release_mem_region(dev->base_addr, SONIC_MEM_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) free_netdev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static struct platform_driver jazz_sonic_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) .probe = jazz_sonic_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) .remove = jazz_sonic_device_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) .name = jazz_sonic_string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) module_platform_driver(jazz_sonic_driver);