Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019, Renesas Electronics Corporation. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stdint.h> |
| 8 | |
| 9 | #include <common/debug.h> |
| 10 | |
| 11 | #include "../qos_common.h" |
| 12 | #include "../qos_reg.h" |
| 13 | #include "qos_init_m3_v30.h" |
| 14 | |
Marek Vasut | a1736be | 2019-06-14 02:21:45 +0200 | [diff] [blame] | 15 | #define RCAR_QOS_VERSION "rev.0.03" |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 16 | |
Marek Vasut | a1736be | 2019-06-14 02:21:45 +0200 | [diff] [blame] | 17 | #define QOSWT_TIME_BANK0 20000000U /* unit:ns */ |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 18 | |
Marek Vasut | a1736be | 2019-06-14 02:21:45 +0200 | [diff] [blame] | 19 | #define QOSWT_WTEN_ENABLE 0x1U |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 20 | |
| 21 | #define QOSCTRL_REF_ARS_ARBSTOPCYCLE_M3_30 (SL_INIT_SSLOTCLK_M3_30 - 0x5U) |
| 22 | |
Marek Vasut | a1736be | 2019-06-14 02:21:45 +0200 | [diff] [blame] | 23 | #define OSWT_WTREF_SLOT0_EN_REQ1_SLOT 3U |
| 24 | #define OSWT_WTREF_SLOT0_EN_REQ2_SLOT 9U |
| 25 | #define QOSWT_WTREF_SLOT0_EN \ |
| 26 | ((0x1U << OSWT_WTREF_SLOT0_EN_REQ1_SLOT) | \ |
| 27 | (0x1U << OSWT_WTREF_SLOT0_EN_REQ2_SLOT)) |
| 28 | #define QOSWT_WTREF_SLOT1_EN \ |
| 29 | ((0x1U << OSWT_WTREF_SLOT0_EN_REQ1_SLOT) | \ |
| 30 | (0x1U << OSWT_WTREF_SLOT0_EN_REQ2_SLOT)) |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 31 | |
Marek Vasut | a1736be | 2019-06-14 02:21:45 +0200 | [diff] [blame] | 32 | #define QOSWT_WTSET0_REQ_SSLOT0 5U |
| 33 | #define WT_BASE_SUB_SLOT_NUM0 12U |
| 34 | #define QOSWT_WTSET0_PERIOD0_M3_30 \ |
| 35 | ((QOSWT_TIME_BANK0 / QOSWT_WTSET0_CYCLE_M3_30) - 1U) |
| 36 | #define QOSWT_WTSET0_SSLOT0 (QOSWT_WTSET0_REQ_SSLOT0 - 1U) |
| 37 | #define QOSWT_WTSET0_SLOTSLOT0 (WT_BASE_SUB_SLOT_NUM0 - 1U) |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 38 | |
Marek Vasut | a1736be | 2019-06-14 02:21:45 +0200 | [diff] [blame] | 39 | #define QOSWT_WTSET1_PERIOD1_M3_30 \ |
| 40 | ((QOSWT_TIME_BANK0 / QOSWT_WTSET0_CYCLE_M3_30) - 1U) |
| 41 | #define QOSWT_WTSET1_SSLOT1 (QOSWT_WTSET0_REQ_SSLOT0 - 1U) |
| 42 | #define QOSWT_WTSET1_SLOTSLOT1 (WT_BASE_SUB_SLOT_NUM0 - 1U) |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 43 | |
| 44 | #if RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT |
| 45 | |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 46 | #if RCAR_REF_INT == RCAR_REF_DEFAULT |
Yoshifumi Hosoya | ca0aa64 | 2019-04-12 17:08:15 +0900 | [diff] [blame] | 47 | #include "qos_init_m3_v30_mstat195.h" |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 48 | #else |
Yoshifumi Hosoya | ca0aa64 | 2019-04-12 17:08:15 +0900 | [diff] [blame] | 49 | #include "qos_init_m3_v30_mstat390.h" |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 50 | #endif |
| 51 | |
| 52 | #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE |
| 53 | |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 54 | #if RCAR_REF_INT == RCAR_REF_DEFAULT |
Yoshifumi Hosoya | ca0aa64 | 2019-04-12 17:08:15 +0900 | [diff] [blame] | 55 | #include "qos_init_m3_v30_qoswt195.h" |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 56 | #else |
Yoshifumi Hosoya | ca0aa64 | 2019-04-12 17:08:15 +0900 | [diff] [blame] | 57 | #include "qos_init_m3_v30_qoswt390.h" |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 58 | #endif |
| 59 | |
| 60 | #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */ |
| 61 | #endif |
| 62 | |
| 63 | static void dbsc_setting(void) |
| 64 | { |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 65 | /* Register write enable */ |
| 66 | io_write_32(DBSC_DBSYSCNT0, 0x00001234U); |
| 67 | |
| 68 | /* BUFCAM settings */ |
Marek Vasut | 6a669f6 | 2019-06-14 01:50:16 +0200 | [diff] [blame] | 69 | io_write_32(DBSC_DBCAM0CNF1, 0x00043218); |
| 70 | io_write_32(DBSC_DBCAM0CNF2, 0x000000F4); |
| 71 | io_write_32(DBSC_DBCAM0CNF3, 0x00000000); |
| 72 | io_write_32(DBSC_DBSCHCNT0, 0x000F0037); |
| 73 | io_write_32(DBSC_DBSCHSZ0, 0x00000001); |
| 74 | io_write_32(DBSC_DBSCHRW0, 0x22421111); |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 75 | |
Marek Vasut | 5ea57a52 | 2019-06-14 01:51:40 +0200 | [diff] [blame] | 76 | /* DDR3 */ |
| 77 | io_write_32(DBSC_SCFCTST2, 0x012F1123); |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 78 | |
| 79 | /* QoS Settings */ |
| 80 | io_write_32(DBSC_DBSCHQOS00, 0x00000F00); |
| 81 | io_write_32(DBSC_DBSCHQOS01, 0x00000B00); |
| 82 | io_write_32(DBSC_DBSCHQOS02, 0x00000000); |
| 83 | io_write_32(DBSC_DBSCHQOS03, 0x00000000); |
| 84 | io_write_32(DBSC_DBSCHQOS40, 0x00000300); |
| 85 | io_write_32(DBSC_DBSCHQOS41, 0x000002F0); |
| 86 | io_write_32(DBSC_DBSCHQOS42, 0x00000200); |
| 87 | io_write_32(DBSC_DBSCHQOS43, 0x00000100); |
| 88 | io_write_32(DBSC_DBSCHQOS90, 0x00000100); |
| 89 | io_write_32(DBSC_DBSCHQOS91, 0x000000F0); |
| 90 | io_write_32(DBSC_DBSCHQOS92, 0x000000A0); |
| 91 | io_write_32(DBSC_DBSCHQOS93, 0x00000040); |
| 92 | io_write_32(DBSC_DBSCHQOS120, 0x00000040); |
| 93 | io_write_32(DBSC_DBSCHQOS121, 0x00000030); |
| 94 | io_write_32(DBSC_DBSCHQOS122, 0x00000020); |
| 95 | io_write_32(DBSC_DBSCHQOS123, 0x00000010); |
| 96 | io_write_32(DBSC_DBSCHQOS130, 0x00000100); |
| 97 | io_write_32(DBSC_DBSCHQOS131, 0x000000F0); |
| 98 | io_write_32(DBSC_DBSCHQOS132, 0x000000A0); |
| 99 | io_write_32(DBSC_DBSCHQOS133, 0x00000040); |
| 100 | io_write_32(DBSC_DBSCHQOS140, 0x000000C0); |
| 101 | io_write_32(DBSC_DBSCHQOS141, 0x000000B0); |
| 102 | io_write_32(DBSC_DBSCHQOS142, 0x00000080); |
| 103 | io_write_32(DBSC_DBSCHQOS143, 0x00000040); |
| 104 | io_write_32(DBSC_DBSCHQOS150, 0x00000040); |
| 105 | io_write_32(DBSC_DBSCHQOS151, 0x00000030); |
| 106 | io_write_32(DBSC_DBSCHQOS152, 0x00000020); |
| 107 | io_write_32(DBSC_DBSCHQOS153, 0x00000010); |
| 108 | |
| 109 | /* Register write protect */ |
| 110 | io_write_32(DBSC_DBSYSCNT0, 0x00000000U); |
| 111 | } |
| 112 | |
| 113 | void qos_init_m3_v30(void) |
| 114 | { |
| 115 | dbsc_setting(); |
| 116 | |
| 117 | /* DRAM Split Address mapping */ |
| 118 | #if RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_4CH |
| 119 | #if RCAR_LSI == RCAR_M3 |
| 120 | #error "Don't set DRAM Split 4ch(M3)" |
| 121 | #else |
| 122 | ERROR("DRAM Split 4ch not supported.(M3)"); |
| 123 | panic(); |
| 124 | #endif |
| 125 | #elif (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_2CH) || \ |
| 126 | (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_AUTO) |
| 127 | NOTICE("BL2: DRAM Split is 2ch\n"); |
| 128 | io_write_32(AXI_ADSPLCR0, 0x00000000U); |
| 129 | io_write_32(AXI_ADSPLCR1, ADSPLCR0_ADRMODE_DEFAULT |
| 130 | | ADSPLCR0_SPLITSEL(0xFFU) |
| 131 | | ADSPLCR0_AREA(0x1DU) |
| 132 | | ADSPLCR0_SWP); |
| 133 | io_write_32(AXI_ADSPLCR2, 0x00001004U); |
| 134 | io_write_32(AXI_ADSPLCR3, 0x00000000U); |
| 135 | #else |
| 136 | NOTICE("BL2: DRAM Split is OFF\n"); |
| 137 | #endif |
| 138 | |
| 139 | #if !(RCAR_QOS_TYPE == RCAR_QOS_NONE) |
| 140 | #if RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT |
| 141 | NOTICE("BL2: QoS is default setting(%s)\n", RCAR_QOS_VERSION); |
| 142 | #endif |
| 143 | |
| 144 | #if RCAR_REF_INT == RCAR_REF_DEFAULT |
| 145 | NOTICE("BL2: DRAM refresh interval 1.95 usec\n"); |
| 146 | #else |
| 147 | NOTICE("BL2: DRAM refresh interval 3.9 usec\n"); |
| 148 | #endif |
| 149 | |
| 150 | #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE |
| 151 | NOTICE("BL2: Periodic Write DQ Training\n"); |
| 152 | #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */ |
| 153 | |
| 154 | io_write_32(QOSCTRL_RAS, 0x00000044U); |
| 155 | io_write_64(QOSCTRL_DANN, 0x0404020002020201UL); |
| 156 | io_write_32(QOSCTRL_DANT, 0x0020100AU); |
| 157 | io_write_32(QOSCTRL_FSS, 0x0000000AU); |
| 158 | io_write_32(QOSCTRL_INSFC, 0x06330001U); |
| 159 | io_write_32(QOSCTRL_EARLYR, 0x00000001U); |
| 160 | io_write_32(QOSCTRL_RACNT0, 0x02010003U); /* GPU Boost Mode ON */ |
| 161 | |
| 162 | /* GPU Boost Mode */ |
| 163 | io_write_32(QOSCTRL_STATGEN0, 0x00000001U); |
| 164 | |
| 165 | io_write_32(QOSCTRL_SL_INIT, SL_INIT_REFFSSLOT | SL_INIT_SLOTSSLOT | SL_INIT_SSLOTCLK_M3_30); |
| 166 | io_write_32(QOSCTRL_REF_ARS, ((QOSCTRL_REF_ARS_ARBSTOPCYCLE_M3_30 << 16))); |
| 167 | |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 168 | uint32_t i; |
| 169 | |
| 170 | for (i = 0U; i < ARRAY_SIZE(mstat_fix); i++) { |
Marek Vasut | 5753df4 | 2019-06-14 01:39:27 +0200 | [diff] [blame] | 171 | io_write_64(QOSBW_FIX_QOS_BANK0 + i * 8, mstat_fix[i]); |
| 172 | io_write_64(QOSBW_FIX_QOS_BANK1 + i * 8, mstat_fix[i]); |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 173 | } |
| 174 | for (i = 0U; i < ARRAY_SIZE(mstat_be); i++) { |
Marek Vasut | 5753df4 | 2019-06-14 01:39:27 +0200 | [diff] [blame] | 175 | io_write_64(QOSBW_BE_QOS_BANK0 + i * 8, mstat_be[i]); |
| 176 | io_write_64(QOSBW_BE_QOS_BANK1 + i * 8, mstat_be[i]); |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 177 | } |
| 178 | #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE |
| 179 | for (i = 0U; i < ARRAY_SIZE(qoswt_fix); i++) { |
Marek Vasut | 5753df4 | 2019-06-14 01:39:27 +0200 | [diff] [blame] | 180 | io_write_64(QOSWT_FIX_WTQOS_BANK0 + i * 8, qoswt_fix[i]); |
| 181 | io_write_64(QOSWT_FIX_WTQOS_BANK1 + i * 8, qoswt_fix[i]); |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 182 | } |
| 183 | for (i = 0U; i < ARRAY_SIZE(qoswt_be); i++) { |
Marek Vasut | 5753df4 | 2019-06-14 01:39:27 +0200 | [diff] [blame] | 184 | io_write_64(QOSWT_BE_WTQOS_BANK0 + i * 8, qoswt_be[i]); |
| 185 | io_write_64(QOSWT_BE_WTQOS_BANK1 + i * 8, qoswt_be[i]); |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 186 | } |
| 187 | #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */ |
Marek Vasut | 3af2005 | 2019-02-25 14:57:08 +0100 | [diff] [blame] | 188 | |
| 189 | /* RT bus Leaf setting */ |
| 190 | io_write_32(RT_ACT0, 0x00000000U); |
| 191 | io_write_32(RT_ACT1, 0x00000000U); |
| 192 | |
| 193 | /* CCI bus Leaf setting */ |
| 194 | io_write_32(CPU_ACT0, 0x00000003U); |
| 195 | io_write_32(CPU_ACT1, 0x00000003U); |
| 196 | io_write_32(CPU_ACT2, 0x00000003U); |
| 197 | io_write_32(CPU_ACT3, 0x00000003U); |
| 198 | |
| 199 | io_write_32(QOSCTRL_RAEN, 0x00000001U); |
| 200 | |
| 201 | #if RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE |
| 202 | /* re-write training setting */ |
| 203 | io_write_32(QOSWT_WTREF, ((QOSWT_WTREF_SLOT1_EN << 16) | QOSWT_WTREF_SLOT0_EN)); |
| 204 | io_write_32(QOSWT_WTSET0, ((QOSWT_WTSET0_PERIOD0_M3_30 << 16) | (QOSWT_WTSET0_SSLOT0 << 8) | QOSWT_WTSET0_SLOTSLOT0)); |
| 205 | io_write_32(QOSWT_WTSET1, ((QOSWT_WTSET1_PERIOD1_M3_30 << 16) | (QOSWT_WTSET1_SSLOT1 << 8) | QOSWT_WTSET1_SLOTSLOT1)); |
| 206 | |
| 207 | io_write_32(QOSWT_WTEN, QOSWT_WTEN_ENABLE); |
| 208 | #endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */ |
| 209 | |
| 210 | io_write_32(QOSCTRL_STATQC, 0x00000001U); |
| 211 | #else |
| 212 | NOTICE("BL2: QoS is None\n"); |
| 213 | |
| 214 | io_write_32(QOSCTRL_RAEN, 0x00000001U); |
| 215 | #endif /* !(RCAR_QOS_TYPE == RCAR_QOS_NONE) */ |
| 216 | } |