pq3diic.c revision 1.7
11.7Sthorpej/* $NetBSD: pq3diic.c,v 1.7 2022/07/22 23:43:24 thorpej Exp $ */ 21.2Smatt/*- 31.2Smatt * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. 41.2Smatt * All rights reserved. 51.2Smatt * 61.2Smatt * This code is derived from software contributed to The NetBSD Foundation 71.2Smatt * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects 81.2Smatt * Agency and which was developed by Matt Thomas of 3am Software Foundry. 91.2Smatt * 101.2Smatt * This material is based upon work supported by the Defense Advanced Research 111.2Smatt * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under 121.2Smatt * Contract No. N66001-09-C-2073. 131.2Smatt * Approved for Public Release, Distribution Unlimited 141.2Smatt * 151.2Smatt * Redistribution and use in source and binary forms, with or without 161.2Smatt * modification, are permitted provided that the following conditions 171.2Smatt * are met: 181.2Smatt * 1. Redistributions of source code must retain the above copyright 191.2Smatt * notice, this list of conditions and the following disclaimer. 201.2Smatt * 2. Redistributions in binary form must reproduce the above copyright 211.2Smatt * notice, this list of conditions and the following disclaimer in the 221.2Smatt * documentation and/or other materials provided with the distribution. 231.2Smatt * 241.2Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 251.2Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 261.2Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 271.2Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 281.2Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 291.2Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 301.2Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 311.2Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 321.2Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 331.2Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 341.2Smatt * POSSIBILITY OF SUCH DAMAGE. 351.2Smatt */ 361.2Smatt 371.2Smatt#include <sys/cdefs.h> 381.7Sthorpej__KERNEL_RCSID(0, "$NetBSD: pq3diic.c,v 1.7 2022/07/22 23:43:24 thorpej Exp $"); 391.2Smatt 401.5Srin#include "ioconf.h" 411.3Smatt 421.2Smatt#include <sys/param.h> 431.2Smatt#include <sys/cpu.h> 441.2Smatt#include <sys/device.h> 451.2Smatt#include <sys/tty.h> 461.2Smatt 471.2Smatt#include <sys/intr.h> 481.2Smatt#include <sys/bus.h> 491.2Smatt 501.2Smatt#include <dev/i2c/i2cvar.h> 511.2Smatt 521.2Smatt#include <dev/i2c/motoi2creg.h> 531.2Smatt#include <dev/i2c/motoi2cvar.h> 541.2Smatt 551.2Smatt#include <powerpc/booke/cpuvar.h> 561.2Smatt#include <powerpc/booke/e500var.h> 571.2Smatt#include <powerpc/booke/e500reg.h> 581.2Smatt 591.2Smattstatic int pq3diic_match(device_t, cfdata_t, void *); 601.2Smattstatic void pq3diic_attach(device_t, device_t, void *); 611.2Smatt 621.7SthorpejCFATTACH_DECL_NEW(pq3diic, sizeof(struct motoi2c_softc), 631.2Smatt pq3diic_match, pq3diic_attach, NULL, NULL); 641.2Smatt 651.2Smattstatic int 661.2Smattpq3diic_match(device_t parent, cfdata_t cf, void *aux) 671.2Smatt{ 681.2Smatt 691.2Smatt if (!e500_cpunode_submatch(parent, cf, cf->cf_name, aux)) 701.2Smatt return 0; 711.2Smatt 721.2Smatt return 1; 731.2Smatt} 741.2Smatt 751.6Sthorpej#if 0 761.2Smattstatic int 771.2Smattpq3diic_intr(void *arg) 781.2Smatt{ 791.2Smatt struct pq3diic_softc * const sc = arg; 801.2Smatt 811.6Sthorpej return motoi2c_intr(&sc->sc_motoi2c); 821.2Smatt} 831.6Sthorpej#endif 841.2Smatt 851.2Smattstatic void 861.2Smattpq3diic_attach(device_t parent, device_t self, void *aux) 871.2Smatt{ 881.2Smatt struct cpunode_softc * const psc = device_private(parent); 891.7Sthorpej struct motoi2c_softc * const sc = device_private(self); 901.2Smatt struct cpunode_attach_args * const cna = aux; 911.2Smatt struct cpunode_locators * const cnl = &cna->cna_locs; 921.2Smatt int error; 931.2Smatt 941.2Smatt psc->sc_children |= cna->cna_childmask; 951.2Smatt sc->sc_dev = self; 961.2Smatt 971.6Sthorpej aprint_normal("\n"); 981.2Smatt 991.7Sthorpej sc->sc_iot = cna->cna_memt; 1001.7Sthorpej error = bus_space_map(sc->sc_iot, cnl->cnl_addr, I2C_SIZE, 1011.7Sthorpej 0, &sc->sc_ioh); 1021.6Sthorpej if (error) { 1031.6Sthorpej aprint_error_dev(self, 1041.6Sthorpej "can't map registers (error = %d)\n", error); 1051.6Sthorpej return; 1061.2Smatt } 1071.2Smatt 1081.7Sthorpej motoi2c_attach(sc, NULL); 1091.6Sthorpej 1101.6Sthorpej#if 0 1111.6Sthorpej /* 1121.6Sthorpej * XXX e500_intr.c can't handle shared interrupts, but that's 1131.6Sthorpej * XXX ok, because motoi2c doesn't support using interrupts 1141.6Sthorpej * XXX at the moment anyway. 1151.6Sthorpej */ 1161.2Smatt sc->sc_ih = intr_establish(cnl->cnl_intrs[0], IPL_VM, IST_ONCHIP, 1171.2Smatt pq3diic_intr, sc); 1181.2Smatt if (sc->sc_ih == NULL) 1191.2Smatt aprint_error_dev(self, "failed to establish interrupt %d\n", 1201.2Smatt cnl->cnl_intrs[0]); 1211.2Smatt else 1221.2Smatt aprint_normal_dev(self, "interrupting on irq %d\n", 1231.2Smatt cnl->cnl_intrs[0]); 1241.6Sthorpej#endif 1251.2Smatt} 126