wss_isapnp.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* $OpenBSD: wss_isapnp.c,v 1.9 2014/09/14 14:17:25 jsg Exp $ */
  2. /* $NetBSD: wss_isapnp.c,v 1.5 1998/11/25 22:17:07 augustss Exp $ */
  3. /*
  4. * Copyright (c) 1997 The NetBSD Foundation, Inc.
  5. * All rights reserved.
  6. *
  7. * This code is derived from software contributed to The NetBSD Foundation
  8. * by Lennart Augustsson (augustss@netbsd.org).
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  21. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  23. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. * POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #include <sys/param.h>
  32. #include <sys/systm.h>
  33. #include <sys/errno.h>
  34. #include <sys/ioctl.h>
  35. #include <sys/syslog.h>
  36. #include <sys/device.h>
  37. #include <machine/bus.h>
  38. #include <sys/audioio.h>
  39. #include <dev/audio_if.h>
  40. #include <dev/isa/isavar.h>
  41. #include <dev/isa/isadmavar.h>
  42. #include <dev/isa/isapnpreg.h>
  43. #include <dev/isa/ad1848var.h>
  44. #include <dev/ic/ad1848reg.h>
  45. #include <dev/isa/madreg.h>
  46. #include <dev/isa/wssreg.h>
  47. #include <dev/isa/wssvar.h>
  48. int wss_isapnp_match(struct device *, void *, void *);
  49. void wss_isapnp_attach(struct device *, struct device *, void *);
  50. struct cfattach wss_isapnp_ca = {
  51. sizeof(struct wss_softc), wss_isapnp_match, wss_isapnp_attach
  52. };
  53. /*
  54. * Probe / attach routines.
  55. */
  56. /*
  57. * Probe for the WSS hardware.
  58. */
  59. int
  60. wss_isapnp_match(parent, match, aux)
  61. struct device *parent;
  62. void *match, *aux;
  63. {
  64. return 1;
  65. }
  66. /*
  67. * Attach hardware to driver, attach hardware driver to audio
  68. * pseudo-device driver.
  69. */
  70. void
  71. wss_isapnp_attach(parent, self, aux)
  72. struct device *parent, *self;
  73. void *aux;
  74. {
  75. struct isapnp_softc *pnp = (struct isapnp_softc *)parent;
  76. struct wss_softc *sc = (struct wss_softc *)self;
  77. struct ad1848_softc *ac = &sc->sc_ad1848;
  78. struct isa_attach_args *ipa = aux;
  79. /* probably broken */
  80. isapnp_write_reg(pnp, ISAPNP_CONFIG_CONTROL, 0x02);
  81. sc->sc_iot = ipa->ia_iot;
  82. sc->sc_ioh = ipa->ipa_io[0].h;
  83. sc->mad_chip_type = MAD_NONE;
  84. /* Set up AD1848 I/O handle. */
  85. ac->sc_iot = sc->sc_iot;
  86. ac->sc_isa = parent->dv_parent;
  87. ac->sc_ioh = sc->sc_ioh;
  88. ac->mode = 2;
  89. ac->sc_iooffs = 0;
  90. sc->sc_ic = ipa->ia_ic;
  91. sc->wss_irq = ipa->ipa_irq[0].num;
  92. sc->wss_drq = ipa->ipa_drq[0].num;
  93. sc->wss_recdrq = ipa->ipa_ndrq > 1 ? ipa->ipa_drq[1].num :
  94. ipa->ipa_drq[0].num;
  95. if (ad1848_probe(&sc->sc_ad1848)==0) {
  96. printf("%s: probe failed\n", ac->sc_dev.dv_xname);
  97. return;
  98. }
  99. wssattach(sc);
  100. }