3 * Copyright (c) 2020 Oskar Holmlund <oskar.holmlund@ohdata.se>
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 ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
21 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 * 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
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
33 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/module.h>
39 #include <sys/resource.h>
40 #include <machine/bus.h>
42 #include <vm/vm_extern.h>
43 #include <vm/vm_kern.h>
46 #include <dev/fdt/simplebus.h>
48 #include <dev/ofw/ofw_bus.h>
49 #include <dev/ofw/ofw_bus_subr.h>
51 #define TI_AM335X_USB_PHY 1
52 #define TI_AM335X_USB_PHY_END 0
54 static struct ofw_compat_data compat_data[] = {
55 { "ti,am335x-usb-phy", TI_AM335X_USB_PHY },
56 { NULL, TI_AM335X_USB_PHY_END }
59 struct ti_usb_phy_softc {
63 static int ti_usb_phy_probe(device_t dev);
64 static int ti_usb_phy_attach(device_t dev);
65 static int ti_usb_phy_detach(device_t dev);
68 ti_usb_phy_probe(device_t dev)
70 if (!ofw_bus_status_okay(dev))
73 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
76 device_set_desc(dev, "TI AM335x USB PHY");
80 return (BUS_PROBE_DEFAULT);
84 ti_usb_phy_attach(device_t dev)
86 struct ti_usb_phy_softc *sc;
89 sc = device_get_softc(dev);
91 node = ofw_bus_get_node(dev);
93 /* FIXME: Add dev/extres/phy/ interface */
95 return (bus_generic_attach(dev));
99 ti_usb_phy_detach(device_t dev)
104 static device_method_t ti_usb_phy_methods[] = {
105 /* Device interface */
106 DEVMETHOD(device_probe, ti_usb_phy_probe),
107 DEVMETHOD(device_attach, ti_usb_phy_attach),
108 DEVMETHOD(device_detach, ti_usb_phy_detach),
113 DEFINE_CLASS_1(ti_usb_phy, ti_usb_phy_driver, ti_usb_phy_methods,
114 sizeof(struct ti_usb_phy_softc), simplebus_driver);
116 static devclass_t ti_usb_phy_devclass;
118 EARLY_DRIVER_MODULE(ti_usb_phy, simplebus, ti_usb_phy_driver,
119 ti_usb_phy_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_FIRST);
120 MODULE_VERSION(ti_usb_phy, 1);
121 MODULE_DEPEND(ti_usb_phy, ti_sysc, 1, 1, 1);