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>
27 * ** Define the BSD style u_int32 and u_int64 type.
28 * ** Are in fact u_int32_t and u_int64_t :-)
32 typedef u_long vm_offset_t;
37 /* hosts_* are kluges to pass info between the zalon7xx_detected()
38 ** and the register_parisc_driver() callbacks.
40 static Scsi_Host_Template *hosts_tptr;
41 static int hosts_used=0;
42 static int zalon_id = 0;
44 extern int zalon_attach(Scsi_Host_Template *tpnt,
45 unsigned long base_addr,
46 struct parisc_device *dev,
54 * Is this function dead code? or is someone planning on using it in the
55 * future. The clock = (int) pdc_result[16] does not look correct to
56 * me ... I think it should be iodc_data[16]. Since this cause a compile
57 * error with the new encapsulated PDC, I'm not compiling in this function.
60 /* poke SCSI clock out of iodc data */
62 static u8 iodc_data[32] __attribute__ ((aligned (64)));
63 static unsigned long pdc_result[32] __attribute__ ((aligned (16))) ={0,0,0,0};
66 lasi_scsi_clock(void * hpa, int defaultclock)
70 status = pdc_iodc_read(&pdc_result, hpa, 0, &iodc_data, 32 );
71 if (status == PDC_RET_OK) {
72 clock = (int) pdc_result[16];
74 printk(KERN_WARNING "%s: pdc_iodc_read returned %d\n", __FUNCTION__, status);
78 printk(KERN_DEBUG "%s: SCSI clock %d\n", __FUNCTION__, clock);
84 zalon_scsi_callback(struct parisc_device *dev)
86 struct gsc_irq gsc_irq;
89 unsigned long zalon = dev->hpa;
91 __raw_writel(CMD_RESET, zalon + IO_MODULE_IO_COMMAND);
92 while (!(__raw_readl(zalon + IO_MODULE_IO_STATUS) & IOSTATUS_RY))
94 __raw_writel(IOIIDATA_MINT5EN | IOIIDATA_PACKEN | IOIIDATA_PREFETCHEN,
95 zalon + IO_MODULE_II_CDATA);
97 /* XXX: Save the Zalon version for bug workarounds? */
98 zalon_vers = __raw_readl(dev->hpa + IO_MODULE_II_CDATA) & 0x07000000;
101 /* Setup the interrupts first.
102 ** Later on request_irq() will register the handler.
104 irq = gsc_alloc_irq(&gsc_irq);
106 printk("%s: Zalon vers field is 0x%x, IRQ %d\n", __FUNCTION__,
109 __raw_writel(gsc_irq.txn_addr | gsc_irq.txn_data, dev->hpa + IO_MODULE_EIM);
111 if ( zalon_vers == 0)
112 printk(KERN_WARNING "%s: Zalon 1.1 or earlier\n", __FUNCTION__);
115 ** zalon_attach: returns -1 on failure, 0 on success
117 hosts_used = zalon_attach(hosts_tptr, dev->hpa + GSC_SCSI_ZALON_OFFSET,
123 hosts_used = (hosts_used == 0);
124 return (hosts_used == 0);
127 static struct parisc_device_id zalon_tbl[] = {
128 { HPHW_A_DMA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00089 },
132 MODULE_DEVICE_TABLE(parisc, zalon_tbl);
134 static struct parisc_driver zalon_driver = {
135 name: "GSC SCSI (Zalon)",
137 probe: zalon_scsi_callback,
140 int zalon7xx_detect(Scsi_Host_Template *tpnt)
142 /* "pass" the parameter to the callback functions */
146 /* claim all zalon cards. */
147 register_parisc_driver(&zalon_driver);
149 /* Check if any callbacks actually found/claimed anything. */
150 return (hosts_used != 0);
154 extern int ncr53c8xx_release(struct Scsi_Host *host);
156 int zalon7xx_release(struct Scsi_Host *host)
158 ncr53c8xx_release(host);
159 unregister_parisc_driver(&zalon_driver);