| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 2 | * jazzsonic.c | 
|  | 3 | * | 
|  | 4 | * (C) 2005 Finn Thain | 
|  | 5 | * | 
|  | 6 | * Converted to DMA API, and (from the mac68k project) introduced | 
|  | 7 | * dhd's support for 16-bit cards. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * | 
|  | 9 | * (C) 1996,1998 by Thomas Bogendoerfer (tsbogend@alpha.franken.de) | 
| Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 10 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * This driver is based on work from Andreas Busse, but most of | 
|  | 12 | * the code is rewritten. | 
| Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 13 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | * (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de) | 
|  | 15 | * | 
|  | 16 | * A driver for the onboard Sonic ethernet controller on Mips Jazz | 
|  | 17 | * systems (Acer Pica-61, Mips Magnum 4000, Olivetti M700 and | 
|  | 18 | * perhaps others, too) | 
|  | 19 | */ | 
|  | 20 |  | 
|  | 21 | #include <linux/kernel.h> | 
|  | 22 | #include <linux/module.h> | 
|  | 23 | #include <linux/types.h> | 
|  | 24 | #include <linux/fcntl.h> | 
| Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | #include <linux/gfp.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/interrupt.h> | 
|  | 27 | #include <linux/init.h> | 
|  | 28 | #include <linux/ioport.h> | 
|  | 29 | #include <linux/in.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/string.h> | 
|  | 31 | #include <linux/delay.h> | 
|  | 32 | #include <linux/errno.h> | 
|  | 33 | #include <linux/netdevice.h> | 
|  | 34 | #include <linux/etherdevice.h> | 
|  | 35 | #include <linux/skbuff.h> | 
| Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 36 | #include <linux/platform_device.h> | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 37 | #include <linux/dma-mapping.h> | 
| Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 38 | #include <linux/slab.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 |  | 
|  | 40 | #include <asm/bootinfo.h> | 
|  | 41 | #include <asm/system.h> | 
|  | 42 | #include <asm/pgtable.h> | 
|  | 43 | #include <asm/io.h> | 
|  | 44 | #include <asm/dma.h> | 
|  | 45 | #include <asm/jazz.h> | 
|  | 46 | #include <asm/jazzdma.h> | 
|  | 47 |  | 
|  | 48 | static char jazz_sonic_string[] = "jazzsonic"; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 |  | 
|  | 50 | #define SONIC_MEM_SIZE	0x100 | 
|  | 51 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #include "sonic.h" | 
|  | 53 |  | 
|  | 54 | /* | 
|  | 55 | * Macros to access SONIC registers | 
|  | 56 | */ | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 57 | #define SONIC_READ(reg) (*((volatile unsigned int *)dev->base_addr+reg)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 |  | 
|  | 59 | #define SONIC_WRITE(reg,val)						\ | 
|  | 60 | do {									\ | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 61 | *((volatile unsigned int *)dev->base_addr+(reg)) = (val);		\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | } while (0) | 
|  | 63 |  | 
|  | 64 |  | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 65 | /* use 0 for production, 1 for verification, >1 for debug */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | #ifdef SONIC_DEBUG | 
|  | 67 | static unsigned int sonic_debug = SONIC_DEBUG; | 
| Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 68 | #else | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | static unsigned int sonic_debug = 1; | 
|  | 70 | #endif | 
|  | 71 |  | 
|  | 72 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | * We cannot use station (ethernet) address prefixes to detect the | 
|  | 74 | * sonic controller since these are board manufacturer depended. | 
| Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 75 | * So we check for known Silicon Revision IDs instead. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | */ | 
|  | 77 | static unsigned short known_revisions[] = | 
|  | 78 | { | 
|  | 79 | 0x04,			/* Mips Magnum 4000 */ | 
|  | 80 | 0xffff			/* end of list */ | 
|  | 81 | }; | 
|  | 82 |  | 
| Finn Thain | f4d8675 | 2007-05-02 12:55:56 +1000 | [diff] [blame] | 83 | static int jazzsonic_open(struct net_device* dev) | 
|  | 84 | { | 
| Kulikov Vasiliy | 62cd69a | 2010-07-10 01:00:35 +0000 | [diff] [blame] | 85 | int retval; | 
|  | 86 |  | 
|  | 87 | retval = request_irq(dev->irq, sonic_interrupt, IRQF_DISABLED, | 
|  | 88 | "sonic", dev); | 
|  | 89 | if (retval) { | 
|  | 90 | printk(KERN_ERR "%s: unable to get IRQ %d.\n", | 
|  | 91 | dev->name, dev->irq); | 
|  | 92 | return retval; | 
| Finn Thain | f4d8675 | 2007-05-02 12:55:56 +1000 | [diff] [blame] | 93 | } | 
| Kulikov Vasiliy | 62cd69a | 2010-07-10 01:00:35 +0000 | [diff] [blame] | 94 |  | 
|  | 95 | retval = sonic_open(dev); | 
|  | 96 | if (retval) | 
|  | 97 | free_irq(dev->irq, dev); | 
|  | 98 | return retval; | 
| Finn Thain | f4d8675 | 2007-05-02 12:55:56 +1000 | [diff] [blame] | 99 | } | 
|  | 100 |  | 
|  | 101 | static int jazzsonic_close(struct net_device* dev) | 
|  | 102 | { | 
|  | 103 | int err; | 
|  | 104 | err = sonic_close(dev); | 
|  | 105 | free_irq(dev->irq, dev); | 
|  | 106 | return err; | 
|  | 107 | } | 
|  | 108 |  | 
| Alexander Beregalov | 502a326 | 2009-04-15 12:52:45 +0000 | [diff] [blame] | 109 | static const struct net_device_ops sonic_netdev_ops = { | 
|  | 110 | .ndo_open		= jazzsonic_open, | 
|  | 111 | .ndo_stop		= jazzsonic_close, | 
|  | 112 | .ndo_start_xmit		= sonic_send_packet, | 
|  | 113 | .ndo_get_stats		= sonic_get_stats, | 
|  | 114 | .ndo_set_multicast_list	= sonic_multicast_list, | 
|  | 115 | .ndo_tx_timeout		= sonic_tx_timeout, | 
|  | 116 | .ndo_change_mtu		= eth_change_mtu, | 
|  | 117 | .ndo_validate_addr	= eth_validate_addr, | 
|  | 118 | .ndo_set_mac_address	= eth_mac_addr, | 
|  | 119 | }; | 
|  | 120 |  | 
| Uwe Kleine-König | 2e76bae | 2009-07-21 11:25:22 +0000 | [diff] [blame] | 121 | static int __devinit sonic_probe1(struct net_device *dev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | { | 
|  | 123 | static unsigned version_printed; | 
|  | 124 | unsigned int silicon_revision; | 
|  | 125 | unsigned int val; | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 126 | struct sonic_local *lp = netdev_priv(dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | int err = -ENODEV; | 
|  | 128 | int i; | 
|  | 129 |  | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 130 | if (!request_mem_region(dev->base_addr, SONIC_MEM_SIZE, jazz_sonic_string)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | return -EBUSY; | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 132 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | /* | 
|  | 134 | * get the Silicon Revision ID. If this is one of the known | 
|  | 135 | * one assume that we found a SONIC ethernet controller at | 
|  | 136 | * the expected location. | 
|  | 137 | */ | 
|  | 138 | silicon_revision = SONIC_READ(SONIC_SR); | 
|  | 139 | if (sonic_debug > 1) | 
|  | 140 | printk("SONIC Silicon Revision = 0x%04x\n",silicon_revision); | 
|  | 141 |  | 
|  | 142 | i = 0; | 
| Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 143 | while (known_revisions[i] != 0xffff && | 
|  | 144 | known_revisions[i] != silicon_revision) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | i++; | 
|  | 146 |  | 
|  | 147 | if (known_revisions[i] == 0xffff) { | 
|  | 148 | printk("SONIC ethernet controller not found (0x%4x)\n", | 
|  | 149 | silicon_revision); | 
|  | 150 | goto out; | 
|  | 151 | } | 
| Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 152 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | if (sonic_debug  &&  version_printed++ == 0) | 
|  | 154 | printk(version); | 
|  | 155 |  | 
| Kay Sievers | c231355 | 2009-03-24 16:38:22 -0700 | [diff] [blame] | 156 | printk(KERN_INFO "%s: Sonic ethernet found at 0x%08lx, ", | 
|  | 157 | dev_name(lp->device), dev->base_addr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 |  | 
|  | 159 | /* | 
|  | 160 | * Put the sonic into software reset, then | 
|  | 161 | * retrieve and print the ethernet address. | 
|  | 162 | */ | 
|  | 163 | SONIC_WRITE(SONIC_CMD,SONIC_CR_RST); | 
|  | 164 | SONIC_WRITE(SONIC_CEP,0); | 
|  | 165 | for (i=0; i<3; i++) { | 
|  | 166 | val = SONIC_READ(SONIC_CAP0-i); | 
|  | 167 | dev->dev_addr[i*2] = val; | 
|  | 168 | dev->dev_addr[i*2+1] = val >> 8; | 
|  | 169 | } | 
|  | 170 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | err = -ENOMEM; | 
| Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 172 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | /* Initialize the device structure. */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 |  | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 175 | lp->dma_bitmode = SONIC_BITMODE32; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 |  | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 177 | /* Allocate the entire chunk of memory for the descriptors. | 
|  | 178 | Note that this cannot cross a 64K boundary. */ | 
|  | 179 | if ((lp->descriptors = dma_alloc_coherent(lp->device, | 
|  | 180 | SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode), | 
|  | 181 | &lp->descriptors_laddr, GFP_KERNEL)) == NULL) { | 
| Kay Sievers | c231355 | 2009-03-24 16:38:22 -0700 | [diff] [blame] | 182 | printk(KERN_ERR "%s: couldn't alloc DMA memory for descriptors.\n", | 
|  | 183 | dev_name(lp->device)); | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 184 | goto out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | } | 
|  | 186 |  | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 187 | /* Now set up the pointers to point to the appropriate places */ | 
|  | 188 | lp->cda = lp->descriptors; | 
|  | 189 | lp->tda = lp->cda + (SIZEOF_SONIC_CDA | 
|  | 190 | * SONIC_BUS_SCALE(lp->dma_bitmode)); | 
|  | 191 | lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS | 
|  | 192 | * SONIC_BUS_SCALE(lp->dma_bitmode)); | 
|  | 193 | lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS | 
|  | 194 | * SONIC_BUS_SCALE(lp->dma_bitmode)); | 
|  | 195 |  | 
|  | 196 | lp->cda_laddr = lp->descriptors_laddr; | 
|  | 197 | lp->tda_laddr = lp->cda_laddr + (SIZEOF_SONIC_CDA | 
|  | 198 | * SONIC_BUS_SCALE(lp->dma_bitmode)); | 
|  | 199 | lp->rda_laddr = lp->tda_laddr + (SIZEOF_SONIC_TD * SONIC_NUM_TDS | 
|  | 200 | * SONIC_BUS_SCALE(lp->dma_bitmode)); | 
|  | 201 | lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS | 
|  | 202 | * SONIC_BUS_SCALE(lp->dma_bitmode)); | 
|  | 203 |  | 
| Alexander Beregalov | 502a326 | 2009-04-15 12:52:45 +0000 | [diff] [blame] | 204 | dev->netdev_ops = &sonic_netdev_ops; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | dev->watchdog_timeo = TX_TIMEOUT; | 
|  | 206 |  | 
|  | 207 | /* | 
|  | 208 | * clear tally counter | 
|  | 209 | */ | 
|  | 210 | SONIC_WRITE(SONIC_CRCT,0xffff); | 
|  | 211 | SONIC_WRITE(SONIC_FAET,0xffff); | 
|  | 212 | SONIC_WRITE(SONIC_MPT,0xffff); | 
|  | 213 |  | 
|  | 214 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | out: | 
| Julia Lawall | c9145a2 | 2009-08-08 21:43:42 +0000 | [diff] [blame] | 216 | release_mem_region(dev->base_addr, SONIC_MEM_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | return err; | 
|  | 218 | } | 
|  | 219 |  | 
|  | 220 | /* | 
|  | 221 | * Probe for a SONIC ethernet controller on a Mips Jazz board. | 
|  | 222 | * Actually probing is superfluous but we're paranoid. | 
|  | 223 | */ | 
| Uwe Kleine-König | 2e76bae | 2009-07-21 11:25:22 +0000 | [diff] [blame] | 224 | static int __devinit jazz_sonic_probe(struct platform_device *pdev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | { | 
|  | 226 | struct net_device *dev; | 
|  | 227 | struct sonic_local *lp; | 
| Thomas Bogendoerfer | ed9f0e0 | 2007-09-08 21:46:49 +0200 | [diff] [blame] | 228 | struct resource *res; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | int err = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 |  | 
| Thomas Bogendoerfer | ed9f0e0 | 2007-09-08 21:46:49 +0200 | [diff] [blame] | 231 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 
|  | 232 | if (!res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | return -ENODEV; | 
|  | 234 |  | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 235 | dev = alloc_etherdev(sizeof(struct sonic_local)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | if (!dev) | 
|  | 237 | return -ENOMEM; | 
|  | 238 |  | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 239 | lp = netdev_priv(dev); | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 240 | lp->device = &pdev->dev; | 
|  | 241 | SET_NETDEV_DEV(dev, &pdev->dev); | 
| Finn Thain | 4564cba | 2009-07-21 12:21:49 -0700 | [diff] [blame] | 242 | platform_set_drvdata(pdev, dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 |  | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 244 | netdev_boot_setup_check(dev); | 
|  | 245 |  | 
| Thomas Bogendoerfer | ed9f0e0 | 2007-09-08 21:46:49 +0200 | [diff] [blame] | 246 | dev->base_addr = res->start; | 
|  | 247 | dev->irq = platform_get_irq(pdev, 0); | 
|  | 248 | err = sonic_probe1(dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | if (err) | 
|  | 250 | goto out; | 
|  | 251 | err = register_netdev(dev); | 
|  | 252 | if (err) | 
|  | 253 | goto out1; | 
|  | 254 |  | 
| Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 255 | printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq); | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 256 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | return 0; | 
|  | 258 |  | 
|  | 259 | out1: | 
| Julia Lawall | c9145a2 | 2009-08-08 21:43:42 +0000 | [diff] [blame] | 260 | release_mem_region(dev->base_addr, SONIC_MEM_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | out: | 
|  | 262 | free_netdev(dev); | 
|  | 263 |  | 
|  | 264 | return err; | 
|  | 265 | } | 
|  | 266 |  | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 267 | MODULE_DESCRIPTION("Jazz SONIC ethernet driver"); | 
|  | 268 | module_param(sonic_debug, int, 0); | 
|  | 269 | MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)"); | 
| Kay Sievers | 72abb46 | 2008-04-18 13:50:44 -0700 | [diff] [blame] | 270 | MODULE_ALIAS("platform:jazzsonic"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | #include "sonic.c" | 
|  | 273 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 274 | static int __devexit jazz_sonic_device_remove (struct platform_device *pdev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | { | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 276 | struct net_device *dev = platform_get_drvdata(pdev); | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 277 | struct sonic_local* lp = netdev_priv(dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 |  | 
| Finn Thain | d74472f | 2007-05-01 22:33:02 +0200 | [diff] [blame] | 279 | unregister_netdev(dev); | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 280 | dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode), | 
|  | 281 | lp->descriptors, lp->descriptors_laddr); | 
| Julia Lawall | c9145a2 | 2009-08-08 21:43:42 +0000 | [diff] [blame] | 282 | release_mem_region(dev->base_addr, SONIC_MEM_SIZE); | 
| Finn Thain | d74472f | 2007-05-01 22:33:02 +0200 | [diff] [blame] | 283 | free_netdev(dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 |  | 
|  | 285 | return 0; | 
|  | 286 | } | 
|  | 287 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 288 | static struct platform_driver jazz_sonic_driver = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | .probe	= jazz_sonic_probe, | 
|  | 290 | .remove	= __devexit_p(jazz_sonic_device_remove), | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 291 | .driver	= { | 
|  | 292 | .name	= jazz_sonic_string, | 
| Kay Sievers | 72abb46 | 2008-04-18 13:50:44 -0700 | [diff] [blame] | 293 | .owner	= THIS_MODULE, | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 294 | }, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | }; | 
| Finn Thain | efcce83 | 2005-08-20 15:53:22 +1000 | [diff] [blame] | 296 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | static int __init jazz_sonic_init_module(void) | 
|  | 298 | { | 
| Thomas Bogendoerfer | ed9f0e0 | 2007-09-08 21:46:49 +0200 | [diff] [blame] | 299 | return platform_driver_register(&jazz_sonic_driver); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | } | 
|  | 301 |  | 
|  | 302 | static void __exit jazz_sonic_cleanup_module(void) | 
|  | 303 | { | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 304 | platform_driver_unregister(&jazz_sonic_driver); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | } | 
|  | 306 |  | 
|  | 307 | module_init(jazz_sonic_init_module); | 
|  | 308 | module_exit(jazz_sonic_cleanup_module); |