123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- /*
- * Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
- #include <stdint.h>
- #include <common/debug.h>
- #include <lib/mmio.h>
- #include "qos_init.h"
- #include "qos_common.h"
- #include "qos_reg.h"
- #include "rcar_def.h"
- #if RCAR_LSI == RCAR_AUTO
- #include "H3/qos_init_h3_v10.h"
- #include "H3/qos_init_h3_v11.h"
- #include "H3/qos_init_h3_v20.h"
- #include "H3/qos_init_h3_v30.h"
- #include "M3/qos_init_m3_v10.h"
- #include "M3/qos_init_m3_v11.h"
- #include "M3/qos_init_m3_v30.h"
- #include "M3N/qos_init_m3n_v10.h"
- #include "V3M/qos_init_v3m.h"
- #endif
- #if RCAR_LSI == RCAR_H3 /* H3 */
- #include "H3/qos_init_h3_v10.h"
- #include "H3/qos_init_h3_v11.h"
- #include "H3/qos_init_h3_v20.h"
- #include "H3/qos_init_h3_v30.h"
- #endif
- #if RCAR_LSI == RCAR_H3N /* H3 */
- #include "H3/qos_init_h3n_v30.h"
- #endif
- #if RCAR_LSI == RCAR_M3 /* M3 */
- #include "M3/qos_init_m3_v10.h"
- #include "M3/qos_init_m3_v11.h"
- #include "M3/qos_init_m3_v30.h"
- #endif
- #if RCAR_LSI == RCAR_M3N /* M3N */
- #include "M3N/qos_init_m3n_v10.h"
- #endif
- #if RCAR_LSI == RCAR_V3M /* V3M */
- #include "V3M/qos_init_v3m.h"
- #endif
- #if RCAR_LSI == RCAR_E3 /* E3 */
- #include "E3/qos_init_e3_v10.h"
- #endif
- #if RCAR_LSI == RCAR_D3 /* D3 */
- #include "D3/qos_init_d3.h"
- #endif
- #if (RCAR_LSI != RCAR_E3) && (RCAR_LSI != RCAR_D3) && (RCAR_LSI != RCAR_V3M)
- #define DRAM_CH_CNT 0x04
- uint32_t qos_init_ddr_ch;
- uint8_t qos_init_ddr_phyvalid;
- #endif
- #define PRR_PRODUCT_ERR(reg) \
- do { \
- ERROR("LSI Product ID(PRR=0x%x) QoS " \
- "initialize not supported.\n", reg); \
- panic(); \
- } while (0)
- #define PRR_CUT_ERR(reg) \
- do { \
- ERROR("LSI Cut ID(PRR=0x%x) QoS " \
- "initialize not supported.\n", reg); \
- panic(); \
- } while (0)
- void rcar_qos_init(void)
- {
- uint32_t reg;
- #if (RCAR_LSI != RCAR_E3) && (RCAR_LSI != RCAR_D3) && (RCAR_LSI != RCAR_V3M)
- uint32_t i;
- qos_init_ddr_ch = 0;
- qos_init_ddr_phyvalid = get_boardcnf_phyvalid();
- for (i = 0; i < DRAM_CH_CNT; i++) {
- if ((qos_init_ddr_phyvalid & (1 << i))) {
- qos_init_ddr_ch++;
- }
- }
- #endif
- reg = mmio_read_32(PRR);
- #if (RCAR_LSI == RCAR_AUTO) || RCAR_LSI_CUT_COMPAT
- switch (reg & PRR_PRODUCT_MASK) {
- case PRR_PRODUCT_H3:
- #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_H3)
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_10:
- qos_init_h3_v10();
- break;
- case PRR_PRODUCT_11:
- qos_init_h3_v11();
- break;
- case PRR_PRODUCT_20:
- qos_init_h3_v20();
- break;
- case PRR_PRODUCT_30:
- default:
- qos_init_h3_v30();
- break;
- }
- #elif (RCAR_LSI == RCAR_H3N)
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_30:
- default:
- qos_init_h3n_v30();
- break;
- }
- #else
- PRR_PRODUCT_ERR(reg);
- #endif
- break;
- case PRR_PRODUCT_M3:
- #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_M3)
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_10:
- qos_init_m3_v10();
- break;
- case PRR_PRODUCT_21: /* M3 Cut 13 */
- qos_init_m3_v11();
- break;
- case PRR_PRODUCT_30: /* M3 Cut 30 */
- default:
- qos_init_m3_v30();
- break;
- }
- #else
- PRR_PRODUCT_ERR(reg);
- #endif
- break;
- case PRR_PRODUCT_M3N:
- #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_M3N)
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_10:
- default:
- qos_init_m3n_v10();
- break;
- }
- #else
- PRR_PRODUCT_ERR(reg);
- #endif
- break;
- case PRR_PRODUCT_V3M:
- #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_V3M)
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_10:
- case PRR_PRODUCT_20:
- default:
- qos_init_v3m();
- break;
- }
- #else
- PRR_PRODUCT_ERR(reg);
- #endif
- break;
- case PRR_PRODUCT_E3:
- #if (RCAR_LSI == RCAR_E3)
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_10:
- default:
- qos_init_e3_v10();
- break;
- }
- #else
- PRR_PRODUCT_ERR(reg);
- #endif
- break;
- case PRR_PRODUCT_D3:
- #if (RCAR_LSI == RCAR_D3)
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_10:
- default:
- qos_init_d3();
- break;
- }
- #else
- PRR_PRODUCT_ERR(reg);
- #endif
- break;
- default:
- PRR_PRODUCT_ERR(reg);
- break;
- }
- #else
- #if RCAR_LSI == RCAR_H3 /* H3 */
- #if RCAR_LSI_CUT == RCAR_CUT_10
- /* H3 Cut 10 */
- if ((PRR_PRODUCT_H3 | PRR_PRODUCT_10)
- != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_h3_v10();
- #elif RCAR_LSI_CUT == RCAR_CUT_11
- /* H3 Cut 11 */
- if ((PRR_PRODUCT_H3 | PRR_PRODUCT_11)
- != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_h3_v11();
- #elif RCAR_LSI_CUT == RCAR_CUT_20
- /* H3 Cut 20 */
- if ((PRR_PRODUCT_H3 | PRR_PRODUCT_20)
- != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_h3_v20();
- #else
- /* H3 Cut 30 or later */
- if ((PRR_PRODUCT_H3)
- != (reg & (PRR_PRODUCT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_h3_v30();
- #endif
- #elif RCAR_LSI == RCAR_H3N /* H3 */
- /* H3N Cut 30 or later */
- if ((PRR_PRODUCT_H3)
- != (reg & (PRR_PRODUCT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_h3n_v30();
- #elif RCAR_LSI == RCAR_M3 /* M3 */
- #if RCAR_LSI_CUT == RCAR_CUT_10
- /* M3 Cut 10 */
- if ((PRR_PRODUCT_M3 | PRR_PRODUCT_10)
- != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_m3_v10();
- #elif RCAR_LSI_CUT == RCAR_CUT_11
- /* M3 Cut 11 */
- if ((PRR_PRODUCT_M3 | PRR_PRODUCT_20)
- != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_m3_v11();
- #elif RCAR_LSI_CUT == RCAR_CUT_13
- /* M3 Cut 13 */
- if ((PRR_PRODUCT_M3 | PRR_PRODUCT_21)
- != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_m3_v11();
- #else
- /* M3 Cut 30 or later */
- if ((PRR_PRODUCT_M3)
- != (reg & (PRR_PRODUCT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_m3_v30();
- #endif
- #elif RCAR_LSI == RCAR_M3N /* M3N */
- /* M3N Cut 10 or later */
- if ((PRR_PRODUCT_M3N)
- != (reg & (PRR_PRODUCT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_m3n_v10();
- #elif RCAR_LSI == RCAR_V3M /* V3M */
- /* V3M Cut 10 or later */
- if ((PRR_PRODUCT_V3M)
- != (reg & (PRR_PRODUCT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_v3m();
- #elif RCAR_LSI == RCAR_D3 /* D3 */
- /* D3 Cut 10 or later */
- if ((PRR_PRODUCT_D3)
- != (reg & (PRR_PRODUCT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_d3();
- #elif RCAR_LSI == RCAR_E3 /* E3 */
- /* E3 Cut 10 or later */
- if ((PRR_PRODUCT_E3)
- != (reg & (PRR_PRODUCT_MASK))) {
- PRR_PRODUCT_ERR(reg);
- }
- qos_init_e3_v10();
- #else
- #error "Don't have QoS initialize routine(Unknown chip)."
- #endif
- #endif
- }
- #if (RCAR_LSI != RCAR_E3) && (RCAR_LSI != RCAR_D3) && (RCAR_LSI != RCAR_V3M)
- uint32_t get_refperiod(void)
- {
- uint32_t refperiod = QOSWT_WTSET0_CYCLE;
- #if (RCAR_LSI == RCAR_AUTO) || RCAR_LSI_CUT_COMPAT
- uint32_t reg;
- reg = mmio_read_32(PRR);
- switch (reg & PRR_PRODUCT_MASK) {
- #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_H3)
- case PRR_PRODUCT_H3:
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_10:
- case PRR_PRODUCT_11:
- break;
- case PRR_PRODUCT_20:
- case PRR_PRODUCT_30:
- default:
- refperiod = REFPERIOD_CYCLE;
- break;
- }
- break;
- #elif (RCAR_LSI == RCAR_H3N)
- case PRR_PRODUCT_H3:
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_30:
- default:
- refperiod = REFPERIOD_CYCLE;
- break;
- }
- break;
- #endif
- #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_M3)
- case PRR_PRODUCT_M3:
- switch (reg & PRR_CUT_MASK) {
- case PRR_PRODUCT_10:
- break;
- case PRR_PRODUCT_20: /* M3 Cut 11 */
- case PRR_PRODUCT_21: /* M3 Cut 13 */
- case PRR_PRODUCT_30: /* M3 Cut 30 */
- default:
- refperiod = REFPERIOD_CYCLE;
- break;
- }
- break;
- #endif
- #if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_M3N)
- case PRR_PRODUCT_M3N:
- refperiod = REFPERIOD_CYCLE;
- break;
- #endif
- default:
- break;
- }
- #elif RCAR_LSI == RCAR_H3
- #if RCAR_LSI_CUT == RCAR_CUT_10
- /* H3 Cut 10 */
- #elif RCAR_LSI_CUT == RCAR_CUT_11
- /* H3 Cut 11 */
- #else
- /* H3 Cut 20 */
- /* H3 Cut 30 or later */
- refperiod = REFPERIOD_CYCLE;
- #endif
- #elif RCAR_LSI == RCAR_H3N
- /* H3N Cut 30 or later */
- refperiod = REFPERIOD_CYCLE;
- #elif RCAR_LSI == RCAR_M3
- #if RCAR_LSI_CUT == RCAR_CUT_10
- /* M3 Cut 10 */
- #else
- /* M3 Cut 11 */
- /* M3 Cut 13 */
- /* M3 Cut 30 or later */
- refperiod = REFPERIOD_CYCLE;
- #endif
- #elif RCAR_LSI == RCAR_M3N /* for M3N */
- refperiod = REFPERIOD_CYCLE;
- #endif
- return refperiod;
- }
- #endif
- void rcar_qos_dbsc_setting(struct rcar_gen3_dbsc_qos_settings *qos,
- unsigned int qos_size, bool dbsc_wren)
- {
- int i;
- /* Register write enable */
- if (dbsc_wren)
- io_write_32(DBSC_DBSYSCNT0, 0x00001234U);
- for (i = 0; i < qos_size; i++)
- io_write_32(qos[i].reg, qos[i].val);
- /* Register write protect */
- if (dbsc_wren)
- io_write_32(DBSC_DBSYSCNT0, 0x00000000U);
- }
|