mirror of
https://github.com/CTCaer/caffeine.git
synced 2025-02-10 21:12:39 +00:00
move payload dma to sc7fw
This commit is contained in:
parent
e11d3dc88c
commit
bb420da56b
@ -28,7 +28,7 @@ ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
|
||||
|
||||
CFLAGS := \
|
||||
-g \
|
||||
-O2 \
|
||||
-Os \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-fomit-frame-pointer \
|
||||
|
@ -21,10 +21,29 @@
|
||||
#include "pmc.h"
|
||||
#include "car.h"
|
||||
#include "i2c.h"
|
||||
#include "timer.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define AVP_CACHE_CONFIG_0 MAKE_REG32((uintptr_t)0x50040000)
|
||||
#define AVP_CACHE_CONFIG_0 MAKE_REG32((uintptr_t)0x50040000)
|
||||
|
||||
#define MAKE_AHBDMA_REG(r) (MAKE_REG32(((uintptr_t)0x60008000) + (r)))
|
||||
|
||||
#define AHBDMA_CMD_0 MAKE_AHBDMA_REG(0x000)
|
||||
#define AHBDMA_STA_0 MAKE_AHBDMA_REG(0x004)
|
||||
|
||||
#define MAKE_AHBDMACHAN_n_REG(n,r) (MAKE_REG32(((uintptr_t)0x60009000) + \
|
||||
(0x20 * (n)) + (r)))
|
||||
|
||||
#define AHBDMACHAN_CHANNEL_0_CSR_0 MAKE_AHBDMACHAN_n_REG(0 ,0x000)
|
||||
#define AHBDMACHAN_CHANNEL_0_AHB_PTR_0 MAKE_AHBDMACHAN_n_REG(0, 0x010)
|
||||
#define AHBDMACHAN_CHANNEL_0_AHB_SEQ_0 MAKE_AHBDMACHAN_n_REG(0, 0x014)
|
||||
#define AHBDMACHAN_CHANNEL_0_XMB_PTR_0 MAKE_AHBDMACHAN_n_REG(0, 0x018)
|
||||
|
||||
#define AHBDMACHAN_CHANNEL_1_CSR_0 MAKE_AHBDMACHAN_n_REG(1, 0x000)
|
||||
#define AHBDMACHAN_CHANNEL_1_AHB_PTR_0 MAKE_AHBDMACHAN_n_REG(1, 0x010)
|
||||
#define AHBDMACHAN_CHANNEL_1_AHB_SEQ_0 MAKE_AHBDMACHAN_n_REG(1, 0x014)
|
||||
#define AHBDMACHAN_CHANNEL_1_XMB_PTR_0 MAKE_AHBDMACHAN_n_REG(1, 0x018)
|
||||
|
||||
#define AHBDMACHAN_CHANNEL_2_CSR_0 MAKE_AHBDMACHAN_n_REG(2 ,0x000)
|
||||
#define AHBDMACHAN_CHANNEL_3_CSR_0 MAKE_AHBDMACHAN_n_REG(3, 0x000)
|
||||
|
||||
noreturn void reboot(void) {
|
||||
APBDEV_PMC_CNTRL_0 = 0x10;
|
||||
@ -33,6 +52,33 @@ noreturn void reboot(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline void ahbdma_copy_payload_to_iram(void) {
|
||||
AHBDMACHAN_CHANNEL_0_CSR_0 = 0;
|
||||
AHBDMACHAN_CHANNEL_1_CSR_0 = 0;
|
||||
AHBDMACHAN_CHANNEL_2_CSR_0 = 0;
|
||||
AHBDMACHAN_CHANNEL_3_CSR_0 = 0;
|
||||
|
||||
while (AHBDMA_STA_0 & (0xFu << 24)) {
|
||||
}
|
||||
|
||||
AHBDMACHAN_CHANNEL_0_AHB_PTR_0 = 0x40010000;
|
||||
AHBDMACHAN_CHANNEL_0_AHB_SEQ_0 = 0x02000000;
|
||||
AHBDMACHAN_CHANNEL_0_XMB_PTR_0 = 0x80000000;
|
||||
|
||||
AHBDMACHAN_CHANNEL_0_CSR_0 = BIT(31) | BIT(26) | (0x3FFFu << 2);
|
||||
|
||||
AHBDMACHAN_CHANNEL_1_AHB_PTR_0 = 0x40020000;
|
||||
AHBDMACHAN_CHANNEL_1_AHB_SEQ_0 = 0x02000000;
|
||||
AHBDMACHAN_CHANNEL_1_XMB_PTR_0 = 0x80010000;
|
||||
|
||||
AHBDMACHAN_CHANNEL_1_CSR_0 = BIT(31) | BIT(26) | (0x3FFFu << 2);
|
||||
|
||||
while (AHBDMA_STA_0 & (0x3u << 24)) {
|
||||
}
|
||||
|
||||
AHBDMA_CMD_0 &= ~BIT(31);
|
||||
}
|
||||
|
||||
static inline void configure_hiz_mode(void) {
|
||||
clkrst_reboot(CARDEVICE_I2C1);
|
||||
|
||||
@ -54,9 +100,10 @@ static inline void configure_pmic_wake_event(void) {
|
||||
void sc7_entry_main(void) {
|
||||
AVP_CACHE_CONFIG_0 |= 0xC00;
|
||||
|
||||
/* FIXME: determine that our payload is in place rather than stupidly waiting */
|
||||
/* if your display remains blank, try adjusting this value */
|
||||
spinlock_wait(0x1000000);
|
||||
while (APBDEV_PMC_PWRGATE_STATUS_0 & 1) {
|
||||
}
|
||||
|
||||
ahbdma_copy_payload_to_iram();
|
||||
|
||||
configure_pmic_wake_event();
|
||||
configure_hiz_mode();
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdalign.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
@ -116,7 +114,7 @@ static inline void query_io_mappings(void) {
|
||||
}
|
||||
|
||||
static inline void ahbdma_global_enable(void) {
|
||||
AHBDMA_CMD_0 = BIT(31);
|
||||
AHBDMA_CMD_0 |= BIT(31);
|
||||
}
|
||||
|
||||
static inline void ahbdma_global_disable(void) {
|
||||
@ -191,21 +189,14 @@ static UNUSED uint32_t ahbdma_read_reg32(uint32_t phys) {
|
||||
}
|
||||
|
||||
static void ahbdma_prepare_for_sleep(void) {
|
||||
AHBDMACHAN_CHANNEL_0_AHB_PTR_0 = 0x40010000;
|
||||
AHBDMACHAN_CHANNEL_0_AHB_SEQ_0 = 0x02000000;
|
||||
AHBDMACHAN_CHANNEL_0_XMB_PTR_0 = 0x80000000;
|
||||
|
||||
AHBDMACHAN_CHANNEL_0_CSR_0 = BIT(31) | (0x3FFFul << 2);
|
||||
|
||||
AHBDMACHAN_CHANNEL_1_AHB_PTR_0 = 0x40020000;
|
||||
AHBDMACHAN_CHANNEL_1_AHB_SEQ_0 = 0x02000000;
|
||||
AHBDMACHAN_CHANNEL_1_XMB_PTR_0 = 0x80010000;
|
||||
|
||||
AHBDMACHAN_CHANNEL_1_CSR_0 = BIT(31) | (0x3FFFul << 2);
|
||||
|
||||
for (unsigned int i = 0; i < 8; ++i) {
|
||||
g_device_pages[(0x20000 >> 2) + i] = 0x40038000;
|
||||
}
|
||||
g_device_pages[0x8000] = 0x40038000;
|
||||
g_device_pages[0x8004] = 0x40038000;
|
||||
g_device_pages[0x8008] = 0x40038000;
|
||||
g_device_pages[0x800C] = 0x40038000;
|
||||
g_device_pages[0x8010] = 0x40038000;
|
||||
g_device_pages[0x8014] = 0x40038000;
|
||||
g_device_pages[0x8018] = 0x40038000;
|
||||
g_device_pages[0x801C] = 0x40038000;
|
||||
|
||||
AHBDMACHAN_CHANNEL_2_AHB_PTR_0 = BPMP_VECTOR_RESET;
|
||||
AHBDMACHAN_CHANNEL_2_AHB_SEQ_0 = 0x02000000;
|
||||
|
Loading…
x
Reference in New Issue
Block a user