📄 pas16.c
字号:
#define AUTOSENSE#define PSEUDO_DMA#define BOARD_REQUIRES_NO_UDELAY /* PAS16 needs no I/O recovery delays */#define UNSAFE /* Not unsafe for PAS16 -- use it *//* * This driver adapted from Drew Eckhardt's Trantor T128 driver * * Copyright 1993, Drew Eckhardt * Visionary Computing * (Unix and Linux consulting and custom programming) * drew@colorado.edu * +1 (303) 666-5836 * * ( Based on T128 - DISTRIBUTION RELEASE 3. ) * * Modified to work with the Pro Audio Spectrum/Studio 16 * by John Weidman. * * * For more information, please consult * * Media Vision * (510) 770-8600 * (800) 348-7116 * * and * * NCR 5380 Family * SCSI Protocol Controller * Databook * * NCR Microelectronics * 1635 Aeroplaza Drive * Colorado Springs, CO 80916 * 1+ (719) 578-3400 * 1+ (800) 334-5454 *//* * Options : * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically * for commands that return with a CHECK CONDITION status. * * LIMIT_TRANSFERSIZE - if defined, limit the pseudo-dma transfers to 512 * bytes at a time. Since interrupts are disabled by default during * these transfers, we might need this to give reasonable interrupt * service time if the transfer size gets too large. * * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance * increase compared to polled I/O. * * PARITY - enable parity checking. Not supported. * * UNSAFE - leave interrupts enabled during pseudo-DMA transfers. This * parameter comes from the NCR5380 code. It is NOT unsafe with * the PAS16 and you should use it. If you don't you will have * a problem with dropped characters during high speed * communications during SCSI transfers. If you really don't * want to use UNSAFE you can try defining LIMIT_TRANSFERSIZE or * twiddle with the transfer size in the high level code. * * The card is detected and initialized in one of several ways : * 1. Autoprobe (default) - There are many different models of * the Pro Audio Spectrum/Studio 16, and I only have one of * them, so this may require a little tweaking. An interrupt * is triggered to autoprobe for the interrupt line. Note: * with the newer model boards, the interrupt is set via * software after reset using the default_irq for the * current board number. * * 2. With command line overrides - pas16=port,irq may be * used on the LILO command line to override the defaults. * * 3. With the PAS16_OVERRIDE compile time define. This is * specified as an array of address, irq tuples. Ie, for * one board at the default 0x388 address, IRQ10, I could say * -DPAS16_OVERRIDE={{0x388, 10}} * NOTE: Untested. * * 4. When included as a module, with arguments passed on the command line: * pas16_irq=xx the interrupt * pas16_addr=xx the port * e.g. "modprobe pas16 pas16_addr=0x388 pas16_irq=5" * * Note that if the override methods are used, place holders must * be specified for other boards in the system. * * * Configuration notes : * The current driver does not support interrupt sharing with the * sound portion of the card. If you use the same irq for the * scsi port and sound you will have problems. Either use * a different irq for the scsi port or don't use interrupts * for the scsi port. * * If you have problems with your card not being recognized, use * the LILO command line override. Try to get it recognized without * interrupts. Ie, for a board at the default 0x388 base port, * boot: linux pas16=0x388,255 * * IRQ_NONE (255) should be specified for no interrupt, * IRQ_AUTO (254) to autoprobe for an IRQ line if overridden * on the command line. * * (IRQ_AUTO == 254, IRQ_NONE == 255 in NCR5380.h) */#include <linux/module.h>#include <asm/system.h>#include <linux/signal.h>#include <linux/proc_fs.h>#include <linux/sched.h>#include <asm/io.h>#include <linux/blk.h>#include "scsi.h"#include "hosts.h"#include "pas16.h"#define AUTOPROBE_IRQ#include "NCR5380.h"#include "constants.h"#include "sd.h"#include <linux/stat.h>#include <linux/init.h>static int pas_maxi = 0;static int pas_wmaxi = 0;static unsigned short pas16_addr = 0;static int pas16_irq = 0;static int scsi_irq_translate[] = { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 };/* The default_irqs array contains values used to set the irq into the * board via software (as must be done on newer model boards without * irq jumpers on the board). The first value in the array will be * assigned to logical board 0, the next to board 1, etc. */static int default_irqs[] __initdata = { PAS16_DEFAULT_BOARD_1_IRQ, PAS16_DEFAULT_BOARD_2_IRQ, PAS16_DEFAULT_BOARD_3_IRQ, PAS16_DEFAULT_BOARD_4_IRQ};static struct override { unsigned short io_port; int irq;} overrides#ifdef PAS16_OVERRIDE[] __initdata = PAS16_OVERRIDE;#else[4] __initdata = { {0, IRQ_AUTO}, {0, IRQ_AUTO}, {0, IRQ_AUTO}, {0, IRQ_AUTO}};#endif#define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))static struct base { unsigned short io_port; int noauto;} bases[] __initdata = { {PAS16_DEFAULT_BASE_1, 0}, {PAS16_DEFAULT_BASE_2, 0}, {PAS16_DEFAULT_BASE_3, 0}, {PAS16_DEFAULT_BASE_4, 0}};#define NO_BASES (sizeof (bases) / sizeof (struct base))unsigned short pas16_offset[8] = { 0x1c00, /* OUTPUT_DATA_REG */ 0x1c01, /* INITIATOR_COMMAND_REG */ 0x1c02, /* MODE_REG */ 0x1c03, /* TARGET_COMMAND_REG */ 0x3c00, /* STATUS_REG ro, SELECT_ENABLE_REG wo */ 0x3c01, /* BUS_AND_STATUS_REG ro, START_DMA_SEND_REG wo */ 0x3c02, /* INPUT_DATA_REGISTER ro, (N/A on PAS16 ?) * START_DMA_TARGET_RECEIVE_REG wo */ 0x3c03, /* RESET_PARITY_INTERRUPT_REG ro, * START_DMA_INITIATOR_RECEIVE_REG wo */};/*----------------------------------------------------------------*//** * enable_board - enable a pas16 board * @board_num: logical board id * @port: port to assign it * * Sets the address on new model PAS16 hardware */static void __init enable_board(int board_num, unsigned short port){ outb(0xbc + board_num, MASTER_ADDRESS_PTR); outb(port >> 2, MASTER_ADDRESS_PTR);}/** * init_board - set up board * @port: board address * @irq: interrupt line * @force_irq: if true allow scsi/audio on the same int * * Set the board up to handle the SCSI interface */static void __init init_board(unsigned short io_port, int irq, int force_irq){ unsigned int tmp; unsigned int pas_irq_code; /* Initialize the SCSI part of the board */ outb(0x30, io_port + P_TIMEOUT_COUNTER_REG); /* Timeout counter */ outb(0x01, io_port + P_TIMEOUT_STATUS_REG_OFFSET); /* Reset TC */ outb(0x01, io_port + WAIT_STATE); /* 1 Wait state */ NCR5380_read(RESET_PARITY_INTERRUPT_REG); /* * Set the SCSI interrupt pointer without mucking up the sound * interrupt pointer in the same byte. */ pas_irq_code = (irq < 16) ? scsi_irq_translate[irq] : 0; tmp = inb(io_port + IO_CONFIG_3); if (((tmp & 0x0f) == pas_irq_code) && pas_irq_code > 0 && !force_irq) { printk(KERN_WARNING "pas16: WARNING: Can't use same irq as sound " "driver -- interrupts disabled\n"); /* Set up the drive parameters, disable 5380 interrupts */ outb(0x4d, io_port + SYS_CONFIG_4); } else { tmp = (tmp & 0x0f) | (pas_irq_code << 4); outb(tmp, io_port + IO_CONFIG_3); /* Set up the drive parameters and enable 5380 interrupts */ outb(0x6d, io_port + SYS_CONFIG_4); }}/** * pas16_hw_detect - probe for hardware * @board_num: logical board ID to probe for * * Determine if a pas16 board is present */static int __init pas16_hw_detect(unsigned short board_num){ unsigned char board_rev, tmp; unsigned short io_port = bases[board_num].io_port; /* See if we can find a PAS16 board at the address associated * with this logical board number. */ /* First, attempt to take a newer model board out of reset and * give it a base address. This shouldn't affect older boards. */ enable_board(board_num, io_port);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -