Skip to content

Commit e95a1b6

Browse files
Russell KingRussell King
authored andcommitted
[ARM] rpc: acornscsi: update to new style ecard driver
Update acornscsi as per all the other ecard drivers to use MMIO accessors rather than the obsolete 'pc io' style inb/outb accessors. Use ecard_request_resources()/ecard_release_resources() for easier resource handling, rather than requesting 5 separate regions individually. Acked-by: James Bottomley <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent a796ef7 commit e95a1b6

File tree

2 files changed

+75
-94
lines changed

2 files changed

+75
-94
lines changed

drivers/scsi/arm/acornscsi.c

Lines changed: 73 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@
136136
#include <linux/init.h>
137137
#include <linux/bitops.h>
138138
#include <linux/stringify.h>
139+
#include <linux/io.h>
139140

140141
#include <asm/system.h>
141-
#include <asm/io.h>
142142
#include <asm/ecard.h>
143143

144144
#include "../scsi.h"
@@ -198,35 +198,40 @@ static void acornscsi_abortcmd(AS_Host *host, unsigned char tag);
198198
* Miscellaneous
199199
*/
200200

201+
/* Offsets from MEMC base */
202+
#define SBIC_REGIDX 0x2000
203+
#define SBIC_REGVAL 0x2004
204+
#define DMAC_OFFSET 0x3000
205+
206+
/* Offsets from FAST IOC base */
207+
#define INT_REG 0x2000
208+
#define PAGE_REG 0x3000
209+
201210
static inline void sbic_arm_write(AS_Host *host, unsigned int reg, unsigned int value)
202211
{
203-
__raw_writeb(reg, host->scsi.io_port);
204-
__raw_writeb(value, host->scsi.io_port + 4);
212+
writeb(reg, host->base + SBIC_REGIDX);
213+
writeb(value, host->base + SBIC_REGVAL);
205214
}
206215

207-
#define sbic_arm_writenext(host,val) \
208-
__raw_writeb((val), (host)->scsi.io_port + 4)
209-
210216
static inline int sbic_arm_read(AS_Host *host, unsigned int reg)
211217
{
212218
if(reg == SBIC_ASR)
213-
return __raw_readl(host->scsi.io_port) & 255;
214-
__raw_writeb(reg, host->scsi.io_port);
215-
return __raw_readl(host->scsi.io_port + 4) & 255;
219+
return readl(host->base + SBIC_REGIDX) & 255;
220+
writeb(reg, host->base + SBIC_REGIDX);
221+
return readl(host->base + SBIC_REGVAL) & 255;
216222
}
217223

218-
#define sbic_arm_readnext(host) \
219-
__raw_readb((host)->scsi.io_port + 4)
224+
#define sbic_arm_writenext(host, val) writeb((val), (host)->base + SBIC_REGVAL)
225+
#define sbic_arm_readnext(host) readb((host)->base + SBIC_REGVAL)
220226

221227
#ifdef USE_DMAC
222228
#define dmac_read(host,reg) \
223-
inb((host)->dma.io_port + (reg))
229+
readb((host)->base + DMAC_OFFSET + ((reg) << 2))
224230

225231
#define dmac_write(host,reg,value) \
226-
({ outb((value), (host)->dma.io_port + (reg)); })
232+
({ writeb((value), (host)->base + DMAC_OFFSET + ((reg) << 2)); })
227233

228-
#define dmac_clearintr(host) \
229-
({ outb(0, (host)->dma.io_intr_clear); })
234+
#define dmac_clearintr(host) writeb(0, (host)->fast + INT_REG)
230235

231236
static inline unsigned int dmac_address(AS_Host *host)
232237
{
@@ -323,20 +328,20 @@ void acornscsi_resetcard(AS_Host *host)
323328

324329
/* assert reset line */
325330
host->card.page_reg = 0x80;
326-
outb(host->card.page_reg, host->card.io_page);
331+
writeb(host->card.page_reg, host->fast + PAGE_REG);
327332

328333
/* wait 3 cs. SCSI standard says 25ms. */
329334
acornscsi_csdelay(3);
330335

331336
host->card.page_reg = 0;
332-
outb(host->card.page_reg, host->card.io_page);
337+
writeb(host->card.page_reg, host->fast + PAGE_REG);
333338

334339
/*
335340
* Should get a reset from the card
336341
*/
337342
timeout = 1000;
338343
do {
339-
if (inb(host->card.io_intr) & 8)
344+
if (readb(host->fast + INT_REG) & 8)
340345
break;
341346
udelay(1);
342347
} while (--timeout);
@@ -357,7 +362,7 @@ void acornscsi_resetcard(AS_Host *host)
357362
*/
358363
timeout = 1000;
359364
do {
360-
if (inb(host->card.io_intr) & 8)
365+
if (readb(host->fast + INT_REG) & 8)
361366
break;
362367
udelay(1);
363368
} while (--timeout);
@@ -377,7 +382,7 @@ void acornscsi_resetcard(AS_Host *host)
377382
sbic_arm_write(host, SBIC_SOURCEID, SOURCEID_ER | SOURCEID_DSP);
378383

379384
host->card.page_reg = 0x40;
380-
outb(host->card.page_reg, host->card.io_page);
385+
writeb(host->card.page_reg, host->fast + PAGE_REG);
381386

382387
/* setup dmac - uPC71071 */
383388
dmac_write(host, DMAC_INIT, 0);
@@ -910,13 +915,13 @@ static
910915
void acornscsi_data_read(AS_Host *host, char *ptr,
911916
unsigned int start_addr, unsigned int length)
912917
{
913-
extern void __acornscsi_in(int port, char *buf, int len);
918+
extern void __acornscsi_in(void __iomem *, char *buf, int len);
914919
unsigned int page, offset, len = length;
915920

916921
page = (start_addr >> 12);
917922
offset = start_addr & ((1 << 12) - 1);
918923

919-
outb((page & 0x3f) | host->card.page_reg, host->card.io_page);
924+
writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG);
920925

921926
while (len > 0) {
922927
unsigned int this_len;
@@ -926,7 +931,7 @@ void acornscsi_data_read(AS_Host *host, char *ptr,
926931
else
927932
this_len = len;
928933

929-
__acornscsi_in(host->card.io_ram + (offset << 1), ptr, this_len);
934+
__acornscsi_in(host->base + (offset << 1), ptr, this_len);
930935

931936
offset += this_len;
932937
ptr += this_len;
@@ -935,10 +940,10 @@ void acornscsi_data_read(AS_Host *host, char *ptr,
935940
if (offset == (1 << 12)) {
936941
offset = 0;
937942
page ++;
938-
outb((page & 0x3f) | host->card.page_reg, host->card.io_page);
943+
writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG);
939944
}
940945
}
941-
outb(host->card.page_reg, host->card.io_page);
946+
writeb(host->card.page_reg, host->fast + PAGE_REG);
942947
}
943948

944949
/*
@@ -955,13 +960,13 @@ static
955960
void acornscsi_data_write(AS_Host *host, char *ptr,
956961
unsigned int start_addr, unsigned int length)
957962
{
958-
extern void __acornscsi_out(int port, char *buf, int len);
963+
extern void __acornscsi_out(void __iomem *, char *buf, int len);
959964
unsigned int page, offset, len = length;
960965

961966
page = (start_addr >> 12);
962967
offset = start_addr & ((1 << 12) - 1);
963968

964-
outb((page & 0x3f) | host->card.page_reg, host->card.io_page);
969+
writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG);
965970

966971
while (len > 0) {
967972
unsigned int this_len;
@@ -971,7 +976,7 @@ void acornscsi_data_write(AS_Host *host, char *ptr,
971976
else
972977
this_len = len;
973978

974-
__acornscsi_out(host->card.io_ram + (offset << 1), ptr, this_len);
979+
__acornscsi_out(host->base + (offset << 1), ptr, this_len);
975980

976981
offset += this_len;
977982
ptr += this_len;
@@ -980,10 +985,10 @@ void acornscsi_data_write(AS_Host *host, char *ptr,
980985
if (offset == (1 << 12)) {
981986
offset = 0;
982987
page ++;
983-
outb((page & 0x3f) | host->card.page_reg, host->card.io_page);
988+
writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG);
984989
}
985990
}
986-
outb(host->card.page_reg, host->card.io_page);
991+
writeb(host->card.page_reg, host->fast + PAGE_REG);
987992
}
988993

989994
/* =========================================================================================
@@ -2468,11 +2473,11 @@ acornscsi_intr(int irq, void *dev_id)
24682473
do {
24692474
ret = INTR_IDLE;
24702475

2471-
iostatus = inb(host->card.io_intr);
2476+
iostatus = readb(host->fast + INT_REG);
24722477

24732478
if (iostatus & 2) {
24742479
acornscsi_dma_intr(host);
2475-
iostatus = inb(host->card.io_intr);
2480+
iostatus = readb(host->fast + INT_REG);
24762481
}
24772482

24782483
if (iostatus & 8)
@@ -2858,11 +2863,11 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start,
28582863
#endif
28592864
"\n\n", VER_MAJOR, VER_MINOR, VER_PATCH);
28602865

2861-
p += sprintf(p, "SBIC: WD33C93A Address: %08X IRQ : %d\n",
2862-
host->scsi.io_port, host->scsi.irq);
2866+
p += sprintf(p, "SBIC: WD33C93A Address: %p IRQ : %d\n",
2867+
host->base + SBIC_REGIDX, host->scsi.irq);
28632868
#ifdef USE_DMAC
2864-
p += sprintf(p, "DMAC: uPC71071 Address: %08X IRQ : %d\n\n",
2865-
host->dma.io_port, host->scsi.irq);
2869+
p += sprintf(p, "DMAC: uPC71071 Address: %p IRQ : %d\n\n",
2870+
host->base + DMAC_OFFSET, host->scsi.irq);
28662871
#endif
28672872

28682873
p += sprintf(p, "Statistics:\n"
@@ -2964,48 +2969,37 @@ acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
29642969
{
29652970
struct Scsi_Host *host;
29662971
AS_Host *ashost;
2967-
int ret = -ENOMEM;
2972+
int ret;
29682973

2969-
host = scsi_host_alloc(&acornscsi_template, sizeof(AS_Host));
2970-
if (!host)
2974+
ret = ecard_request_resources(ec);
2975+
if (ret)
29712976
goto out;
29722977

2978+
host = scsi_host_alloc(&acornscsi_template, sizeof(AS_Host));
2979+
if (!host) {
2980+
ret = -ENOMEM;
2981+
goto out_release;
2982+
}
2983+
29732984
ashost = (AS_Host *)host->hostdata;
29742985

2975-
host->io_port = ecard_address(ec, ECARD_MEMC, 0);
2976-
host->irq = ec->irq;
2986+
ashost->base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
2987+
ashost->fast = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
2988+
if (!ashost->base || !ashost->fast)
2989+
goto out_put;
29772990

2978-
ashost->host = host;
2979-
ashost->scsi.io_port = ioaddr(host->io_port + 0x800);
2980-
ashost->scsi.irq = host->irq;
2981-
ashost->card.io_intr = POD_SPACE(host->io_port) + 0x800;
2982-
ashost->card.io_page = POD_SPACE(host->io_port) + 0xc00;
2983-
ashost->card.io_ram = ioaddr(host->io_port);
2984-
ashost->dma.io_port = host->io_port + 0xc00;
2985-
ashost->dma.io_intr_clear = POD_SPACE(host->io_port) + 0x800;
2991+
host->irq = ec->irq;
2992+
ashost->host = host;
2993+
ashost->scsi.irq = host->irq;
29862994

2987-
ec->irqaddr = (char *)ioaddr(ashost->card.io_intr);
2995+
ec->irqaddr = ashost->fast + INT_REG;
29882996
ec->irqmask = 0x0a;
29892997

2990-
ret = -EBUSY;
2991-
if (!request_region(host->io_port + 0x800, 2, "acornscsi(sbic)"))
2992-
goto err_1;
2993-
if (!request_region(ashost->card.io_intr, 1, "acornscsi(intr)"))
2994-
goto err_2;
2995-
if (!request_region(ashost->card.io_page, 1, "acornscsi(page)"))
2996-
goto err_3;
2997-
#ifdef USE_DMAC
2998-
if (!request_region(ashost->dma.io_port, 256, "acornscsi(dmac)"))
2999-
goto err_4;
3000-
#endif
3001-
if (!request_region(host->io_port, 2048, "acornscsi(ram)"))
3002-
goto err_5;
3003-
30042998
ret = request_irq(host->irq, acornscsi_intr, IRQF_DISABLED, "acornscsi", ashost);
30052999
if (ret) {
30063000
printk(KERN_CRIT "scsi%d: IRQ%d not free: %d\n",
30073001
host->host_no, ashost->scsi.irq, ret);
3008-
goto err_6;
3002+
goto out_put;
30093003
}
30103004

30113005
memset(&ashost->stats, 0, sizeof (ashost->stats));
@@ -3017,27 +3011,22 @@ acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
30173011

30183012
ret = scsi_add_host(host, &ec->dev);
30193013
if (ret)
3020-
goto err_7;
3014+
goto out_irq;
30213015

30223016
scsi_scan_host(host);
30233017
goto out;
30243018

3025-
err_7:
3019+
out_irq:
30263020
free_irq(host->irq, ashost);
3027-
err_6:
3028-
release_region(host->io_port, 2048);
3029-
err_5:
3030-
#ifdef USE_DMAC
3031-
release_region(ashost->dma.io_port, 256);
3032-
#endif
3033-
err_4:
3034-
release_region(ashost->card.io_page, 1);
3035-
err_3:
3036-
release_region(ashost->card.io_intr, 1);
3037-
err_2:
3038-
release_region(host->io_port + 0x800, 2);
3039-
err_1:
3021+
msgqueue_free(&ashost->scsi.msgs);
3022+
queue_free(&ashost->queues.disconnected);
3023+
queue_free(&ashost->queues.issue);
3024+
out_put:
3025+
ecardm_iounmap(ec, ashost->fast);
3026+
ecardm_iounmap(ec, ashost->base);
30403027
scsi_host_put(host);
3028+
out_release:
3029+
ecard_release_resources(ec);
30413030
out:
30423031
return ret;
30433032
}
@@ -3053,20 +3042,17 @@ static void __devexit acornscsi_remove(struct expansion_card *ec)
30533042
/*
30543043
* Put card into RESET state
30553044
*/
3056-
outb(0x80, ashost->card.io_page);
3045+
writeb(0x80, ashost->fast + PAGE_REG);
30573046

30583047
free_irq(host->irq, ashost);
30593048

3060-
release_region(host->io_port + 0x800, 2);
3061-
release_region(ashost->card.io_intr, 1);
3062-
release_region(ashost->card.io_page, 1);
3063-
release_region(ashost->dma.io_port, 256);
3064-
release_region(host->io_port, 2048);
3065-
30663049
msgqueue_free(&ashost->scsi.msgs);
30673050
queue_free(&ashost->queues.disconnected);
30683051
queue_free(&ashost->queues.issue);
3052+
ecardm_iounmap(ec, ashost->fast);
3053+
ecardm_iounmap(ec, ashost->base);
30693054
scsi_host_put(host);
3055+
ecard_release_resources(ec);
30703056
}
30713057

30723058
static const struct ecard_id acornscsi_cids[] = {

drivers/scsi/arm/acornscsi.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@
179179

180180
/* miscellaneous internal variables */
181181

182-
#define POD_SPACE(x) ((x) + 0xd0000)
183182
#define MASK_ON (MASKREG_M3|MASKREG_M2|MASKREG_M1|MASKREG_M0)
184183
#define MASK_OFF (MASKREG_M3|MASKREG_M2|MASKREG_M1)
185184

@@ -279,10 +278,11 @@ typedef struct acornscsi_hostdata {
279278
struct Scsi_Host *host; /* host */
280279
struct scsi_cmnd *SCpnt; /* currently processing command */
281280
struct scsi_cmnd *origSCpnt; /* original connecting command */
281+
void __iomem *base; /* memc base address */
282+
void __iomem *fast; /* fast ioc base address */
282283

283284
/* driver information */
284285
struct {
285-
unsigned int io_port; /* base address of WD33C93 */
286286
unsigned int irq; /* interrupt */
287287
phase_t phase; /* current phase */
288288

@@ -329,8 +329,6 @@ typedef struct acornscsi_hostdata {
329329

330330
/* DMA info */
331331
struct {
332-
unsigned int io_port; /* base address of DMA controller */
333-
unsigned int io_intr_clear; /* address of DMA interrupt clear */
334332
unsigned int free_addr; /* next free address */
335333
unsigned int start_addr; /* start address of current transfer */
336334
dmadir_t direction; /* dma direction */
@@ -345,9 +343,6 @@ typedef struct acornscsi_hostdata {
345343

346344
/* card info */
347345
struct {
348-
unsigned int io_intr; /* base address of interrupt id reg */
349-
unsigned int io_page; /* base address of page reg */
350-
unsigned int io_ram; /* base address of RAM access */
351346
unsigned char page_reg; /* current setting of page reg */
352347
} card;
353348

0 commit comments

Comments
 (0)