diff options
Diffstat (limited to 'drivers/scsi/arm/oak.c')
-rw-r--r-- | drivers/scsi/arm/oak.c | 74 |
1 files changed, 44 insertions, 30 deletions
diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c index c21b8392c928..849cdf89f7bb 100644 --- a/drivers/scsi/arm/oak.c +++ b/drivers/scsi/arm/oak.c | |||
@@ -23,15 +23,18 @@ | |||
23 | 23 | ||
24 | #define OAKSCSI_PUBLIC_RELEASE 1 | 24 | #define OAKSCSI_PUBLIC_RELEASE 1 |
25 | 25 | ||
26 | #define NCR5380_read(reg) oakscsi_read(_instance, reg) | 26 | #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) |
27 | #define NCR5380_write(reg, value) oakscsi_write(_instance, reg, value) | 27 | #define NCR5380_local_declare() void __iomem *_base |
28 | #define NCR5380_setup(host) _base = priv(host)->base | ||
29 | |||
30 | #define NCR5380_read(reg) readb(_base + ((reg) << 2)) | ||
31 | #define NCR5380_write(reg, value) writeb(value, _base + ((reg) << 2)) | ||
28 | #define NCR5380_intr oakscsi_intr | 32 | #define NCR5380_intr oakscsi_intr |
29 | #define NCR5380_queue_command oakscsi_queue_command | 33 | #define NCR5380_queue_command oakscsi_queue_command |
30 | #define NCR5380_proc_info oakscsi_proc_info | 34 | #define NCR5380_proc_info oakscsi_proc_info |
31 | 35 | ||
32 | #define NCR5380_implementation_fields int port, ctrl | 36 | #define NCR5380_implementation_fields \ |
33 | #define NCR5380_local_declare() struct Scsi_Host *_instance | 37 | void __iomem *base |
34 | #define NCR5380_setup(instance) _instance = instance | ||
35 | 38 | ||
36 | #define BOARD_NORMAL 0 | 39 | #define BOARD_NORMAL 0 |
37 | #define BOARD_NCR53C400 1 | 40 | #define BOARD_NCR53C400 1 |
@@ -39,60 +42,62 @@ | |||
39 | #include "../NCR5380.h" | 42 | #include "../NCR5380.h" |
40 | 43 | ||
41 | #undef START_DMA_INITIATOR_RECEIVE_REG | 44 | #undef START_DMA_INITIATOR_RECEIVE_REG |
42 | #define START_DMA_INITIATOR_RECEIVE_REG (7 + 128) | 45 | #define START_DMA_INITIATOR_RECEIVE_REG (128 + 7) |
43 | 46 | ||
44 | const char * oakscsi_info (struct Scsi_Host *spnt) | 47 | const char * oakscsi_info (struct Scsi_Host *spnt) |
45 | { | 48 | { |
46 | return ""; | 49 | return ""; |
47 | } | 50 | } |
48 | 51 | ||
49 | #define STAT(p) inw(p + 144) | 52 | #define STAT ((128 + 16) << 2) |
50 | extern void inswb(int from, void *to, int len); | 53 | #define DATA ((128 + 8) << 2) |
51 | 54 | ||
52 | static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, | 55 | static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, |
53 | int len) | 56 | int len) |
54 | { | 57 | { |
55 | int iobase = instance->io_port; | 58 | void __iomem *base = priv(instance)->base; |
59 | |||
56 | printk("writing %p len %d\n",addr, len); | 60 | printk("writing %p len %d\n",addr, len); |
57 | if(!len) return -1; | 61 | if(!len) return -1; |
58 | 62 | ||
59 | while(1) | 63 | while(1) |
60 | { | 64 | { |
61 | int status; | 65 | int status; |
62 | while(((status = STAT(iobase)) & 0x100)==0); | 66 | while (((status = readw(base + STAT)) & 0x100)==0); |
63 | } | 67 | } |
64 | } | 68 | } |
65 | 69 | ||
66 | static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, | 70 | static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, |
67 | int len) | 71 | int len) |
68 | { | 72 | { |
69 | int iobase = instance->io_port; | 73 | void __iomem *base = priv(instance)->base; |
70 | printk("reading %p len %d\n", addr, len); | 74 | printk("reading %p len %d\n", addr, len); |
71 | while(len > 0) | 75 | while(len > 0) |
72 | { | 76 | { |
73 | int status, timeout; | 77 | unsigned int status, timeout; |
74 | unsigned long b; | 78 | unsigned long b; |
75 | 79 | ||
76 | timeout = 0x01FFFFFF; | 80 | timeout = 0x01FFFFFF; |
77 | 81 | ||
78 | while(((status = STAT(iobase)) & 0x100)==0) | 82 | while (((status = readw(base + STAT)) & 0x100)==0) |
79 | { | 83 | { |
80 | timeout--; | 84 | timeout--; |
81 | if(status & 0x200 || !timeout) | 85 | if(status & 0x200 || !timeout) |
82 | { | 86 | { |
83 | printk("status = %08X\n",status); | 87 | printk("status = %08X\n", status); |
84 | return 1; | 88 | return 1; |
85 | } | 89 | } |
86 | } | 90 | } |
91 | |||
87 | if(len >= 128) | 92 | if(len >= 128) |
88 | { | 93 | { |
89 | inswb(iobase + 136, addr, 128); | 94 | readsw(base + DATA, addr, 128); |
90 | addr += 128; | 95 | addr += 128; |
91 | len -= 128; | 96 | len -= 128; |
92 | } | 97 | } |
93 | else | 98 | else |
94 | { | 99 | { |
95 | b = (unsigned long) inw(iobase + 136); | 100 | b = (unsigned long) readw(base + DATA); |
96 | *addr ++ = b; | 101 | *addr ++ = b; |
97 | len -= 1; | 102 | len -= 1; |
98 | if(len) | 103 | if(len) |
@@ -103,10 +108,8 @@ printk("reading %p len %d\n", addr, len); | |||
103 | return 0; | 108 | return 0; |
104 | } | 109 | } |
105 | 110 | ||
106 | #define oakscsi_read(instance,reg) (inb((instance)->io_port + (reg))) | ||
107 | #define oakscsi_write(instance,reg,val) (outb((val), (instance)->io_port + (reg))) | ||
108 | |||
109 | #undef STAT | 111 | #undef STAT |
112 | #undef DATA | ||
110 | 113 | ||
111 | #include "../NCR5380.c" | 114 | #include "../NCR5380.c" |
112 | 115 | ||
@@ -132,18 +135,26 @@ oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
132 | struct Scsi_Host *host; | 135 | struct Scsi_Host *host; |
133 | int ret = -ENOMEM; | 136 | int ret = -ENOMEM; |
134 | 137 | ||
135 | host = scsi_host_alloc(&oakscsi_template, sizeof(struct NCR5380_hostdata)); | 138 | ret = ecard_request_resources(ec); |
136 | if (!host) | 139 | if (ret) |
137 | goto out; | 140 | goto out; |
138 | 141 | ||
139 | host->io_port = ecard_address(ec, ECARD_MEMC, 0); | 142 | host = scsi_host_alloc(&oakscsi_template, sizeof(struct NCR5380_hostdata)); |
143 | if (!host) { | ||
144 | ret = -ENOMEM; | ||
145 | goto release; | ||
146 | } | ||
147 | |||
148 | priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), | ||
149 | ecard_resource_len(ec, ECARD_RES_MEMC)); | ||
150 | if (!priv(host)->base) { | ||
151 | ret = -ENOMEM; | ||
152 | goto unreg; | ||
153 | } | ||
154 | |||
140 | host->irq = IRQ_NONE; | 155 | host->irq = IRQ_NONE; |
141 | host->n_io_port = 255; | 156 | host->n_io_port = 255; |
142 | 157 | ||
143 | ret = -EBUSY; | ||
144 | if (!request_region (host->io_port, host->n_io_port, "Oak SCSI")) | ||
145 | goto unreg; | ||
146 | |||
147 | NCR5380_init(host, 0); | 158 | NCR5380_init(host, 0); |
148 | 159 | ||
149 | printk("scsi%d: at port 0x%08lx irqs disabled", | 160 | printk("scsi%d: at port 0x%08lx irqs disabled", |
@@ -156,15 +167,17 @@ oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
156 | 167 | ||
157 | ret = scsi_add_host(host, &ec->dev); | 168 | ret = scsi_add_host(host, &ec->dev); |
158 | if (ret) | 169 | if (ret) |
159 | goto out_release; | 170 | goto out_unmap; |
160 | 171 | ||
161 | scsi_scan_host(host); | 172 | scsi_scan_host(host); |
162 | goto out; | 173 | goto out; |
163 | 174 | ||
164 | out_release: | 175 | out_unmap: |
165 | release_region(host->io_port, host->n_io_port); | 176 | iounmap(priv(host)->base); |
166 | unreg: | 177 | unreg: |
167 | scsi_host_put(host); | 178 | scsi_host_put(host); |
179 | release: | ||
180 | ecard_release_resources(ec); | ||
168 | out: | 181 | out: |
169 | return ret; | 182 | return ret; |
170 | } | 183 | } |
@@ -177,8 +190,9 @@ static void __devexit oakscsi_remove(struct expansion_card *ec) | |||
177 | scsi_remove_host(host); | 190 | scsi_remove_host(host); |
178 | 191 | ||
179 | NCR5380_exit(host); | 192 | NCR5380_exit(host); |
180 | release_region(host->io_port, host->n_io_port); | 193 | iounmap(priv(host)->base); |
181 | scsi_host_put(host); | 194 | scsi_host_put(host); |
195 | ecard_release_resources(ec); | ||
182 | } | 196 | } |
183 | 197 | ||
184 | static const struct ecard_id oakscsi_cids[] = { | 198 | static const struct ecard_id oakscsi_cids[] = { |