2 * Zalon 53c7xx device driver.
3 * By Richard Hirst (rhirst@linuxcare.com)
6 #include <linux/init.h>
7 #include <linux/types.h>
8 #include <linux/stat.h>
10 #include <linux/blk.h>
11 #include <linux/sched.h>
12 #include <linux/version.h>
13 #include <linux/config.h>
14 #include <linux/module.h>
17 #include <asm/pgtable.h>
19 #include <asm/hardware.h>
20 #include <asm/delay.h>
23 #include "../parisc/gsc.h"
27 #include "ncr53c8xx.h"
31 MODULE_AUTHOR("Richard Hirst");
32 MODULE_DESCRIPTION("Bluefish/Zalon 720 SCSI Driver");
33 MODULE_LICENSE("GPL");
35 static ncr_chip zalon720_chip __initdata
= {
36 .device_id
= PSEUDO_720_ID
,
42 .features
= FE_WIDE
| FE_DIFF
| FE_EHP
| FE_MUX
| FE_EA
,
49 * Is this function dead code? or is someone planning on using it in the
50 * future. The clock = (int) pdc_result[16] does not look correct to
51 * me ... I think it should be iodc_data[16]. Since this cause a compile
52 * error with the new encapsulated PDC, I'm not compiling in this function.
55 /* poke SCSI clock out of iodc data */
57 static u8 iodc_data
[32] __attribute__ ((aligned (64)));
58 static unsigned long pdc_result
[32] __attribute__ ((aligned (16))) ={0,0,0,0};
61 lasi_scsi_clock(void * hpa
, int defaultclock
)
65 status
= pdc_iodc_read(&pdc_result
, hpa
, 0, &iodc_data
, 32 );
66 if (status
== PDC_RET_OK
) {
67 clock
= (int) pdc_result
[16];
69 printk(KERN_WARNING
"%s: pdc_iodc_read returned %d\n", __FUNCTION__
, status
);
73 printk(KERN_DEBUG
"%s: SCSI clock %d\n", __FUNCTION__
, clock
);
78 static Scsi_Host_Template zalon7xx_template
= {
79 .module
= THIS_MODULE
,
80 .proc_name
= "zalon7xx",
84 zalon_scsi_callback(struct parisc_device
*dev
)
86 struct gsc_irq gsc_irq
;
89 unsigned long zalon
= dev
->hpa
;
90 unsigned long io_port
= zalon
+ GSC_SCSI_ZALON_OFFSET
;
92 struct Scsi_Host
*host
;
95 __raw_writel(CMD_RESET
, zalon
+ IO_MODULE_IO_COMMAND
);
96 while (!(__raw_readl(zalon
+ IO_MODULE_IO_STATUS
) & IOSTATUS_RY
))
98 __raw_writel(IOIIDATA_MINT5EN
| IOIIDATA_PACKEN
| IOIIDATA_PREFETCHEN
,
99 zalon
+ IO_MODULE_II_CDATA
);
101 /* XXX: Save the Zalon version for bug workarounds? */
102 zalon_vers
= __raw_readl(dev
->hpa
+ IO_MODULE_II_CDATA
) & 0x07000000;
105 /* Setup the interrupts first.
106 ** Later on request_irq() will register the handler.
108 irq
= gsc_alloc_irq(&gsc_irq
);
110 printk("%s: Zalon vers field is 0x%x, IRQ %d\n", __FUNCTION__
,
113 __raw_writel(gsc_irq
.txn_addr
| gsc_irq
.txn_data
, dev
->hpa
+ IO_MODULE_EIM
);
115 if ( zalon_vers
== 0)
116 printk(KERN_WARNING
"%s: Zalon 1.1 or earlier\n", __FUNCTION__
);
118 memset(&device
, 0, sizeof(ncr_device
));
120 /* The following three are needed before any other access. */
121 writeb(0x20, io_port
+ 0x38); /* DCNTL_REG, EA */
122 writeb(0x04, io_port
+ 0x1b); /* CTEST0_REG, EHP */
123 writeb(0x80, io_port
+ 0x22); /* CTEST4_REG, MUX */
125 /* Initialise ncr_device structure with items required by ncr_attach. */
126 device
.chip
= zalon720_chip
;
128 device
.dev
= &dev
->dev
;
129 device
.slot
.base
= (u_long
)io_port
;
130 device
.slot
.base_c
= (u_long
)io_port
;
131 device
.slot
.irq
= irq
;
132 device
.differential
= 2;
134 host
= ncr_attach(&zalon7xx_template
, unit
, &device
);
138 strlcpy(dev
->dev
.name
, "zalon7xx", sizeof(dev
->dev
.name
));
140 if(request_irq(irq
, ncr53c8xx_intr
, SA_SHIRQ
, dev
->dev
.name
, host
)) {
141 printk(KERN_ERR
"%s: irq problem with %d, detaching\n ",
148 dev_set_drvdata(&dev
->dev
, host
);
150 scsi_add_host(host
, &dev
->dev
);
157 static struct parisc_device_id zalon_tbl
[] = {
158 { HPHW_A_DMA
, HVERSION_REV_ANY_ID
, HVERSION_ANY_ID
, 0x00089 },
162 MODULE_DEVICE_TABLE(parisc
, zalon_tbl
);
164 static int __exit
zalon_remove(struct parisc_device
*dev
)
166 struct Scsi_Host
*host
= dev_get_drvdata(&dev
->dev
);
169 scsi_remove_host(host
);
170 ncr53c8xx_release(host
);
177 static struct parisc_driver zalon_driver
= {
178 .name
= "GSC SCSI (Zalon)",
179 .id_table
= zalon_tbl
,
180 .probe
= zalon_scsi_callback
,
181 .remove
= __devexit_p(zalon_remove
),
184 static int __init
zalon7xx_init(void)
186 return register_parisc_driver(&zalon_driver
);
189 static void __exit
zalon7xx_exit(void)
191 unregister_parisc_driver(&zalon_driver
);
194 module_init(zalon7xx_init
);
195 module_exit(zalon7xx_exit
);