cregit-Linux how code gets into the kernel

Release 4.7 drivers/scsi/arm/arxescsi.c

Directory: drivers/scsi/arm
/*
 * linux/drivers/scsi/arm/arxescsi.c
 *
 * Copyright (C) 1997-2000 Russell King, Stefan Hanske
 *
 * This driver is based on experimentation.  Hence, it may have made
 * assumptions about the particular card that I have available, and
 * may not be reliable!
 *
 * Changelog:
 *  30-08-1997  RMK     0.0.0   Created, READONLY version as cumana_2.c
 *  22-01-1998  RMK     0.0.1   Updated to 2.1.80
 *  15-04-1998  RMK     0.0.1   Only do PIO if FAS216 will allow it.
 *  11-06-1998  SH      0.0.2   Changed to support ARXE 16-bit SCSI card
 *                              enabled writing
 *  01-01-2000  SH      0.1.0   Added *real* pseudo dma writing
 *                              (arxescsi_pseudo_dma_write)
 *  02-04-2000  RMK     0.1.1   Updated for new error handling code.
 *  22-10-2000  SH              Updated for new registering scheme.
 */
#include <linux/module.h>
#include <linux/blkdev.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/ioport.h>
#include <linux/proc_fs.h>
#include <linux/unistd.h>
#include <linux/stat.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/interrupt.h>

#include <asm/dma.h>
#include <asm/io.h>
#include <asm/ecard.h>

#include "../scsi.h"
#include <scsi/scsi_host.h>
#include "fas216.h"


struct arxescsi_info {
	
FAS216_Info		info;
	
struct expansion_card	*ec;
	
void __iomem		*base;
};


#define DMADATA_OFFSET	(0x200)


#define DMASTAT_OFFSET	(0x600)

#define DMASTAT_DRQ	(1 << 0)


#define CSTATUS_IRQ	(1 << 0)


#define VERSION "1.10 (23/01/2003 2.5.57)"

/*
 * Function: int arxescsi_dma_setup(host, SCpnt, direction, min_type)
 * Purpose : initialises DMA/PIO
 * Params  : host      - host
 *           SCpnt     - command
 *           direction - DMA on to/off of card
 *           min_type  - minimum DMA support that we must have for this transfer
 * Returns : 0 if we should not set CMD_WITHDMA for transfer info command
 */

static fasdmatype_t arxescsi_dma_setup(struct Scsi_Host *host, struct scsi_pointer *SCp, fasdmadir_t direction, fasdmatype_t min_type) { /* * We don't do real DMA */ return fasdma_pseudo; }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git2492.31%150.00%
christoph hellwigchristoph hellwig27.69%150.00%
Total26100.00%2100.00%


static void arxescsi_pseudo_dma_write(unsigned char *addr, void __iomem *base) { __asm__ __volatile__( " stmdb sp!, {r0-r12}\n" " mov r3, %0\n" " mov r1, %1\n" " add r2, r1, #512\n" " mov r4, #256\n" ".loop_1: ldmia r3!, {r6, r8, r10, r12}\n" " mov r5, r6, lsl #16\n" " mov r7, r8, lsl #16\n" ".loop_2: ldrb r0, [r1, #1536]\n" " tst r0, #1\n" " beq .loop_2\n" " stmia r2, {r5-r8}\n\t" " mov r9, r10, lsl #16\n" " mov r11, r12, lsl #16\n" ".loop_3: ldrb r0, [r1, #1536]\n" " tst r0, #1\n" " beq .loop_3\n" " stmia r2, {r9-r12}\n" " subs r4, r4, #16\n" " bne .loop_1\n" " ldmia sp!, {r0-r12}\n" : : "r" (addr), "r" (base)); }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git1368.42%133.33%
russell kingrussell king631.58%266.67%
Total19100.00%3100.00%

/* * Function: int arxescsi_dma_pseudo(host, SCpnt, direction, transfer) * Purpose : handles pseudo DMA * Params : host - host * SCpnt - command * direction - DMA on to/off of card * transfer - minimum number of bytes we expect to transfer */
static void arxescsi_dma_pseudo(struct Scsi_Host *host, struct scsi_pointer *SCp, fasdmadir_t direction, int transfer) { struct arxescsi_info *info = (struct arxescsi_info *)host->hostdata; unsigned int length, error = 0; void __iomem *base = info->info.scsi.io_base; unsigned char *addr; length = SCp->this_residual; addr = SCp->ptr; if (direction == DMA_OUT) { unsigned int word; while (length > 256) { if (readb(base + 0x80) & STAT_INT) { error = 1; break; } arxescsi_pseudo_dma_write(addr, base); addr += 256; length -= 256; } if (!error) while (length > 0) { if (readb(base + 0x80) & STAT_INT) break; if (!(readb(base + DMASTAT_OFFSET) & DMASTAT_DRQ)) continue; word = *addr | *(addr + 1) << 8; writew(word, base + DMADATA_OFFSET); if (length > 1) { addr += 2; length -= 2; } else { addr += 1; length -= 1; } } } else { if (transfer && (transfer & 255)) { while (length >= 256) { if (readb(base + 0x80) & STAT_INT) { error = 1; break; } if (!(readb(base + DMASTAT_OFFSET) & DMASTAT_DRQ)) continue; readsw(base + DMADATA_OFFSET, addr, 256 >> 1); addr += 256; length -= 256; } } if (!(error)) while (length > 0) { unsigned long word; if (readb(base + 0x80) & STAT_INT) break; if (!(readb(base + DMASTAT_OFFSET) & DMASTAT_DRQ)) continue; word = readw(base + DMADATA_OFFSET); *addr++ = word; if (--length > 0) { *addr++ = word >> 8; length --; } } } }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git30882.13%233.33%
russell kingrussell king6517.33%350.00%
christoph hellwigchristoph hellwig20.53%116.67%
Total375100.00%6100.00%

/* * Function: int arxescsi_dma_stop(host, SCpnt) * Purpose : stops DMA/PIO * Params : host - host * SCpnt - command */
static void arxescsi_dma_stop(struct Scsi_Host *host, struct scsi_pointer *SCp) { /* * no DMA to stop */ }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git1588.24%150.00%
christoph hellwigchristoph hellwig211.76%150.00%
Total17100.00%2100.00%

/* * Function: const char *arxescsi_info(struct Scsi_Host * host) * Purpose : returns a descriptive string about this interface, * Params : host - driver host structure to return info for. * Returns : pointer to a static buffer containing null terminated string. */
static const char *arxescsi_info(struct Scsi_Host *host) { struct arxescsi_info *info = (struct arxescsi_info *)host->hostdata; static char string[150]; sprintf(string, "%s (%s) in slot %d v%s", host->hostt->name, info->info.scsi.type, info->ec->slot_no, VERSION); return string; }

Contributors

PersonTokensPropCommitsCommitProp
russell kingrussell king5481.82%375.00%
pre-gitpre-git1218.18%125.00%
Total66100.00%4100.00%


static int arxescsi_show_info(struct seq_file *m, struct Scsi_Host *host) { struct arxescsi_info *info; info = (struct arxescsi_info *)host->hostdata; seq_printf(m, "ARXE 16-bit SCSI driver v%s\n", VERSION); fas216_print_host(&info->info, m); fas216_print_stats(&info->info, m); fas216_print_devices(&info->info, m); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
russell kingrussell king5574.32%350.00%
al viroal viro1216.22%116.67%
pre-gitpre-git68.11%116.67%
christoph hellwigchristoph hellwig11.35%116.67%
Total74100.00%6100.00%

static struct scsi_host_template arxescsi_template = { .show_info = arxescsi_show_info, .name = "ARXE SCSI card", .info = arxescsi_info, .queuecommand = fas216_noqueue_command, .eh_host_reset_handler = fas216_eh_host_reset, .eh_bus_reset_handler = fas216_eh_bus_reset, .eh_device_reset_handler = fas216_eh_device_reset, .eh_abort_handler = fas216_eh_abort, .can_queue = 0, .this_id = 7, .sg_tablesize = SG_ALL, .use_clustering = DISABLE_CLUSTERING, .proc_name = "arxescsi", };
static int arxescsi_probe(struct expansion_card *ec, const struct ecard_id *id) { struct Scsi_Host *host; struct arxescsi_info *info; void __iomem *base; int ret; ret = ecard_request_resources(ec); if (ret) goto out; base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); if (!base) { ret = -ENOMEM; goto out_region; } host = scsi_host_alloc(&arxescsi_template, sizeof(struct arxescsi_info)); if (!host) { ret = -ENOMEM; goto out_region; } info = (struct arxescsi_info *)host->hostdata; info->ec = ec; info->base = base; info->info.scsi.io_base = base + 0x2000; info->info.scsi.irq = 0; info->info.scsi.dma = NO_DMA; info->info.scsi.io_shift = 5; info->info.ifcfg.clockrate = 24; /* MHz */ info->info.ifcfg.select_timeout = 255; info->info.ifcfg.asyncperiod = 200; /* ns */ info->info.ifcfg.sync_max_depth = 0; info->info.ifcfg.cntl3 = CNTL3_FASTSCSI | CNTL3_FASTCLK; info->info.ifcfg.disconnect_ok = 0; info->info.ifcfg.wide_max_size = 0; info->info.ifcfg.capabilities = FASCAP_PSEUDODMA; info->info.dma.setup = arxescsi_dma_setup; info->info.dma.pseudo = arxescsi_dma_pseudo; info->info.dma.stop = arxescsi_dma_stop; ec->irqaddr = base; ec->irqmask = CSTATUS_IRQ; ret = fas216_init(host); if (ret) goto out_unregister; ret = fas216_add(host, &ec->dev); if (ret == 0) goto out; fas216_release(host); out_unregister: scsi_host_put(host); out_region: ecard_release_resources(ec); out: return ret; }

Contributors

PersonTokensPropCommitsCommitProp
russell kingrussell king18652.25%872.73%
pre-gitpre-git16345.79%19.09%
mike andersonmike anderson51.40%19.09%
dave jonesdave jones20.56%19.09%
Total356100.00%11100.00%


static void arxescsi_remove(struct expansion_card *ec) { struct Scsi_Host *host = ecard_get_drvdata(ec); ecard_set_drvdata(ec, NULL); fas216_remove(host); fas216_release(host); scsi_host_put(host); ecard_release_resources(ec); }

Contributors

PersonTokensPropCommitsCommitProp
russell kingrussell king2756.25%571.43%
pre-gitpre-git1939.58%114.29%
mike andersonmike anderson24.17%114.29%
Total48100.00%7100.00%

static const struct ecard_id arxescsi_cids[] = { { MANU_ARXE, PROD_ARXE_SCSI }, { 0xffff, 0xffff }, }; static struct ecard_driver arxescsi_driver = { .probe = arxescsi_probe, .remove = arxescsi_remove, .id_table = arxescsi_cids, .drv = { .name = "arxescsi", }, };
static int __init init_arxe_scsi_driver(void) { return ecard_register_driver(&arxescsi_driver); }

Contributors

PersonTokensPropCommitsCommitProp
linus torvaldslinus torvalds1487.50%150.00%
russell kingrussell king212.50%150.00%
Total16100.00%2100.00%


static void __exit exit_arxe_scsi_driver(void) { ecard_remove_driver(&arxescsi_driver); }

Contributors

PersonTokensPropCommitsCommitProp
linus torvaldslinus torvalds1386.67%150.00%
russell kingrussell king213.33%150.00%
Total15100.00%2100.00%

module_init(init_arxe_scsi_driver); module_exit(exit_arxe_scsi_driver); MODULE_AUTHOR("Stefan Hanske"); MODULE_DESCRIPTION("ARXESCSI driver for Acorn machines"); MODULE_LICENSE("GPL");

Overall Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git61749.12%310.00%
russell kingrussell king54843.63%1446.67%
linus torvaldslinus torvalds564.46%310.00%
al viroal viro141.11%13.33%
christoph hellwigchristoph hellwig90.72%310.00%
mike andersonmike anderson70.56%26.67%
dave jonesdave jones20.16%13.33%
arjan van de venarjan van de ven10.08%13.33%
adrian bunkadrian bunk10.08%13.33%
uwe zeisbergeruwe zeisberger10.08%13.33%
greg kroah-hartmangreg kroah-hartman0.00%00.00%
Total1256100.00%30100.00%
Directory: drivers/scsi/arm
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}