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/blkdev.h>
11 #include <linux/sched.h>
12 #include <linux/version.h>
13 #include <linux/config.h>
14 #include <linux/module.h>
16 #include <scsi/scsicam.h>
19 #include <asm/pgtable.h>
21 #include <asm/hardware.h>
22 #include <asm/delay.h>
25 #include "../parisc/gsc.h"
29 #include "ncr53c8xx.h"
31 MODULE_AUTHOR("Richard Hirst");
32 MODULE_DESCRIPTION("Bluefish/Zalon 720 SCSI Driver");
33 MODULE_LICENSE("GPL");
35 #define GSC_SCSI_ZALON_OFFSET 0x800
37 #define IO_MODULE_EIM (1*4)
38 #define IO_MODULE_DC_ADATA (2*4)
39 #define IO_MODULE_II_CDATA (3*4)
40 #define IO_MODULE_IO_COMMAND (12*4)
41 #define IO_MODULE_IO_STATUS (13*4)
43 #define IOSTATUS_RY 0x40
44 #define IOSTATUS_FE 0x80
45 #define IOIIDATA_SMINT5L 0x40000000
46 #define IOIIDATA_MINT5EN 0x20000000
47 #define IOIIDATA_PACKEN 0x10000000
48 #define IOIIDATA_PREFETCHEN 0x08000000
49 #define IOIIDATA_IOII 0x00000020
53 static ncr_chip zalon720_chip __initdata = {
54 .device_id = PSEUDO_720_ID,
60 .features = FE_WIDE | FE_DIFF | FE_EHP| FE_MUX | FE_EA,
67 * Is this function dead code? or is someone planning on using it in the
68 * future. The clock = (int) pdc_result[16] does not look correct to
69 * me ... I think it should be iodc_data[16]. Since this cause a compile
70 * error with the new encapsulated PDC, I'm not compiling in this function.
73 /* poke SCSI clock out of iodc data */
75 static u8 iodc_data[32] __attribute__ ((aligned (64)));
76 static unsigned long pdc_result[32] __attribute__ ((aligned (16))) ={0,0,0,0};
79 lasi_scsi_clock(void * hpa, int defaultclock)
83 status = pdc_iodc_read(&pdc_result, hpa, 0, &iodc_data, 32 );
84 if (status == PDC_RET_OK) {
85 clock = (int) pdc_result[16];
87 printk(KERN_WARNING "%s: pdc_iodc_read returned %d\n", __FUNCTION__, status);
91 printk(KERN_DEBUG "%s: SCSI clock %d\n", __FUNCTION__, clock);
96 static Scsi_Host_Template zalon7xx_template = {
97 .module = THIS_MODULE,
98 .proc_name = "zalon7xx",
102 zalon_probe(struct parisc_device *dev)
104 struct gsc_irq gsc_irq;
106 int irq, error = -ENODEV;
107 unsigned long zalon = dev->hpa;
108 unsigned long io_port = zalon + GSC_SCSI_ZALON_OFFSET;
110 struct Scsi_Host *host;
111 struct ncr_device device;
113 __raw_writel(CMD_RESET, zalon + IO_MODULE_IO_COMMAND);
114 while (!(__raw_readl(zalon + IO_MODULE_IO_STATUS) & IOSTATUS_RY))
116 __raw_writel(IOIIDATA_MINT5EN | IOIIDATA_PACKEN | IOIIDATA_PREFETCHEN,
117 zalon + IO_MODULE_II_CDATA);
119 /* XXX: Save the Zalon version for bug workarounds? */
120 zalon_vers = __raw_readl(dev->hpa + IO_MODULE_II_CDATA) & 0x07000000;
123 /* Setup the interrupts first.
124 ** Later on request_irq() will register the handler.
126 irq = gsc_alloc_irq(&gsc_irq);
128 printk("%s: Zalon vers field is 0x%x, IRQ %d\n", __FUNCTION__,
131 __raw_writel(gsc_irq.txn_addr | gsc_irq.txn_data, dev->hpa + IO_MODULE_EIM);
134 printk(KERN_WARNING "%s: Zalon 1.1 or earlier\n", __FUNCTION__);
136 memset(&device, 0, sizeof(struct ncr_device));
138 /* The following three are needed before any other access. */
139 writeb(0x20, io_port + 0x38); /* DCNTL_REG, EA */
140 writeb(0x04, io_port + 0x1b); /* CTEST0_REG, EHP */
141 writeb(0x80, io_port + 0x22); /* CTEST4_REG, MUX */
143 /* Initialise ncr_device structure with items required by ncr_attach. */
144 device.chip = zalon720_chip;
146 device.dev = &dev->dev;
147 device.slot.base = (u_long)io_port;
148 device.slot.base_c = (u_long)io_port;
149 device.slot.irq = irq;
150 device.differential = 2;
152 host = ncr_attach(&zalon7xx_template, unit, &device);
156 if (request_irq(irq, ncr53c8xx_intr, SA_SHIRQ, dev->dev.bus_id, host)) {
157 printk(KERN_ERR "%s: irq problem with %d, detaching\n ",
158 dev->dev.bus_id, irq);
164 dev_set_drvdata(&dev->dev, host);
166 error = scsi_add_host(host, &dev->dev);
170 scsi_scan_host(host);
176 ncr53c8xx_release(host);
180 static struct parisc_device_id zalon_tbl[] = {
181 { HPHW_A_DMA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00089 },
185 MODULE_DEVICE_TABLE(parisc, zalon_tbl);
187 static int __exit zalon_remove(struct parisc_device *dev)
189 struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
192 scsi_remove_host(host);
193 ncr53c8xx_release(host);
200 static struct parisc_driver zalon_driver = {
201 .name = "GSC SCSI (Zalon)",
202 .id_table = zalon_tbl,
203 .probe = zalon_probe,
204 .remove = __devexit_p(zalon_remove),
207 static int __init zalon7xx_init(void)
209 return register_parisc_driver(&zalon_driver);
212 static void __exit zalon7xx_exit(void)
214 unregister_parisc_driver(&zalon_driver);
217 module_init(zalon7xx_init);
218 module_exit(zalon7xx_exit);