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 | { |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 21 | /* BUFCAM settings */ |
| 22 | /* DBSC_DBCAM0CNF0 not set */ |
Marek Vasut | 6a669f6 | 2019-06-14 01:50:16 +0200 | [diff] [blame] | 23 | io_write_32(DBSC_DBCAM0CNF1, 0x00043218); |
| 24 | io_write_32(DBSC_DBCAM0CNF2, 0x000000F4); |
| 25 | io_write_32(DBSC_DBCAM0CNF3, 0x00000000); |
| 26 | io_write_32(DBSC_DBSCHCNT0, 0x080F0037); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 27 | /* DBSC_DBSCHCNT1 not set */ |
Marek Vasut | 6a669f6 | 2019-06-14 01:50:16 +0200 | [diff] [blame] | 28 | io_write_32(DBSC_DBSCHSZ0, 0x00000001); |
| 29 | io_write_32(DBSC_DBSCHRW0, 0x22421111); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 30 | |
Marek Vasut | 5ea57a52 | 2019-06-14 01:51:40 +0200 | [diff] [blame] | 31 | /* DDR3 */ |
| 32 | io_write_32(DBSC_SCFCTST2, 0x012F1123); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 33 | |
| 34 | /* QoS Settings */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 35 | io_write_32(DBSC_DBSCHQOS00, 0x00000F00); |
| 36 | io_write_32(DBSC_DBSCHQOS01, 0x00000B00); |
| 37 | io_write_32(DBSC_DBSCHQOS02, 0x00000000); |
| 38 | io_write_32(DBSC_DBSCHQOS03, 0x00000000); |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 39 | io_write_32(DBSC_DBSCHQOS40, 0x00000300); |
| 40 | io_write_32(DBSC_DBSCHQOS41, 0x000002F0); |
| 41 | io_write_32(DBSC_DBSCHQOS42, 0x00000200); |
| 42 | io_write_32(DBSC_DBSCHQOS43, 0x00000100); |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 43 | io_write_32(DBSC_DBSCHQOS90, 0x00000300); |
| 44 | io_write_32(DBSC_DBSCHQOS91, 0x000002F0); |
| 45 | io_write_32(DBSC_DBSCHQOS92, 0x00000200); |
| 46 | io_write_32(DBSC_DBSCHQOS93, 0x00000100); |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 47 | io_write_32(DBSC_DBSCHQOS130, 0x00000100); |
| 48 | io_write_32(DBSC_DBSCHQOS131, 0x000000F0); |
| 49 | io_write_32(DBSC_DBSCHQOS132, 0x000000A0); |
| 50 | io_write_32(DBSC_DBSCHQOS133, 0x00000040); |
| 51 | io_write_32(DBSC_DBSCHQOS140, 0x000000C0); |
| 52 | io_write_32(DBSC_DBSCHQOS141, 0x000000B0); |
| 53 | io_write_32(DBSC_DBSCHQOS142, 0x00000080); |
| 54 | io_write_32(DBSC_DBSCHQOS143, 0x00000040); |
| 55 | io_write_32(DBSC_DBSCHQOS150, 0x00000040); |
| 56 | io_write_32(DBSC_DBSCHQOS151, 0x00000030); |
| 57 | io_write_32(DBSC_DBSCHQOS152, 0x00000020); |
| 58 | io_write_32(DBSC_DBSCHQOS153, 0x00000010); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | void qos_init_m3_v10(void) |
| 62 | { |
| 63 | dbsc_setting(); |
| 64 | |
| 65 | /* DRAM Split Address mapping */ |
| 66 | #if RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_4CH |
| 67 | #if RCAR_LSI == RCAR_M3 |
| 68 | #error "Don't set DRAM Split 4ch(M3)" |
| 69 | #else |
| 70 | ERROR("DRAM Split 4ch not supported.(M3)"); |
| 71 | panic(); |
| 72 | #endif |
| 73 | #elif (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_2CH) || \ |
| 74 | (RCAR_DRAM_SPLIT == RCAR_DRAM_SPLIT_AUTO) |
| 75 | NOTICE("BL2: DRAM Split is 2ch\n"); |
| 76 | io_write_32(AXI_ADSPLCR0, 0x00000000U); |
| 77 | io_write_32(AXI_ADSPLCR1, ADSPLCR0_ADRMODE_DEFAULT |
| 78 | | ADSPLCR0_SPLITSEL(0xFFU) |
| 79 | | ADSPLCR0_AREA(0x1CU) |
| 80 | | ADSPLCR0_SWP); |
| 81 | io_write_32(AXI_ADSPLCR2, 0x089A0000U); |
| 82 | io_write_32(AXI_ADSPLCR3, 0x00000000U); |
| 83 | #else |
| 84 | NOTICE("BL2: DRAM Split is OFF\n"); |
| 85 | #endif |
| 86 | |
| 87 | #if !(RCAR_QOS_TYPE == RCAR_QOS_NONE) |
| 88 | #if RCAR_QOS_TYPE == RCAR_QOS_TYPE_DEFAULT |
| 89 | NOTICE("BL2: QoS is default setting(%s)\n", RCAR_QOS_VERSION); |
| 90 | #endif |
| 91 | |
| 92 | /* Resource Alloc setting */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 93 | io_write_32(QOSCTRL_RAS, 0x00000028U); |
| 94 | io_write_32(QOSCTRL_FIXTH, 0x000F0005U); |
| 95 | io_write_32(QOSCTRL_REGGD, 0x00000000U); |
| 96 | io_write_64(QOSCTRL_DANN, 0x0101010102020201UL); |
| 97 | io_write_32(QOSCTRL_DANT, 0x00100804U); |
| 98 | io_write_32(QOSCTRL_EC, 0x00000000U); |
| 99 | io_write_64(QOSCTRL_EMS, 0x0000000000000000UL); |
| 100 | io_write_32(QOSCTRL_FSS, 0x000003e8U); |
| 101 | io_write_32(QOSCTRL_INSFC, 0xC7840001U); |
| 102 | io_write_32(QOSCTRL_BERR, 0x00000000U); |
| 103 | io_write_32(QOSCTRL_RACNT0, 0x00000000U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 104 | |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 105 | /* QOSBW setting */ |
| 106 | io_write_32(QOSCTRL_SL_INIT, |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 107 | SL_INIT_REFFSSLOT | SL_INIT_SLOTSSLOT | SL_INIT_SSLOTCLK); |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 108 | io_write_32(QOSCTRL_REF_ARS, 0x00330000U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 109 | |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 110 | /* QOSBW SRAM setting */ |
Marek Vasut | 5753df4 | 2019-06-14 01:39:27 +0200 | [diff] [blame] | 111 | uint32_t i; |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 112 | |
Marek Vasut | 5753df4 | 2019-06-14 01:39:27 +0200 | [diff] [blame] | 113 | for (i = 0U; i < ARRAY_SIZE(mstat_fix); i++) { |
| 114 | io_write_64(QOSBW_FIX_QOS_BANK0 + i * 8, mstat_fix[i]); |
| 115 | io_write_64(QOSBW_FIX_QOS_BANK1 + i * 8, mstat_fix[i]); |
| 116 | } |
| 117 | for (i = 0U; i < ARRAY_SIZE(mstat_be); i++) { |
| 118 | io_write_64(QOSBW_BE_QOS_BANK0 + i * 8, mstat_be[i]); |
| 119 | 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] | 120 | } |
| 121 | |
| 122 | /* 3DG bus Leaf setting */ |
| 123 | io_write_32(0xFD820808U, 0x00001234U); |
| 124 | io_write_32(0xFD820800U, 0x00000006U); |
| 125 | io_write_32(0xFD821800U, 0x00000006U); |
| 126 | io_write_32(0xFD822800U, 0x00000006U); |
| 127 | io_write_32(0xFD823800U, 0x00000006U); |
| 128 | io_write_32(0xFD824800U, 0x00000006U); |
| 129 | io_write_32(0xFD825800U, 0x00000006U); |
| 130 | io_write_32(0xFD826800U, 0x00000006U); |
| 131 | io_write_32(0xFD827800U, 0x00000006U); |
| 132 | |
| 133 | /* RT bus Leaf setting */ |
| 134 | io_write_32(0xFFC50800U, 0x00000000U); |
| 135 | io_write_32(0xFFC51800U, 0x00000000U); |
| 136 | |
| 137 | /* Resource Alloc start */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 138 | io_write_32(QOSCTRL_RAEN, 0x00000001U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 139 | |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 140 | /* QOSBW start */ |
| 141 | io_write_32(QOSCTRL_STATQC, 0x00000001U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 142 | #else |
| 143 | NOTICE("BL2: QoS is None\n"); |
| 144 | |
| 145 | /* Resource Alloc setting */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 146 | io_write_32(QOSCTRL_EC, 0x00000000U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 147 | /* Resource Alloc start */ |
Marek Vasut | 2dd95b8 | 2019-06-14 01:41:10 +0200 | [diff] [blame] | 148 | io_write_32(QOSCTRL_RAEN, 0x00000001U); |
Jorge Ramirez-Ortiz | 47503d2 | 2018-09-23 09:36:52 +0200 | [diff] [blame] | 149 | #endif /* !(RCAR_QOS_TYPE == RCAR_QOS_NONE) */ |
| 150 | } |