003 File Manager
Current Path:
/usr/src/sys/mips/ingenic
usr
/
src
/
sys
/
mips
/
ingenic
/
📁
..
📄
files.jz4780
(1.22 KB)
📄
files.x1000
(653 B)
📄
jz4780_aic.c
(16.34 KB)
📄
jz4780_aic.h
(3.86 KB)
📄
jz4780_clk.h
(3.39 KB)
📄
jz4780_clk_gen.c
(8.48 KB)
📄
jz4780_clk_otg.c
(4.42 KB)
📄
jz4780_clk_pll.c
(5.84 KB)
📄
jz4780_clock.c
(20.19 KB)
📄
jz4780_clock.h
(1.52 KB)
📄
jz4780_codec.c
(8.15 KB)
📄
jz4780_codec.h
(5.32 KB)
📄
jz4780_common.h
(1.72 KB)
📄
jz4780_cpuregs.h
(3.04 KB)
📄
jz4780_dme.c
(3.28 KB)
📄
jz4780_dwc_fdt.c
(5.13 KB)
📄
jz4780_efuse.c
(5.48 KB)
📄
jz4780_ehci.c
(8.31 KB)
📄
jz4780_gpio.c
(20.2 KB)
📄
jz4780_gpio_if.m
(1.53 KB)
📄
jz4780_intr.c
(8.03 KB)
📄
jz4780_lcd.c
(13.77 KB)
📄
jz4780_lcd.h
(6.31 KB)
📄
jz4780_machdep.c
(6 KB)
📄
jz4780_mmc.c
(25.45 KB)
📄
jz4780_mp.c
(4.21 KB)
📄
jz4780_mpboot.S
(1.62 KB)
📄
jz4780_nand.c
(3.28 KB)
📄
jz4780_nemc.c
(10.2 KB)
📄
jz4780_ohci.c
(8.4 KB)
📄
jz4780_pdma.c
(12.54 KB)
📄
jz4780_pdma.h
(5.12 KB)
📄
jz4780_pinctrl.c
(6.51 KB)
📄
jz4780_pinctrl.h
(1.48 KB)
📄
jz4780_regs.h
(30.75 KB)
📄
jz4780_rtc.c
(5.57 KB)
📄
jz4780_smb.c
(11.34 KB)
📄
jz4780_smb.h
(3.06 KB)
📄
jz4780_timer.c
(8.61 KB)
📄
jz4780_uart.c
(5.83 KB)
Editing: jz4780_dwc_fdt.c
/* * Copyright 2015 Alexander Kabaev <kan@FreeBSD.org>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/kernel.h> #include <sys/bus.h> #include <sys/callout.h> #include <sys/condvar.h> #include <sys/module.h> #include <dev/extres/clk/clk.h> #include <dev/ofw/ofw_bus_subr.h> #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> #include <dev/usb/usb_busdma.h> #include <dev/usb/usb_process.h> #include <dev/usb/usb_controller.h> #include <dev/usb/usb_bus.h> #include <dev/usb/controller/dwc_otg.h> #include <dev/usb/controller/dwc_otg_fdt.h> #include <mips/ingenic/jz4780_clock.h> #include <mips/ingenic/jz4780_regs.h> static device_probe_t jz4780_dwc_otg_probe; static device_attach_t jz4780_dwc_otg_attach; static device_detach_t jz4780_dwc_otg_detach; struct jz4780_dwc_otg_softc { struct dwc_otg_fdt_softc base; /* storage for DWC OTG code */ clk_t phy_clk; clk_t otg_clk; }; static int jz4780_dwc_otg_clk_enable(device_t dev) { struct jz4780_dwc_otg_softc *sc; int err; sc = device_get_softc(dev); /* Configure and enable phy clock */ err = clk_get_by_ofw_name(dev, 0, "otg_phy", &sc->phy_clk); if (err != 0) { device_printf(dev, "unable to lookup %s clock\n", "otg_phy"); return (err); } err = clk_set_freq(sc->phy_clk, 48000000, 0); if (err != 0) { device_printf(dev, "unable to set %s clock to 48 kHZ\n", "otg_phy"); return (err); } err = clk_enable(sc->phy_clk); if (err != 0) { device_printf(dev, "unable to enable %s clock\n", "otg_phy"); return (err); } /* Configure and enable otg1 clock */ err = clk_get_by_ofw_name(dev, 0, "otg1", &sc->otg_clk); if (err != 0) { device_printf(dev, "unable to lookup %s clock\n", "otg1"); return (err); } err = clk_enable(sc->phy_clk); if (err != 0) { device_printf(dev, "unable to enable %s clock\n", "otg1"); return (err); } return (0); } static int jz4780_dwc_otg_probe(device_t dev) { if (!ofw_bus_status_okay(dev)) return (ENXIO); if (!ofw_bus_is_compatible(dev, "ingenic,jz4780-otg")) return (ENXIO); device_set_desc(dev, "DWC OTG 2.0 integrated USB controller (jz4780)"); return (BUS_PROBE_VENDOR); } static int jz4780_dwc_otg_attach(device_t dev) { struct jz4780_dwc_otg_softc *sc; struct resource *res; int err, rid; sc = device_get_softc(dev); err = jz4780_dwc_otg_clk_enable(dev); if (err != 0) goto fail; err = jz4780_otg_enable(); if (err != 0) { device_printf(dev, "CGU failed to enable OTG\n"); goto fail; } /* Voodoo: Switch off VBUS overcurrent detection in OTG PHY */ res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (res != NULL) { uint32_t reg; reg = bus_read_4(res, JZ_DWC2_GUSBCFG); reg |= 0xc; bus_write_4(res, JZ_DWC2_GUSBCFG, reg); bus_release_resource(dev, SYS_RES_MEMORY, rid, res); } sc->base.sc_otg.sc_phy_type = DWC_OTG_PHY_UTMI; sc->base.sc_otg.sc_phy_bits = 16; err = dwc_otg_attach(dev); if (err != 0) goto fail; return (0); fail: if (sc->otg_clk) clk_release(sc->otg_clk); if (sc->phy_clk) clk_release(sc->phy_clk); return (err); } static int jz4780_dwc_otg_detach(device_t dev) { struct jz4780_dwc_otg_softc *sc; int err; err = dwc_otg_detach(dev); if (err != 0) return (err); sc = device_get_softc(dev); if (sc->otg_clk) clk_release(sc->otg_clk); if (sc->phy_clk) clk_release(sc->phy_clk); return (0); } static device_method_t jz4780_dwc_otg_methods[] = { /* bus interface */ DEVMETHOD(device_probe, jz4780_dwc_otg_probe), DEVMETHOD(device_attach, jz4780_dwc_otg_attach), DEVMETHOD(device_detach, jz4780_dwc_otg_detach), DEVMETHOD_END }; static devclass_t jz4780_dwc_otg_devclass; DEFINE_CLASS_1(jzotg, jz4780_dwc_otg_driver, jz4780_dwc_otg_methods, sizeof(struct jz4780_dwc_otg_softc), dwc_otg_driver); DRIVER_MODULE(jzotg, simplebus, jz4780_dwc_otg_driver, jz4780_dwc_otg_devclass, 0, 0); MODULE_DEPEND(jzotg, usb, 1, 1, 1);
Upload File
Create Folder