Path: blob/main/sys/arm/nvidia/tegra124/tegra124_car.h
39536 views
/*-1* Copyright (c) 2016 Michal Meloun <[email protected]>2* All rights reserved.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 AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, 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#ifndef _TEGRA124_CAR_27#define _TEGRA124_CAR_2829#include "clkdev_if.h"3031#define RD4(sc, reg, val) CLKDEV_READ_4((sc)->clkdev, reg, val)32#define WR4(sc, reg, val) CLKDEV_WRITE_4((sc)->clkdev, reg, val)33#define MD4(sc, reg, mask, set) CLKDEV_MODIFY_4((sc)->clkdev, reg, mask, set)34#define DEVICE_LOCK(sc) CLKDEV_DEVICE_LOCK((sc)->clkdev)35#define DEVICE_UNLOCK(sc) CLKDEV_DEVICE_UNLOCK((sc)->clkdev)3637#define RST_DEVICES_L 0x00438#define RST_DEVICES_H 0x00839#define RST_DEVICES_U 0x00C40#define CLK_OUT_ENB_L 0x01041#define CLK_OUT_ENB_H 0x01442#define CLK_OUT_ENB_U 0x01843#define CCLK_BURST_POLICY 0x02044#define SUPER_CCLK_DIVIDER 0x02445#define SCLK_BURST_POLICY 0x02846#define SUPER_SCLK_DIVIDER 0x02c47#define CLK_SYSTEM_RATE 0x0304849#define OSC_CTRL 0x05050#define OSC_CTRL_OSC_FREQ_SHIFT 2851#define OSC_CTRL_PLL_REF_DIV_SHIFT 265253#define PLLE_SS_CNTL 0x06854#define PLLE_SS_CNTL_SSCINCINTRV_MASK (0x3f << 24)55#define PLLE_SS_CNTL_SSCINCINTRV_VAL (0x20 << 24)56#define PLLE_SS_CNTL_SSCINC_MASK (0xff << 16)57#define PLLE_SS_CNTL_SSCINC_VAL (0x1 << 16)58#define PLLE_SS_CNTL_SSCINVERT (1 << 15)59#define PLLE_SS_CNTL_SSCCENTER (1 << 14)60#define PLLE_SS_CNTL_SSCBYP (1 << 12)61#define PLLE_SS_CNTL_INTERP_RESET (1 << 11)62#define PLLE_SS_CNTL_BYPASS_SS (1 << 10)63#define PLLE_SS_CNTL_SSCMAX_MASK 0x1ff64#define PLLE_SS_CNTL_SSCMAX_VAL 0x2565#define PLLE_SS_CNTL_DISABLE (PLLE_SS_CNTL_BYPASS_SS | \66PLLE_SS_CNTL_INTERP_RESET | \67PLLE_SS_CNTL_SSCBYP)68#define PLLE_SS_CNTL_COEFFICIENTS_MASK (PLLE_SS_CNTL_SSCMAX_MASK | \69PLLE_SS_CNTL_SSCINC_MASK | \70PLLE_SS_CNTL_SSCINCINTRV_MASK)71#define PLLE_SS_CNTL_COEFFICIENTS_VAL (PLLE_SS_CNTL_SSCMAX_VAL | \72PLLE_SS_CNTL_SSCINC_VAL | \73PLLE_SS_CNTL_SSCINCINTRV_VAL)7475#define PLLC_BASE 0x08076#define PLLC_OUT 0x08477#define PLLC_MISC2 0x08878#define PLLC_MISC 0x08c79#define PLLM_BASE 0x09080#define PLLM_OUT 0x09481#define PLLM_MISC 0x09c82#define PLLP_BASE 0x0a083#define PLLP_MISC 0x0ac84#define PLLP_OUTA 0x0a485#define PLLP_OUTB 0x0a886#define PLLA_BASE 0x0b087#define PLLA_OUT 0x0b488#define PLLA_MISC 0x0bc89#define PLLU_BASE 0x0c090#define PLLU_MISC 0x0cc91#define PLLD_BASE 0x0d092#define PLLD_MISC 0x0dc93#define PLLX_BASE 0x0e094#define PLLX_MISC 0x0e495#define PLLE_BASE 0x0e896#define PLLE_BASE_LOCK_OVERRIDE (1 << 29)97#define PLLE_BASE_DIVCML_SHIFT 2498#define PLLE_BASE_DIVCML_MASK 0xf99100#define PLLE_MISC 0x0ec101#define PLLE_MISC_SETUP_BASE_SHIFT 16102#define PLLE_MISC_SETUP_BASE_MASK (0xffff << PLLE_MISC_SETUP_BASE_SHIFT)103#define PLLE_MISC_READY (1 << 15)104#define PLLE_MISC_IDDQ_SWCTL (1 << 14)105#define PLLE_MISC_IDDQ_OVERRIDE_VALUE (1 << 13)106#define PLLE_MISC_LOCK (1 << 11)107#define PLLE_MISC_REF_ENABLE (1 << 10)108#define PLLE_MISC_LOCK_ENABLE (1 << 9)109#define PLLE_MISC_PTS (1 << 8)110#define PLLE_MISC_VREG_BG_CTRL_SHIFT 4111#define PLLE_MISC_VREG_BG_CTRL_MASK (3 << PLLE_MISC_VREG_BG_CTRL_SHIFT)112#define PLLE_MISC_VREG_CTRL_SHIFT 2113#define PLLE_MISC_VREG_CTRL_MASK (2 << PLLE_MISC_VREG_CTRL_SHIFT)114115#define CLK_SOURCE_I2S1 0x100116#define CLK_SOURCE_I2S2 0x104117#define CLK_SOURCE_SPDIF_OUT 0x108118#define CLK_SOURCE_SPDIF_IN 0x10c119#define CLK_SOURCE_PWM 0x110120#define CLK_SOURCE_SPI2 0x118121#define CLK_SOURCE_SPI3 0x11c122#define CLK_SOURCE_I2C1 0x124123#define CLK_SOURCE_I2C5 0x128124#define CLK_SOURCE_SPI1 0x134125#define CLK_SOURCE_DISP1 0x138126#define CLK_SOURCE_DISP2 0x13c127#define CLK_SOURCE_ISP 0x144128#define CLK_SOURCE_VI 0x148129#define CLK_SOURCE_SDMMC1 0x150130#define CLK_SOURCE_SDMMC2 0x154131#define CLK_SOURCE_SDMMC4 0x164132#define CLK_SOURCE_VFIR 0x168133#define CLK_SOURCE_HSI 0x174134#define CLK_SOURCE_UARTA 0x178135#define CLK_SOURCE_UARTB 0x17c136#define CLK_SOURCE_HOST1X 0x180137#define CLK_SOURCE_HDMI 0x18c138#define CLK_SOURCE_I2C2 0x198139#define CLK_SOURCE_EMC 0x19c140#define CLK_SOURCE_UARTC 0x1a0141#define CLK_SOURCE_VI_SENSOR 0x1a8142#define CLK_SOURCE_SPI4 0x1b4143#define CLK_SOURCE_I2C3 0x1b8144#define CLK_SOURCE_SDMMC3 0x1bc145#define CLK_SOURCE_UARTD 0x1c0146#define CLK_SOURCE_VDE 0x1c8147#define CLK_SOURCE_OWR 0x1cc148#define CLK_SOURCE_NOR 0x1d0149#define CLK_SOURCE_CSITE 0x1d4150#define CLK_SOURCE_I2S0 0x1d8151#define CLK_SOURCE_DTV 0x1dc152#define CLK_SOURCE_MSENC 0x1f0153#define CLK_SOURCE_TSEC 0x1f4154#define CLK_SOURCE_SPARE2 0x1f8155156#define CLK_OUT_ENB_X 0x280157#define RST_DEVICES_X 0x28C158159#define RST_DEVICES_V 0x358160#define RST_DEVICES_W 0x35C161#define CLK_OUT_ENB_V 0x360162#define CLK_OUT_ENB_W 0x364163#define CCLKG_BURST_POLICY 0x368164#define SUPER_CCLKG_DIVIDER 0x36C165#define CCLKLP_BURST_POLICY 0x370166#define SUPER_CCLKLP_DIVIDER 0x374167168#define CLK_SOURCE_MSELECT 0x3b4169#define CLK_SOURCE_TSENSOR 0x3b8170#define CLK_SOURCE_I2S3 0x3bc171#define CLK_SOURCE_I2S4 0x3c0172#define CLK_SOURCE_I2C4 0x3c4173#define CLK_SOURCE_SPI5 0x3c8174#define CLK_SOURCE_SPI6 0x3cc175#define CLK_SOURCE_AUDIO 0x3d0176#define CLK_SOURCE_DAM0 0x3d8177#define CLK_SOURCE_DAM1 0x3dc178#define CLK_SOURCE_DAM2 0x3e0179#define CLK_SOURCE_HDA2CODEC_2X 0x3e4180#define CLK_SOURCE_ACTMON 0x3e8181#define CLK_SOURCE_EXTPERIPH1 0x3ec182#define CLK_SOURCE_EXTPERIPH2 0x3f0183#define CLK_SOURCE_EXTPERIPH3 0x3f4184#define CLK_SOURCE_I2C_SLOW 0x3fc185186#define CLK_SOURCE_SYS 0x400187#define CLK_SOURCE_SOR0 0x414188#define CLK_SOURCE_SATA_OOB 0x420189#define CLK_SOURCE_SATA 0x424190#define CLK_SOURCE_HDA 0x428191#define UTMIP_PLL_CFG0 0x480192#define UTMIP_PLL_CFG1 0x484193#define UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP (1 << 17)194#define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN (1 << 16)195#define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP (1 << 15)196#define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN (1 << 14)197#define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN (1 << 12)198#define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 6)199#define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)200201#define UTMIP_PLL_CFG2 0x488202#define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18)203#define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6)204#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN (1 << 4)205#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN (1 << 2)206#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN (1 << 0)207208#define PLLE_AUX 0x48c209#define PLLE_AUX_PLLRE_SEL (1 << 28)210#define PLLE_AUX_SEQ_START_STATE (1 << 25)211#define PLLE_AUX_SEQ_ENABLE (1 << 24)212#define PLLE_AUX_SS_SWCTL (1 << 6)213#define PLLE_AUX_ENABLE_SWCTL (1 << 4)214#define PLLE_AUX_USE_LOCKDET (1 << 3)215#define PLLE_AUX_PLLP_SEL (1 << 2)216217#define SATA_PLL_CFG0 0x490218#define SATA_PLL_CFG0_SEQ_START_STATE (1 << 25)219#define SATA_PLL_CFG0_SEQ_ENABLE (1 << 24)220#define SATA_PLL_CFG0_SEQ_PADPLL_PD_INPUT_VALUE (1 << 7)221#define SATA_PLL_CFG0_SEQ_LANE_PD_INPUT_VALUE (1 << 6)222#define SATA_PLL_CFG0_SEQ_RESET_INPUT_VALUE (1 << 5)223#define SATA_PLL_CFG0_SEQ_IN_SWCTL (1 << 4)224#define SATA_PLL_CFG0_PADPLL_USE_LOCKDET (1 << 2)225#define SATA_PLL_CFG0_PADPLL_RESET_OVERRIDE_VALUE (1 << 1)226#define SATA_PLL_CFG0_PADPLL_RESET_SWCTL (1 << 0)227228#define SATA_PLL_CFG1 0x494229#define PCIE_PLL_CFG0 0x498230#define PCIE_PLL_CFG0_SEQ_START_STATE (1 << 25)231#define PCIE_PLL_CFG0_SEQ_ENABLE (1 << 24)232233#define PLLD2_BASE 0x4b8234#define PLLD2_MISC 0x4bc235#define UTMIP_PLL_CFG3 0x4c0236#define PLLRE_BASE 0x4c4237#define PLLRE_MISC 0x4c8238#define PLLC2_BASE 0x4e8239#define PLLC2_MISC 0x4ec240#define PLLC3_BASE 0x4fc241242#define PLLC3_MISC 0x500243#define PLLX_MISC2 0x514244#define PLLX_MISC2 0x514245#define PLLX_MISC3 0x518246#define PLLX_MISC3_DYNRAMP_STEPB_MASK 0xFF247#define PLLX_MISC3_DYNRAMP_STEPB_SHIFT 24248#define PLLX_MISC3_DYNRAMP_STEPA_MASK 0xFF249#define PLLX_MISC3_DYNRAMP_STEPA_SHIFT 16250#define PLLX_MISC3_NDIV_NEW_MASK 0xFF251#define PLLX_MISC3_NDIV_NEW_SHIFT 8252#define PLLX_MISC3_EN_FSTLCK (1 << 5)253#define PLLX_MISC3_LOCK_OVERRIDE (1 << 4)254#define PLLX_MISC3_PLL_FREQLOCK (1 << 3)255#define PLLX_MISC3_DYNRAMP_DONE (1 << 2)256#define PLLX_MISC3_CLAMP_NDIV (1 << 1)257#define PLLX_MISC3_EN_DYNRAMP (1 << 0)258#define XUSBIO_PLL_CFG0 0x51c259#define XUSBIO_PLL_CFG0_SEQ_START_STATE (1 << 25)260#define XUSBIO_PLL_CFG0_SEQ_ENABLE (1 << 24)261#define XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET (1 << 6)262#define XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL (1 << 2)263#define XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL (1 << 0)264265#define PLLP_RESHIFT 0x528266#define UTMIPLL_HW_PWRDN_CFG0 0x52c267#define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE (1 << 25)268#define UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE (1 << 24)269#define UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET (1 << 6)270#define UTMIPLL_HW_PWRDN_CFG0_SEQ_RESET_INPUT_VALUE (1 << 5)271#define UTMIPLL_HW_PWRDN_CFG0_SEQ_IN_SWCTL (1 << 4)272#define UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL (1 << 2)273#define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE (1 << 1)274#define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL (1 << 0)275276#define PLLDP_BASE 0x590277#define PLLDP_MISC 0x594278#define PLLC4_BASE 0x5a4279#define PLLC4_MISC 0x5a8280281#define CLK_SOURCE_XUSB_CORE_HOST 0x600282#define CLK_SOURCE_XUSB_FALCON 0x604283#define CLK_SOURCE_XUSB_FS 0x608284#define CLK_SOURCE_XUSB_CORE_DEV 0x60c285#define CLK_SOURCE_XUSB_SS 0x610286#define CLK_SOURCE_CILAB 0x614287#define CLK_SOURCE_CILCD 0x618288#define CLK_SOURCE_CILE 0x61c289#define CLK_SOURCE_DSIA_LP 0x620290#define CLK_SOURCE_DSIB_LP 0x624291#define CLK_SOURCE_ENTROPY 0x628292#define CLK_SOURCE_DVFS_REF 0x62c293#define CLK_SOURCE_DVFS_SOC 0x630294#define CLK_SOURCE_TRACECLKIN 0x634295#define CLK_SOURCE_ADX 0x638296#define CLK_SOURCE_AMX 0x63c297#define CLK_SOURCE_EMC_LATENCY 0x640298#define CLK_SOURCE_SOC_THERM 0x644299#define CLK_SOURCE_VI_SENSOR2 0x658300#define CLK_SOURCE_I2C6 0x65c301#define CLK_SOURCE_EMC_DLL 0x664302#define CLK_SOURCE_HDMI_AUDIO 0x668303#define CLK_SOURCE_CLK72MHZ 0x66c304#define CLK_SOURCE_ADX1 0x670305#define CLK_SOURCE_AMX1 0x674306#define CLK_SOURCE_VIC 0x678307#define PLLP_OUTC 0x67c308#define PLLP_MISC1 0x680309310struct tegra124_car_softc {311device_t dev;312struct resource * mem_res;313struct mtx mtx;314struct clkdom *clkdom;315int type;316};317318struct tegra124_init_item {319char *name;320char *parent;321uint64_t frequency;322int enable;323};324325void tegra124_init_plls(struct tegra124_car_softc *sc);326327void tegra124_periph_clock(struct tegra124_car_softc *sc);328void tegra124_super_mux_clock(struct tegra124_car_softc *sc);329330int tegra124_hwreset_by_idx(struct tegra124_car_softc *sc, intptr_t idx,331bool reset);332333#endif /*_TEGRA124_CAR_*/334335336