blob: 0174d5bfc806faba1c5113ba1c0aef1cdad67fe8 [file] [log] [blame]
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +02001/*
2 * Copyright (c) 2017-2018, Renesas Electronics Corporation. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef QOS_COMMON_H
8#define QOS_COMMON_H
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +02009
10#define RCAR_REF_DEFAULT (0U)
11
12#if (RCAR_LSI == RCAR_E3)
13/* define used for E3 */
14#if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 3.9usec */
15#define SUB_SLOT_CYCLE_E3 (0xAFU) /* 175 */
16#else /* REF 7.8usec */
17#define SUB_SLOT_CYCLE_E3 (0x15EU) /* 350 */
18#endif /* (RCAR_REF_INT == RCAR_REF_DEFAULT) */
19
20#define OPERATING_FREQ_E3 (266U) /* MHz */
21#define SL_INIT_SSLOTCLK_E3 (SUB_SLOT_CYCLE_E3 -1U)
22#define QOSWT_WTSET0_CYCLE_E3 ((SUB_SLOT_CYCLE_E3 * BASE_SUB_SLOT_NUM * 1000U)/OPERATING_FREQ_E3) /* unit:ns */
23#endif
24
25#if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_M3N)
26/* define used for M3N */
27#if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 1.95usec */
28#define SUB_SLOT_CYCLE_M3N (0x84U) /* 132 */
29#else /* REF 3.9usec */
30#define SUB_SLOT_CYCLE_M3N (0x108U) /* 264 */
31#endif /* (RCAR_REF_INT == RCAR_REF_DEFAULT) */
32
33#define SL_INIT_SSLOTCLK_M3N (SUB_SLOT_CYCLE_M3N -1U)
34#define QOSWT_WTSET0_CYCLE_M3N ((SUB_SLOT_CYCLE_M3N * BASE_SUB_SLOT_NUM * 1000U)/OPERATING_FREQ) /* unit:ns */
35#endif
36
37#if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_H3)
38/* define used for H3 */
39#if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 1.95usec */
40#define SUB_SLOT_CYCLE_H3_20 (0x84U) /* 132 */
41#else /* REF 3.9usec */
42#define SUB_SLOT_CYCLE_H3_20 (0x108U) /* 264 */
43#endif /* (RCAR_REF_INT == RCAR_REF_DEFAULT) */
44
45#define SL_INIT_SSLOTCLK_H3_20 (SUB_SLOT_CYCLE_H3_20 -1U)
46#define QOSWT_WTSET0_CYCLE_H3_20 ((SUB_SLOT_CYCLE_H3_20 * BASE_SUB_SLOT_NUM * 1000U)/OPERATING_FREQ) /* unit:ns */
47
48/* define used for H3 Cut 30 */
49#define SUB_SLOT_CYCLE_H3_30 (SUB_SLOT_CYCLE_H3_20) /* same as H3 Cut 20 */
50#define SL_INIT_SSLOTCLK_H3_30 (SUB_SLOT_CYCLE_H3_30 -1U)
51#define QOSWT_WTSET0_CYCLE_H3_30 ((SUB_SLOT_CYCLE_H3_30 * BASE_SUB_SLOT_NUM * 1000U)/OPERATING_FREQ) /* unit:ns */
52
53#endif
54
55#if (RCAR_LSI == RCAR_H3N)
56/* define used for H3N */
57#if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 1.95usec */
58#define SUB_SLOT_CYCLE_H3N (0x84U) /* 132 */
59#else /* REF 3.9usec */
60#define SUB_SLOT_CYCLE_H3N (0x108U) /* 264 */
61#endif /* (RCAR_REF_INT == RCAR_REF_DEFAULT) */
62
63#define SL_INIT_SSLOTCLK_H3N (SUB_SLOT_CYCLE_H3N -1U)
64#define QOSWT_WTSET0_CYCLE_H3N ((SUB_SLOT_CYCLE_H3N * BASE_SUB_SLOT_NUM * 1000U)/OPERATING_FREQ) /* unit:ns */
65
66#endif
67
68#if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_M3)
69/* define used for M3 */
70#if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 1.95usec */
71#define SUB_SLOT_CYCLE_M3_11 (0x84U) /* 132 */
72#else /* REF 3.9usec */
73#define SUB_SLOT_CYCLE_M3_11 (0x108U) /* 264 */
74#endif /* (RCAR_REF_INT == RCAR_REF_DEFAULT) */
75
76#define SL_INIT_SSLOTCLK_M3_11 (SUB_SLOT_CYCLE_M3_11 -1U)
77#define QOSWT_WTSET0_CYCLE_M3_11 ((SUB_SLOT_CYCLE_M3_11 * BASE_SUB_SLOT_NUM * 1000U)/OPERATING_FREQ) /* unit:ns */
78#endif
79
80#define OPERATING_FREQ (400U) /* MHz */
81#define BASE_SUB_SLOT_NUM (0x6U)
82#define SUB_SLOT_CYCLE (0x7EU) /* 126 */
83
84#define QOSWT_WTSET0_CYCLE ((SUB_SLOT_CYCLE * BASE_SUB_SLOT_NUM * 1000U)/OPERATING_FREQ) /* unit:ns */
85
86#define SL_INIT_REFFSSLOT (0x3U << 24U)
87#define SL_INIT_SLOTSSLOT ((BASE_SUB_SLOT_NUM - 1U) << 16U)
88#define SL_INIT_SSLOTCLK (SUB_SLOT_CYCLE -1U)
89
90static inline void io_write_32(uintptr_t addr, uint32_t value)
91{
92 *(volatile uint32_t *)addr = value;
93}
94
95static inline uint32_t io_read_32(uintptr_t addr)
96{
97 return *(volatile uint32_t *)addr;
98}
99
100static inline void io_write_64(uintptr_t addr, uint64_t value)
101{
102 *(volatile uint64_t *)addr = value;
103}
104
105typedef struct {
106 uintptr_t addr;
107 uint64_t value;
108} mstat_slot_t;
109
110extern uint32_t qos_init_ddr_ch;
111extern uint8_t qos_init_ddr_phyvalid;
112
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +0000113#endif /* QOS_COMMON_H */