11.1Sthorpej/* $NetBSD: gfpic_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $ */ 21.1Sthorpej 31.1Sthorpej/*- 41.1Sthorpej * Copyright (c) 2023 The NetBSD Foundation, Inc. 51.1Sthorpej * All rights reserved. 61.1Sthorpej * 71.1Sthorpej * This code is derived from software contributed to The NetBSD Foundation 81.1Sthorpej * by Jason R. Thorpe. 91.1Sthorpej * 101.1Sthorpej * Redistribution and use in source and binary forms, with or without 111.1Sthorpej * modification, are permitted provided that the following conditions 121.1Sthorpej * are met: 131.1Sthorpej * 1. Redistributions of source code must retain the above copyright 141.1Sthorpej * notice, this list of conditions and the following disclaimer. 151.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 161.1Sthorpej * notice, this list of conditions and the following disclaimer in the 171.1Sthorpej * documentation and/or other materials provided with the distribution. 181.1Sthorpej * 191.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Sthorpej * POSSIBILITY OF SUCH DAMAGE. 301.1Sthorpej */ 311.1Sthorpej 321.1Sthorpej#include <sys/cdefs.h> 331.1Sthorpej__KERNEL_RCSID(0, "$NetBSD: gfpic_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $"); 341.1Sthorpej 351.1Sthorpej#include <sys/types.h> 361.1Sthorpej#include <sys/bus.h> 371.1Sthorpej#include <sys/device.h> 381.1Sthorpej#include <sys/intr.h> 391.1Sthorpej#include <sys/systm.h> 401.1Sthorpej 411.1Sthorpej#include <virt68k/dev/mainbusvar.h> 421.1Sthorpej 431.1Sthorpej#include <dev/goldfish/gfpicvar.h> 441.1Sthorpej 451.1Sthorpejstatic const struct device_compatible_entry compat_data[] = { 461.1Sthorpej { .compat = "google,goldfish-pic" }, 471.1Sthorpej DEVICE_COMPAT_EOL 481.1Sthorpej}; 491.1Sthorpej 501.1Sthorpejstatic int 511.1Sthorpejgfpic_mainbus_match(device_t parent, cfdata_t cf, void *aux) 521.1Sthorpej{ 531.1Sthorpej struct mainbus_attach_args * const ma = aux; 541.1Sthorpej 551.1Sthorpej return mainbus_compatible_match(ma, compat_data); 561.1Sthorpej} 571.1Sthorpej 581.1Sthorpejstatic void 591.1Sthorpejgfpic_mainbus_attach(device_t parent, device_t self, void *aux) 601.1Sthorpej{ 611.1Sthorpej struct gfpic_softc * const sc = device_private(self); 621.1Sthorpej struct mainbus_attach_args * const ma = aux; 631.1Sthorpej 641.1Sthorpej sc->sc_dev = self; 651.1Sthorpej sc->sc_bst = ma->ma_st; 661.1Sthorpej if (bus_space_map(sc->sc_bst, ma->ma_addr, ma->ma_size, 0, 671.1Sthorpej &sc->sc_bsh) != 0) { 681.1Sthorpej aprint_error(": couldn't map registers\n"); 691.1Sthorpej return; 701.1Sthorpej } 711.1Sthorpej 721.1Sthorpej gfpic_attach(sc); 731.1Sthorpej 741.1Sthorpej aprint_normal_dev(self, "interrupting at IPL %d\n", ma->ma_irq); 751.1Sthorpej intr_register_pic(self, ma->ma_irq); 761.1Sthorpej} 771.1Sthorpej 781.1SthorpejCFATTACH_DECL_NEW(gfpic_mainbus, sizeof(struct gfpic_softc), 791.1Sthorpej gfpic_mainbus_match, gfpic_mainbus_attach, NULL, NULL); 80