NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: PR/39652



The following reply was made to PR kern/39652; it has been noted by GNATS.

From: "Jonathan A. Kollasch" <jakllsch%kollasch.net@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: PR/39652
Date: Fri, 20 Nov 2009 22:32:48 +0000

 --opJtzjQTFsWo+cga
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Attached is a patch that may help,
 also available at http://www.netbsd.org/~jakllsch/auich-map.diff
 
 --opJtzjQTFsWo+cga
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="auich-map.diff"
 
 Index: auich.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/pci/auich.c,v
 retrieving revision 1.131
 diff -u -r1.131 auich.c
 --- auich.c    12 Nov 2009 19:39:26 -0000      1.131
 +++ auich.c    20 Nov 2009 22:13:23 -0000
 @@ -215,8 +215,11 @@
        int  sc_sts_reg;
        /* 440MX workaround */
        int  sc_dmamap_flags;
 -      /* Native mode? */
 -      int  sc_native_mode;
 +      /* flags */
 +      int  sc_iose    :1,
 +           sc_csr_io  :1,
 +           sc_csr_mem :1,
 +                      :29;
  
        /* sysctl */
        struct sysctllog *sc_log;
 @@ -482,46 +485,55 @@
        if (d->id == PCIID_ICH4 || d->id == PCIID_ICH5 || d->id == PCIID_ICH6
            || d->id == PCIID_ICH7 || d->id == PCIID_I6300ESB
            || d->id == PCIID_ICH4MODEM) {
 -              sc->sc_native_mode = 1;
                /*
                 * Use native mode for Intel 6300ESB and ICH4/ICH5/ICH6/ICH7
                 */
 +
 +              sc->sc_csr_mem = 1;
 +              v = pci_conf_read(pa->pa_pc, pa->pa_tag,
 +                  PCI_COMMAND_STATUS_REG);
 +              pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
 +                             v | PCI_COMMAND_MEM_ENABLE);
 +              pa->pa_flags |= PCI_FLAGS_MEM_ENABLED;
 +
                if (pci_mapreg_map(pa, ICH_MMBAR, PCI_MAPREG_TYPE_MEM, 0,
 -                                 &sc->iot, &sc->mix_ioh, NULL, 
&sc->mix_size)) {
 -                      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,
 -                                         &sc->mix_size)) {
 -                              aprint_error_dev(self, "can't map codec i/o 
space\n");
 -                              return;
 -                      }
 +                  &sc->iot, &sc->mix_ioh, NULL, &sc->mix_size)) {
 +                      goto retry_map;
                }
                if (pci_mapreg_map(pa, ICH_MBBAR, PCI_MAPREG_TYPE_MEM, 0,
 -                                 &sc->iot, &sc->aud_ioh, NULL, 
&sc->aud_size)) {
 -                      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_NABMBAR, PCI_MAPREG_TYPE_IO,
 -                                         0, &sc->iot, &sc->aud_ioh, NULL,
 -                                         &sc->aud_size)) {
 -                              aprint_error_dev(self, "can't map device i/o 
space\n");
 -                              return;
 -                      }
 -              }
 -      } else {
 -              if (pci_mapreg_map(pa, ICH_NAMBAR, PCI_MAPREG_TYPE_IO, 0,
 -                                 &sc->iot, &sc->mix_ioh, NULL, 
&sc->mix_size)) {
 -                      aprint_error_dev(self, "can't map codec i/o space\n");
 -                      return;
 -              }
 -              if (pci_mapreg_map(pa, ICH_NABMBAR, PCI_MAPREG_TYPE_IO, 0,
 -                                 &sc->iot, &sc->aud_ioh, NULL, 
&sc->aud_size)) {
 -                      aprint_error_dev(self, "can't map device i/o space\n");
 -                      return;
 +                  &sc->iot, &sc->aud_ioh, NULL, &sc->aud_size)) {
 +                      goto retry_map;
                }
 +              goto map_done;
 +      } else
 +              goto non_native_map;
 +
 +retry_map:
 +      sc->sc_iose = 1;
 +      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);
 +
 +non_native_map:
 +      sc->sc_csr_io = 1;
 +      v = pci_conf_read(pa->pa_pc, pa->pa_tag,
 +          PCI_COMMAND_STATUS_REG);
 +      pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
 +                     v | PCI_COMMAND_IO_ENABLE);
 +      pa->pa_flags |= PCI_FLAGS_IO_ENABLED;
 +
 +      if (pci_mapreg_map(pa, ICH_NAMBAR, PCI_MAPREG_TYPE_IO, 0,
 +                         &sc->iot, &sc->mix_ioh, NULL, &sc->mix_size)) {
 +              aprint_error_dev(self, "can't map codec i/o space\n");
 +              return;
        }
 +      if (pci_mapreg_map(pa, ICH_NABMBAR, PCI_MAPREG_TYPE_IO, 0,
 +                         &sc->iot, &sc->aud_ioh, NULL, &sc->aud_size)) {
 +              aprint_error_dev(self, "can't map device i/o space\n");
 +              return;
 +      }
 +
 +map_done:
        sc->dmat = pa->pa_dmat;
  
        /* enable bus mastering */
 @@ -1578,12 +1590,19 @@
        struct auich_softc *sc = device_private(dv);
        pcireg_t v;
  
 -      if (sc->sc_native_mode) {
 +      if (sc->sc_iose) {
                v = pci_conf_read(sc->sc_pc, sc->sc_pt, ICH_CFG);
                pci_conf_write(sc->sc_pc, sc->sc_pt, ICH_CFG,
                               v | ICH_CFG_IOSE);
        }
  
 +      v = pci_conf_read(sc->sc_pc, sc->sc_pt, PCI_COMMAND_STATUS_REG);
 +      if (sc->sc_csr_io)
 +              v |= PCI_COMMAND_IO_ENABLE;
 +      if (sc->sc_csr_mem)
 +              v |= PCI_COMMAND_MEM_ENABLE;
 +      pci_conf_write(sc->sc_pc, sc->sc_pt, PCI_COMMAND_STATUS_REG, v);
 +
        auich_reset_codec(sc);
        DELAY(1000);
        (sc->codec_if->vtbl->restore_ports)(sc->codec_if);
 
 --opJtzjQTFsWo+cga--
 


Home | Main Index | Thread Index | Old Index