Subject: AC97 patch for ICH5 (native mode) & AD1985 codec
To: None <current-users@netbsd.org>
From: Lars Heidieker <lars@heidieker.de>
List: current-users
Date: 11/20/2003 10:02:26
Hi,

the AD1985 codec has the configuration as the AD1980 in terms of swapped 
sourround and lineout.
The ICH5 (at least on Intels PEARL Boards) must be driven in native mode. If 
not you end with the message "could not map codec io space".
I have inserted "ac97_read(as, AC97_REG_RESET, &id1);" in ac97.c that is just 
to make sure the codec is ready after the reset otherwise the read of the 
codec id failed (at least on my board)

Index: ic/ac97.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/ac97.c,v
retrieving revision 1.49
diff -r1.49 ac97.c
327c327
< static void ac97_ad1980_init(struct ac97_softc *);
---
> static void ac97_ad198x_init(struct ac97_softc *);
371c371
<         0xffffffff,                   "Analog Devices AD1980", 
ac97_ad1980_ini
t },
---
>         0xffffffff,                   "Analog Devices AD1980", 
ac97_ad198x_ini
t },
377c377
<         0xffffffff,                   "Analog Devices AD1985" },
---
>         0xffffffff,                   "Analog Devices AD1985", 
ac97_ad198x_ini
t },
899c899
<       host_if->write(host_if->arg, AC97_REG_RESET, 0);
---
>       host_if->write(host_if->arg, AC97_REG_POWER, 0);
903a904,905
>       ac97_read(as, AC97_REG_RESET, &id1);
>
1504c1506
< ac97_ad1980_init(struct ac97_softc *as)
---
> ac97_ad198x_init(struct ac97_softc *as)

Index: pci/auich.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/auich.c,v
retrieving revision 1.54
diff -r1.54 auich.c
421,434c421,445
<               v = pci_conf_read(pa->pa_pc, pa->pa_tag, ICH_CFG);
<               pci_conf_write(pa->pa_pc, pa->pa_tag, ICH_CFG, v | 
ICH_CFG_IOSE);
<       }
<       if (pci_mapreg_map(pa, ICH_NAMBAR, PCI_MAPREG_TYPE_IO, 0,
<                          &sc->iot, &sc->mix_ioh, NULL, &mix_size)) {
<               aprint_error("%s: can't map codec i/o space\n",
<                   sc->sc_dev.dv_xname);
<               return;
<       }
<       if (pci_mapreg_map(pa, ICH_NABMBAR, PCI_MAPREG_TYPE_IO, 0,
<                          &sc->iot, &sc->aud_ioh, NULL, &aud_size)) {
<               aprint_error("%s: can't map device i/o space\n",
<                   sc->sc_dev.dv_xname);
<               return;
---
>               if (pci_mapreg_map(pa, ICH_MMBAR, PCI_MAPREG_TYPE_MEM, 0,
>                                  &sc->iot, &sc->mix_ioh, NULL, &mix_size)) {
>                       aprint_error("%s: can't map codec i/o space\n",
>                           sc->sc_dev.dv_xname);
>                       return;
>               }
>               if (pci_mapreg_map(pa, ICH_MBBAR, PCI_MAPREG_TYPE_MEM, 0,
>                               &sc->iot, &sc->aud_ioh, NULL, &aud_size)) {
>                       aprint_error("%s: can't map device i/o space\n",
>                       sc->sc_dev.dv_xname);
>                       return;
>               }
>       } else {
>               if (pci_mapreg_map(pa, ICH_NAMBAR, PCI_MAPREG_TYPE_IO, 0,
>                                  &sc->iot, &sc->mix_ioh, NULL, &mix_size)) {
>                       aprint_error("%s: can't map codec i/o space\n",
>                           sc->sc_dev.dv_xname);
>                       return;
>               }
>               if (pci_mapreg_map(pa, ICH_NABMBAR, PCI_MAPREG_TYPE_IO, 0,
>                               &sc->iot, &sc->aud_ioh, NULL, &aud_size)) {
>                       aprint_error("%s: can't map device i/o space\n",
>                       sc->sc_dev.dv_xname);
>                       return;
>               }
Index: pci/auichreg.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/auichreg.h,v
retrieving revision 1.6
diff -r1.6 auichreg.h
45a46,47
> #define ICH_MMBAR     0x18
> #define ICH_MBBAR     0x1c