Properly detect if BAR5 is IO or MEM type; avoid a message about not being

able to map the BAR on boot (note that it's just cosmetic, the registers were
mapped anyway). Tested by paul at whooppee.com; thanks !
This commit is contained in:
bouyer 2006-11-12 22:42:20 +00:00
parent ec585a4e4d
commit df1600e329
1 changed files with 25 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: viaide.c,v 1.35 2006/10/27 08:22:31 bouyer Exp $ */
/* $NetBSD: viaide.c,v 1.36 2006/11/12 22:42:20 bouyer Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: viaide.c,v 1.35 2006/10/27 08:22:31 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: viaide.c,v 1.36 2006/11/12 22:42:20 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -651,6 +651,7 @@ static int
via_sata_chip_map_common(struct pciide_softc *sc, struct pci_attach_args *pa)
{
bus_size_t satasize;
int maptype, ret;
if (pciide_chipen(sc, pa) == 0)
return 0;
@ -674,17 +675,30 @@ via_sata_chip_map_common(struct pciide_softc *sc, struct pci_attach_args *pa)
sc->sc_wdcdev.sc_atac.atac_set_modes = sata_setup_channel;
wdc_allocate_regs(&sc->sc_wdcdev);
if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x14,
PCI_MAPREG_TYPE_IO, 0, &sc->sc_ba5_st, &sc->sc_ba5_sh,
NULL, &satasize) != 0) {
if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x14,
maptype = pci_mapreg_type(pa->pa_pc, pa->pa_tag,
PCI_MAPREG_START + 0x14);
switch(maptype) {
case PCI_MAPREG_TYPE_IO:
ret = pci_mapreg_map(pa, PCI_MAPREG_START + 0x14,
PCI_MAPREG_TYPE_IO, 0, &sc->sc_ba5_st, &sc->sc_ba5_sh,
NULL, &satasize);
break;
case PCI_MAPREG_MEM_TYPE_32BIT:
ret = pci_mapreg_map(pa, PCI_MAPREG_START + 0x14,
PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
0, &sc->sc_ba5_st, &sc->sc_ba5_sh,
NULL, &satasize) != 0) {
aprint_error("%s: couldn't map sata regs\n",
sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
return 0;
}
NULL, &satasize);
break;
default:
aprint_error("%s: couldn't map sata regs, unsupported"
"maptype (0x%x)\n", sc->sc_wdcdev.sc_atac.atac_dev.dv_xname,
maptype);
return 0;
}
if (ret != 0) {
aprint_error("%s: couldn't map sata regs\n",
sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
return 0;
}
return 1;
}