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_clk_otg.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. */ /* * Ingenic JZ4780 OTG PHY clock driver. * */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> #include <sys/bus.h> #include <sys/lock.h> #include <sys/mutex.h> #include <sys/resource.h> #include <machine/bus.h> #include <mips/ingenic/jz4780_clk.h> #include <mips/ingenic/jz4780_regs.h> /* JZ4780 OTG PHY clock */ static int jz4780_clk_otg_init(struct clknode *clk, device_t dev); static int jz4780_clk_otg_recalc_freq(struct clknode *clk, uint64_t *freq); static int jz4780_clk_otg_set_freq(struct clknode *clk, uint64_t fin, uint64_t *fout, int flags, int *stop); struct jz4780_clk_otg_sc { struct mtx *clk_mtx; struct resource *clk_res; }; /* * JZ4780 OTG PHY clock methods */ static clknode_method_t jz4780_clk_otg_methods[] = { CLKNODEMETHOD(clknode_init, jz4780_clk_otg_init), CLKNODEMETHOD(clknode_recalc_freq, jz4780_clk_otg_recalc_freq), CLKNODEMETHOD(clknode_set_freq, jz4780_clk_otg_set_freq), CLKNODEMETHOD_END }; DEFINE_CLASS_1(jz4780_clk_pll, jz4780_clk_otg_class, jz4780_clk_otg_methods, sizeof(struct jz4780_clk_otg_sc), clknode_class); static int jz4780_clk_otg_init(struct clknode *clk, device_t dev) { struct jz4780_clk_otg_sc *sc; uint32_t reg; sc = clknode_get_softc(clk); CLK_LOCK(sc); /* Force the use fo the core clock */ reg = CLK_RD_4(sc, JZ_USBPCR1); reg &= ~PCR_REFCLK_M; reg |= PCR_REFCLK_CORE; CLK_WR_4(sc, JZ_USBPCR1, reg); CLK_UNLOCK(sc); clknode_init_parent_idx(clk, 0); return (0); } static const struct { uint32_t div_val; uint32_t freq; } otg_div_table[] = { { PCR_CLK_12, 12000000 }, { PCR_CLK_192, 19200000 }, { PCR_CLK_24, 24000000 }, { PCR_CLK_48, 48000000 } }; static int jz4780_clk_otg_recalc_freq(struct clknode *clk, uint64_t *freq) { struct jz4780_clk_otg_sc *sc; uint32_t reg; int i; sc = clknode_get_softc(clk); reg = CLK_RD_4(sc, JZ_USBPCR1); reg &= PCR_CLK_M; for (i = 0; i < nitems(otg_div_table); i++) if (otg_div_table[i].div_val == reg) *freq = otg_div_table[i].freq; return (0); } static int jz4780_clk_otg_set_freq(struct clknode *clk, uint64_t fin, uint64_t *fout, int flags, int *stop) { struct jz4780_clk_otg_sc *sc; uint32_t reg; int i; sc = clknode_get_softc(clk); for (i = 0; i < nitems(otg_div_table) - 1; i++) { if (*fout < (otg_div_table[i].freq + otg_div_table[i + 1].freq) / 2) break; } *fout = otg_div_table[i].freq; *stop = 1; if (flags & CLK_SET_DRYRUN) return (0); CLK_LOCK(sc); reg = CLK_RD_4(sc, JZ_USBPCR1); /* Set the calculated values */ reg &= ~PCR_CLK_M; reg |= otg_div_table[i].div_val; /* Initiate the change */ CLK_WR_4(sc, JZ_USBPCR1, reg); CLK_UNLOCK(sc); return (0); } int jz4780_clk_otg_register(struct clkdom *clkdom, struct clknode_init_def *clkdef, struct mtx *dev_mtx, struct resource *mem_res) { struct clknode *clk; struct jz4780_clk_otg_sc *sc; clk = clknode_create(clkdom, &jz4780_clk_otg_class, clkdef); if (clk == NULL) return (1); sc = clknode_get_softc(clk); sc->clk_mtx = dev_mtx; sc->clk_res = mem_res; clknode_register(clkdom, clk); return (0); }
Upload File
Create Folder