Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/soc/bpmp.h
1476 views
1
/*
2
* BPMP-Lite Cache/MMU and Frequency driver for Tegra X1
3
*
4
* Copyright (c) 2019-2024 CTCaer
5
*
6
* This program is free software; you can redistribute it and/or modify it
7
* under the terms and conditions of the GNU General Public License,
8
* version 2, as published by the Free Software Foundation.
9
*
10
* This program is distributed in the hope it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
* more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef _BPMP_H_
20
#define _BPMP_H_
21
22
#include <utils/types.h>
23
24
typedef enum
25
{
26
BPMP_MMU_MAINT_NOP = 0,
27
BPMP_MMU_MAINT_CLEAN_PHY = 1,
28
BPMP_MMU_MAINT_INVALID_PHY = 2,
29
BPMP_MMU_MAINT_CLEAN_INVALID_PHY = 3,
30
BPMP_MMU_MAINT_CLEAN_LINE = 9,
31
BPMP_MMU_MAINT_INVALID_LINE = 10,
32
BPMP_MMU_MAINT_CLEAN_INVALID_LINE = 11,
33
BPMP_MMU_MAINT_CLEAN_WAY = 17,
34
BPMP_MMU_MAINT_INVALID_WAY = 18,
35
BPMP_MMU_MAINT_CLN_INV_WAY = 19
36
} bpmp_maintenance_t;
37
38
typedef struct _bpmp_mmu_entry_t
39
{
40
u32 start_addr;
41
u32 end_addr;
42
u32 attr;
43
u32 enable;
44
} bpmp_mmu_entry_t;
45
46
typedef enum
47
{
48
BPMP_CLK_NORMAL, // 408MHz 0% - 136MHz APB.
49
BPMP_CLK_HIGH_BOOST, // 544MHz 33% - 136MHz APB.
50
BPMP_CLK_HIGH2_BOOST, // 563MHz 38% - 141MHz APB.
51
BPMP_CLK_SUPER_BOOST, // 576MHz 41% - 144MHz APB.
52
BPMP_CLK_HYPER_BOOST, // 589MHz 44% - 147MHz APB.
53
//BPMP_CLK_DEV_BOOST, // 608MHz 49% - 152MHz APB.
54
BPMP_CLK_MAX
55
} bpmp_freq_t;
56
57
typedef enum
58
{
59
BPMP_STATE_STANDBY = 0, // 32KHz.
60
BPMP_STATE_IDLE = 1,
61
BPMP_STATE_RUN = 2,
62
63
BPMP_STATE_IRQ = BIT(2),
64
BPMP_STATE_FIQ = BIT(3),
65
} bpmp_state_t;
66
67
#define BPMP_CLK_LOWEST_BOOST BPMP_CLK_HIGH2_BOOST
68
#define BPMP_CLK_LOWER_BOOST BPMP_CLK_SUPER_BOOST
69
#define BPMP_CLK_DEFAULT_BOOST BPMP_CLK_HYPER_BOOST
70
71
void bpmp_mmu_maintenance(u32 op, bool force);
72
void bpmp_mmu_set_entry(int idx, const bpmp_mmu_entry_t *entry, bool apply);
73
void bpmp_mmu_enable();
74
void bpmp_mmu_disable();
75
void bpmp_clk_rate_relaxed(bool enable);
76
void bpmp_clk_rate_get();
77
void bpmp_clk_rate_set(bpmp_freq_t fid);
78
void bpmp_state_set(bpmp_state_t state);
79
void bpmp_usleep(u32 us);
80
void bpmp_msleep(u32 ms);
81
void bpmp_halt();
82
83
#endif
84
85