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