1298498Ssgalabov/*- 2298498Ssgalabov * Copyright (c) 2016 Stanislav Galabov. 3298498Ssgalabov * All rights reserved. 4298498Ssgalabov * 5298498Ssgalabov * Redistribution and use in source and binary forms, with or without 6298498Ssgalabov * modification, are permitted provided that the following conditions 7298498Ssgalabov * are met: 8298498Ssgalabov * 1. Redistributions of source code must retain the above copyright 9298498Ssgalabov * notice, this list of conditions and the following disclaimer. 10298498Ssgalabov * 2. Redistributions in binary form must reproduce the above copyright 11298498Ssgalabov * notice, this list of conditions and the following disclaimer in the 12298498Ssgalabov * documentation and/or other materials provided with the distribution. 13298498Ssgalabov * 14298498Ssgalabov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15298498Ssgalabov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16298498Ssgalabov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17298498Ssgalabov * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18298498Ssgalabov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19298498Ssgalabov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20298498Ssgalabov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21298498Ssgalabov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22298498Ssgalabov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23298498Ssgalabov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24298498Ssgalabov * SUCH DAMAGE. 25298498Ssgalabov */ 26298498Ssgalabov 27298498Ssgalabov#include <sys/cdefs.h> 28298498Ssgalabov__FBSDID("$FreeBSD$"); 29298498Ssgalabov#include <sys/param.h> 30298498Ssgalabov#include <sys/systm.h> 31298498Ssgalabov#include <sys/module.h> 32298498Ssgalabov#include <sys/bus.h> 33298498Ssgalabov#include <sys/conf.h> 34298498Ssgalabov#include <sys/kernel.h> 35298498Ssgalabov#include <sys/rman.h> 36298498Ssgalabov 37298498Ssgalabov#include <dev/ofw/openfirm.h> 38298498Ssgalabov#include <dev/ofw/ofw_bus.h> 39298498Ssgalabov#include <dev/ofw/ofw_bus_subr.h> 40298498Ssgalabov 41298498Ssgalabov#include <dev/fdt/simplebus.h> 42298498Ssgalabov 43298498Ssgalabov/* 44298498Ssgalabov * Driver for Mediatek/Ralink Palmbus 45298498Ssgalabov * 46298498Ssgalabov * Currently the only reason for the existence of this driver is so that we can 47298498Ssgalabov * minimize the changes required to the upstream DTS files we use. 48298498Ssgalabov * Otherwise palmbus is a very simple subclass of our simplebus and the only 49298498Ssgalabov * difference between the two is the actual value of the compatible property. 50298498Ssgalabov */ 51298498Ssgalabov 52298498Ssgalabovstatic int 53298498Ssgalabovpalmbus_probe(device_t dev) 54298498Ssgalabov{ 55298498Ssgalabov 56298498Ssgalabov if (!ofw_bus_status_okay(dev)) 57298498Ssgalabov return (ENXIO); 58298498Ssgalabov 59298498Ssgalabov if (!(ofw_bus_is_compatible(dev, "palmbus") && 60298498Ssgalabov ofw_bus_has_prop(dev, "ranges")) && 61298498Ssgalabov (ofw_bus_get_type(dev) == NULL || strcmp(ofw_bus_get_type(dev), 62298498Ssgalabov "soc") != 0)) 63298498Ssgalabov return (ENXIO); 64298498Ssgalabov 65298498Ssgalabov device_set_desc(dev, "MTK Palmbus"); 66298498Ssgalabov 67298498Ssgalabov return (0); 68298498Ssgalabov} 69298498Ssgalabov 70298498Ssgalabovstatic device_method_t palmbus_methods[] = { 71298498Ssgalabov DEVMETHOD(device_probe, palmbus_probe), 72298498Ssgalabov 73298498Ssgalabov DEVMETHOD_END 74298498Ssgalabov}; 75298498Ssgalabov 76298498SsgalabovDEFINE_CLASS_1(palmbus, palmbus_driver, palmbus_methods, 77298498Ssgalabov sizeof(struct simplebus_softc), simplebus_driver); 78298498Ssgalabovstatic devclass_t palmbus_devclass; 79298498SsgalabovEARLY_DRIVER_MODULE(palmbus, ofwbus, palmbus_driver, palmbus_devclass, 0, 0, 80298498Ssgalabov BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); 81298498SsgalabovMODULE_VERSION(palmbus, 1); 82