Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 1 | /* |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 2 | * Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved. |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stdint.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
| 9 | #include <common/debug.h> |
| 10 | |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 11 | #include "../qos_common.h" |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 12 | #include "../qos_reg.h" |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 13 | #include "qos_init_m3_v10.h" |
| 14 | |
| 15 | #define RCAR_QOS_VERSION "rev.0.19" |
| 16 | |
Marek Vasut | 92c7efc | 2019-06-14 01:44:43 +0200 | [diff] [blame] | 17 | #include "qos_init_m3_v10_mstat.h" |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 18 | |
| 19 | static void dbsc_setting(void) |
| 20 | { |
| 21 | uint32_t md = 0; |
| 22 | |
| 23 | /* BUFCAM settings */ |
| 24 | /* DBSC_DBCAM0CNF0 not set */ |
Marek Vasut | 6a669f6 | 2019-06-14 01:50:16 +0200 | [diff] [blame^] | 25 | io_write_32(DBSC_DBCAM0CNF1, 0x00043218); |
| 26 | io_write_32(DBSC_DBCAM0CNF2, 0x000000F4); |
| 27 | io_write_32(DBSC_DBCAM0CNF3, 0x00000000); |
| 28 | io_write_32(DBSC_DBSCHCNT0, 0x080F0037); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 29 | /* DBSC_DBSCHCNT1 not set */ |
Marek Vasut | 6a669f6 | 2019-06-14 01:50:16 +0200 | [diff] [blame^] | 30 | io_write_32(DBSC_DBSCHSZ0, 0x00000001); |
| 31 | io_write_32(DBSC_DBSCHRW0, 0x22421111); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 32 | |
| 33 | md = (*((volatile uint32_t *)RST_MODEMR) & 0x000A0000) >> 17; |
| 34 | |
| 35 | switch (md) { |
| 36 | case 0x0: |
| 37 | /* DDR3200 */ |
| 38 | io_write_32(DBSC_SCFCTST2, 0x012F1123); |
| 39 | break; |
| 40 | case 0x1: /* MD19=0,MD17=1 : LPDDR4-3000, 4GByte(1GByte x4) */ |
| 41 | /* DDR2800 */ |
| 42 | io_write_32(DBSC_SCFCTST2, 0x012F1123); |
| 43 | break; |
| 44 | case 0x4: /* MD19=1,MD17=0 : LPDDR4-2400, 4GByte(1GByte x4) */ |
| 45 | /* DDR2400 */ |
| 46 | io_write_32(DBSC_SCFCTST2, 0x012F1123); |
| 47 | break; |
| 48 | default: /* MD19=1,MD17=1 : LPDDR4-1600, 4GByte(1GByte x4) */ |
| 49 | /* DDR1600 */ |
| 50 | io_write_32(DBSC_SCFCTST2, 0x012F1123); |
| 51 | break; |
| 52 | } |
| 53 | |
| 54 | /* QoS Settings */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 55 | io_write_32(DBSC_DBSCHQOS00, 0x00000F00); |
| 56 | io_write_32(DBSC_DBSCHQOS01, 0x00000B00); |
| 57 | io_write_32(DBSC_DBSCHQOS02, 0x00000000); |
| 58 | io_write_32(DBSC_DBSCHQOS03, 0x00000000); |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 59 | io_write_32(DBSC_DBSCHQOS40, 0x00000300); |
| 60 | io_write_32(DBSC_DBSCHQOS41, 0x000002F0); |
| 61 | io_write_32(DBSC_DBSCHQOS42, 0x00000200); |
| 62 | io_write_32(DBSC_DBSCHQOS43, 0x00000100); |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 63 | io_write_32(DBSC_DBSCHQOS90, 0x00000300); |
| 64 | io_write_32(DBSC_DBSCHQOS91, 0x000002F0); |
| 65 | io_write_32(DBSC_DBSCHQOS92, 0x00000200); |
| 66 | io_write_32(DBSC_DBSCHQOS93, 0x00000100); |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 67 | io_write_32(DBSC_DBSCHQOS130, 0x00000100); |
| 68 | io_write_32(DBSC_DBSCHQOS131, 0x000000F0); |
| 69 | io_write_32(DBSC_DBSCHQOS132, 0x000000A0); |
| 70 | io_write_32(DBSC_DBSCHQOS133, 0x00000040); |
| 71 | io_write_32(DBSC_DBSCHQOS140, 0x000000C0); |
| 72 | io_write_32(DBSC_DBSCHQOS141, 0x000000B0); |
| 73 | io_write_32(DBSC_DBSCHQOS142, 0x00000080); |
| 74 | io_write_32(DBSC_DBSCHQOS143, 0x00000040); |
| 75 | io_write_32(DBSC_DBSCHQOS150, 0x00000040); |
| 76 | io_write_32(DBSC_DBSCHQOS151, 0x00000030); |
| 77 | io_write_32(DBSC_DBSCHQOS152, 0x00000020); |
| 78 | io_write_32(DBSC_DBSCHQOS153, 0x00000010); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | void qos_init_m3_v10(void) |
| 82 | { |
| 83 | dbsc_setting(); |
| 84 | |
| 85 | /* DRAM Split Address mapping */ |
| 86 | #if RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_4CH |
| 87 | #if RCAR_LSI == RCAR_M3 |
| 88 | #error "Don't set DRAM Split 4ch(M3)" |
| 89 | #else |
| 90 | ERROR("DRAM Split 4ch not supported.(M3)"); |
| 91 | panic(); |
| 92 | #endif |
| 93 | #elif (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_2CH) || \ |
| 94 | (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_AUTO) |
| 95 | NOTICE("BL2: DRAM Split is 2ch\n"); |
| 96 | io_write_32(AXI_ADSPLCR0, 0x00000000U); |
| 97 | io_write_32(AXI_ADSPLCR1, ADSPLCR0_ADRMODE_DEFAULT |
| 98 | | ADSPLCR0_SPLITSEL(0xFFU) |
| 99 | | ADSPLCR0_AREA(0x1CU) |
| 100 | | ADSPLCR0_SWP); |
| 101 | io_write_32(AXI_ADSPLCR2, 0x089A0000U); |
| 102 | io_write_32(AXI_ADSPLCR3, 0x00000000U); |
| 103 | #else |
| 104 | NOTICE("BL2: DRAM Split is OFF\n"); |
| 105 | #endif |
| 106 | |
| 107 | #if !(RCAR_QOS_TYPE == RCAR_QOS_NONE) |
| 108 | #if RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT |
| 109 | NOTICE("BL2: QoS is default setting(%s)\n", RCAR_QOS_VERSION); |
| 110 | #endif |
| 111 | |
| 112 | /* Resource Alloc setting */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 113 | io_write_32(QOSCTRL_RAS, 0x00000028U); |
| 114 | io_write_32(QOSCTRL_FIXTH, 0x000F0005U); |
| 115 | io_write_32(QOSCTRL_REGGD, 0x00000000U); |
| 116 | io_write_64(QOSCTRL_DANN, 0x0101010102020201UL); |
| 117 | io_write_32(QOSCTRL_DANT, 0x00100804U); |
| 118 | io_write_32(QOSCTRL_EC, 0x00000000U); |
| 119 | io_write_64(QOSCTRL_EMS, 0x0000000000000000UL); |
| 120 | io_write_32(QOSCTRL_FSS, 0x000003e8U); |
| 121 | io_write_32(QOSCTRL_INSFC, 0xC7840001U); |
| 122 | io_write_32(QOSCTRL_BERR, 0x00000000U); |
| 123 | io_write_32(QOSCTRL_RACNT0, 0x00000000U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 124 | |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 125 | /* QOSBW setting */ |
| 126 | io_write_32(QOSCTRL_SL_INIT, |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 127 | SL_INIT_REFFSSLOT | SL_INIT_SLOTSSLOT | SL_INIT_SSLOTCLK); |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 128 | io_write_32(QOSCTRL_REF_ARS, 0x00330000U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 129 | |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 130 | /* QOSBW SRAM setting */ |
Marek Vasut | 5753df4 | 2019-06-14 01:39:27 +0200 | [diff] [blame] | 131 | uint32_t i; |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 132 | |
Marek Vasut | 5753df4 | 2019-06-14 01:39:27 +0200 | [diff] [blame] | 133 | for (i = 0U; i < ARRAY_SIZE(mstat_fix); i++) { |
| 134 | io_write_64(QOSBW_FIX_QOS_BANK0 + i * 8, mstat_fix[i]); |
| 135 | io_write_64(QOSBW_FIX_QOS_BANK1 + i * 8, mstat_fix[i]); |
| 136 | } |
| 137 | for (i = 0U; i < ARRAY_SIZE(mstat_be); i++) { |
| 138 | io_write_64(QOSBW_BE_QOS_BANK0 + i * 8, mstat_be[i]); |
| 139 | io_write_64(QOSBW_BE_QOS_BANK1 + i * 8, mstat_be[i]); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | /* 3DG bus Leaf setting */ |
| 143 | io_write_32(0xFD820808U, 0x00001234U); |
| 144 | io_write_32(0xFD820800U, 0x00000006U); |
| 145 | io_write_32(0xFD821800U, 0x00000006U); |
| 146 | io_write_32(0xFD822800U, 0x00000006U); |
| 147 | io_write_32(0xFD823800U, 0x00000006U); |
| 148 | io_write_32(0xFD824800U, 0x00000006U); |
| 149 | io_write_32(0xFD825800U, 0x00000006U); |
| 150 | io_write_32(0xFD826800U, 0x00000006U); |
| 151 | io_write_32(0xFD827800U, 0x00000006U); |
| 152 | |
| 153 | /* RT bus Leaf setting */ |
| 154 | io_write_32(0xFFC50800U, 0x00000000U); |
| 155 | io_write_32(0xFFC51800U, 0x00000000U); |
| 156 | |
| 157 | /* Resource Alloc start */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 158 | io_write_32(QOSCTRL_RAEN, 0x00000001U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 159 | |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 160 | /* QOSBW start */ |
| 161 | io_write_32(QOSCTRL_STATQC, 0x00000001U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 162 | #else |
| 163 | NOTICE("BL2: QoS is None\n"); |
| 164 | |
| 165 | /* Resource Alloc setting */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 166 | io_write_32(QOSCTRL_EC, 0x00000000U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 167 | /* Resource Alloc start */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 168 | io_write_32(QOSCTRL_RAEN, 0x00000001U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 169 | #endif /* !(RCAR_QOS_TYPE == RCAR_QOS_NONE) */ |
| 170 | } |