1ffc08b21SMarcel Moolenaar /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 4ffc08b21SMarcel Moolenaar * Copyright (c) 2006 Marcel Moolenaar 5ffc08b21SMarcel Moolenaar * All rights reserved. 6ffc08b21SMarcel Moolenaar * 7ffc08b21SMarcel Moolenaar * Redistribution and use in source and binary forms, with or without 8ffc08b21SMarcel Moolenaar * modification, are permitted provided that the following conditions 9ffc08b21SMarcel Moolenaar * are met: 10ffc08b21SMarcel Moolenaar * 11ffc08b21SMarcel Moolenaar * 1. Redistributions of source code must retain the above copyright 12ffc08b21SMarcel Moolenaar * notice, this list of conditions and the following disclaimer. 13ffc08b21SMarcel Moolenaar * 2. Redistributions in binary form must reproduce the above copyright 14ffc08b21SMarcel Moolenaar * notice, this list of conditions and the following disclaimer in the 15ffc08b21SMarcel Moolenaar * documentation and/or other materials provided with the distribution. 16ffc08b21SMarcel Moolenaar * 17ffc08b21SMarcel Moolenaar * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18ffc08b21SMarcel Moolenaar * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19ffc08b21SMarcel Moolenaar * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20ffc08b21SMarcel Moolenaar * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21ffc08b21SMarcel Moolenaar * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22ffc08b21SMarcel Moolenaar * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23ffc08b21SMarcel Moolenaar * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24ffc08b21SMarcel Moolenaar * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25ffc08b21SMarcel Moolenaar * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26ffc08b21SMarcel Moolenaar * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27ffc08b21SMarcel Moolenaar */ 28ffc08b21SMarcel Moolenaar 29ffc08b21SMarcel Moolenaar #include <sys/cdefs.h> 30ffc08b21SMarcel Moolenaar __FBSDID("$FreeBSD$"); 31ffc08b21SMarcel Moolenaar 32ffc08b21SMarcel Moolenaar #include <sys/param.h> 33ffc08b21SMarcel Moolenaar #include <sys/systm.h> 34ffc08b21SMarcel Moolenaar #include <sys/bus.h> 35ffc08b21SMarcel Moolenaar #include <sys/conf.h> 36ffc08b21SMarcel Moolenaar #include <sys/kernel.h> 37ffc08b21SMarcel Moolenaar #include <sys/module.h> 38ffc08b21SMarcel Moolenaar 39ffc08b21SMarcel Moolenaar #include <dev/ofw/ofw_bus.h> 40ffc08b21SMarcel Moolenaar 41ffc08b21SMarcel Moolenaar #include <machine/bus.h> 42ffc08b21SMarcel Moolenaar #include <sys/rman.h> 43ffc08b21SMarcel Moolenaar #include <machine/resource.h> 44ffc08b21SMarcel Moolenaar 45ffc08b21SMarcel Moolenaar #include <dev/scc/scc_bfe.h> 46ffc08b21SMarcel Moolenaar 47ffc08b21SMarcel Moolenaar #define MACIO_REGSHFT 4 48ffc08b21SMarcel Moolenaar #define MACIO_RCLK 230400 49ffc08b21SMarcel Moolenaar 50ffc08b21SMarcel Moolenaar static int 51ffc08b21SMarcel Moolenaar scc_macio_probe(device_t dev) 52ffc08b21SMarcel Moolenaar { 53ffc08b21SMarcel Moolenaar struct scc_softc *sc; 54ffc08b21SMarcel Moolenaar const char *nm; 55ffc08b21SMarcel Moolenaar 56ffc08b21SMarcel Moolenaar sc = device_get_softc(dev); 57ffc08b21SMarcel Moolenaar nm = ofw_bus_get_name(dev); 58a4ec123cSBrandon Bergren /* Attach to modern escc (channel shift 4 bits) */ 59ffc08b21SMarcel Moolenaar if (!strcmp(nm, "escc")) { 60ffc08b21SMarcel Moolenaar device_set_desc(dev, "Zilog Z8530 dual channel SCC"); 61a4ec123cSBrandon Bergren sc->sc_class = &scc_z8530_escc_class; 62cad72a80SMarcel Moolenaar return (scc_bfe_probe(dev, MACIO_REGSHFT, MACIO_RCLK, 0)); 63ffc08b21SMarcel Moolenaar } 64ffc08b21SMarcel Moolenaar return (ENXIO); 65ffc08b21SMarcel Moolenaar } 66ffc08b21SMarcel Moolenaar 676239f9e5SMarcel Moolenaar static int 686239f9e5SMarcel Moolenaar scc_macio_attach(device_t dev) 696239f9e5SMarcel Moolenaar { 706239f9e5SMarcel Moolenaar 716239f9e5SMarcel Moolenaar return (scc_bfe_attach(dev, 3)); 726239f9e5SMarcel Moolenaar } 736239f9e5SMarcel Moolenaar 74ffc08b21SMarcel Moolenaar static device_method_t scc_macio_methods[] = { 75ffc08b21SMarcel Moolenaar /* Device interface */ 76ffc08b21SMarcel Moolenaar DEVMETHOD(device_probe, scc_macio_probe), 776239f9e5SMarcel Moolenaar DEVMETHOD(device_attach, scc_macio_attach), 78ffc08b21SMarcel Moolenaar DEVMETHOD(device_detach, scc_bfe_detach), 79ffc08b21SMarcel Moolenaar 80ffc08b21SMarcel Moolenaar DEVMETHOD(bus_alloc_resource, scc_bus_alloc_resource), 81ffc08b21SMarcel Moolenaar DEVMETHOD(bus_release_resource, scc_bus_release_resource), 82ffc08b21SMarcel Moolenaar DEVMETHOD(bus_get_resource, scc_bus_get_resource), 83ffc08b21SMarcel Moolenaar DEVMETHOD(bus_read_ivar, scc_bus_read_ivar), 84ffc08b21SMarcel Moolenaar DEVMETHOD(bus_setup_intr, scc_bus_setup_intr), 85ffc08b21SMarcel Moolenaar DEVMETHOD(bus_teardown_intr, scc_bus_teardown_intr), 864b7ec270SMarius Strobl 874b7ec270SMarius Strobl DEVMETHOD_END 88ffc08b21SMarcel Moolenaar }; 89ffc08b21SMarcel Moolenaar 90ffc08b21SMarcel Moolenaar static driver_t scc_macio_driver = { 91ffc08b21SMarcel Moolenaar scc_driver_name, 92ffc08b21SMarcel Moolenaar scc_macio_methods, 93ffc08b21SMarcel Moolenaar sizeof(struct scc_softc), 94ffc08b21SMarcel Moolenaar }; 95ffc08b21SMarcel Moolenaar 9676979b62SJohn Baldwin DRIVER_MODULE(scc, macio, scc_macio_driver, NULL, NULL); 97