1d1d3233eSRafal Jaworowski /*- 2d1d3233eSRafal Jaworowski * Copyright (c) 2006 Juniper Networks. 3d1d3233eSRafal Jaworowski * All rights reserved. 4d1d3233eSRafal Jaworowski * 5d1d3233eSRafal Jaworowski * Redistribution and use in source and binary forms, with or without 6d1d3233eSRafal Jaworowski * modification, are permitted provided that the following conditions 7d1d3233eSRafal Jaworowski * are met: 8d1d3233eSRafal Jaworowski * 1. Redistributions of source code must retain the above copyright 9d1d3233eSRafal Jaworowski * notice, this list of conditions and the following disclaimer. 10d1d3233eSRafal Jaworowski * 2. Redistributions in binary form must reproduce the above copyright 11d1d3233eSRafal Jaworowski * notice, this list of conditions and the following disclaimer in the 12d1d3233eSRafal Jaworowski * documentation and/or other materials provided with the distribution. 13d1d3233eSRafal Jaworowski * 3. The name of the author may not be used to endorse or promote products 14d1d3233eSRafal Jaworowski * derived from this software without specific prior written permission. 15d1d3233eSRafal Jaworowski * 16d1d3233eSRafal Jaworowski * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17d1d3233eSRafal Jaworowski * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18d1d3233eSRafal Jaworowski * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19d1d3233eSRafal Jaworowski * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20d1d3233eSRafal Jaworowski * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21d1d3233eSRafal Jaworowski * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22d1d3233eSRafal Jaworowski * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23d1d3233eSRafal Jaworowski * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24d1d3233eSRafal Jaworowski * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25d1d3233eSRafal Jaworowski * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26d1d3233eSRafal Jaworowski * SUCH DAMAGE. 27d1d3233eSRafal Jaworowski */ 28d1d3233eSRafal Jaworowski 29d1d3233eSRafal Jaworowski #include <sys/cdefs.h> 30d1d3233eSRafal Jaworowski __FBSDID("$FreeBSD$"); 31d1d3233eSRafal Jaworowski 32d1d3233eSRafal Jaworowski #include <sys/param.h> 33d1d3233eSRafal Jaworowski #include <sys/systm.h> 34d1d3233eSRafal Jaworowski #include <sys/bus.h> 35d1d3233eSRafal Jaworowski #include <sys/conf.h> 36d1d3233eSRafal Jaworowski #include <sys/kernel.h> 37d1d3233eSRafal Jaworowski #include <sys/lock.h> 38d1d3233eSRafal Jaworowski #include <sys/malloc.h> 39d1d3233eSRafal Jaworowski #include <sys/module.h> 40d1d3233eSRafal Jaworowski #include <sys/rman.h> 41d1d3233eSRafal Jaworowski #include <sys/tty.h> 42d1d3233eSRafal Jaworowski #include <machine/bus.h> 43d1d3233eSRafal Jaworowski 44d1d3233eSRafal Jaworowski #include <dev/ofw/ofw_bus.h> 45d1d3233eSRafal Jaworowski #include <dev/ofw/ofw_bus_subr.h> 46d1d3233eSRafal Jaworowski #include <dev/quicc/quicc_bfe.h> 47d1d3233eSRafal Jaworowski 48d1d3233eSRafal Jaworowski static int quicc_fdt_probe(device_t dev); 49d1d3233eSRafal Jaworowski 50d1d3233eSRafal Jaworowski static device_method_t quicc_fdt_methods[] = { 51d1d3233eSRafal Jaworowski /* Device interface */ 52d1d3233eSRafal Jaworowski DEVMETHOD(device_probe, quicc_fdt_probe), 53d1d3233eSRafal Jaworowski DEVMETHOD(device_attach, quicc_bfe_attach), 54d1d3233eSRafal Jaworowski DEVMETHOD(device_detach, quicc_bfe_detach), 55d1d3233eSRafal Jaworowski 56d1d3233eSRafal Jaworowski DEVMETHOD(bus_alloc_resource, quicc_bus_alloc_resource), 57d1d3233eSRafal Jaworowski DEVMETHOD(bus_release_resource, quicc_bus_release_resource), 58d1d3233eSRafal Jaworowski DEVMETHOD(bus_get_resource, quicc_bus_get_resource), 59d1d3233eSRafal Jaworowski DEVMETHOD(bus_read_ivar, quicc_bus_read_ivar), 60d1d3233eSRafal Jaworowski DEVMETHOD(bus_setup_intr, quicc_bus_setup_intr), 61d1d3233eSRafal Jaworowski DEVMETHOD(bus_teardown_intr, quicc_bus_teardown_intr), 62d1d3233eSRafal Jaworowski 63*4b7ec270SMarius Strobl DEVMETHOD_END 64d1d3233eSRafal Jaworowski }; 65d1d3233eSRafal Jaworowski 66d1d3233eSRafal Jaworowski static driver_t quicc_fdt_driver = { 67d1d3233eSRafal Jaworowski quicc_driver_name, 68d1d3233eSRafal Jaworowski quicc_fdt_methods, 69d1d3233eSRafal Jaworowski sizeof(struct quicc_softc), 70d1d3233eSRafal Jaworowski }; 71d1d3233eSRafal Jaworowski 72d1d3233eSRafal Jaworowski static int 73d1d3233eSRafal Jaworowski quicc_fdt_probe(device_t dev) 74d1d3233eSRafal Jaworowski { 75d1d3233eSRafal Jaworowski phandle_t par; 76d1d3233eSRafal Jaworowski pcell_t clock; 77d1d3233eSRafal Jaworowski 78d1d3233eSRafal Jaworowski if (!ofw_bus_is_compatible(dev, "fsl,cpm2")) 79d1d3233eSRafal Jaworowski return (ENXIO); 80d1d3233eSRafal Jaworowski 81d1d3233eSRafal Jaworowski par = OF_parent(ofw_bus_get_node(dev)); 82d1d3233eSRafal Jaworowski if (OF_getprop(par, "bus-frequency", &clock, sizeof(clock)) <= 0) 83d1d3233eSRafal Jaworowski clock = 0; 84d1d3233eSRafal Jaworowski 85d1d3233eSRafal Jaworowski return (quicc_bfe_probe(dev, (uintptr_t)clock)); 86d1d3233eSRafal Jaworowski } 87d1d3233eSRafal Jaworowski 88d1d3233eSRafal Jaworowski DRIVER_MODULE(quicc, simplebus, quicc_fdt_driver, quicc_devclass, 0, 0); 89