Path: blob/main/sys/arm/ti/am335x/am335x_usb_phy.c
39536 views
/*-1*2* Copyright (c) 2020 Oskar Holmlund <[email protected]>3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR14* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES15* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,17* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,18* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;19* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED20* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,21* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#include <sys/param.h>27#include <sys/systm.h>28#include <sys/bus.h>29#include <sys/fbio.h>30#include <sys/kernel.h>31#include <sys/module.h>32#include <sys/rman.h>33#include <sys/resource.h>34#include <machine/bus.h>35#include <vm/vm.h>36#include <vm/vm_extern.h>37#include <vm/vm_kern.h>38#include <vm/pmap.h>3940#include <dev/fdt/simplebus.h>4142#include <dev/ofw/ofw_bus.h>43#include <dev/ofw/ofw_bus_subr.h>4445#define TI_AM335X_USB_PHY 146#define TI_AM335X_USB_PHY_END 04748static struct ofw_compat_data compat_data[] = {49{ "ti,am335x-usb-phy", TI_AM335X_USB_PHY },50{ NULL, TI_AM335X_USB_PHY_END }51};5253struct ti_usb_phy_softc {54device_t dev;55};5657static int ti_usb_phy_probe(device_t dev);58static int ti_usb_phy_attach(device_t dev);59static int ti_usb_phy_detach(device_t dev);6061static int62ti_usb_phy_probe(device_t dev)63{64if (!ofw_bus_status_okay(dev))65return (ENXIO);6667if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)68return (ENXIO);6970device_set_desc(dev, "TI AM335x USB PHY");71if (!bootverbose)72device_quiet(dev);7374return (BUS_PROBE_DEFAULT);75}7677static int78ti_usb_phy_attach(device_t dev)79{80struct ti_usb_phy_softc *sc;8182sc = device_get_softc(dev);83sc->dev = dev;8485/* FIXME: Add dev/phy/ interface */8687bus_attach_children(dev);88return (0);89}9091static int92ti_usb_phy_detach(device_t dev)93{94return (EBUSY);95}9697static device_method_t ti_usb_phy_methods[] = {98/* Device interface */99DEVMETHOD(device_probe, ti_usb_phy_probe),100DEVMETHOD(device_attach, ti_usb_phy_attach),101DEVMETHOD(device_detach, ti_usb_phy_detach),102103DEVMETHOD_END104};105106DEFINE_CLASS_1(ti_usb_phy, ti_usb_phy_driver, ti_usb_phy_methods,107sizeof(struct ti_usb_phy_softc), simplebus_driver);108109EARLY_DRIVER_MODULE(ti_usb_phy, simplebus, ti_usb_phy_driver, 0, 0,110BUS_PASS_BUS + BUS_PASS_ORDER_FIRST);111MODULE_VERSION(ti_usb_phy, 1);112MODULE_DEPEND(ti_usb_phy, ti_sysc, 1, 1, 1);113114115