diff options
author | <jejb@mulgrave.(none)> | 2005-04-03 05:57:48 -0400 |
---|---|---|
committer | James Bottomley <jejb@titanic> | 2005-04-16 21:09:43 -0400 |
commit | 56fece20086ebe32bce2c0d74ceadd516b56baae (patch) | |
tree | 3ce88fad34483bfc393feb2ee5f3a7f4b8a17f0b /drivers/scsi/53c700.h | |
parent | e183b06bf0be6c525867476df186d20f8f1efe54 (diff) |
[PATCH] finally fix 53c700 to use the generic iomem infrastructure
This driver has had it's own different infrastructure for doing this for
ages, but it's time it used the common one.
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/53c700.h')
-rw-r--r-- | drivers/scsi/53c700.h | 192 |
1 files changed, 20 insertions, 172 deletions
diff --git a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h index df4aa30ae0aa..e86012cf6ab7 100644 --- a/drivers/scsi/53c700.h +++ b/drivers/scsi/53c700.h | |||
@@ -14,10 +14,6 @@ | |||
14 | #include <scsi/scsi_device.h> | 14 | #include <scsi/scsi_device.h> |
15 | 15 | ||
16 | 16 | ||
17 | #if defined(CONFIG_53C700_MEM_MAPPED) && defined(CONFIG_53C700_IO_MAPPED) | ||
18 | #define CONFIG_53C700_BOTH_MAPPED | ||
19 | #endif | ||
20 | |||
21 | /* Turn on for general debugging---too verbose for normal use */ | 17 | /* Turn on for general debugging---too verbose for normal use */ |
22 | #undef NCR_700_DEBUG | 18 | #undef NCR_700_DEBUG |
23 | /* Debug the tag queues, checking hash queue allocation and deallocation | 19 | /* Debug the tag queues, checking hash queue allocation and deallocation |
@@ -49,13 +45,6 @@ | |||
49 | /* magic byte identifying an internally generated REQUEST_SENSE command */ | 45 | /* magic byte identifying an internally generated REQUEST_SENSE command */ |
50 | #define NCR_700_INTERNAL_SENSE_MAGIC 0x42 | 46 | #define NCR_700_INTERNAL_SENSE_MAGIC 0x42 |
51 | 47 | ||
52 | /* WARNING: Leave this in for now: the dependency preprocessor doesn't | ||
53 | * pick up file specific flags, so must define here if they are not | ||
54 | * set */ | ||
55 | #if !defined(CONFIG_53C700_IO_MAPPED) && !defined(CONFIG_53C700_MEM_MAPPED) | ||
56 | #error "Config.in must define either CONFIG_53C700_IO_MAPPED or CONFIG_53C700_MEM_MAPPED to use this scsi core." | ||
57 | #endif | ||
58 | |||
59 | struct NCR_700_Host_Parameters; | 48 | struct NCR_700_Host_Parameters; |
60 | 49 | ||
61 | /* These are the externally used routines */ | 50 | /* These are the externally used routines */ |
@@ -184,7 +173,7 @@ struct NCR_700_command_slot { | |||
184 | struct NCR_700_Host_Parameters { | 173 | struct NCR_700_Host_Parameters { |
185 | /* These must be filled in by the calling driver */ | 174 | /* These must be filled in by the calling driver */ |
186 | int clock; /* board clock speed in MHz */ | 175 | int clock; /* board clock speed in MHz */ |
187 | unsigned long base; /* the base for the port (copied to host) */ | 176 | void __iomem *base; /* the base for the port (copied to host) */ |
188 | struct device *dev; | 177 | struct device *dev; |
189 | __u32 dmode_extra; /* adjustable bus settings */ | 178 | __u32 dmode_extra; /* adjustable bus settings */ |
190 | __u32 differential:1; /* if we are differential */ | 179 | __u32 differential:1; /* if we are differential */ |
@@ -199,9 +188,6 @@ struct NCR_700_Host_Parameters { | |||
199 | /* NOTHING BELOW HERE NEEDS ALTERING */ | 188 | /* NOTHING BELOW HERE NEEDS ALTERING */ |
200 | __u32 fast:1; /* if we can alter the SCSI bus clock | 189 | __u32 fast:1; /* if we can alter the SCSI bus clock |
201 | speed (so can negiotiate sync) */ | 190 | speed (so can negiotiate sync) */ |
202 | #ifdef CONFIG_53C700_BOTH_MAPPED | ||
203 | __u32 mem_mapped; /* set if memory mapped */ | ||
204 | #endif | ||
205 | int sync_clock; /* The speed of the SYNC core */ | 191 | int sync_clock; /* The speed of the SYNC core */ |
206 | 192 | ||
207 | __u32 *script; /* pointer to script location */ | 193 | __u32 *script; /* pointer to script location */ |
@@ -246,12 +232,18 @@ struct NCR_700_Host_Parameters { | |||
246 | #ifdef CONFIG_53C700_LE_ON_BE | 232 | #ifdef CONFIG_53C700_LE_ON_BE |
247 | #define bE (hostdata->force_le_on_be ? 0 : 3) | 233 | #define bE (hostdata->force_le_on_be ? 0 : 3) |
248 | #define bSWAP (hostdata->force_le_on_be) | 234 | #define bSWAP (hostdata->force_le_on_be) |
235 | /* This is terrible, but there's no raw version of ioread32. That means | ||
236 | * that on a be board we swap twice (once in ioread32 and once again to | ||
237 | * get the value correct) */ | ||
238 | #define bS_to_io(x) ((hostdata->force_le_on_be) ? (x) : cpu_to_le32(x)) | ||
249 | #elif defined(__BIG_ENDIAN) | 239 | #elif defined(__BIG_ENDIAN) |
250 | #define bE 3 | 240 | #define bE 3 |
251 | #define bSWAP 0 | 241 | #define bSWAP 0 |
242 | #define bS_to_io(x) (x) | ||
252 | #elif defined(__LITTLE_ENDIAN) | 243 | #elif defined(__LITTLE_ENDIAN) |
253 | #define bE 0 | 244 | #define bE 0 |
254 | #define bSWAP 0 | 245 | #define bSWAP 0 |
246 | #define bS_to_io(x) (x) | ||
255 | #else | 247 | #else |
256 | #error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined, did you include byteorder.h?" | 248 | #error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined, did you include byteorder.h?" |
257 | #endif | 249 | #endif |
@@ -455,91 +447,42 @@ struct NCR_700_Host_Parameters { | |||
455 | 447 | ||
456 | 448 | ||
457 | static inline __u8 | 449 | static inline __u8 |
458 | NCR_700_mem_readb(struct Scsi_Host *host, __u32 reg) | 450 | NCR_700_readb(struct Scsi_Host *host, __u32 reg) |
459 | { | ||
460 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | ||
461 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | ||
462 | |||
463 | return readb(host->base + (reg^bE)); | ||
464 | } | ||
465 | |||
466 | static inline __u32 | ||
467 | NCR_700_mem_readl(struct Scsi_Host *host, __u32 reg) | ||
468 | { | ||
469 | __u32 value = __raw_readl(host->base + reg); | ||
470 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | ||
471 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | ||
472 | #if 1 | ||
473 | /* sanity check the register */ | ||
474 | if((reg & 0x3) != 0) | ||
475 | BUG(); | ||
476 | #endif | ||
477 | |||
478 | return bS_to_cpu(value); | ||
479 | } | ||
480 | |||
481 | static inline void | ||
482 | NCR_700_mem_writeb(__u8 value, struct Scsi_Host *host, __u32 reg) | ||
483 | { | ||
484 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | ||
485 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | ||
486 | |||
487 | writeb(value, host->base + (reg^bE)); | ||
488 | } | ||
489 | |||
490 | static inline void | ||
491 | NCR_700_mem_writel(__u32 value, struct Scsi_Host *host, __u32 reg) | ||
492 | { | ||
493 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | ||
494 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | ||
495 | |||
496 | #if 1 | ||
497 | /* sanity check the register */ | ||
498 | if((reg & 0x3) != 0) | ||
499 | BUG(); | ||
500 | #endif | ||
501 | |||
502 | __raw_writel(bS_to_host(value), host->base + reg); | ||
503 | } | ||
504 | |||
505 | static inline __u8 | ||
506 | NCR_700_io_readb(struct Scsi_Host *host, __u32 reg) | ||
507 | { | 451 | { |
508 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | 452 | const struct NCR_700_Host_Parameters *hostdata |
509 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | 453 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; |
510 | 454 | ||
511 | return inb(host->base + (reg^bE)); | 455 | return ioread8(hostdata->base + (reg^bE)); |
512 | } | 456 | } |
513 | 457 | ||
514 | static inline __u32 | 458 | static inline __u32 |
515 | NCR_700_io_readl(struct Scsi_Host *host, __u32 reg) | 459 | NCR_700_readl(struct Scsi_Host *host, __u32 reg) |
516 | { | 460 | { |
517 | __u32 value = inl(host->base + reg); | 461 | const struct NCR_700_Host_Parameters *hostdata |
518 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | ||
519 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | 462 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; |
520 | 463 | __u32 value = ioread32(hostdata->base + reg); | |
521 | #if 1 | 464 | #if 1 |
522 | /* sanity check the register */ | 465 | /* sanity check the register */ |
523 | if((reg & 0x3) != 0) | 466 | if((reg & 0x3) != 0) |
524 | BUG(); | 467 | BUG(); |
525 | #endif | 468 | #endif |
526 | 469 | ||
527 | return bS_to_cpu(value); | 470 | return bS_to_io(value); |
528 | } | 471 | } |
529 | 472 | ||
530 | static inline void | 473 | static inline void |
531 | NCR_700_io_writeb(__u8 value, struct Scsi_Host *host, __u32 reg) | 474 | NCR_700_writeb(__u8 value, struct Scsi_Host *host, __u32 reg) |
532 | { | 475 | { |
533 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | 476 | const struct NCR_700_Host_Parameters *hostdata |
534 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | 477 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; |
535 | 478 | ||
536 | outb(value, host->base + (reg^bE)); | 479 | iowrite8(value, hostdata->base + (reg^bE)); |
537 | } | 480 | } |
538 | 481 | ||
539 | static inline void | 482 | static inline void |
540 | NCR_700_io_writel(__u32 value, struct Scsi_Host *host, __u32 reg) | 483 | NCR_700_writel(__u32 value, struct Scsi_Host *host, __u32 reg) |
541 | { | 484 | { |
542 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | 485 | const struct NCR_700_Host_Parameters *hostdata |
543 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | 486 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; |
544 | 487 | ||
545 | #if 1 | 488 | #if 1 |
@@ -548,102 +491,7 @@ NCR_700_io_writel(__u32 value, struct Scsi_Host *host, __u32 reg) | |||
548 | BUG(); | 491 | BUG(); |
549 | #endif | 492 | #endif |
550 | 493 | ||
551 | outl(bS_to_host(value), host->base + reg); | 494 | iowrite32(bS_to_io(value), hostdata->base + reg); |
552 | } | ||
553 | |||
554 | #ifdef CONFIG_53C700_BOTH_MAPPED | ||
555 | |||
556 | static inline __u8 | ||
557 | NCR_700_readb(struct Scsi_Host *host, __u32 reg) | ||
558 | { | ||
559 | __u8 val; | ||
560 | |||
561 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | ||
562 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | ||
563 | |||
564 | if(hostdata->mem_mapped) | ||
565 | val = NCR_700_mem_readb(host, reg); | ||
566 | else | ||
567 | val = NCR_700_io_readb(host, reg); | ||
568 | |||
569 | return val; | ||
570 | } | ||
571 | |||
572 | static inline __u32 | ||
573 | NCR_700_readl(struct Scsi_Host *host, __u32 reg) | ||
574 | { | ||
575 | __u32 val; | ||
576 | |||
577 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | ||
578 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | ||
579 | |||
580 | if(hostdata->mem_mapped) | ||
581 | val = NCR_700_mem_readl(host, reg); | ||
582 | else | ||
583 | val = NCR_700_io_readl(host, reg); | ||
584 | |||
585 | return val; | ||
586 | } | ||
587 | |||
588 | static inline void | ||
589 | NCR_700_writeb(__u8 value, struct Scsi_Host *host, __u32 reg) | ||
590 | { | ||
591 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | ||
592 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | ||
593 | |||
594 | if(hostdata->mem_mapped) | ||
595 | NCR_700_mem_writeb(value, host, reg); | ||
596 | else | ||
597 | NCR_700_io_writeb(value, host, reg); | ||
598 | } | ||
599 | |||
600 | static inline void | ||
601 | NCR_700_writel(__u32 value, struct Scsi_Host *host, __u32 reg) | ||
602 | { | ||
603 | const struct NCR_700_Host_Parameters *hostdata __attribute__((unused)) | ||
604 | = (struct NCR_700_Host_Parameters *)host->hostdata[0]; | ||
605 | |||
606 | if(hostdata->mem_mapped) | ||
607 | NCR_700_mem_writel(value, host, reg); | ||
608 | else | ||
609 | NCR_700_io_writel(value, host, reg); | ||
610 | } | ||
611 | |||
612 | static inline void | ||
613 | NCR_700_set_mem_mapped(struct NCR_700_Host_Parameters *hostdata) | ||
614 | { | ||
615 | hostdata->mem_mapped = 1; | ||
616 | } | ||
617 | |||
618 | static inline void | ||
619 | NCR_700_set_io_mapped(struct NCR_700_Host_Parameters *hostdata) | ||
620 | { | ||
621 | hostdata->mem_mapped = 0; | ||
622 | } | 495 | } |
623 | 496 | ||
624 | |||
625 | #elif defined(CONFIG_53C700_IO_MAPPED) | ||
626 | |||
627 | #define NCR_700_readb NCR_700_io_readb | ||
628 | #define NCR_700_readl NCR_700_io_readl | ||
629 | #define NCR_700_writeb NCR_700_io_writeb | ||
630 | #define NCR_700_writel NCR_700_io_writel | ||
631 | |||
632 | #define NCR_700_set_io_mapped(x) | ||
633 | #define NCR_700_set_mem_mapped(x) error I/O mapped only | ||
634 | |||
635 | #elif defined(CONFIG_53C700_MEM_MAPPED) | ||
636 | |||
637 | #define NCR_700_readb NCR_700_mem_readb | ||
638 | #define NCR_700_readl NCR_700_mem_readl | ||
639 | #define NCR_700_writeb NCR_700_mem_writeb | ||
640 | #define NCR_700_writel NCR_700_mem_writel | ||
641 | |||
642 | #define NCR_700_set_io_mapped(x) error MEM mapped only | ||
643 | #define NCR_700_set_mem_mapped(x) | ||
644 | |||
645 | #else | ||
646 | #error neither CONFIG_53C700_MEM_MAPPED nor CONFIG_53C700_IO_MAPPED is set | ||
647 | #endif | ||
648 | |||
649 | #endif | 497 | #endif |