summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/arm/ecoscsi.c
blob: 5265a9884338b90e0d5e8e551f7d0487e6b7c61f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#define AUTOSENSE
/* #define PSEUDO_DMA */

/*
 * EcoSCSI Generic NCR5380 driver
 *
 * Copyright 1995, Russell King
 *
 * ALPHA RELEASE 1.
 *
 * For more information, please consult
 *
 * NCR 5380 Family
 * SCSI Protocol Controller
 * Databook
 *
 * NCR Microelectronics
 * 1635 Aeroplaza Drive
 * Colorado Springs, CO 80916
 * 1+ (719) 578-3400
 * 1+ (800) 334-5454
 */

#include <linux/module.h>
#include <linux/signal.h>
#include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/blkdev.h>

#include <asm/io.h>
#include <asm/system.h>

#include "../scsi.h"
#include <scsi/scsi_host.h>

#define priv(host)			((struct NCR5380_hostdata *)(host)->hostdata)

#define NCR5380_local_declare()		void __iomem *_base
#define NCR5380_setup(host)		_base = priv(host)->base

#define NCR5380_read(reg)		({ writeb(reg | 8, _base); readb(_base + 4); })
#define NCR5380_write(reg, value)	({ writeb(reg | 8, _base); writeb(value, _base + 4); })

#define NCR5380_intr			ecoscsi_intr
#define NCR5380_queue_command		ecoscsi_queue_command
#define NCR5380_proc_info		ecoscsi_proc_info

#define NCR5380_implementation_fields	\
	void __iomem *base

#include "../NCR5380.h"

#define ECOSCSI_PUBLIC_RELEASE 1

/*
 * Function : ecoscsi_setup(char *str, int *ints)
 *
 * Purpose : LILO command line initialization of the overrides array,
 *
 * Inputs : str - unused, ints - array of integer parameters with ints[0]
 *	equal to the number of ints.
 *
 */

void ecoscsi_setup(char *str, int *ints)
{
}

const char * ecoscsi_info (struct Scsi_Host *spnt)
{
	return "";
}

#define BOARD_NORMAL	0
#define BOARD_NCR53C400	1

#include "../NCR5380.c"

static struct scsi_host_template ecoscsi_template =  {
	.module		= THIS_MODULE,
	.name		= "Serial Port EcoSCSI NCR5380",
	.proc_name	= "ecoscsi",
	.info		= ecoscsi_info,
	.queuecommand	= ecoscsi_queue_command,
	.eh_abort_handler	= NCR5380_abort,
	.eh_bus_reset_handler	= NCR5380_bus_reset,
	.can_queue	= 16,
	.this_id	= 7,
	.sg_tablesize	= SG_ALL,
	.cmd_per_lun	= 2,
	.use_clustering	= DISABLE_CLUSTERING
};

static struct Scsi_Host *host;

static int __init ecoscsi_init(void)
{
	void __iomem *_base;
	int ret;

	if (!request_mem_region(0x33a0000, 4096, "ecoscsi")) {
		ret = -EBUSY;
		goto out;
	}

	_base = ioremap(0x33a0000, 4096);
	if (!_base) {
		ret = -ENOMEM;
		goto out_release;
	}

	NCR5380_write(MODE_REG, 0x20);		/* Is it really SCSI? */
	if (NCR5380_read(MODE_REG) != 0x20)	/* Write to a reg.    */
		goto out_unmap;

	NCR5380_write(MODE_REG, 0x00);		/* it back.	      */
	if (NCR5380_read(MODE_REG) != 0x00)
		goto out_unmap;

	host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata));
	if (!host) {
		ret = -ENOMEM;
		goto out_unmap;
	}

	priv(host)->base = _base;
	host->irq = IRQ_NONE;

	NCR5380_init(host, 0);

	printk("scsi%d: at port 0x%08lx irqs disabled", host->host_no, host->io_port);
	printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
		host->can_queue, host->cmd_per_lun, ECOSCSI_PUBLIC_RELEASE);
	printk("\nscsi%d:", host->host_no);
	NCR5380_print_options(host);
	printk("\n");

	scsi_add_host(host, NULL); /* XXX handle failure */
	scsi_scan_host(host);
	return 0;

 out_unmap:
	iounmap(_base);
 out_release:
	release_mem_region(0x33a0000, 4096);
 out:
	return ret;
}

static void __exit ecoscsi_exit(void)
{
	scsi_remove_host(host);
	NCR5380_exit(host);
	scsi_host_put(host);
	release_mem_region(0x33a0000, 4096);
	return 0;
}

module_init(ecoscsi_init);
module_exit(ecoscsi_exit);

MODULE_AUTHOR("Russell King");
MODULE_DESCRIPTION("Econet-SCSI driver for Acorn machines");
MODULE_LICENSE("GPL");