Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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 <James.Bottomley@HansenPartnership.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Russell King and committed by
Russell King
e95a1b65 a796ef70

+75 -94
+73 -87
drivers/scsi/arm/acornscsi.c
··· 136 136 #include <linux/init.h> 137 137 #include <linux/bitops.h> 138 138 #include <linux/stringify.h> 139 + #include <linux/io.h> 139 140 140 141 #include <asm/system.h> 141 - #include <asm/io.h> 142 142 #include <asm/ecard.h> 143 143 144 144 #include "../scsi.h" ··· 198 198 * Miscellaneous 199 199 */ 200 200 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 + 201 210 static inline void sbic_arm_write(AS_Host *host, unsigned int reg, unsigned int value) 202 211 { 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); 205 214 } 206 - 207 - #define sbic_arm_writenext(host,val) \ 208 - __raw_writeb((val), (host)->scsi.io_port + 4) 209 215 210 216 static inline int sbic_arm_read(AS_Host *host, unsigned int reg) 211 217 { 212 218 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; 216 222 } 217 223 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) 220 226 221 227 #ifdef USE_DMAC 222 228 #define dmac_read(host,reg) \ 223 - inb((host)->dma.io_port + (reg)) 229 + readb((host)->base + DMAC_OFFSET + ((reg) << 2)) 224 230 225 231 #define dmac_write(host,reg,value) \ 226 - ({ outb((value), (host)->dma.io_port + (reg)); }) 232 + ({ writeb((value), (host)->base + DMAC_OFFSET + ((reg) << 2)); }) 227 233 228 - #define dmac_clearintr(host) \ 229 - ({ outb(0, (host)->dma.io_intr_clear); }) 234 + #define dmac_clearintr(host) writeb(0, (host)->fast + INT_REG) 230 235 231 236 static inline unsigned int dmac_address(AS_Host *host) 232 237 { ··· 328 323 329 324 /* assert reset line */ 330 325 host->card.page_reg = 0x80; 331 - outb(host->card.page_reg, host->card.io_page); 326 + writeb(host->card.page_reg, host->fast + PAGE_REG); 332 327 333 328 /* wait 3 cs. SCSI standard says 25ms. */ 334 329 acornscsi_csdelay(3); 335 330 336 331 host->card.page_reg = 0; 337 - outb(host->card.page_reg, host->card.io_page); 332 + writeb(host->card.page_reg, host->fast + PAGE_REG); 338 333 339 334 /* 340 335 * Should get a reset from the card 341 336 */ 342 337 timeout = 1000; 343 338 do { 344 - if (inb(host->card.io_intr) & 8) 339 + if (readb(host->fast + INT_REG) & 8) 345 340 break; 346 341 udelay(1); 347 342 } while (--timeout); ··· 362 357 */ 363 358 timeout = 1000; 364 359 do { 365 - if (inb(host->card.io_intr) & 8) 360 + if (readb(host->fast + INT_REG) & 8) 366 361 break; 367 362 udelay(1); 368 363 } while (--timeout); ··· 382 377 sbic_arm_write(host, SBIC_SOURCEID, SOURCEID_ER | SOURCEID_DSP); 383 378 384 379 host->card.page_reg = 0x40; 385 - outb(host->card.page_reg, host->card.io_page); 380 + writeb(host->card.page_reg, host->fast + PAGE_REG); 386 381 387 382 /* setup dmac - uPC71071 */ 388 383 dmac_write(host, DMAC_INIT, 0); ··· 915 910 void acornscsi_data_read(AS_Host *host, char *ptr, 916 911 unsigned int start_addr, unsigned int length) 917 912 { 918 - extern void __acornscsi_in(int port, char *buf, int len); 913 + extern void __acornscsi_in(void __iomem *, char *buf, int len); 919 914 unsigned int page, offset, len = length; 920 915 921 916 page = (start_addr >> 12); 922 917 offset = start_addr & ((1 << 12) - 1); 923 918 924 - outb((page & 0x3f) | host->card.page_reg, host->card.io_page); 919 + writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG); 925 920 926 921 while (len > 0) { 927 922 unsigned int this_len; ··· 931 926 else 932 927 this_len = len; 933 928 934 - __acornscsi_in(host->card.io_ram + (offset << 1), ptr, this_len); 929 + __acornscsi_in(host->base + (offset << 1), ptr, this_len); 935 930 936 931 offset += this_len; 937 932 ptr += this_len; ··· 940 935 if (offset == (1 << 12)) { 941 936 offset = 0; 942 937 page ++; 943 - outb((page & 0x3f) | host->card.page_reg, host->card.io_page); 938 + writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG); 944 939 } 945 940 } 946 - outb(host->card.page_reg, host->card.io_page); 941 + writeb(host->card.page_reg, host->fast + PAGE_REG); 947 942 } 948 943 949 944 /* ··· 960 955 void acornscsi_data_write(AS_Host *host, char *ptr, 961 956 unsigned int start_addr, unsigned int length) 962 957 { 963 - extern void __acornscsi_out(int port, char *buf, int len); 958 + extern void __acornscsi_out(void __iomem *, char *buf, int len); 964 959 unsigned int page, offset, len = length; 965 960 966 961 page = (start_addr >> 12); 967 962 offset = start_addr & ((1 << 12) - 1); 968 963 969 - outb((page & 0x3f) | host->card.page_reg, host->card.io_page); 964 + writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG); 970 965 971 966 while (len > 0) { 972 967 unsigned int this_len; ··· 976 971 else 977 972 this_len = len; 978 973 979 - __acornscsi_out(host->card.io_ram + (offset << 1), ptr, this_len); 974 + __acornscsi_out(host->base + (offset << 1), ptr, this_len); 980 975 981 976 offset += this_len; 982 977 ptr += this_len; ··· 985 980 if (offset == (1 << 12)) { 986 981 offset = 0; 987 982 page ++; 988 - outb((page & 0x3f) | host->card.page_reg, host->card.io_page); 983 + writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG); 989 984 } 990 985 } 991 - outb(host->card.page_reg, host->card.io_page); 986 + writeb(host->card.page_reg, host->fast + PAGE_REG); 992 987 } 993 988 994 989 /* ========================================================================================= ··· 2473 2468 do { 2474 2469 ret = INTR_IDLE; 2475 2470 2476 - iostatus = inb(host->card.io_intr); 2471 + iostatus = readb(host->fast + INT_REG); 2477 2472 2478 2473 if (iostatus & 2) { 2479 2474 acornscsi_dma_intr(host); 2480 - iostatus = inb(host->card.io_intr); 2475 + iostatus = readb(host->fast + INT_REG); 2481 2476 } 2482 2477 2483 2478 if (iostatus & 8) ··· 2863 2858 #endif 2864 2859 "\n\n", VER_MAJOR, VER_MINOR, VER_PATCH); 2865 2860 2866 - p += sprintf(p, "SBIC: WD33C93A Address: %08X IRQ : %d\n", 2867 - host->scsi.io_port, host->scsi.irq); 2861 + p += sprintf(p, "SBIC: WD33C93A Address: %p IRQ : %d\n", 2862 + host->base + SBIC_REGIDX, host->scsi.irq); 2868 2863 #ifdef USE_DMAC 2869 - p += sprintf(p, "DMAC: uPC71071 Address: %08X IRQ : %d\n\n", 2870 - host->dma.io_port, host->scsi.irq); 2864 + p += sprintf(p, "DMAC: uPC71071 Address: %p IRQ : %d\n\n", 2865 + host->base + DMAC_OFFSET, host->scsi.irq); 2871 2866 #endif 2872 2867 2873 2868 p += sprintf(p, "Statistics:\n" ··· 2969 2964 { 2970 2965 struct Scsi_Host *host; 2971 2966 AS_Host *ashost; 2972 - int ret = -ENOMEM; 2967 + int ret; 2968 + 2969 + ret = ecard_request_resources(ec); 2970 + if (ret) 2971 + goto out; 2973 2972 2974 2973 host = scsi_host_alloc(&acornscsi_template, sizeof(AS_Host)); 2975 - if (!host) 2976 - goto out; 2974 + if (!host) { 2975 + ret = -ENOMEM; 2976 + goto out_release; 2977 + } 2977 2978 2978 2979 ashost = (AS_Host *)host->hostdata; 2979 2980 2980 - host->io_port = ecard_address(ec, ECARD_MEMC, 0); 2981 + ashost->base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); 2982 + ashost->fast = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); 2983 + if (!ashost->base || !ashost->fast) 2984 + goto out_put; 2985 + 2981 2986 host->irq = ec->irq; 2987 + ashost->host = host; 2988 + ashost->scsi.irq = host->irq; 2982 2989 2983 - ashost->host = host; 2984 - ashost->scsi.io_port = ioaddr(host->io_port + 0x800); 2985 - ashost->scsi.irq = host->irq; 2986 - ashost->card.io_intr = POD_SPACE(host->io_port) + 0x800; 2987 - ashost->card.io_page = POD_SPACE(host->io_port) + 0xc00; 2988 - ashost->card.io_ram = ioaddr(host->io_port); 2989 - ashost->dma.io_port = host->io_port + 0xc00; 2990 - ashost->dma.io_intr_clear = POD_SPACE(host->io_port) + 0x800; 2991 - 2992 - ec->irqaddr = (char *)ioaddr(ashost->card.io_intr); 2990 + ec->irqaddr = ashost->fast + INT_REG; 2993 2991 ec->irqmask = 0x0a; 2994 - 2995 - ret = -EBUSY; 2996 - if (!request_region(host->io_port + 0x800, 2, "acornscsi(sbic)")) 2997 - goto err_1; 2998 - if (!request_region(ashost->card.io_intr, 1, "acornscsi(intr)")) 2999 - goto err_2; 3000 - if (!request_region(ashost->card.io_page, 1, "acornscsi(page)")) 3001 - goto err_3; 3002 - #ifdef USE_DMAC 3003 - if (!request_region(ashost->dma.io_port, 256, "acornscsi(dmac)")) 3004 - goto err_4; 3005 - #endif 3006 - if (!request_region(host->io_port, 2048, "acornscsi(ram)")) 3007 - goto err_5; 3008 2992 3009 2993 ret = request_irq(host->irq, acornscsi_intr, IRQF_DISABLED, "acornscsi", ashost); 3010 2994 if (ret) { 3011 2995 printk(KERN_CRIT "scsi%d: IRQ%d not free: %d\n", 3012 2996 host->host_no, ashost->scsi.irq, ret); 3013 - goto err_6; 2997 + goto out_put; 3014 2998 } 3015 2999 3016 3000 memset(&ashost->stats, 0, sizeof (ashost->stats)); ··· 3011 3017 3012 3018 ret = scsi_add_host(host, &ec->dev); 3013 3019 if (ret) 3014 - goto err_7; 3020 + goto out_irq; 3015 3021 3016 3022 scsi_scan_host(host); 3017 3023 goto out; 3018 3024 3019 - err_7: 3025 + out_irq: 3020 3026 free_irq(host->irq, ashost); 3021 - err_6: 3022 - release_region(host->io_port, 2048); 3023 - err_5: 3024 - #ifdef USE_DMAC 3025 - release_region(ashost->dma.io_port, 256); 3026 - #endif 3027 - err_4: 3028 - release_region(ashost->card.io_page, 1); 3029 - err_3: 3030 - release_region(ashost->card.io_intr, 1); 3031 - err_2: 3032 - release_region(host->io_port + 0x800, 2); 3033 - err_1: 3027 + msgqueue_free(&ashost->scsi.msgs); 3028 + queue_free(&ashost->queues.disconnected); 3029 + queue_free(&ashost->queues.issue); 3030 + out_put: 3031 + ecardm_iounmap(ec, ashost->fast); 3032 + ecardm_iounmap(ec, ashost->base); 3034 3033 scsi_host_put(host); 3034 + out_release: 3035 + ecard_release_resources(ec); 3035 3036 out: 3036 3037 return ret; 3037 3038 } ··· 3042 3053 /* 3043 3054 * Put card into RESET state 3044 3055 */ 3045 - outb(0x80, ashost->card.io_page); 3056 + writeb(0x80, ashost->fast + PAGE_REG); 3046 3057 3047 3058 free_irq(host->irq, ashost); 3048 - 3049 - release_region(host->io_port + 0x800, 2); 3050 - release_region(ashost->card.io_intr, 1); 3051 - release_region(ashost->card.io_page, 1); 3052 - release_region(ashost->dma.io_port, 256); 3053 - release_region(host->io_port, 2048); 3054 3059 3055 3060 msgqueue_free(&ashost->scsi.msgs); 3056 3061 queue_free(&ashost->queues.disconnected); 3057 3062 queue_free(&ashost->queues.issue); 3063 + ecardm_iounmap(ec, ashost->fast); 3064 + ecardm_iounmap(ec, ashost->base); 3058 3065 scsi_host_put(host); 3066 + ecard_release_resources(ec); 3059 3067 } 3060 3068 3061 3069 static const struct ecard_id acornscsi_cids[] = {
+2 -7
drivers/scsi/arm/acornscsi.h
··· 179 179 180 180 /* miscellaneous internal variables */ 181 181 182 - #define POD_SPACE(x) ((x) + 0xd0000) 183 182 #define MASK_ON (MASKREG_M3|MASKREG_M2|MASKREG_M1|MASKREG_M0) 184 183 #define MASK_OFF (MASKREG_M3|MASKREG_M2|MASKREG_M1) 185 184 ··· 278 279 struct Scsi_Host *host; /* host */ 279 280 struct scsi_cmnd *SCpnt; /* currently processing command */ 280 281 struct scsi_cmnd *origSCpnt; /* original connecting command */ 282 + void __iomem *base; /* memc base address */ 283 + void __iomem *fast; /* fast ioc base address */ 281 284 282 285 /* driver information */ 283 286 struct { 284 - unsigned int io_port; /* base address of WD33C93 */ 285 287 unsigned int irq; /* interrupt */ 286 288 phase_t phase; /* current phase */ 287 289 ··· 329 329 330 330 /* DMA info */ 331 331 struct { 332 - unsigned int io_port; /* base address of DMA controller */ 333 - unsigned int io_intr_clear; /* address of DMA interrupt clear */ 334 332 unsigned int free_addr; /* next free address */ 335 333 unsigned int start_addr; /* start address of current transfer */ 336 334 dmadir_t direction; /* dma direction */ ··· 343 345 344 346 /* card info */ 345 347 struct { 346 - unsigned int io_intr; /* base address of interrupt id reg */ 347 - unsigned int io_page; /* base address of page reg */ 348 - unsigned int io_ram; /* base address of RAM access */ 349 348 unsigned char page_reg; /* current setting of page reg */ 350 349 } card; 351 350