deq.c revision 1.1
11.1Smacallan/* $NetBSD: deq.c,v 1.1 2005/08/10 14:28:22 macallan Exp $ */ 21.1Smacallan 31.1Smacallan/*- 41.1Smacallan * Copyright (C) 2005 Michael Lorenz 51.1Smacallan * 61.1Smacallan * Redistribution and use in source and binary forms, with or without 71.1Smacallan * modification, are permitted provided that the following conditions 81.1Smacallan * are met: 91.1Smacallan * 1. Redistributions of source code must retain the above copyright 101.1Smacallan * notice, this list of conditions and the following disclaimer. 111.1Smacallan * 2. Redistributions in binary form must reproduce the above copyright 121.1Smacallan * notice, this list of conditions and the following disclaimer in the 131.1Smacallan * documentation and/or other materials provided with the distribution. 141.1Smacallan * 3. The name of the author may not be used to endorse or promote products 151.1Smacallan * derived from this software without specific prior written permission. 161.1Smacallan * 171.1Smacallan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 181.1Smacallan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 191.1Smacallan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 201.1Smacallan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 211.1Smacallan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 221.1Smacallan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231.1Smacallan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241.1Smacallan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251.1Smacallan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261.1Smacallan * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271.1Smacallan */ 281.1Smacallan 291.1Smacallan/* 301.1Smacallan * a dummy device to attach to OF's deq node marking the TAS3004 audio mixer / 311.1Smacallan * equalizer chip, needed by snapper 321.1Smacallan */ 331.1Smacallan 341.1Smacallan#include <sys/cdefs.h> 351.1Smacallan__KERNEL_RCSID(0, "$NetBSD: deq.c,v 1.1 2005/08/10 14:28:22 macallan Exp $"); 361.1Smacallan 371.1Smacallan#include <sys/param.h> 381.1Smacallan#include <sys/systm.h> 391.1Smacallan#include <sys/kernel.h> 401.1Smacallan#include <sys/device.h> 411.1Smacallan#include <sys/malloc.h> 421.1Smacallan 431.1Smacallan#include <uvm/uvm_extern.h> 441.1Smacallan 451.1Smacallan#include <dev/ofw/openfirm.h> 461.1Smacallan#include <dev/i2c/i2cvar.h> 471.1Smacallan 481.1Smacallan#include <machine/autoconf.h> 491.1Smacallan#include <macppc/dev/ki2cvar.h> 501.1Smacallan#include <macppc/dev/deqvar.h> 511.1Smacallan 521.1Smacallanstatic void deq_attach(struct device *, struct device *, void *); 531.1Smacallanstatic int deq_match(struct device *, struct cfdata *, void *); 541.1Smacallan 551.1SmacallanCFATTACH_DECL(deq, sizeof(struct deq_softc), 561.1Smacallan deq_match, deq_attach, NULL, NULL); 571.1Smacallan 581.1Smacallanint 591.1Smacallandeq_match(parent, cf, aux) 601.1Smacallan struct device *parent; 611.1Smacallan struct cfdata *cf; 621.1Smacallan void *aux; 631.1Smacallan{ 641.1Smacallan struct ki2c_confargs *ka = aux; 651.1Smacallan char compat[32]; 661.1Smacallan 671.1Smacallan if (strcmp(ka->ka_name, "deq") != 0) 681.1Smacallan return 0; 691.1Smacallan 701.1Smacallan memset(compat, 0, sizeof(compat)); 711.1Smacallan if(OF_getprop(ka->ka_node, "i2c-address", compat, sizeof(compat))) 721.1Smacallan return 1; 731.1Smacallan return 0; 741.1Smacallan} 751.1Smacallan 761.1Smacallanvoid 771.1Smacallandeq_attach(parent, self, aux) 781.1Smacallan struct device *parent, *self; 791.1Smacallan void *aux; 801.1Smacallan{ 811.1Smacallan struct deq_softc *sc = (struct deq_softc *)self; 821.1Smacallan struct ki2c_confargs *ka = aux; 831.1Smacallan int node; 841.1Smacallan 851.1Smacallan node = ka->ka_node; 861.1Smacallan sc->sc_node = node; 871.1Smacallan sc->sc_parent = parent; 881.1Smacallan sc->sc_address = ka->ka_addr & 0xfe; 891.1Smacallan sc->sc_i2c = ka->ka_tag; 901.1Smacallan printf(" Apple Digital Equalizer, addr %x\n", sc->sc_address); 911.1Smacallan} 92