1291683Sganbold/*- 2291683Sganbold * Copyright (c) 2015 Ganbold Tsagaankhuu <ganbold@FreeBSD.org> 3291683Sganbold * All rights reserved. 4291683Sganbold * 5291683Sganbold * Redistribution and use in source and binary forms, with or without 6291683Sganbold * modification, are permitted provided that the following conditions 7291683Sganbold * are met: 8291683Sganbold * 1. Redistributions of source code must retain the above copyright 9291683Sganbold * notice, this list of conditions and the following disclaimer. 10291683Sganbold * 2. Redistributions in binary form must reproduce the above copyright 11291683Sganbold * notice, this list of conditions and the following disclaimer in the 12291683Sganbold * documentation and/or other materials provided with the distribution. 13291683Sganbold * 14291683Sganbold * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15291683Sganbold * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16291683Sganbold * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17291683Sganbold * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18291683Sganbold * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19291683Sganbold * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20291683Sganbold * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21291683Sganbold * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22291683Sganbold * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23291683Sganbold * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24291683Sganbold * SUCH DAMAGE. 25291683Sganbold */ 26291683Sganbold 27291683Sganbold#include <sys/cdefs.h> 28291683Sganbold__FBSDID("$FreeBSD$"); 29291683Sganbold 30291683Sganbold#include <sys/param.h> 31291683Sganbold#include <sys/systm.h> 32291683Sganbold#include <sys/bus.h> 33291683Sganbold#include <sys/kernel.h> 34291683Sganbold#include <sys/module.h> 35291683Sganbold 36291683Sganbold#include <machine/bus.h> 37291683Sganbold 38291683Sganbold#include <dev/dwc/if_dwc.h> 39291683Sganbold#include <dev/dwc/if_dwcvar.h> 40291683Sganbold#include <dev/ofw/ofw_bus.h> 41291683Sganbold#include <dev/ofw/ofw_bus_subr.h> 42291683Sganbold 43291683Sganbold#include "if_dwc_if.h" 44291683Sganbold 45291683Sganboldstatic int 46291683Sganboldaml8726_if_dwc_probe(device_t dev) 47291683Sganbold{ 48291683Sganbold 49291683Sganbold if (!ofw_bus_status_okay(dev)) 50291683Sganbold return (ENXIO); 51291683Sganbold if (!ofw_bus_is_compatible(dev, "amlogic,meson6-dwmac")) 52291683Sganbold return (ENXIO); 53291683Sganbold device_set_desc(dev, "Amlogic Meson Gigabit Ethernet Controller"); 54291683Sganbold 55291683Sganbold return (BUS_PROBE_DEFAULT); 56291683Sganbold} 57291683Sganbold 58291683Sganboldstatic int 59291683Sganboldaml8726_if_dwc_init(device_t dev) 60291683Sganbold{ 61291683Sganbold 62291683Sganbold return (0); 63291683Sganbold} 64291683Sganbold 65291683Sganboldstatic int 66291683Sganboldaml8726_if_dwc_mac_type(device_t dev) 67291683Sganbold{ 68291683Sganbold 69291683Sganbold return (DWC_GMAC_ALT_DESC); 70291683Sganbold} 71291683Sganbold 72291683Sganboldstatic int 73291683Sganboldaml8726_if_dwc_mii_clk(device_t dev) 74291683Sganbold{ 75291683Sganbold 76291683Sganbold return (GMAC_MII_CLK_100_150M_DIV62); 77291683Sganbold} 78291683Sganbold 79291683Sganboldstatic device_method_t aml8726_dwc_methods[] = { 80291683Sganbold DEVMETHOD(device_probe, aml8726_if_dwc_probe), 81291683Sganbold 82291683Sganbold DEVMETHOD(if_dwc_init, aml8726_if_dwc_init), 83291683Sganbold DEVMETHOD(if_dwc_mac_type, aml8726_if_dwc_mac_type), 84291683Sganbold DEVMETHOD(if_dwc_mii_clk, aml8726_if_dwc_mii_clk), 85291683Sganbold 86291683Sganbold DEVMETHOD_END 87291683Sganbold}; 88291683Sganbold 89291683Sganboldstatic devclass_t aml8726_dwc_devclass; 90291683Sganbold 91291683Sganboldextern driver_t dwc_driver; 92291683Sganbold 93291683SganboldDEFINE_CLASS_1(dwc, aml8726_dwc_driver, aml8726_dwc_methods, 94291683Sganbold sizeof(struct dwc_softc), dwc_driver); 95291683SganboldDRIVER_MODULE(aml8726_dwc, simplebus, aml8726_dwc_driver, 96291683Sganbold aml8726_dwc_devclass, 0, 0); 97291683Sganbold 98291683SganboldMODULE_DEPEND(aml8726_dwc, dwc, 1, 1, 1); 99