Sat Nov 5 17:44:25 2011 UTC ()
Simplify bus space mapping.


(rkujawa)
diff -r1.4 -r1.5 src/sys/arch/amiga/dev/efa.c

cvs diff -r1.4 -r1.5 src/sys/arch/amiga/dev/efa.c (expand / switch to unified diff)

--- src/sys/arch/amiga/dev/efa.c 2011/10/30 11:10:42 1.4
+++ src/sys/arch/amiga/dev/efa.c 2011/11/05 17:44:25 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: efa.c,v 1.4 2011/10/30 11:10:42 rkujawa Exp $ */ 1/* $NetBSD: efa.c,v 1.5 2011/11/05 17:44:25 rkujawa Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc. 4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Radoslaw Kujawa. 8 * by Radoslaw Kujawa.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -94,30 +94,26 @@ CFATTACH_DECL_NEW(efa, sizeof(struct efa @@ -94,30 +94,26 @@ CFATTACH_DECL_NEW(efa, sizeof(struct efa
94#define PIO_NSUPP 0xFFFFFFFF 94#define PIO_NSUPP 0xFFFFFFFF
95 95
96static const bus_addr_t pio_offsets[] =  96static const bus_addr_t pio_offsets[] =
97 { FATA1_PIO0_OFF, PIO_NSUPP, PIO_NSUPP, FATA1_PIO3_OFF, FATA1_PIO4_OFF,  97 { FATA1_PIO0_OFF, PIO_NSUPP, PIO_NSUPP, FATA1_PIO3_OFF, FATA1_PIO4_OFF,
98 FATA1_PIO5_OFF }; 98 FATA1_PIO5_OFF };
99static const unsigned int wdr_offsets_pio0[] =  99static const unsigned int wdr_offsets_pio0[] =
100 { FATA1_PIO0_OFF_DATA, FATA1_PIO0_OFF_ERROR, FATA1_PIO0_OFF_SECCNT, 100 { FATA1_PIO0_OFF_DATA, FATA1_PIO0_OFF_ERROR, FATA1_PIO0_OFF_SECCNT,
101 FATA1_PIO0_OFF_SECTOR, FATA1_PIO0_OFF_CYL_LO, FATA1_PIO0_OFF_CYL_HI, 101 FATA1_PIO0_OFF_SECTOR, FATA1_PIO0_OFF_CYL_LO, FATA1_PIO0_OFF_CYL_HI,
102 FATA1_PIO0_OFF_SDH, FATA1_PIO0_OFF_COMMAND }; 102 FATA1_PIO0_OFF_SDH, FATA1_PIO0_OFF_COMMAND };
103static const unsigned int wdr_offsets_pion[] = 103static const unsigned int wdr_offsets_pion[] =
104 { FATA1_PION_OFF_DATA, FATA1_PION_OFF_ERROR, FATA1_PION_OFF_SECCNT, 104 { FATA1_PION_OFF_DATA, FATA1_PION_OFF_ERROR, FATA1_PION_OFF_SECCNT,
105 FATA1_PION_OFF_SECTOR, FATA1_PION_OFF_CYL_LO, FATA1_PION_OFF_CYL_HI, 105 FATA1_PION_OFF_SECTOR, FATA1_PION_OFF_CYL_LO, FATA1_PION_OFF_CYL_HI,
106 FATA1_PION_OFF_SDH, FATA1_PION_OFF_COMMAND }; 106 FATA1_PION_OFF_SDH, FATA1_PION_OFF_COMMAND };
107static const unsigned int wdr_offsets_pion32[] = 
108 { FATA1_PION_OFF_DATA32, FATA1_PION_OFF_ERROR, FATA1_PION_OFF_SECCNT, 
109 FATA1_PION_OFF_SECTOR, FATA1_PION_OFF_CYL_LO, FATA1_PION_OFF_CYL_HI, 
110 FATA1_PION_OFF_SDH, FATA1_PION_OFF_COMMAND }; 
111 107
112int 108int
113efa_probe(device_t parent, cfdata_t cfp, void *aux) 109efa_probe(device_t parent, cfdata_t cfp, void *aux)
114{ 110{
115 /* 111 /*
116 * FastATA 1200 uses portions of Gayle IDE interface, and efa driver  112 * FastATA 1200 uses portions of Gayle IDE interface, and efa driver
117 * can't coexist with wdc_amiga. Match "wdc" on an A1200, because  113 * can't coexist with wdc_amiga. Match "wdc" on an A1200, because
118 * FastATA 1200 does not autoconfigure.  114 * FastATA 1200 does not autoconfigure.
119 */ 115 */
120 if (!matchname(aux, "wdc") || !is_a1200()) 116 if (!matchname(aux, "wdc") || !is_a1200())
121 return(0); 117 return(0);
122 118
123 if (!efa_compare_status()) 119 if (!efa_compare_status())
@@ -429,68 +425,47 @@ efa_mapreg_native(struct efa_softc *sc)  @@ -429,68 +425,47 @@ efa_mapreg_native(struct efa_softc *sc)
429 if (j == 0 && sc->sc_32bit_io) 425 if (j == 0 && sc->sc_32bit_io)
430 sc->sc_ports[i].mode_ok[j] = false; 426 sc->sc_ports[i].mode_ok[j] = false;
431  427
432 wdr_fata->ctl_ioh = wdr_gayle->ctl_ioh;  428 wdr_fata->ctl_ioh = wdr_gayle->ctl_ioh;
433 }; 429 };
434 } 430 }
435 return true; 431 return true;
436} 432}
437 433
438 434
439static void 435static void
440efa_fata_subregion_pio0(struct wdc_regs *wdr_fata)  436efa_fata_subregion_pio0(struct wdc_regs *wdr_fata)
441{ 437{
 438 int i;
442 439
443 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  440 for (i = 0; i < WDC_NREG; i++)
444 FATA1_PIO0_OFF_DATA, 4, &wdr_fata->cmd_iohs[wd_data]); 441 bus_space_subregion(wdr_fata->cmd_iot,
445 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  442 wdr_fata->cmd_baseioh, wdr_offsets_pio0[i],
446 FATA1_PIO0_OFF_ERROR, 1, &wdr_fata->cmd_iohs[wd_error]); 443 i == 0 ? 4 : 1, &wdr_fata->cmd_iohs[i]);
447 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
448 FATA1_PIO0_OFF_SECCNT, 1, &wdr_fata->cmd_iohs[wd_seccnt]); 
449 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
450 FATA1_PIO0_OFF_SECTOR, 1, &wdr_fata->cmd_iohs[wd_sector]); 
451 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
452 FATA1_PIO0_OFF_CYL_LO, 1, &wdr_fata->cmd_iohs[wd_cyl_lo]); 
453 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
454 FATA1_PIO0_OFF_CYL_HI, 1, &wdr_fata->cmd_iohs[wd_cyl_hi]); 
455 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
456 FATA1_PIO0_OFF_SDH, 1, &wdr_fata->cmd_iohs[wd_sdh]); 
457 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
458 FATA1_PIO0_OFF_COMMAND, 1, &wdr_fata->cmd_iohs[wd_command]); 
459} 444}
460 445
461static void 446static void
462efa_fata_subregion_pion(struct wdc_regs *wdr_fata, bool data32)  447efa_fata_subregion_pion(struct wdc_regs *wdr_fata, bool data32)
463{ 448{
 449 int i;
 450
464 if (data32) 451 if (data32)
465 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  452 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,
466 FATA1_PION_OFF_DATA32, 8, &wdr_fata->data32ioh); 453 FATA1_PION_OFF_DATA32, 8, &wdr_fata->data32ioh);
467 454
468 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  455 for (i = 0; i < WDC_NREG; i++)
469 FATA1_PION_OFF_DATA, 4, &wdr_fata->cmd_iohs[wd_data]); 456 bus_space_subregion(wdr_fata->cmd_iot,
470 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  457 wdr_fata->cmd_baseioh, wdr_offsets_pion[i],
471 FATA1_PION_OFF_ERROR, 1, &wdr_fata->cmd_iohs[wd_error]); 458 i == 0 ? 4 : 1, &wdr_fata->cmd_iohs[i]);
472 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
473 FATA1_PION_OFF_SECCNT, 1, &wdr_fata->cmd_iohs[wd_seccnt]); 
474 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
475 FATA1_PION_OFF_SECTOR, 1, &wdr_fata->cmd_iohs[wd_sector]); 
476 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
477 FATA1_PION_OFF_CYL_LO, 1, &wdr_fata->cmd_iohs[wd_cyl_lo]); 
478 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
479 FATA1_PION_OFF_CYL_HI, 1, &wdr_fata->cmd_iohs[wd_cyl_hi]); 
480 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
481 FATA1_PION_OFF_SDH, 1, &wdr_fata->cmd_iohs[wd_sdh]); 
482 bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh,  
483 FATA1_PION_OFF_COMMAND, 1, &wdr_fata->cmd_iohs[wd_command]); 
484} 459}
485 460
486static void 461static void
487efa_setup_channel(struct ata_channel *chp) 462efa_setup_channel(struct ata_channel *chp)
488{ 463{
489 int drive, chnum; 464 int drive, chnum;
490 uint8_t mode;  465 uint8_t mode;
491 struct atac_softc *atac;  466 struct atac_softc *atac;
492 struct ata_drive_datas *drvp; 467 struct ata_drive_datas *drvp;
493 struct efa_softc *sc; 468 struct efa_softc *sc;
494 int ipl; 469 int ipl;
495 470
496 chnum = chp->ch_channel; 471 chnum = chp->ch_channel;