Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #include <linux/types.h> |
| 2 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | #include <linux/ioport.h> |
| 4 | #include <linux/init.h> |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 5 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | #include <linux/spinlock.h> |
| 7 | #include <linux/interrupt.h> |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 8 | #include <linux/platform_device.h> |
Paul Gortmaker | acf3368f | 2011-05-27 09:47:43 -0400 | [diff] [blame] | 9 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <asm/page.h> |
| 12 | #include <asm/pgtable.h> |
| 13 | #include <asm/amigaints.h> |
| 14 | #include <asm/amigahw.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | #include "scsi.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include "wd33c93.h" |
| 18 | #include "a3000.h" |
| 19 | |
Adrian Bunk | 9387edb | 2009-03-04 12:06:08 -0800 | [diff] [blame] | 20 | |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 21 | struct a3000_hostdata { |
| 22 | struct WD33C93_hostdata wh; |
| 23 | struct a3000_scsiregs *regs; |
| 24 | }; |
| 25 | |
Geert Uytterhoeven | a8169e6 | 2009-05-17 13:35:07 +0200 | [diff] [blame] | 26 | static irqreturn_t a3000_intr(int irq, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
Geert Uytterhoeven | a8169e6 | 2009-05-17 13:35:07 +0200 | [diff] [blame] | 28 | struct Scsi_Host *instance = data; |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 29 | struct a3000_hostdata *hdata = shost_priv(instance); |
| 30 | unsigned int status = hdata->regs->ISTR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | if (!(status & ISTR_INT_P)) |
| 34 | return IRQ_NONE; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 35 | if (status & ISTR_INTS) { |
Geert Uytterhoeven | a8169e6 | 2009-05-17 13:35:07 +0200 | [diff] [blame] | 36 | spin_lock_irqsave(instance->host_lock, flags); |
| 37 | wd33c93_intr(instance); |
| 38 | spin_unlock_irqrestore(instance->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | return IRQ_HANDLED; |
| 40 | } |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 41 | pr_warning("Non-serviced A3000 SCSI-interrupt? ISTR = %02x\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | return IRQ_NONE; |
| 43 | } |
| 44 | |
Henrik Kretzschmar | 6539641 | 2006-09-12 23:49:33 +0200 | [diff] [blame] | 45 | static int dma_setup(struct scsi_cmnd *cmd, int dir_in) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | { |
Geert Uytterhoeven | a8169e6 | 2009-05-17 13:35:07 +0200 | [diff] [blame] | 47 | struct Scsi_Host *instance = cmd->device->host; |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 48 | struct a3000_hostdata *hdata = shost_priv(instance); |
| 49 | struct WD33C93_hostdata *wh = &hdata->wh; |
| 50 | struct a3000_scsiregs *regs = hdata->regs; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 51 | unsigned short cntr = CNTR_PDMD | CNTR_INTEN; |
| 52 | unsigned long addr = virt_to_bus(cmd->SCp.ptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 54 | /* |
| 55 | * if the physical address has the wrong alignment, or if |
| 56 | * physical address is bad, or if it is a write and at the |
| 57 | * end of a physical memory chunk, then allocate a bounce |
| 58 | * buffer |
| 59 | */ |
| 60 | if (addr & A3000_XFER_MASK) { |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 61 | wh->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; |
| 62 | wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len, |
| 63 | GFP_KERNEL); |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 64 | |
| 65 | /* can't allocate memory; use PIO */ |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 66 | if (!wh->dma_bounce_buffer) { |
| 67 | wh->dma_bounce_len = 0; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 68 | return 1; |
| 69 | } |
| 70 | |
| 71 | if (!dir_in) { |
| 72 | /* copy to bounce buffer for a write */ |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 73 | memcpy(wh->dma_bounce_buffer, cmd->SCp.ptr, |
Geert Uytterhoeven | afdbbc1 | 2010-04-04 11:00:39 +0200 | [diff] [blame] | 74 | cmd->SCp.this_residual); |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 75 | } |
| 76 | |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 77 | addr = virt_to_bus(wh->dma_bounce_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 80 | /* setup dma direction */ |
| 81 | if (!dir_in) |
| 82 | cntr |= CNTR_DDIR; |
| 83 | |
| 84 | /* remember direction */ |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 85 | wh->dma_dir = dir_in; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 86 | |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 87 | regs->CNTR = cntr; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 88 | |
| 89 | /* setup DMA *physical* address */ |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 90 | regs->ACR = addr; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 91 | |
| 92 | if (dir_in) { |
| 93 | /* invalidate any cache */ |
| 94 | cache_clear(addr, cmd->SCp.this_residual); |
| 95 | } else { |
| 96 | /* push any dirty cache */ |
| 97 | cache_push(addr, cmd->SCp.this_residual); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 100 | /* start DMA */ |
| 101 | mb(); /* make sure setup is completed */ |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 102 | regs->ST_DMA = 1; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 103 | mb(); /* make sure DMA has started before next IO */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 105 | /* return success */ |
| 106 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Henrik Kretzschmar | 6539641 | 2006-09-12 23:49:33 +0200 | [diff] [blame] | 109 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, |
| 110 | int status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 112 | struct a3000_hostdata *hdata = shost_priv(instance); |
| 113 | struct WD33C93_hostdata *wh = &hdata->wh; |
| 114 | struct a3000_scsiregs *regs = hdata->regs; |
Geert Uytterhoeven | afdbbc1 | 2010-04-04 11:00:39 +0200 | [diff] [blame] | 115 | |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 116 | /* disable SCSI interrupts */ |
| 117 | unsigned short cntr = CNTR_PDMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 119 | if (!wh->dma_dir) |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 120 | cntr |= CNTR_DDIR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 122 | regs->CNTR = cntr; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 123 | mb(); /* make sure CNTR is updated before next IO */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 125 | /* flush if we were reading */ |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 126 | if (wh->dma_dir) { |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 127 | regs->FLUSH = 1; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 128 | mb(); /* don't allow prefetch */ |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 129 | while (!(regs->ISTR & ISTR_FE_FLG)) |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 130 | barrier(); |
| 131 | mb(); /* no IO until FLUSH is done */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 133 | |
| 134 | /* clear a possible interrupt */ |
| 135 | /* I think that this CINT is only necessary if you are |
| 136 | * using the terminal count features. HM 7 Mar 1994 |
| 137 | */ |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 138 | regs->CINT = 1; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 139 | |
| 140 | /* stop DMA */ |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 141 | regs->SP_DMA = 1; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 142 | mb(); /* make sure DMA is stopped before next IO */ |
| 143 | |
| 144 | /* restore the CONTROL bits (minus the direction flag) */ |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 145 | regs->CNTR = CNTR_PDMD | CNTR_INTEN; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 146 | mb(); /* make sure CNTR is updated before next IO */ |
| 147 | |
| 148 | /* copy from a bounce buffer, if necessary */ |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 149 | if (status && wh->dma_bounce_buffer) { |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 150 | if (SCpnt) { |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 151 | if (wh->dma_dir && SCpnt) |
| 152 | memcpy(SCpnt->SCp.ptr, wh->dma_bounce_buffer, |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 153 | SCpnt->SCp.this_residual); |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 154 | kfree(wh->dma_bounce_buffer); |
| 155 | wh->dma_bounce_buffer = NULL; |
| 156 | wh->dma_bounce_len = 0; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 157 | } else { |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 158 | kfree(wh->dma_bounce_buffer); |
| 159 | wh->dma_bounce_buffer = NULL; |
| 160 | wh->dma_bounce_len = 0; |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 161 | } |
| 162 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Henrik Kretzschmar | 6539641 | 2006-09-12 23:49:33 +0200 | [diff] [blame] | 165 | static int a3000_bus_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | { |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 167 | struct Scsi_Host *instance = cmd->device->host; |
| 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | /* FIXME perform bus-specific reset */ |
Geert Uytterhoeven | 2135101 | 2010-04-04 11:00:35 +0200 | [diff] [blame] | 170 | |
Jeff Garzik | df0ae24 | 2005-05-28 07:57:14 -0400 | [diff] [blame] | 171 | /* FIXME 2: kill this entire function, which should |
| 172 | cause mid-layer to call wd33c93_host_reset anyway? */ |
Jeff Garzik | 68b3aa7 | 2005-05-28 07:56:31 -0400 | [diff] [blame] | 173 | |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 174 | spin_lock_irq(instance->host_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | wd33c93_host_reset(cmd); |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 176 | spin_unlock_irq(instance->host_lock); |
Jeff Garzik | 68b3aa7 | 2005-05-28 07:56:31 -0400 | [diff] [blame] | 177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | return SUCCESS; |
| 179 | } |
| 180 | |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 181 | static struct scsi_host_template amiga_a3000_scsi_template = { |
| 182 | .module = THIS_MODULE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | .name = "Amiga 3000 built-in SCSI", |
Al Viro | 408bb25 | 2013-03-31 00:30:35 -0400 | [diff] [blame] | 184 | .show_info = wd33c93_show_info, |
| 185 | .write_info = wd33c93_write_info, |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 186 | .proc_name = "A3000", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | .queuecommand = wd33c93_queuecommand, |
| 188 | .eh_abort_handler = wd33c93_abort, |
| 189 | .eh_bus_reset_handler = a3000_bus_reset, |
| 190 | .eh_host_reset_handler = wd33c93_host_reset, |
| 191 | .can_queue = CAN_QUEUE, |
| 192 | .this_id = 7, |
| 193 | .sg_tablesize = SG_ALL, |
| 194 | .cmd_per_lun = CMD_PER_LUN, |
| 195 | .use_clustering = ENABLE_CLUSTERING |
| 196 | }; |
| 197 | |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 198 | static int __init amiga_a3000_scsi_probe(struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | { |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 200 | struct resource *res; |
| 201 | struct Scsi_Host *instance; |
| 202 | int error; |
| 203 | struct a3000_scsiregs *regs; |
| 204 | wd33c93_regs wdregs; |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 205 | struct a3000_hostdata *hdata; |
Geert Uytterhoeven | d753722 | 2009-05-17 12:17:23 +0200 | [diff] [blame] | 206 | |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 207 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 208 | if (!res) |
| 209 | return -ENODEV; |
| 210 | |
| 211 | if (!request_mem_region(res->start, resource_size(res), "wd33c93")) |
| 212 | return -EBUSY; |
| 213 | |
| 214 | instance = scsi_host_alloc(&amiga_a3000_scsi_template, |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 215 | sizeof(struct a3000_hostdata)); |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 216 | if (!instance) { |
| 217 | error = -ENOMEM; |
| 218 | goto fail_alloc; |
| 219 | } |
| 220 | |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 221 | instance->irq = IRQ_AMIGA_PORTS; |
| 222 | |
Geert Uytterhoeven | 6112ea0 | 2011-01-09 11:03:43 +0100 | [diff] [blame] | 223 | regs = ZTWO_VADDR(res->start); |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 224 | regs->DAWR = DAWR_A3000; |
| 225 | |
| 226 | wdregs.SASR = ®s->SASR; |
| 227 | wdregs.SCMD = ®s->SCMD; |
| 228 | |
| 229 | hdata = shost_priv(instance); |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 230 | hdata->wh.no_sync = 0xff; |
| 231 | hdata->wh.fast = 0; |
| 232 | hdata->wh.dma_mode = CTRL_DMA; |
| 233 | hdata->regs = regs; |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 234 | |
| 235 | wd33c93_init(instance, wdregs, dma_setup, dma_stop, WD33C93_FS_12_15); |
| 236 | error = request_irq(IRQ_AMIGA_PORTS, a3000_intr, IRQF_SHARED, |
| 237 | "A3000 SCSI", instance); |
| 238 | if (error) |
| 239 | goto fail_irq; |
| 240 | |
| 241 | regs->CNTR = CNTR_PDMD | CNTR_INTEN; |
| 242 | |
| 243 | error = scsi_add_host(instance, NULL); |
| 244 | if (error) |
| 245 | goto fail_host; |
| 246 | |
| 247 | platform_set_drvdata(pdev, instance); |
| 248 | |
| 249 | scsi_scan_host(instance); |
| 250 | return 0; |
| 251 | |
| 252 | fail_host: |
| 253 | free_irq(IRQ_AMIGA_PORTS, instance); |
| 254 | fail_irq: |
| 255 | scsi_host_put(instance); |
| 256 | fail_alloc: |
| 257 | release_mem_region(res->start, resource_size(res)); |
| 258 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 261 | static int __exit amiga_a3000_scsi_remove(struct platform_device *pdev) |
| 262 | { |
| 263 | struct Scsi_Host *instance = platform_get_drvdata(pdev); |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 264 | struct a3000_hostdata *hdata = shost_priv(instance); |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 265 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 266 | |
Geert Uytterhoeven | 2b21d5e | 2010-04-12 21:55:15 +0200 | [diff] [blame] | 267 | hdata->regs->CNTR = 0; |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 268 | scsi_remove_host(instance); |
| 269 | free_irq(IRQ_AMIGA_PORTS, instance); |
| 270 | scsi_host_put(instance); |
| 271 | release_mem_region(res->start, resource_size(res)); |
| 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | static struct platform_driver amiga_a3000_scsi_driver = { |
| 276 | .remove = __exit_p(amiga_a3000_scsi_remove), |
| 277 | .driver = { |
| 278 | .name = "amiga-a3000-scsi", |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 279 | }, |
| 280 | }; |
| 281 | |
Jingoo Han | a915b84 | 2013-05-02 15:30:31 +0900 | [diff] [blame] | 282 | module_platform_driver_probe(amiga_a3000_scsi_driver, amiga_a3000_scsi_probe); |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 283 | |
| 284 | MODULE_DESCRIPTION("Amiga 3000 built-in SCSI"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | MODULE_LICENSE("GPL"); |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 286 | MODULE_ALIAS("platform:amiga-a3000-scsi"); |