diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/microcode/Makefile | 4 | ||||
-rw-r--r-- | sys/dev/microcode/cirruslogic/Makefile | 24 | ||||
-rw-r--r-- | sys/dev/microcode/cirruslogic/build.c | 39 | ||||
-rw-r--r-- | sys/dev/microcode/cirruslogic/cs4280-license | 10 | ||||
-rw-r--r-- | sys/dev/pci/cs4280.c | 110 | ||||
-rw-r--r-- | sys/dev/pci/files.pci | 6 |
6 files changed, 152 insertions, 41 deletions
diff --git a/sys/dev/microcode/Makefile b/sys/dev/microcode/Makefile index 224727e0581..b6f97b13c29 100644 --- a/sys/dev/microcode/Makefile +++ b/sys/dev/microcode/Makefile @@ -1,5 +1,5 @@ -# $OpenBSD: Makefile,v 1.6 2004/12/19 15:21:08 deraadt Exp $ +# $OpenBSD: Makefile,v 1.7 2004/12/19 16:06:23 deraadt Exp $ -SUBDIR= atmel tigon neomagic symbol kue typhoon uyap +SUBDIR= atmel tigon neomagic symbol kue typhoon uyap cirruslogic yds .include <bsd.subdir.mk> diff --git a/sys/dev/microcode/cirruslogic/Makefile b/sys/dev/microcode/cirruslogic/Makefile new file mode 100644 index 00000000000..98b117dd081 --- /dev/null +++ b/sys/dev/microcode/cirruslogic/Makefile @@ -0,0 +1,24 @@ +# $OpenBSD: Makefile,v 1.1 2004/12/19 16:06:23 deraadt Exp $ + +NOPROG= +NOMAN= + +# PCI capable systems only +.if (${MACHINE} == "i386") + +FIRM= cs4280 + +CLEANFILES+= build ${FIRM} + +all: build + ${.OBJDIR}/build + +afterinstall: + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \ + ${FIRM} ${DESTDIR}/etc/firmware + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \ + ${.CURDIR}/cs4280-license ${DESTDIR}/etc/firmware +.endif + +.include <bsd.prog.mk> + diff --git a/sys/dev/microcode/cirruslogic/build.c b/sys/dev/microcode/cirruslogic/build.c new file mode 100644 index 00000000000..52daaf77f65 --- /dev/null +++ b/sys/dev/microcode/cirruslogic/build.c @@ -0,0 +1,39 @@ +/* $OpenBSD: build.c,v 1.1 2004/12/19 16:06:23 deraadt Exp $ */ + +/* + * Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <sys/types.h> +#include <fcntl.h> + +#include <dev/pci/cs4280reg.h> +#include "cs4280_image.h" +#define FILENAME "cs4280" + +int +main(int argc, char *argv[]) +{ + int i; + int fd; + + printf("creating %s length %d\n", FILENAME, sizeof BA1Struct); + fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644); + if (fd == -1) + err(1, "%s", FILENAME); + + write(fd, &BA1Struct, sizeof BA1Struct); + close(fd); + return 0; +} diff --git a/sys/dev/microcode/cirruslogic/cs4280-license b/sys/dev/microcode/cirruslogic/cs4280-license new file mode 100644 index 00000000000..13dca56f70f --- /dev/null +++ b/sys/dev/microcode/cirruslogic/cs4280-license @@ -0,0 +1,10 @@ + * This source is based on cwcimage.h in cwcealdr1.zip, the + * sample source by Crystal Semiconductor. + * (ftp://ftp.alsa-project.org/pub/manuals/cirrus/cwcealdr1.zip.) + * + * Just remove \r in each line and add this comments. + * + * Original file contains no copyright notice. + +This license needs to be solved by someone finding the right person +at Crystal Semiconductor. diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c index 9ebd6b395be..d31f0e60295 100644 --- a/sys/dev/pci/cs4280.c +++ b/sys/dev/pci/cs4280.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4280.c,v 1.20 2004/01/08 22:38:20 deraadt Exp $ */ +/* $OpenBSD: cs4280.c,v 1.21 2004/12/19 16:06:22 deraadt Exp $ */ /* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */ /* @@ -75,7 +75,6 @@ int cs4280debug = 0; #include <dev/pci/pcidevs.h> #include <dev/pci/pcivar.h> #include <dev/pci/cs4280reg.h> -#include <dev/microcode/cirruslogic/cs4280_image.h> #include <sys/audioio.h> #include <dev/audio_if.h> @@ -170,6 +169,7 @@ struct cs4280_softc { int cs4280_match(struct device *, void *, void *); void cs4280_attach(struct device *, struct device *, void *); +void cs4280_attachhook(void *xsc); int cs4280_intr(void *); void cs4280_reset(void *); int cs4280_download_image(struct cs4280_softc *); @@ -194,6 +194,7 @@ struct cfattach clcs_ca = { }; int cs4280_init(struct cs4280_softc *, int); +int cs4280_init2(struct cs4280_softc *, int); int cs4280_open(void *, int); void cs4280_close(void *); @@ -553,6 +554,43 @@ cs4280_set_dac_rate(sc, rate) } void +cs4280_attachhook(void *xsc) +{ + struct cs4280_softc *sc = xsc; + mixer_ctrl_t ctl; + + /* Initialization */ + if (cs4280_init2(sc, 1) != 0) + return; + + printf("%s: firmware loaded\n", sc->sc_dev.dv_xname); + + /* Turn mute off of DAC, CD and master volumes by default */ + ctl.type = AUDIO_MIXER_ENUM; + ctl.un.ord = 0; /* off */ + + ctl.dev = cs4280_get_portnum_by_name(sc, AudioCoutputs, + AudioNmaster, AudioNmute); + cs4280_mixer_set_port(sc, &ctl); + + ctl.dev = cs4280_get_portnum_by_name(sc, AudioCinputs, + AudioNdac, AudioNmute); + cs4280_mixer_set_port(sc, &ctl); + + ctl.dev = cs4280_get_portnum_by_name(sc, AudioCinputs, + AudioNcd, AudioNmute); + cs4280_mixer_set_port(sc, &ctl); + + audio_attach_mi(&cs4280_hw_if, sc, &sc->sc_dev); + +#if NMIDI > 0 + midi_attach_mi(&cs4280_midi_hw_if, sc, &sc->sc_dev); +#endif + sc->sc_suspend = PWR_RESUME; + sc->sc_powerhook = powerhook_establish(cs4280_power, sc); +} + +void cs4280_attach(parent, self, aux) struct device *parent; struct device *self; @@ -563,7 +601,6 @@ cs4280_attach(parent, self, aux) pci_chipset_tag_t pc = pa->pa_pc; char const *intrstr; pci_intr_handle_t ih; - mixer_ctrl_t ctl; u_int32_t mem; /* Map I/O register */ @@ -614,9 +651,11 @@ cs4280_attach(parent, self, aux) printf(": %s\n", intrstr); /* Initialization */ - if(cs4280_init(sc, 1) != 0) + if (cs4280_init(sc, 1) != 0) return; + mountroothook_establish(cs4280_attachhook, sc); + /* AC 97 attachement */ sc->host_if.arg = sc; sc->host_if.attach = cs4280_attach_codec; @@ -628,30 +667,6 @@ cs4280_attach(parent, self, aux) printf("%s: ac97_attach failed\n", sc->sc_dev.dv_xname); return; } - - /* Turn mute off of DAC, CD and master volumes by default */ - ctl.type = AUDIO_MIXER_ENUM; - ctl.un.ord = 0; /* off */ - - ctl.dev = cs4280_get_portnum_by_name(sc, AudioCoutputs, - AudioNmaster, AudioNmute); - cs4280_mixer_set_port(sc, &ctl); - - ctl.dev = cs4280_get_portnum_by_name(sc, AudioCinputs, - AudioNdac, AudioNmute); - cs4280_mixer_set_port(sc, &ctl); - - ctl.dev = cs4280_get_portnum_by_name(sc, AudioCinputs, - AudioNcd, AudioNmute); - cs4280_mixer_set_port(sc, &ctl); - - audio_attach_mi(&cs4280_hw_if, sc, &sc->sc_dev); - -#if NMIDI > 0 - midi_attach_mi(&cs4280_midi_hw_if, sc, &sc->sc_dev); -#endif - sc->sc_suspend = PWR_RESUME; - sc->sc_powerhook = powerhook_establish(cs4280_power, sc); } int @@ -856,25 +871,37 @@ cs4280_download(sc, src, offset, len) return (0); } +struct BA1struct *BA1Struct; + int cs4280_download_image(sc) struct cs4280_softc *sc; { int idx, err; u_int32_t offset = 0; + static u_char *cs4280_firmware; + static size_t cs4280_firmwarelen; err = 0; + if (cs4280_firmware == NULL) { + err = loadfirmware("cs4280", &cs4280_firmware, + &cs4280_firmwarelen); + if (err) + return (err); + } + + BA1Struct = (struct BA1struct *)cs4280_firmware; + for (idx = 0; idx < BA1_MEMORY_COUNT; ++idx) { - err = cs4280_download(sc, &BA1Struct.map[offset], - BA1Struct.memory[idx].offset, - BA1Struct.memory[idx].size); + err = cs4280_download(sc, &BA1Struct->map[offset], + BA1Struct->memory[idx].offset, BA1Struct->memory[idx].size); if (err != 0) { printf("%s: load_image failed at %d\n", sc->sc_dev.dv_xname, idx); return (-1); } - offset += BA1Struct.memory[idx].size / sizeof(u_int32_t); + offset += BA1Struct->memory[idx].size / sizeof(u_int32_t); } return (err); } @@ -918,14 +945,14 @@ cs4280_check_images(sc) err = 0; /*for (idx=0; idx < BA1_MEMORY_COUNT; ++idx) { */ for (idx = 0; idx < 1; ++idx) { - err = cs4280_checkimage(sc, &BA1Struct.map[offset], - BA1Struct.memory[idx].offset, - BA1Struct.memory[idx].size); + err = cs4280_checkimage(sc, &BA1Struct->map[offset], + BA1Struct->memory[idx].offset, + BA1Struct->memory[idx].size); if (err != 0) { printf("%s: check_image failed at %d\n", sc->sc_dev.dv_xname, idx); } - offset += BA1Struct.memory[idx].size / sizeof(u_int32_t); + offset += BA1Struct->memory[idx].size / sizeof(u_int32_t); } return (err); } @@ -1701,6 +1728,16 @@ cs4280_init(sc, init) /* reset the processor */ cs4280_reset(sc); + return (0); +} + +int +cs4280_init2(sc, init) + struct cs4280_softc *sc; + int init; +{ + int n; + u_int32_t mem; /* Download the image to the processor */ if (cs4280_download_image(sc) != 0) { @@ -1809,6 +1846,7 @@ cs4280_power(why, v) } sc->sc_suspend = why; cs4280_init(sc, 0); + cs4280_init2(sc, 0); cs4280_reset_codec(sc); /* restore ac97 registers */ diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci index 85ce0be2a0b..8e9f2c0464d 100644 --- a/sys/dev/pci/files.pci +++ b/sys/dev/pci/files.pci @@ -1,4 +1,4 @@ -# $OpenBSD: files.pci,v 1.167 2004/12/17 08:04:45 jsg Exp $ +# $OpenBSD: files.pci,v 1.168 2004/12/19 16:06:23 deraadt Exp $ # $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $ # # Config file and device description for machine-independent PCI code. @@ -110,7 +110,7 @@ attach autri at pci file dev/pci/autri.c autri # CS4280 CrystalClear Audio -device clcs: audio, auconv, mulaw, ac97 +device clcs: audio, auconv, mulaw, ac97, firmload attach clcs at pci file dev/pci/cs4280.c clcs @@ -263,7 +263,7 @@ attach tl at pci file dev/pci/if_tl.c tl # 3Com 3c990 -device txp: ether, ifnet, ifmedia +device txp: ether, ifnet, ifmedia, firmload attach txp at pci file dev/pci/if_txp.c txp |