1257384Sian/*- 2257384Sian * Copyright (c) 2013 Ian Lepore <ian@freebsd.org> 3257384Sian * All rights reserved. 4257384Sian * 5257384Sian * Redistribution and use in source and binary forms, with or without 6257384Sian * modification, are permitted provided that the following conditions 7257384Sian * are met: 8257384Sian * 1. Redistributions of source code must retain the above copyright 9257384Sian * notice, this list of conditions and the following disclaimer. 10257384Sian * 2. Redistributions in binary form must reproduce the above copyright 11257384Sian * notice, this list of conditions and the following disclaimer in the 12257384Sian * documentation and/or other materials provided with the distribution. 13257384Sian * 14257384Sian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15257384Sian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16257384Sian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17257384Sian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18257384Sian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19257384Sian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20257384Sian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21257384Sian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22257384Sian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23257384Sian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24257384Sian * SUCH DAMAGE. 25257384Sian */ 26257384Sian 27257384Sian#include <sys/cdefs.h> 28257384Sian__FBSDID("$FreeBSD: releng/10.3/sys/arm/freescale/imx/imx_nop_usbphy.c 266371 2014-05-17 22:29:24Z ian $"); 29257384Sian 30257384Sian/* 31257384Sian * USBPHY "no-op" driver for Freescale family of SoCs. This driver is used on 32257384Sian * SoCs which have usbphy hardware whose clocks need to be enabled, but no other 33257384Sian * action has to be taken to make the hardware work. 34257384Sian */ 35257384Sian 36257384Sian#include "opt_bus.h" 37257384Sian 38257384Sian#include <sys/param.h> 39257384Sian#include <sys/systm.h> 40257384Sian#include <sys/kernel.h> 41257384Sian#include <sys/module.h> 42257384Sian#include <sys/bus.h> 43257384Sian#include <sys/rman.h> 44257384Sian 45257384Sian#include <dev/ofw/ofw_bus.h> 46257384Sian#include <dev/ofw/ofw_bus_subr.h> 47257384Sian 48257384Sian#include <machine/bus.h> 49257384Sian 50266371Sian#include <arm/freescale/imx/imx_ccmvar.h> 51257384Sian 52257384Sian/* 53257384Sian * Table of supported FDT compat strings. 54257384Sian */ 55257384Sianstatic struct ofw_compat_data compat_data[] = { 56257384Sian {"nop-usbphy", true}, 57257384Sian {"usb-nop-xceiv", true}, 58257384Sian {NULL, false}, 59257384Sian}; 60257384Sian 61257384Sianstruct usbphy_softc { 62257384Sian device_t dev; 63257384Sian u_int phy_num; 64257384Sian}; 65257384Sian 66257384Sianstatic int 67257384Sianusbphy_detach(device_t dev) 68257384Sian{ 69257384Sian 70257384Sian return (0); 71257384Sian} 72257384Sian 73257384Sianstatic int 74257384Sianusbphy_attach(device_t dev) 75257384Sian{ 76257384Sian struct usbphy_softc *sc; 77257384Sian 78257384Sian sc = device_get_softc(dev); 79257384Sian 80257384Sian /* 81257384Sian * Turn on the phy clocks. 82257384Sian */ 83257384Sian imx_ccm_usbphy_enable(dev); 84257384Sian 85257384Sian return (0); 86257384Sian} 87257384Sian 88257384Sianstatic int 89257384Sianusbphy_probe(device_t dev) 90257384Sian{ 91257384Sian 92266152Sian if (!ofw_bus_status_okay(dev)) 93266152Sian return (ENXIO); 94266152Sian 95257384Sian if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) { 96257384Sian device_set_desc(dev, "Freescale USB PHY"); 97257384Sian return (BUS_PROBE_DEFAULT); 98257384Sian } 99257384Sian 100257384Sian return (ENXIO); 101257384Sian} 102257384Sian 103257384Sianstatic device_method_t usbphy_methods[] = { 104257384Sian /* Device interface */ 105257384Sian DEVMETHOD(device_probe, usbphy_probe), 106257384Sian DEVMETHOD(device_attach, usbphy_attach), 107257384Sian DEVMETHOD(device_detach, usbphy_detach), 108257384Sian 109257384Sian DEVMETHOD_END 110257384Sian}; 111257384Sian 112257384Sianstatic driver_t usbphy_driver = { 113257384Sian "usbphy", 114257384Sian usbphy_methods, 115257384Sian sizeof(struct usbphy_softc) 116257384Sian}; 117257384Sian 118257384Sianstatic devclass_t usbphy_devclass; 119257384Sian 120257384SianDRIVER_MODULE(usbphy, simplebus, usbphy_driver, usbphy_devclass, 0, 0); 121257384Sian 122