0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #include <linux/module.h>
0036 #include <linux/types.h>
0037 #include <linux/blkdev.h>
0038 #include <linux/interrupt.h>
0039 #include <linux/init.h>
0040 #include <linux/nvram.h>
0041 #include <linux/bitops.h>
0042 #include <linux/wait.h>
0043 #include <linux/platform_device.h>
0044
0045 #include <asm/setup.h>
0046 #include <asm/atarihw.h>
0047 #include <asm/atariints.h>
0048 #include <asm/atari_stdma.h>
0049 #include <asm/atari_stram.h>
0050 #include <asm/io.h>
0051
0052 #include <scsi/scsi_host.h>
0053
0054 #define DMA_MIN_SIZE 32
0055
0056
0057
0058 #define NCR5380_implementation_fields
0059
0060 static u8 (*atari_scsi_reg_read)(unsigned int);
0061 static void (*atari_scsi_reg_write)(unsigned int, u8);
0062
0063 #define NCR5380_read(reg) atari_scsi_reg_read(reg)
0064 #define NCR5380_write(reg, value) atari_scsi_reg_write(reg, value)
0065
0066 #define NCR5380_queue_command atari_scsi_queue_command
0067 #define NCR5380_abort atari_scsi_abort
0068 #define NCR5380_info atari_scsi_info
0069
0070 #define NCR5380_dma_xfer_len atari_scsi_dma_xfer_len
0071 #define NCR5380_dma_recv_setup atari_scsi_dma_recv_setup
0072 #define NCR5380_dma_send_setup atari_scsi_dma_send_setup
0073 #define NCR5380_dma_residual atari_scsi_dma_residual
0074
0075 #define NCR5380_acquire_dma_irq(instance) falcon_get_lock(instance)
0076 #define NCR5380_release_dma_irq(instance) falcon_release_lock()
0077
0078 #include "NCR5380.h"
0079
0080
0081 #define IS_A_TT() ATARIHW_PRESENT(TT_SCSI)
0082
0083 #define SCSI_DMA_WRITE_P(elt,val) \
0084 do { \
0085 unsigned long v = val; \
0086 tt_scsi_dma.elt##_lo = v & 0xff; \
0087 v >>= 8; \
0088 tt_scsi_dma.elt##_lmd = v & 0xff; \
0089 v >>= 8; \
0090 tt_scsi_dma.elt##_hmd = v & 0xff; \
0091 v >>= 8; \
0092 tt_scsi_dma.elt##_hi = v & 0xff; \
0093 } while(0)
0094
0095 #define SCSI_DMA_READ_P(elt) \
0096 (((((((unsigned long)tt_scsi_dma.elt##_hi << 8) | \
0097 (unsigned long)tt_scsi_dma.elt##_hmd) << 8) | \
0098 (unsigned long)tt_scsi_dma.elt##_lmd) << 8) | \
0099 (unsigned long)tt_scsi_dma.elt##_lo)
0100
0101
0102 static inline void SCSI_DMA_SETADR(unsigned long adr)
0103 {
0104 st_dma.dma_lo = (unsigned char)adr;
0105 MFPDELAY();
0106 adr >>= 8;
0107 st_dma.dma_md = (unsigned char)adr;
0108 MFPDELAY();
0109 adr >>= 8;
0110 st_dma.dma_hi = (unsigned char)adr;
0111 MFPDELAY();
0112 }
0113
0114 static inline unsigned long SCSI_DMA_GETADR(void)
0115 {
0116 unsigned long adr;
0117 adr = st_dma.dma_lo;
0118 MFPDELAY();
0119 adr |= (st_dma.dma_md & 0xff) << 8;
0120 MFPDELAY();
0121 adr |= (st_dma.dma_hi & 0xff) << 16;
0122 MFPDELAY();
0123 return adr;
0124 }
0125
0126 static void atari_scsi_fetch_restbytes(void);
0127
0128 static unsigned long atari_dma_residual, atari_dma_startaddr;
0129 static short atari_dma_active;
0130
0131 static char *atari_dma_buffer;
0132
0133 static unsigned long atari_dma_phys_buffer;
0134
0135 static char *atari_dma_orig_addr;
0136
0137
0138
0139
0140
0141
0142 #define STRAM_BUFFER_SIZE (4096)
0143
0144 static unsigned long atari_dma_stram_mask;
0145 #define STRAM_ADDR(a) (((a) & atari_dma_stram_mask) == 0)
0146
0147 static int setup_can_queue = -1;
0148 module_param(setup_can_queue, int, 0);
0149 static int setup_cmd_per_lun = -1;
0150 module_param(setup_cmd_per_lun, int, 0);
0151 static int setup_sg_tablesize = -1;
0152 module_param(setup_sg_tablesize, int, 0);
0153 static int setup_hostid = -1;
0154 module_param(setup_hostid, int, 0);
0155 static int setup_toshiba_delay = -1;
0156 module_param(setup_toshiba_delay, int, 0);
0157
0158
0159 static int scsi_dma_is_ignored_buserr(unsigned char dma_stat)
0160 {
0161 int i;
0162 unsigned long addr = SCSI_DMA_READ_P(dma_addr), end_addr;
0163
0164 if (dma_stat & 0x01) {
0165
0166
0167
0168
0169
0170
0171 for (i = 0; i < m68k_num_memory; ++i) {
0172 end_addr = m68k_memory[i].addr + m68k_memory[i].size;
0173 if (end_addr <= addr && addr <= end_addr + 4)
0174 return 1;
0175 }
0176 }
0177 return 0;
0178 }
0179
0180
0181 static irqreturn_t scsi_tt_intr(int irq, void *dev)
0182 {
0183 struct Scsi_Host *instance = dev;
0184 struct NCR5380_hostdata *hostdata = shost_priv(instance);
0185 int dma_stat;
0186
0187 dma_stat = tt_scsi_dma.dma_ctrl;
0188
0189 dsprintk(NDEBUG_INTR, instance, "NCR5380 interrupt, DMA status = %02x\n",
0190 dma_stat & 0xff);
0191
0192
0193
0194
0195 if (dma_stat & 0x80) {
0196 if (!scsi_dma_is_ignored_buserr(dma_stat)) {
0197 printk(KERN_ERR "SCSI DMA caused bus error near 0x%08lx\n",
0198 SCSI_DMA_READ_P(dma_addr));
0199 printk(KERN_CRIT "SCSI DMA bus error -- bad DMA programming!");
0200 }
0201 }
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212 if ((dma_stat & 0x02) && !(dma_stat & 0x40)) {
0213 atari_dma_residual = hostdata->dma_len -
0214 (SCSI_DMA_READ_P(dma_addr) - atari_dma_startaddr);
0215
0216 dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n",
0217 atari_dma_residual);
0218
0219 if ((signed int)atari_dma_residual < 0)
0220 atari_dma_residual = 0;
0221 if ((dma_stat & 1) == 0) {
0222
0223
0224
0225
0226 atari_scsi_fetch_restbytes();
0227 } else {
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246 if (atari_dma_residual & 0x1ff) {
0247 dprintk(NDEBUG_DMA, "SCSI DMA: DMA bug corrected, "
0248 "difference %ld bytes\n",
0249 512 - (atari_dma_residual & 0x1ff));
0250 atari_dma_residual = (atari_dma_residual + 511) & ~0x1ff;
0251 }
0252 }
0253 tt_scsi_dma.dma_ctrl = 0;
0254 }
0255
0256
0257 if (dma_stat & 0x40) {
0258 atari_dma_residual = 0;
0259 if ((dma_stat & 1) == 0)
0260 atari_scsi_fetch_restbytes();
0261 tt_scsi_dma.dma_ctrl = 0;
0262 }
0263
0264 NCR5380_intr(irq, dev);
0265
0266 return IRQ_HANDLED;
0267 }
0268
0269
0270 static irqreturn_t scsi_falcon_intr(int irq, void *dev)
0271 {
0272 struct Scsi_Host *instance = dev;
0273 struct NCR5380_hostdata *hostdata = shost_priv(instance);
0274 int dma_stat;
0275
0276
0277
0278
0279 st_dma.dma_mode_status = 0x90;
0280 dma_stat = st_dma.dma_mode_status;
0281
0282
0283
0284
0285 if (!(dma_stat & 0x01)) {
0286
0287 printk(KERN_CRIT "SCSI DMA error near 0x%08lx!\n", SCSI_DMA_GETADR());
0288 }
0289
0290
0291
0292
0293
0294
0295 if (atari_dma_active && (dma_stat & 0x02)) {
0296 unsigned long transferred;
0297
0298 transferred = SCSI_DMA_GETADR() - atari_dma_startaddr;
0299
0300
0301
0302
0303
0304 if (transferred & 15)
0305 printk(KERN_ERR "SCSI DMA error: %ld bytes lost in "
0306 "ST-DMA fifo\n", transferred & 15);
0307
0308 atari_dma_residual = hostdata->dma_len - transferred;
0309 dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n",
0310 atari_dma_residual);
0311 } else
0312 atari_dma_residual = 0;
0313 atari_dma_active = 0;
0314
0315 if (atari_dma_orig_addr) {
0316
0317
0318
0319 memcpy(atari_dma_orig_addr, phys_to_virt(atari_dma_startaddr),
0320 hostdata->dma_len - atari_dma_residual);
0321 atari_dma_orig_addr = NULL;
0322 }
0323
0324 NCR5380_intr(irq, dev);
0325
0326 return IRQ_HANDLED;
0327 }
0328
0329
0330 static void atari_scsi_fetch_restbytes(void)
0331 {
0332 int nr;
0333 char *src, *dst;
0334 unsigned long phys_dst;
0335
0336
0337 phys_dst = SCSI_DMA_READ_P(dma_addr);
0338 nr = phys_dst & 3;
0339 if (nr) {
0340
0341
0342 phys_dst ^= nr;
0343 dprintk(NDEBUG_DMA, "SCSI DMA: there are %d rest bytes for phys addr 0x%08lx",
0344 nr, phys_dst);
0345
0346 dst = phys_to_virt(phys_dst);
0347 dprintk(NDEBUG_DMA, " = virt addr %p\n", dst);
0348 for (src = (char *)&tt_scsi_dma.dma_restdata; nr != 0; --nr)
0349 *dst++ = *src++;
0350 }
0351 }
0352
0353
0354
0355
0356
0357
0358 static void falcon_release_lock(void)
0359 {
0360 if (IS_A_TT())
0361 return;
0362
0363 if (stdma_is_locked_by(scsi_falcon_intr))
0364 stdma_release();
0365 }
0366
0367
0368
0369
0370
0371
0372
0373
0374 static int falcon_get_lock(struct Scsi_Host *instance)
0375 {
0376 if (IS_A_TT())
0377 return 1;
0378
0379 if (stdma_is_locked_by(scsi_falcon_intr))
0380 return 1;
0381
0382
0383 return stdma_try_lock(scsi_falcon_intr, instance);
0384 }
0385
0386 #ifndef MODULE
0387 static int __init atari_scsi_setup(char *str)
0388 {
0389
0390
0391
0392
0393
0394 int ints[8];
0395
0396 get_options(str, ARRAY_SIZE(ints), ints);
0397
0398 if (ints[0] < 1) {
0399 printk("atari_scsi_setup: no arguments!\n");
0400 return 0;
0401 }
0402 if (ints[0] >= 1)
0403 setup_can_queue = ints[1];
0404 if (ints[0] >= 2)
0405 setup_cmd_per_lun = ints[2];
0406 if (ints[0] >= 3)
0407 setup_sg_tablesize = ints[3];
0408 if (ints[0] >= 4)
0409 setup_hostid = ints[4];
0410
0411
0412 if (ints[0] >= 7)
0413 setup_toshiba_delay = ints[7];
0414
0415 return 1;
0416 }
0417
0418 __setup("atascsi=", atari_scsi_setup);
0419 #endif
0420
0421 static unsigned long atari_scsi_dma_setup(struct NCR5380_hostdata *hostdata,
0422 void *data, unsigned long count,
0423 int dir)
0424 {
0425 unsigned long addr = virt_to_phys(data);
0426
0427 dprintk(NDEBUG_DMA, "scsi%d: setting up dma, data = %p, phys = %lx, count = %ld, dir = %d\n",
0428 hostdata->host->host_no, data, addr, count, dir);
0429
0430 if (!IS_A_TT() && !STRAM_ADDR(addr)) {
0431
0432
0433
0434
0435
0436 if (dir)
0437 memcpy(atari_dma_buffer, data, count);
0438 else
0439 atari_dma_orig_addr = data;
0440 addr = atari_dma_phys_buffer;
0441 }
0442
0443 atari_dma_startaddr = addr;
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454 dma_cache_maintenance(addr, count, dir);
0455
0456 if (IS_A_TT()) {
0457 tt_scsi_dma.dma_ctrl = dir;
0458 SCSI_DMA_WRITE_P(dma_addr, addr);
0459 SCSI_DMA_WRITE_P(dma_cnt, count);
0460 tt_scsi_dma.dma_ctrl = dir | 2;
0461 } else {
0462
0463
0464 SCSI_DMA_SETADR(addr);
0465
0466
0467 dir <<= 8;
0468 st_dma.dma_mode_status = 0x90 | dir;
0469 st_dma.dma_mode_status = 0x90 | (dir ^ 0x100);
0470 st_dma.dma_mode_status = 0x90 | dir;
0471 udelay(40);
0472
0473
0474 st_dma.fdc_acces_seccount = (count + (dir ? 511 : 0)) >> 9;
0475 udelay(40);
0476 st_dma.dma_mode_status = 0x10 | dir;
0477 udelay(40);
0478
0479 atari_dma_active = 1;
0480 }
0481
0482 return count;
0483 }
0484
0485 static inline int atari_scsi_dma_recv_setup(struct NCR5380_hostdata *hostdata,
0486 unsigned char *data, int count)
0487 {
0488 return atari_scsi_dma_setup(hostdata, data, count, 0);
0489 }
0490
0491 static inline int atari_scsi_dma_send_setup(struct NCR5380_hostdata *hostdata,
0492 unsigned char *data, int count)
0493 {
0494 return atari_scsi_dma_setup(hostdata, data, count, 1);
0495 }
0496
0497 static int atari_scsi_dma_residual(struct NCR5380_hostdata *hostdata)
0498 {
0499 return atari_dma_residual;
0500 }
0501
0502
0503 #define CMD_SURELY_BLOCK_MODE 0
0504 #define CMD_SURELY_BYTE_MODE 1
0505 #define CMD_MODE_UNKNOWN 2
0506
0507 static int falcon_classify_cmd(struct scsi_cmnd *cmd)
0508 {
0509 unsigned char opcode = cmd->cmnd[0];
0510
0511 if (opcode == READ_DEFECT_DATA || opcode == READ_LONG ||
0512 opcode == READ_BUFFER)
0513 return CMD_SURELY_BYTE_MODE;
0514 else if (opcode == READ_6 || opcode == READ_10 ||
0515 opcode == 0xa8 || opcode == READ_REVERSE ||
0516 opcode == RECOVER_BUFFERED_DATA) {
0517
0518
0519
0520 if (cmd->device->type == TYPE_TAPE && !(cmd->cmnd[1] & 1))
0521 return CMD_SURELY_BYTE_MODE;
0522 else
0523 return CMD_SURELY_BLOCK_MODE;
0524 } else
0525 return CMD_MODE_UNKNOWN;
0526 }
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538 static int atari_scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata,
0539 struct scsi_cmnd *cmd)
0540 {
0541 int wanted_len = NCR5380_to_ncmd(cmd)->this_residual;
0542 int possible_len, limit;
0543
0544 if (wanted_len < DMA_MIN_SIZE)
0545 return 0;
0546
0547 if (IS_A_TT())
0548
0549 return wanted_len;
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579 if (cmd->sc_data_direction == DMA_TO_DEVICE) {
0580
0581
0582
0583
0584 possible_len = wanted_len;
0585 } else {
0586
0587
0588
0589
0590 if (wanted_len & 0x1ff)
0591 possible_len = 0;
0592 else {
0593
0594
0595 switch (falcon_classify_cmd(cmd)) {
0596 case CMD_SURELY_BLOCK_MODE:
0597 possible_len = wanted_len;
0598 break;
0599 case CMD_SURELY_BYTE_MODE:
0600 possible_len = 0;
0601 break;
0602 case CMD_MODE_UNKNOWN:
0603 default:
0604
0605
0606 possible_len = (wanted_len < 1024) ? 0 : wanted_len;
0607 break;
0608 }
0609 }
0610 }
0611
0612
0613 limit = (atari_dma_buffer && !STRAM_ADDR(virt_to_phys(NCR5380_to_ncmd(cmd)->ptr))) ?
0614 STRAM_BUFFER_SIZE : 255*512;
0615 if (possible_len > limit)
0616 possible_len = limit;
0617
0618 if (possible_len != wanted_len)
0619 dprintk(NDEBUG_DMA, "DMA transfer now %d bytes instead of %d\n",
0620 possible_len, wanted_len);
0621
0622 return possible_len;
0623 }
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633 static u8 atari_scsi_tt_reg_read(unsigned int reg)
0634 {
0635 return tt_scsi_regp[reg * 2];
0636 }
0637
0638 static void atari_scsi_tt_reg_write(unsigned int reg, u8 value)
0639 {
0640 tt_scsi_regp[reg * 2] = value;
0641 }
0642
0643 static u8 atari_scsi_falcon_reg_read(unsigned int reg)
0644 {
0645 unsigned long flags;
0646 u8 result;
0647
0648 reg += 0x88;
0649 local_irq_save(flags);
0650 dma_wd.dma_mode_status = (u_short)reg;
0651 result = (u8)dma_wd.fdc_acces_seccount;
0652 local_irq_restore(flags);
0653 return result;
0654 }
0655
0656 static void atari_scsi_falcon_reg_write(unsigned int reg, u8 value)
0657 {
0658 unsigned long flags;
0659
0660 reg += 0x88;
0661 local_irq_save(flags);
0662 dma_wd.dma_mode_status = (u_short)reg;
0663 dma_wd.fdc_acces_seccount = (u_short)value;
0664 local_irq_restore(flags);
0665 }
0666
0667
0668 #include "NCR5380.c"
0669
0670 static int atari_scsi_host_reset(struct scsi_cmnd *cmd)
0671 {
0672 int rv;
0673 unsigned long flags;
0674
0675 local_irq_save(flags);
0676
0677
0678 if (IS_A_TT()) {
0679 tt_scsi_dma.dma_ctrl = 0;
0680 } else {
0681 if (stdma_is_locked_by(scsi_falcon_intr))
0682 st_dma.dma_mode_status = 0x90;
0683 atari_dma_active = 0;
0684 atari_dma_orig_addr = NULL;
0685 }
0686
0687 rv = NCR5380_host_reset(cmd);
0688
0689
0690
0691
0692
0693
0694
0695 local_irq_restore(flags);
0696
0697 return rv;
0698 }
0699
0700 #define DRV_MODULE_NAME "atari_scsi"
0701 #define PFX DRV_MODULE_NAME ": "
0702
0703 static struct scsi_host_template atari_scsi_template = {
0704 .module = THIS_MODULE,
0705 .proc_name = DRV_MODULE_NAME,
0706 .name = "Atari native SCSI",
0707 .info = atari_scsi_info,
0708 .queuecommand = atari_scsi_queue_command,
0709 .eh_abort_handler = atari_scsi_abort,
0710 .eh_host_reset_handler = atari_scsi_host_reset,
0711 .this_id = 7,
0712 .cmd_per_lun = 2,
0713 .dma_boundary = PAGE_SIZE - 1,
0714 .cmd_size = sizeof(struct NCR5380_cmd),
0715 };
0716
0717 static int __init atari_scsi_probe(struct platform_device *pdev)
0718 {
0719 struct Scsi_Host *instance;
0720 int error;
0721 struct resource *irq;
0722 int host_flags = 0;
0723
0724 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
0725 if (!irq)
0726 return -ENODEV;
0727
0728 if (ATARIHW_PRESENT(TT_SCSI)) {
0729 atari_scsi_reg_read = atari_scsi_tt_reg_read;
0730 atari_scsi_reg_write = atari_scsi_tt_reg_write;
0731 } else {
0732 atari_scsi_reg_read = atari_scsi_falcon_reg_read;
0733 atari_scsi_reg_write = atari_scsi_falcon_reg_write;
0734 }
0735
0736 if (ATARIHW_PRESENT(TT_SCSI)) {
0737 atari_scsi_template.can_queue = 16;
0738 atari_scsi_template.sg_tablesize = SG_ALL;
0739 } else {
0740 atari_scsi_template.can_queue = 1;
0741 atari_scsi_template.sg_tablesize = 1;
0742 }
0743
0744 if (setup_can_queue > 0)
0745 atari_scsi_template.can_queue = setup_can_queue;
0746
0747 if (setup_cmd_per_lun > 0)
0748 atari_scsi_template.cmd_per_lun = setup_cmd_per_lun;
0749
0750
0751 if (ATARIHW_PRESENT(TT_SCSI) && setup_sg_tablesize > 0)
0752 atari_scsi_template.sg_tablesize = setup_sg_tablesize;
0753
0754 if (setup_hostid >= 0) {
0755 atari_scsi_template.this_id = setup_hostid & 7;
0756 } else if (IS_REACHABLE(CONFIG_NVRAM)) {
0757
0758 if (ATARIHW_PRESENT(TT_CLK)) {
0759 unsigned char b;
0760 loff_t offset = 16;
0761 ssize_t count = nvram_read(&b, 1, &offset);
0762
0763
0764
0765
0766 if ((count == 1) && (b & 0x80))
0767 atari_scsi_template.this_id = b & 7;
0768 }
0769 }
0770
0771
0772
0773
0774
0775
0776 if (ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) &&
0777 m68k_realnum_memory > 1) {
0778 atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
0779 if (!atari_dma_buffer) {
0780 pr_err(PFX "can't allocate ST-RAM double buffer\n");
0781 return -ENOMEM;
0782 }
0783 atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer);
0784 atari_dma_orig_addr = NULL;
0785 }
0786
0787 instance = scsi_host_alloc(&atari_scsi_template,
0788 sizeof(struct NCR5380_hostdata));
0789 if (!instance) {
0790 error = -ENOMEM;
0791 goto fail_alloc;
0792 }
0793
0794 instance->irq = irq->start;
0795
0796 host_flags |= IS_A_TT() ? 0 : FLAG_LATE_DMA_SETUP;
0797 host_flags |= setup_toshiba_delay > 0 ? FLAG_TOSHIBA_DELAY : 0;
0798
0799 error = NCR5380_init(instance, host_flags);
0800 if (error)
0801 goto fail_init;
0802
0803 if (IS_A_TT()) {
0804 error = request_irq(instance->irq, scsi_tt_intr, 0,
0805 "NCR5380", instance);
0806 if (error) {
0807 pr_err(PFX "request irq %d failed, aborting\n",
0808 instance->irq);
0809 goto fail_irq;
0810 }
0811 tt_mfp.active_edge |= 0x80;
0812
0813 tt_scsi_dma.dma_ctrl = 0;
0814 atari_dma_residual = 0;
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828 if (MACH_IS_MEDUSA) {
0829 struct NCR5380_hostdata *hostdata =
0830 shost_priv(instance);
0831
0832 hostdata->read_overruns = 4;
0833 }
0834 } else {
0835
0836
0837
0838 atari_dma_residual = 0;
0839 atari_dma_active = 0;
0840 atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000
0841 : 0xff000000);
0842 }
0843
0844 NCR5380_maybe_reset_bus(instance);
0845
0846 error = scsi_add_host(instance, NULL);
0847 if (error)
0848 goto fail_host;
0849
0850 platform_set_drvdata(pdev, instance);
0851
0852 scsi_scan_host(instance);
0853 return 0;
0854
0855 fail_host:
0856 if (IS_A_TT())
0857 free_irq(instance->irq, instance);
0858 fail_irq:
0859 NCR5380_exit(instance);
0860 fail_init:
0861 scsi_host_put(instance);
0862 fail_alloc:
0863 if (atari_dma_buffer)
0864 atari_stram_free(atari_dma_buffer);
0865 return error;
0866 }
0867
0868 static int __exit atari_scsi_remove(struct platform_device *pdev)
0869 {
0870 struct Scsi_Host *instance = platform_get_drvdata(pdev);
0871
0872 scsi_remove_host(instance);
0873 if (IS_A_TT())
0874 free_irq(instance->irq, instance);
0875 NCR5380_exit(instance);
0876 scsi_host_put(instance);
0877 if (atari_dma_buffer)
0878 atari_stram_free(atari_dma_buffer);
0879 return 0;
0880 }
0881
0882 static struct platform_driver atari_scsi_driver = {
0883 .remove = __exit_p(atari_scsi_remove),
0884 .driver = {
0885 .name = DRV_MODULE_NAME,
0886 },
0887 };
0888
0889 module_platform_driver_probe(atari_scsi_driver, atari_scsi_probe);
0890
0891 MODULE_ALIAS("platform:" DRV_MODULE_NAME);
0892 MODULE_LICENSE("GPL");