1 /* $NetBSD: iic_eumb.c,v 1.20 2022/07/22 23:43:24 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 2010,2011 Frank Wille. 5 * All rights reserved. 6 * 7 * Written by Frank Wille for The NetBSD Project. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #include <sys/cdefs.h> 32 __KERNEL_RCSID(0, "$NetBSD: iic_eumb.c,v 1.20 2022/07/22 23:43:24 thorpej Exp $"); 33 34 #include <sys/param.h> 35 #include <sys/device.h> 36 37 #include <sys/bus.h> 38 #include <dev/i2c/motoi2cvar.h> 39 #include <sandpoint/sandpoint/eumbvar.h> 40 41 static int iic_eumb_match(device_t, cfdata_t, void *); 42 static void iic_eumb_attach(device_t, device_t, void *); 43 44 CFATTACH_DECL_NEW(iic_eumb, sizeof(struct motoi2c_softc), 45 iic_eumb_match, iic_eumb_attach, NULL, NULL); 46 47 static int found; 48 49 static int 50 iic_eumb_match(device_t parent, cfdata_t cf, void *aux) 51 { 52 53 return found == 0; 54 } 55 56 static void 57 iic_eumb_attach(device_t parent, device_t self, void *aux) 58 { 59 struct motoi2c_softc *sc = device_private(self); 60 struct eumb_attach_args *eaa = aux; 61 bus_space_handle_t ioh; 62 63 sc->sc_dev = self; 64 found = 1; 65 66 aprint_naive("\n"); 67 aprint_normal("\n"); 68 69 /* 70 * map EUMB registers and attach MI motoi2c with default settings 71 */ 72 bus_space_map(eaa->eumb_bt, 0x3000, 0x20, 0, &ioh); 73 sc->sc_iot = eaa->eumb_bt; 74 sc->sc_ioh = ioh; 75 motoi2c_attach(sc, NULL); 76 } 77