11.1Sphx/* $NetBSD: zz9k_usb.c,v 1.1 2023/05/03 13:49:30 phx Exp $ */ 21.1Sphx 31.1Sphx/* 41.1Sphx * Copyright (c) 2020 The NetBSD Foundation, Inc. 51.1Sphx * All rights reserved. 61.1Sphx * 71.1Sphx * This code is derived from software contributed to The NetBSD Foundation 81.1Sphx * by Alain Runa. 91.1Sphx * 101.1Sphx * Redistribution and use in source and binary forms, with or without 111.1Sphx * modification, are permitted provided that the following conditions 121.1Sphx * are met: 131.1Sphx * 1. Redistributions of source code must retain the above copyright 141.1Sphx * notice, this list of conditions and the following disclaimer. 151.1Sphx * 2. Redistributions in binary form must reproduce the above copyright 161.1Sphx * notice, this list of conditions and the following disclaimer in the 171.1Sphx * documentation and/or other materials provided with the distribution. 181.1Sphx * 191.1Sphx * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 201.1Sphx * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 211.1Sphx * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 221.1Sphx * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 231.1Sphx * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 241.1Sphx * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 251.1Sphx * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 261.1Sphx * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 271.1Sphx * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 281.1Sphx * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 291.1Sphx */ 301.1Sphx 311.1Sphx#include <sys/cdefs.h> 321.1Sphx__KERNEL_RCSID(0, "$NetBSD: zz9k_usb.c,v 1.1 2023/05/03 13:49:30 phx Exp $"); 331.1Sphx 341.1Sphx/* miscellaneous */ 351.1Sphx#include <sys/types.h> /* size_t */ 361.1Sphx#include <sys/stdint.h> /* uintXX_t */ 371.1Sphx#include <sys/stdbool.h> /* bool */ 381.1Sphx 391.1Sphx/* driver(9) */ 401.1Sphx#include <sys/param.h> /* NODEV */ 411.1Sphx#include <sys/device.h> /* CFATTACH_DECL_NEW(), device_priv() */ 421.1Sphx#include <sys/errno.h> /* . */ 431.1Sphx 441.1Sphx/* bus_space(9) and zorro bus */ 451.1Sphx#include <sys/bus.h> /* bus_space_xxx(), bus_space_xxx_t */ 461.1Sphx#include <sys/cpu.h> /* kvtop() */ 471.1Sphx#include <sys/systm.h> /* aprint_xxx() */ 481.1Sphx 491.1Sphx/* zz9k related */ 501.1Sphx#include <amiga/dev/zz9kvar.h> /* zz9kbus_attach_args */ 511.1Sphx#include <amiga/dev/zz9kreg.h> /* ZZ9000 registers */ 521.1Sphx#include "zz9k_usb.h" /* NZZ9K_USB */ 531.1Sphx 541.1Sphx 551.1Sphx/* The allmighty softc structure */ 561.1Sphxstruct zzusb_softc { 571.1Sphx device_t sc_dev; 581.1Sphx struct bus_space_tag sc_bst; 591.1Sphx bus_space_tag_t sc_iot; 601.1Sphx bus_space_handle_t sc_regh; 611.1Sphx}; 621.1Sphx 631.1Sphx/* driver(9) essentials */ 641.1Sphxstatic int zzusb_match(device_t parent, cfdata_t match, void *aux); 651.1Sphxstatic void zzusb_attach(device_t parent, device_t self, void *aux); 661.1SphxCFATTACH_DECL_NEW(zz9k_usb, sizeof(struct zzusb_softc), 671.1Sphx zzusb_match, zzusb_attach, NULL, NULL); 681.1Sphx 691.1Sphx 701.1Sphx/* Go ahead, make my day. */ 711.1Sphx 721.1Sphxstatic int 731.1Sphxzzusb_match(device_t parent, cfdata_t match, void *aux) 741.1Sphx{ 751.1Sphx struct zz9kbus_attach_args *bap = aux; 761.1Sphx 771.1Sphx if (strcmp(bap->zzaa_name, "zz9k_usb") != 0) 781.1Sphx return 0; 791.1Sphx 801.1Sphx return 1; 811.1Sphx} 821.1Sphx 831.1Sphxstatic void 841.1Sphxzzusb_attach(device_t parent, device_t self, void *aux) 851.1Sphx{ 861.1Sphx struct zz9kbus_attach_args *bap = aux; 871.1Sphx struct zzusb_softc *sc = device_private(self); 881.1Sphx struct zzusb_softc *psc = device_private(parent); 891.1Sphx 901.1Sphx sc->sc_dev = self; 911.1Sphx sc->sc_bst.base = bap->zzaa_base; 921.1Sphx sc->sc_bst.absm = &amiga_bus_stride_1; 931.1Sphx sc->sc_iot = &sc->sc_bst; 941.1Sphx sc->sc_regh = psc->sc_regh; 951.1Sphx 961.1Sphx uint16_t capacity = ZZREG_R(ZZ9K_USB_CAPACITY); 971.1Sphx aprint_normal(": USB device %sdetected.\n", 981.1Sphx (capacity == 0) ? "not " : ""); 991.1Sphx aprint_normal_dev (sc->sc_dev, 1001.1Sphx "MNT ZZ9000 USB driver is not implemented yet.\n"); 1011.1Sphx 1021.1Sphx aprint_debug_dev(sc->sc_dev, "[DEBUG] registers at %p/%p (pa/va)\n", 1031.1Sphx (void *)kvtop((void *)sc->sc_regh), 1041.1Sphx bus_space_vaddr(sc->sc_iot, sc->sc_regh)); 1051.1Sphx 1061.1Sphx /* to be implemented */ 1071.1Sphx} 108