2018-09-07 16:00:13 +01:00
|
|
|
/*
|
2019-04-08 03:00:49 +01:00
|
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
2018-09-07 16:00:13 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-02-26 10:00:02 +00:00
|
|
|
#ifndef EXOSPHERE_FLOW_CTLR_H
|
|
|
|
#define EXOSPHERE_FLOW_CTLR_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2018-03-09 22:56:16 +00:00
|
|
|
#include <stdbool.h>
|
2018-02-26 10:00:02 +00:00
|
|
|
#include "cpu_context.h"
|
|
|
|
#include "memory_map.h"
|
|
|
|
|
|
|
|
/* Exosphere register definitions for the Tegra X1 Flow Controller. */
|
|
|
|
|
2018-02-26 21:30:51 +00:00
|
|
|
static inline uintptr_t get_flow_base(void) {
|
|
|
|
return MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_FLOWCTRL);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FLOW_BASE (get_flow_base())
|
2018-02-26 10:00:02 +00:00
|
|
|
|
2018-03-03 19:23:13 +00:00
|
|
|
#define MAKE_FLOW_REG(ofs) MAKE_REG32(FLOW_BASE + ofs)
|
2018-02-26 10:00:02 +00:00
|
|
|
|
|
|
|
#define FLOW_CTLR_HALT_COP_EVENTS_0 MAKE_FLOW_REG(0x004)
|
2018-03-02 20:16:30 +00:00
|
|
|
#define FLOW_CTLR_FLOW_DBG_QUAL_0 MAKE_FLOW_REG(0x050)
|
2018-02-26 10:00:02 +00:00
|
|
|
#define FLOW_CTLR_L2FLUSH_CONTROL_0 MAKE_FLOW_REG(0x094)
|
2018-03-02 20:16:30 +00:00
|
|
|
#define FLOW_CTLR_BPMP_CLUSTER_CONTROL_0 MAKE_FLOW_REG(0x098)
|
2018-02-26 10:00:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
unsigned int CPUN_CSR_OFS;
|
|
|
|
unsigned int HALT_CPUN_EVENTS_OFS;
|
|
|
|
unsigned int CC4_COREN_CTRL_OFS;
|
|
|
|
} g_flow_core_offsets[NUM_CPU_CORES] = {
|
|
|
|
{0x008, 0x000, 0x06C},
|
|
|
|
{0x018, 0x014, 0x070},
|
|
|
|
{0x020, 0x01C, 0x074},
|
|
|
|
{0x028, 0x024, 0x078},
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void flow_set_cc4_ctrl(uint32_t core, uint32_t cc4_ctrl) {
|
|
|
|
MAKE_FLOW_REG(g_flow_core_offsets[core].CC4_COREN_CTRL_OFS) = cc4_ctrl;
|
|
|
|
}
|
|
|
|
|
2018-03-09 22:56:16 +00:00
|
|
|
static inline void flow_set_halt_events(uint32_t core, bool halt_events) {
|
|
|
|
MAKE_FLOW_REG(g_flow_core_offsets[core].HALT_CPUN_EVENTS_OFS) = (halt_events ? 0x40000F00 : 0x40000000);
|
2018-02-26 10:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void flow_set_csr(uint32_t core, uint32_t csr) {
|
2018-03-09 22:56:16 +00:00
|
|
|
MAKE_FLOW_REG(g_flow_core_offsets[core].CPUN_CSR_OFS) = (0x100 << core) | (csr << 12) | 0xC001;
|
2018-02-26 10:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void flow_clear_csr0_and_events(uint32_t core) {
|
|
|
|
MAKE_FLOW_REG(g_flow_core_offsets[core].CPUN_CSR_OFS) = 0;
|
|
|
|
MAKE_FLOW_REG(g_flow_core_offsets[core].HALT_CPUN_EVENTS_OFS) = 0;
|
|
|
|
}
|
|
|
|
|
2018-02-26 21:30:51 +00:00
|
|
|
#endif
|