2 * Copyright (c) 2015 Ganbold Tsagaankhuu <ganbold@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <sys/param.h>
31 #include <sys/systm.h>
33 #include <sys/kernel.h>
34 #include <sys/module.h>
36 #include <machine/bus.h>
38 #include <dev/dwc/if_dwc.h>
39 #include <dev/dwc/if_dwcvar.h>
40 #include <dev/ofw/ofw_bus.h>
41 #include <dev/ofw/ofw_bus_subr.h>
43 #include "if_dwc_if.h"
46 aml8726_if_dwc_probe(device_t dev)
49 if (!ofw_bus_status_okay(dev))
51 if (!ofw_bus_is_compatible(dev, "amlogic,meson6-dwmac"))
53 device_set_desc(dev, "Amlogic Meson Gigabit Ethernet Controller");
55 return (BUS_PROBE_DEFAULT);
59 aml8726_if_dwc_init(device_t dev)
66 aml8726_if_dwc_mac_type(device_t dev)
69 return (DWC_GMAC_ALT_DESC);
73 aml8726_if_dwc_mii_clk(device_t dev)
76 return (GMAC_MII_CLK_100_150M_DIV62);
79 static device_method_t aml8726_dwc_methods[] = {
80 DEVMETHOD(device_probe, aml8726_if_dwc_probe),
82 DEVMETHOD(if_dwc_init, aml8726_if_dwc_init),
83 DEVMETHOD(if_dwc_mac_type, aml8726_if_dwc_mac_type),
84 DEVMETHOD(if_dwc_mii_clk, aml8726_if_dwc_mii_clk),
89 static devclass_t aml8726_dwc_devclass;
91 extern driver_t dwc_driver;
93 DEFINE_CLASS_1(dwc, aml8726_dwc_driver, aml8726_dwc_methods,
94 sizeof(struct dwc_softc), dwc_driver);
95 DRIVER_MODULE(aml8726_dwc, simplebus, aml8726_dwc_driver,
96 aml8726_dwc_devclass, 0, 0);
98 MODULE_DEPEND(aml8726_dwc, dwc, 1, 1, 1);