|
From: Richard B. <rb...@us...> - 2002-11-29 04:32:47
|
Update of /cvsroot/linux-vax/kernel-2.4/drivers/scsi
In directory sc8-pr-cvs1:/tmp/cvs-serv3052/drivers/scsi
Modified Files:
vax_esp.c vax_esp.h
Log Message:
Updates to scsi driver for 3100/85. Still very much work in progress
Index: vax_esp.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/scsi/vax_esp.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- vax_esp.c 12 Jun 2002 07:57:26 -0000 1.3
+++ vax_esp.c 29 Nov 2002 04:32:44 -0000 1.4
@@ -22,8 +22,10 @@
#include <asm/irq.h>
#include <asm/dma.h>
#include <asm/pgalloc.h>
+#include <asm/mm/pagelet.h>
#include <asm/vsa.h>
#include <asm/mv.h>
+#include <asm/ka55.h>
#include <asm/pgtable.h>
@@ -44,7 +46,6 @@
unsigned char scsi_cur_buff = 1; /* Leave space for command buffer */
__u32 esp_virt_buffer;
-int scsi_current_length = 0;
volatile unsigned char cmd_buffer[16];
@@ -55,10 +56,12 @@
volatile unsigned long *scsi_sdr0;
volatile unsigned long *scsi_sdr1;
-volatile unsigned long *scsi_dma_address;
-volatile unsigned long *scsi_dma_direction;
+unsigned char *scsi_dma_buffer; /* 64K area for DMA transfers */
+int scsi_current_length = 0;
+
+extern struct ka55_cpu_regs *ka55_cpu;
-struct vax_scsi_pte *esp_pte;
+unsigned long *esp_pte; /* device page table pointer */
unsigned long esp_pte_offset;
static void scsi_dma_int(int, void *, struct pt_regs *);
@@ -69,12 +72,14 @@
struct NCR_ESP *esp;
struct ConfigDev *esp_dev;
unsigned long scsi_base;
- struct vax_scsi_pte *pte;
- unsigned long l;
+ unsigned long *pte;
+ unsigned long l,m;
- scsi_base = 0x200c0080;
+ //scsi_base = 0x200c0080;
- /* On the 3100/85 the SCSI DMA registers are at 0x25c00000 (address & direction
+ /* On the 3100/85:
+ * The SCSI DMA registers are at 0x25c00000 (address & direction) which
+ * is part of the vsbus cpu registers and should already be mapped
* The SCSI DMA Map registers are at 0x27000000-27007FFF (8K)
* The SCSI controller registers are at0X26000080-BF
*/
@@ -130,32 +135,43 @@
/* ESP register base */
esp->eregs = (struct ESP_regs *) ioremap (scsi_base,sizeof(struct ESP_regs));
+ printk("esp->eregs located at 0x%x, virt: 0x%x\n",virt_to_phys(esp->eregs),esp->eregs);
/* Set the command buffer */
esp->esp_command = (volatile unsigned char *) cmd_buffer;
+ esp->esp_command_dvma = esp->esp_command; /* for now just set to the same location */
/* Now we have to create and initialise our DMA area.
* Initially we need to allocate the memory and clear the page table entries for the device
*/
- esp_pte = pte = (struct vax_scsi_pte *)ioremap (0x27000000,32767);
+ esp_pte = pte = (unsigned long *)ioremap (0x27000000,0x7fff);
+ //printk("setting ptes to 0\n");
for (l=0; l<8192; l++){
((unsigned long *)pte)[l] = 0; /* can't use bzero as access must be via longword */
}
esp_pte_offset = 0;
- /* now we need to create the dma area
- * As we use memory we will map the PTE for this memory into the PTE's for the device
+ /* now we need to create the dma area.
+ * The PTE's of the memory we allocate we will copy to the PTE map for the device
+ * Being a vax we have to actually work with pagelets (hardware page).
*/
- esp->esp_command_dvma = (__u32) kmalloc (VAX_SCSI_MAX_TRANSFER,GFP_ATOMIC);
-
-
+ printk("kmalloc of dma memory\n");
+ scsi_dma_buffer = (char *) kmalloc (VAX_SCSI_MAX_TRANSFER,GFP_ATOMIC);
+ printk("scsi_dma_buffer at 0x%x\n",scsi_dma_buffer);
+ printk("now getting pagelets\n");
+ for (l=0; l<=(VAX_SCSI_MAX_TRANSFER/PAGELET_SIZE);l++){
+ /* should return a copy of the pagelet for the segment of the allocated buffer */
+ m = &scsi_dma_buffer[(l*PAGELET_SIZE)];
+ // printk("address of dma buffer pagelet %d = 0x%x\n",l,m);
+ esp_pte[l] = (SPT_BASE + ((m >> PAGELET_SHIFT) << SIZEOF_PTR_LOG2));
+ // printk("esp_pte[%d] = 0x%x\n",l,esp_pte[l]);
+ }
- /* need to find address and direction scsi registers.
- * on the KA55 they're just offsets from the base register location.
- * -- ugly code -- should set this inside vsbus.c somewhere
+ /* need to set the address and direction scsi registers.
+ * on the KA55 they're located in the cpu register area.
*/
- scsi_dma_address = (unsigned long *)ioremap(VSA_KA55_BASE_REGS,1);
- scsi_dma_direction = (unsigned long *)((unsigned long)&scsi_dma_address + VAX_SCSI_DMA_DIRECTION); /* add offset */
+ ka55_cpu->scsi_adr = virt_to_phys(scsi_dma_buffer);
+ ka55_cpu->scsi_dir = VAX_SCSI_DMA_MAP_LOADED | VAX_SCSI_DMA_ACTIVE;
// esp->irq = SCSI_INT;
esp->irq = 255;
@@ -168,13 +184,13 @@
esp->scsi_id = 6;
- /* Check for differential SCSI-bus */
+ /* We don't have a differential SCSI-bus */
esp->diff = 0;
esp_initialize(esp);
if(nesps) {
- printk("ESP: Total of %d ESP hosts found, %d actually in use.\n", nesps, esps_in_use);
+ printk("VAX_ESP: Total of %d ESP hosts found, %d actually in use.\n", nesps, esps_in_use);
esps_running = esps_in_use;
return esps_in_use;
} else
@@ -187,31 +203,31 @@
extern volatile unsigned int *isr;
unsigned int dummy;
- printk ("dma_int called\n");
+ printk ("vax_esp: dma_int called\n");
}
static int dma_bytes_sent(struct NCR_ESP *esp, int fifo_count)
{
- printk ("dma_bytes_sent called\n");
+ printk ("vax_esp: dma_bytes_sent called\n");
return fifo_count;
}
static void dma_drain(struct NCR_ESP *esp)
{
unsigned long nw = *scsi_scr;
- printk ("dma_drain called\n");
+ printk ("vax_esp: dma_drain called\n");
}
static int dma_can_transfer(struct NCR_ESP *esp, Scsi_Cmnd * sp)
{
- printk ("dma_can_transfer called\n");
+ printk ("vax_esp: dma_can_transfer called\n");
return sp->SCp.this_residual;;
}
static void dma_dump_state(struct NCR_ESP *esp)
{
- printk ("dma_dump_state called\n");
+ printk ("vax_esp: dma_dump_state called\n");
}
static void dma_init_read(struct NCR_ESP *esp, __u32 vaddress, int length)
@@ -219,7 +235,7 @@
extern volatile unsigned int *isr;
unsigned int dummy;
- printk ("dma_init_read called\n");
+ printk ("vax_esp: dma_init_read called\n");
}
@@ -227,33 +243,50 @@
{
extern volatile unsigned int *isr;
unsigned int dummy;
- struct vax_scsi_pte *pte;
-
- printk ("dma_init_write called\n");
- printk (" vaddress = 0x%x, length = %d\n",vaddress,length);
- /* need to get the PTE of the buffer and transfer it to the device PTE map */
- printk(" virt_to_page(vaddress) = 0x%x\n",(unsigned long)virt_to_page(vaddress));
- pte = (struct vax_scsi_pte *)virt_to_page(vaddress);
- esp_pte[esp_pte_offset++] = pte[0];
- // scsi_dma_direction = scsi_dma_direction | VAX_SCSI_DMA_FROM_MEMORY;
-
+ unsigned long *pte;
+ unsigned int i;
+ unsigned char *vaddress_char;
+
+ printk ("vax_esp: dma_init_write called\n");
+ vaddress_char = vaddress;
+ printk ("dma data at 0x%x for %d bytes\n",vaddress,length);
+ printk("dma data [");
+ for (i=0;i<length;i++){
+ if (i> 0)
+ printk(",");
+ printk("%2.2x",vaddress_char[i]);
+ }
+ printk("]\n");
+ /* move data to dma buffer - but where ?*/
+ memcpy(scsi_dma_buffer,vaddress,length);
+ printk("SCSI dma data [");
+ for (i=0;i<length;i++){
+ if (i> 0)
+ printk(",");
+ printk("%2.2x",scsi_dma_buffer[i]);
+ }
+ printk("]\n");
+ printk("vax_esp: dma_init_write: setting scsi_adr to 0x%x\n",virt_to_phys(scsi_dma_buffer));
+ ka55_cpu->scsi_adr = virt_to_phys(scsi_dma_buffer); /* note: virtual address */
+ /* tell device that it should read from memory */
+ ka55_cpu->scsi_dir |= VAX_SCSI_DMA_FROM_MEMORY;
}
static void dma_ints_off(struct NCR_ESP *esp)
{
- printk ("dma_ints_off called\n");
+ printk ("vax_esp: dma_ints_off called\n");
// disable_irq(SCSI_DMA_INT);
}
static void dma_ints_on(struct NCR_ESP *esp)
{
- printk ("dma_ints_on called\n");
+ printk ("vax_esp: dma_ints_on called\n");
// enable_irq(SCSI_DMA_INT);
}
static int dma_irq_p(struct NCR_ESP *esp)
{
- printk ("dma_irq_p called\n");
+ printk ("vax_esp: dma_irq_p called\n");
return (esp->eregs->esp_status & ESP_STAT_INTR);
}
@@ -262,7 +295,7 @@
/*
* FIXME: what's this good for?
*/
- printk ("dma_ports_p called\n");
+ printk ("vax_esp: dma_ports_p called\n");
return 1;
}
@@ -272,7 +305,7 @@
* On the Sparc, DMA_ST_WRITE means "move data from device to memory"
* so when (write) is true, it actually means READ!
*/
- printk ("dma_setup called\n");
+ printk ("vax_esp: dma_setup called\n");
#if 0
if (write) {
dma_init_read(esp, addr, count);
@@ -282,26 +315,36 @@
#endif
}
-static void dma_mmu_get_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd * sp)
+static void dma_mmu_get_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd * scmd)
{
- printk("dma_mmu_get_scsi_one called\n");
- // sp->SCp.have_data_in = virt_to_phys(sp->SCp.buffer);
- //sp->SCp.ptr = (char *) ((unsigned long) sp->SCp.have_data_in);
+ printk("vax_esp: dma_mmu_get_scsi_one called\n");
+ /* need to allocate a buffer for the dma command we will send
+ * This will be appended to the end of whatever is currently in the buffer
+ * and increase our end marker
+ */
+ scmd->SCp.ptr = &scsi_dma_buffer[scsi_current_length];
+ scsi_current_length += scmd->SCp.this_residual;
}
static void dma_mmu_get_scsi_sgl(struct NCR_ESP *esp, Scsi_Cmnd * sp)
{
int sz = sp->SCp.buffers_residual;
struct mmu_sglist *sg = (struct mmu_sglist *) sp->SCp.buffer;
- printk ("dma_mmu_get_scsi_sgl called\n");
+ printk ("vax_esp: dma_mmu_get_scsi_sgl called\n");
}
static void dma_advance_sg(Scsi_Cmnd * sp)
{
- printk ("dma_adavnce_sg called\n");
+ printk ("vax_esp: dma_adavnce_sg called\n");
// sp->SCp.ptr = (char *) ((unsigned long) sp->SCp.buffer->dvma_addr);
}
static Scsi_Host_Template driver_template = SCSI_VAX_ESP;
#include "scsi_module.c"
+
+
+
+
+
+
Index: vax_esp.h
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/scsi/vax_esp.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- vax_esp.h 12 Jun 2002 07:57:26 -0000 1.3
+++ vax_esp.h 29 Nov 2002 04:32:44 -0000 1.4
@@ -57,7 +57,7 @@
#define SCSI_VAX_ESP { \
proc_name: "esp", \
proc_info: &esp_proc_info, \
- name: "NCR53C94", \
+ name: "VAX NCR53C94", \
detect: vax_esp_detect, \
info: esp_info, \
command: esp_command, \
@@ -67,9 +67,10 @@
can_queue: 7, \
this_id: 6, \
sg_tablesize: SG_ALL, \
- cmd_per_lun: 1, \
use_new_eh_code: 1, \
+ cmd_per_lun: 1, \
use_clustering: DISABLE_CLUSTERING, }
+
// controller id is 6 on the 3100/85
|