diff options
| author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-27 09:38:32 -0400 |
|---|---|---|
| committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-27 09:38:32 -0400 |
| commit | 4c3032d8a4d6c97bd6e02bcab524ef2428d89561 (patch) | |
| tree | 4528851a9b04282f602cebb6b2ab4bc677b63259 /include/linux | |
| parent | 387750c3bf49c22f6189436032145e2131985076 (diff) | |
ide: add struct ide_io_ports (take 3)
* Add struct ide_io_ports and use it instead of `unsigned long io_ports[]`
in ide_hwif_t.
* Rename io_ports[] in hw_regs_t to io_ports_array[].
* Use un-named union for 'unsigned long io_ports_array[]' and 'struct
ide_io_ports io_ports' in hw_regs_t.
* Remove IDE_*_OFFSET defines.
v2:
* scc_pata.c build fix from Stephen Rothwell.
v3:
* Fix ctl_adrr typo in Sparc-specific part of ns87415.c.
(Noticed by Andrew Morton)
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/ide.h | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h index f4c7ec25f614..772228cf7115 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
| @@ -61,23 +61,30 @@ typedef unsigned char byte; /* used everywhere */ | |||
| 61 | */ | 61 | */ |
| 62 | #define IDE_NR_PORTS (10) | 62 | #define IDE_NR_PORTS (10) |
| 63 | 63 | ||
| 64 | #define IDE_DATA_OFFSET (0) | 64 | struct ide_io_ports { |
| 65 | #define IDE_ERROR_OFFSET (1) | 65 | unsigned long data_addr; |
| 66 | #define IDE_NSECTOR_OFFSET (2) | 66 | |
| 67 | #define IDE_SECTOR_OFFSET (3) | 67 | union { |
| 68 | #define IDE_LCYL_OFFSET (4) | 68 | unsigned long error_addr; /* read: error */ |
| 69 | #define IDE_HCYL_OFFSET (5) | 69 | unsigned long feature_addr; /* write: feature */ |
| 70 | #define IDE_SELECT_OFFSET (6) | 70 | }; |
| 71 | #define IDE_STATUS_OFFSET (7) | 71 | |
| 72 | #define IDE_CONTROL_OFFSET (8) | 72 | unsigned long nsect_addr; |
| 73 | #define IDE_IRQ_OFFSET (9) | 73 | unsigned long lbal_addr; |
| 74 | 74 | unsigned long lbam_addr; | |
| 75 | #define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET | 75 | unsigned long lbah_addr; |
| 76 | #define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET | 76 | |
| 77 | #define IDE_ALTSTATUS_OFFSET IDE_CONTROL_OFFSET | 77 | unsigned long device_addr; |
| 78 | #define IDE_IREASON_OFFSET IDE_NSECTOR_OFFSET | 78 | |
| 79 | #define IDE_BCOUNTL_OFFSET IDE_LCYL_OFFSET | 79 | union { |
| 80 | #define IDE_BCOUNTH_OFFSET IDE_HCYL_OFFSET | 80 | unsigned long status_addr; /* read: status */ |
| 81 | unsigned long command_addr; /* write: command */ | ||
| 82 | }; | ||
| 83 | |||
| 84 | unsigned long ctl_addr; | ||
| 85 | |||
| 86 | unsigned long irq_addr; | ||
| 87 | }; | ||
| 81 | 88 | ||
| 82 | #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) | 89 | #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) |
| 83 | #define BAD_R_STAT (BUSY_STAT | ERR_STAT) | 90 | #define BAD_R_STAT (BUSY_STAT | ERR_STAT) |
| @@ -156,7 +163,11 @@ typedef u8 hwif_chipset_t; | |||
| 156 | * Structure to hold all information about the location of this port | 163 | * Structure to hold all information about the location of this port |
| 157 | */ | 164 | */ |
| 158 | typedef struct hw_regs_s { | 165 | typedef struct hw_regs_s { |
| 159 | unsigned long io_ports[IDE_NR_PORTS]; /* task file registers */ | 166 | union { |
| 167 | struct ide_io_ports io_ports; | ||
| 168 | unsigned long io_ports_array[IDE_NR_PORTS]; | ||
| 169 | }; | ||
| 170 | |||
| 160 | int irq; /* our irq number */ | 171 | int irq; /* our irq number */ |
| 161 | ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ | 172 | ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ |
| 162 | hwif_chipset_t chipset; | 173 | hwif_chipset_t chipset; |
| @@ -172,10 +183,10 @@ static inline void ide_std_init_ports(hw_regs_t *hw, | |||
| 172 | { | 183 | { |
| 173 | unsigned int i; | 184 | unsigned int i; |
| 174 | 185 | ||
| 175 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) | 186 | for (i = 0; i <= 7; i++) |
| 176 | hw->io_ports[i] = io_addr++; | 187 | hw->io_ports_array[i] = io_addr++; |
| 177 | 188 | ||
| 178 | hw->io_ports[IDE_CONTROL_OFFSET] = ctl_addr; | 189 | hw->io_ports.ctl_addr = ctl_addr; |
| 179 | } | 190 | } |
| 180 | 191 | ||
| 181 | #include <asm/ide.h> | 192 | #include <asm/ide.h> |
| @@ -424,8 +435,8 @@ typedef struct hwif_s { | |||
| 424 | 435 | ||
| 425 | char name[6]; /* name of interface, eg. "ide0" */ | 436 | char name[6]; /* name of interface, eg. "ide0" */ |
| 426 | 437 | ||
| 427 | /* task file registers for pata and sata */ | 438 | struct ide_io_ports io_ports; |
| 428 | unsigned long io_ports[IDE_NR_PORTS]; | 439 | |
| 429 | unsigned long sata_scr[SATA_NR_PORTS]; | 440 | unsigned long sata_scr[SATA_NR_PORTS]; |
| 430 | 441 | ||
| 431 | ide_drive_t drives[MAX_DRIVES]; /* drive info */ | 442 | ide_drive_t drives[MAX_DRIVES]; /* drive info */ |
| @@ -1330,29 +1341,28 @@ static inline void ide_set_irq(ide_drive_t *drive, int on) | |||
| 1330 | { | 1341 | { |
| 1331 | ide_hwif_t *hwif = drive->hwif; | 1342 | ide_hwif_t *hwif = drive->hwif; |
| 1332 | 1343 | ||
| 1333 | hwif->OUTB(drive->ctl | (on ? 0 : 2), | 1344 | hwif->OUTB(drive->ctl | (on ? 0 : 2), hwif->io_ports.ctl_addr); |
| 1334 | hwif->io_ports[IDE_CONTROL_OFFSET]); | ||
| 1335 | } | 1345 | } |
| 1336 | 1346 | ||
| 1337 | static inline u8 ide_read_status(ide_drive_t *drive) | 1347 | static inline u8 ide_read_status(ide_drive_t *drive) |
| 1338 | { | 1348 | { |
| 1339 | ide_hwif_t *hwif = drive->hwif; | 1349 | ide_hwif_t *hwif = drive->hwif; |
| 1340 | 1350 | ||
| 1341 | return hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); | 1351 | return hwif->INB(hwif->io_ports.status_addr); |
| 1342 | } | 1352 | } |
| 1343 | 1353 | ||
| 1344 | static inline u8 ide_read_altstatus(ide_drive_t *drive) | 1354 | static inline u8 ide_read_altstatus(ide_drive_t *drive) |
| 1345 | { | 1355 | { |
| 1346 | ide_hwif_t *hwif = drive->hwif; | 1356 | ide_hwif_t *hwif = drive->hwif; |
| 1347 | 1357 | ||
| 1348 | return hwif->INB(hwif->io_ports[IDE_CONTROL_OFFSET]); | 1358 | return hwif->INB(hwif->io_ports.ctl_addr); |
| 1349 | } | 1359 | } |
| 1350 | 1360 | ||
| 1351 | static inline u8 ide_read_error(ide_drive_t *drive) | 1361 | static inline u8 ide_read_error(ide_drive_t *drive) |
| 1352 | { | 1362 | { |
| 1353 | ide_hwif_t *hwif = drive->hwif; | 1363 | ide_hwif_t *hwif = drive->hwif; |
| 1354 | 1364 | ||
| 1355 | return hwif->INB(hwif->io_ports[IDE_ERROR_OFFSET]); | 1365 | return hwif->INB(hwif->io_ports.error_addr); |
| 1356 | } | 1366 | } |
| 1357 | 1367 | ||
| 1358 | /* | 1368 | /* |
| @@ -1365,7 +1375,7 @@ static inline void ide_atapi_discard_data(ide_drive_t *drive, unsigned bcount) | |||
| 1365 | 1375 | ||
| 1366 | /* FIXME: use ->atapi_input_bytes */ | 1376 | /* FIXME: use ->atapi_input_bytes */ |
| 1367 | while (bcount--) | 1377 | while (bcount--) |
| 1368 | (void)hwif->INB(hwif->io_ports[IDE_DATA_OFFSET]); | 1378 | (void)hwif->INB(hwif->io_ports.data_addr); |
| 1369 | } | 1379 | } |
| 1370 | 1380 | ||
| 1371 | static inline void ide_atapi_write_zeros(ide_drive_t *drive, unsigned bcount) | 1381 | static inline void ide_atapi_write_zeros(ide_drive_t *drive, unsigned bcount) |
| @@ -1374,7 +1384,7 @@ static inline void ide_atapi_write_zeros(ide_drive_t *drive, unsigned bcount) | |||
| 1374 | 1384 | ||
| 1375 | /* FIXME: use ->atapi_output_bytes */ | 1385 | /* FIXME: use ->atapi_output_bytes */ |
| 1376 | while (bcount--) | 1386 | while (bcount--) |
| 1377 | hwif->OUTB(0, hwif->io_ports[IDE_DATA_OFFSET]); | 1387 | hwif->OUTB(0, hwif->io_ports.data_addr); |
| 1378 | } | 1388 | } |
| 1379 | 1389 | ||
| 1380 | #endif /* _IDE_H */ | 1390 | #endif /* _IDE_H */ |
