1*e3525114SXing Zheng /* 2*e3525114SXing Zheng * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. 3*e3525114SXing Zheng * 4*e3525114SXing Zheng * Redistribution and use in source and binary forms, with or without 5*e3525114SXing Zheng * modification, are permitted provided that the following conditions are met: 6*e3525114SXing Zheng * 7*e3525114SXing Zheng * Redistributions of source code must retain the above copyright notice, this 8*e3525114SXing Zheng * list of conditions and the following disclaimer. 9*e3525114SXing Zheng * 10*e3525114SXing Zheng * Redistributions in binary form must reproduce the above copyright notice, 11*e3525114SXing Zheng * this list of conditions and the following disclaimer in the documentation 12*e3525114SXing Zheng * and/or other materials provided with the distribution. 13*e3525114SXing Zheng * 14*e3525114SXing Zheng * Neither the name of ARM nor the names of its contributors may be used 15*e3525114SXing Zheng * to endorse or promote products derived from this software without specific 16*e3525114SXing Zheng * prior written permission. 17*e3525114SXing Zheng * 18*e3525114SXing Zheng * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19*e3525114SXing Zheng * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*e3525114SXing Zheng * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*e3525114SXing Zheng * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22*e3525114SXing Zheng * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*e3525114SXing Zheng * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*e3525114SXing Zheng * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*e3525114SXing Zheng * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*e3525114SXing Zheng * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*e3525114SXing Zheng * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*e3525114SXing Zheng * POSSIBILITY OF SUCH DAMAGE. 29*e3525114SXing Zheng */ 30*e3525114SXing Zheng 31*e3525114SXing Zheng #ifndef __PLAT_ROCKCHIP_RK3399_DRIVER_SECURE_H__ 32*e3525114SXing Zheng #define __PLAT_ROCKCHIP_RK3399_DRIVER_SECURE_H__ 33*e3525114SXing Zheng 34*e3525114SXing Zheng /************************************************** 35*e3525114SXing Zheng * sgrf reg, offset 36*e3525114SXing Zheng **************************************************/ 37*e3525114SXing Zheng #define SGRF_SOC_CON0_1(n) (0xc000 + (n) * 4) 38*e3525114SXing Zheng #define SGRF_SOC_CON3_7(n) (0xe00c + ((n) - 3) * 4) 39*e3525114SXing Zheng #define SGRF_SOC_CON8_15(n) (0x8020 + ((n) - 8) * 4) 40*e3525114SXing Zheng #define SGRF_SOC_CON(n) (n < 3 ? SGRF_SOC_CON0_1(n) :\ 41*e3525114SXing Zheng (n < 8 ? SGRF_SOC_CON3_7(n) :\ 42*e3525114SXing Zheng SGRF_SOC_CON8_15(n))) 43*e3525114SXing Zheng 44*e3525114SXing Zheng #define SGRF_PMU_SLV_CON0_1(n) (0xc240 + ((n) - 0) * 4) 45*e3525114SXing Zheng #define SGRF_SLV_SECURE_CON0_4(n) (0xe3c0 + ((n) - 0) * 4) 46*e3525114SXing Zheng #define SGRF_DDRRGN_CON0_16(n) ((n) * 4) 47*e3525114SXing Zheng #define SGRF_DDRRGN_CON20_34(n) (0x50 + ((n) - 20) * 4) 48*e3525114SXing Zheng 49*e3525114SXing Zheng /* All of master in ns */ 50*e3525114SXing Zheng #define SGRF_SOC_ALLMST_NS 0xffff 51*e3525114SXing Zheng 52*e3525114SXing Zheng /* security config for slave */ 53*e3525114SXing Zheng #define SGRF_SLV_S_WMSK 0xffff0000 54*e3525114SXing Zheng #define SGRF_SLV_S_ALL_NS 0x0 55*e3525114SXing Zheng 56*e3525114SXing Zheng /* security config pmu slave ip */ 57*e3525114SXing Zheng /* All of slaves is ns */ 58*e3525114SXing Zheng #define SGRF_PMU_SLV_S_NS BIT_WITH_WMSK(0) 59*e3525114SXing Zheng /* slaves secure attr is configed */ 60*e3525114SXing Zheng #define SGRF_PMU_SLV_S_CFGED WMSK_BIT(0) 61*e3525114SXing Zheng #define SGRF_PMU_SLV_CRYPTO1_NS WMSK_BIT(1) 62*e3525114SXing Zheng 63*e3525114SXing Zheng #define SGRF_PMUSRAM_S BIT(8) 64*e3525114SXing Zheng 65*e3525114SXing Zheng /* ddr region */ 66*e3525114SXing Zheng #define SGRF_DDR_RGN_0_16_WMSK 0x0fff /* DDR RGN 0~16 size mask */ 67*e3525114SXing Zheng 68*e3525114SXing Zheng #define SGRF_DDR_RGN_DPLL_CLK BIT_WITH_WMSK(15) /* DDR PLL output clock */ 69*e3525114SXing Zheng #define SGRF_DDR_RGN_RTC_CLK BIT_WITH_WMSK(14) /* 32K clock for DDR PLL */ 70*e3525114SXing Zheng 71*e3525114SXing Zheng /* All security of the DDR RGNs are bypass */ 72*e3525114SXing Zheng #define SGRF_DDR_RGN_BYPS BIT_WITH_WMSK(9) 73*e3525114SXing Zheng /* All security of the DDR RGNs are not bypass */ 74*e3525114SXing Zheng #define SGRF_DDR_RGN_NO_BYPS WMSK_BIT(9) 75*e3525114SXing Zheng 76*e3525114SXing Zheng /* The MST access the ddr rgn n with secure attribution */ 77*e3525114SXing Zheng #define SGRF_L_MST_S_DDR_RGN(n) BIT_WITH_WMSK((n)) 78*e3525114SXing Zheng /* bits[16:8]*/ 79*e3525114SXing Zheng #define SGRF_H_MST_S_DDR_RGN(n) BIT_WITH_WMSK((n) + 8) 80*e3525114SXing Zheng 81*e3525114SXing Zheng #define SGRF_PMU_CON0 0x0c100 82*e3525114SXing Zheng #define SGRF_PMU_CON(n) (SGRF_PMU_CON0 + (n) * 4) 83*e3525114SXing Zheng 84*e3525114SXing Zheng /************************************************** 85*e3525114SXing Zheng * secure timer 86*e3525114SXing Zheng **************************************************/ 87*e3525114SXing Zheng /* chanal0~5 */ 88*e3525114SXing Zheng #define STIMER0_CHN_BASE(n) (STIME_BASE + 0x20 * (n)) 89*e3525114SXing Zheng /* chanal6~11 */ 90*e3525114SXing Zheng #define STIMER1_CHN_BASE(n) (STIME_BASE + 0x8000 + 0x20 * (n)) 91*e3525114SXing Zheng 92*e3525114SXing Zheng /* low 32 bits */ 93*e3525114SXing Zheng #define TIMER_END_COUNT0 0x00 94*e3525114SXing Zheng /* high 32 bits */ 95*e3525114SXing Zheng #define TIMER_END_COUNT1 0x04 96*e3525114SXing Zheng 97*e3525114SXing Zheng #define TIMER_CURRENT_VALUE0 0x08 98*e3525114SXing Zheng #define TIMER_CURRENT_VALUE1 0x0C 99*e3525114SXing Zheng 100*e3525114SXing Zheng /* low 32 bits */ 101*e3525114SXing Zheng #define TIMER_INIT_COUNT0 0x10 102*e3525114SXing Zheng /* high 32 bits */ 103*e3525114SXing Zheng #define TIMER_INIT_COUNT1 0x14 104*e3525114SXing Zheng 105*e3525114SXing Zheng #define TIMER_INTSTATUS 0x18 106*e3525114SXing Zheng #define TIMER_CONTROL_REG 0x1c 107*e3525114SXing Zheng 108*e3525114SXing Zheng #define TIMER_EN 0x1 109*e3525114SXing Zheng 110*e3525114SXing Zheng #define TIMER_FMODE (0x0 << 1) 111*e3525114SXing Zheng #define TIMER_RMODE (0x1 << 1) 112*e3525114SXing Zheng 113*e3525114SXing Zheng /************************************************** 114*e3525114SXing Zheng * secure WDT 115*e3525114SXing Zheng **************************************************/ 116*e3525114SXing Zheng #define PCLK_WDT_CA53_GATE_SHIFT 8 117*e3525114SXing Zheng #define PCLK_WDT_CM0_GATE_SHIFT 10 118*e3525114SXing Zheng 119*e3525114SXing Zheng /* export secure operating APIs */ 120*e3525114SXing Zheng void secure_watchdog_disable(void); 121*e3525114SXing Zheng void secure_watchdog_enable(void); 122*e3525114SXing Zheng void secure_timer_init(void); 123*e3525114SXing Zheng void secure_sgrf_init(void); 124*e3525114SXing Zheng void secure_sgrf_ddr_rgn_init(void); 125*e3525114SXing Zheng 126*e3525114SXing Zheng #endif /* __PLAT_ROCKCHIP_RK3399_DRIVER_SECURE_H__ */ 127