mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 11:21:23 +00:00
bpmp: Add forcable maintenance
+ Fix build issues
This commit is contained in:
parent
9811ba53e0
commit
bc7dec2e61
9 changed files with 19 additions and 23 deletions
|
@ -78,9 +78,9 @@ bpmp_mmu_entry_t mmu_entries[] =
|
||||||
{ IPL_LOAD_ADDR, 0x40040000, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true }
|
{ IPL_LOAD_ADDR, 0x40040000, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true }
|
||||||
};
|
};
|
||||||
|
|
||||||
void bpmp_mmu_maintenance(u32 op)
|
void bpmp_mmu_maintenance(u32 op, bool force)
|
||||||
{
|
{
|
||||||
if (!(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE))
|
if (!force && !(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_CLR_MAINT_DONE;
|
BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_CLR_MAINT_DONE;
|
||||||
|
@ -132,13 +132,13 @@ void bpmp_mmu_enable()
|
||||||
BPMP_CACHE_CTRL(BPMP_CACHE_MMU_CMD) = MMU_CMD_COPY_SHADOW;
|
BPMP_CACHE_CTRL(BPMP_CACHE_MMU_CMD) = MMU_CMD_COPY_SHADOW;
|
||||||
|
|
||||||
// Invalidate cache.
|
// Invalidate cache.
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, true);
|
||||||
|
|
||||||
// Enable cache.
|
// Enable cache.
|
||||||
BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = CFG_ENABLE | CFG_FORCE_WRITE_THROUGH | CFG_TAG_CHK_ABRT_ON_ERR;
|
BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = CFG_ENABLE | CFG_FORCE_WRITE_THROUGH | CFG_TAG_CHK_ABRT_ON_ERR;
|
||||||
|
|
||||||
// HW bug. Invalidate cache again.
|
// HW bug. Invalidate cache again.
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bpmp_mmu_disable()
|
void bpmp_mmu_disable()
|
||||||
|
@ -147,13 +147,10 @@ void bpmp_mmu_disable()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Clean and invalidate cache.
|
// Clean and invalidate cache.
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
|
||||||
|
|
||||||
// Disable cache.
|
// Disable cache.
|
||||||
BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = 0;
|
BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = 0;
|
||||||
|
|
||||||
// HW bug. Invalidate cache again.
|
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const u8 pllc4_divn[] = {
|
const u8 pllc4_divn[] = {
|
||||||
|
|
|
@ -42,7 +42,7 @@ typedef enum
|
||||||
BPMP_CLK_MAX
|
BPMP_CLK_MAX
|
||||||
} bpmp_freq_t;
|
} bpmp_freq_t;
|
||||||
|
|
||||||
void bpmp_mmu_maintenance(u32 op);
|
void bpmp_mmu_maintenance(u32 op, bool force);
|
||||||
void bpmp_mmu_set_entry(int idx, bpmp_mmu_entry_t *entry, bool apply);
|
void bpmp_mmu_set_entry(int idx, bpmp_mmu_entry_t *entry, bool apply);
|
||||||
void bpmp_mmu_enable();
|
void bpmp_mmu_enable();
|
||||||
void bpmp_mmu_disable();
|
void bpmp_mmu_disable();
|
||||||
|
|
|
@ -95,7 +95,7 @@ static int emummc_raw_get_part_off(int part_idx)
|
||||||
int emummc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc)
|
int emummc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc)
|
||||||
{
|
{
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
if (!sdmmc_storage_init_mmc(storage, sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400))
|
if (!sdmmc_storage_init_mmc(storage, sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
if (h_cfg.emummc_force_disable)
|
if (h_cfg.emummc_force_disable)
|
||||||
|
|
|
@ -830,7 +830,7 @@ static int _sdmmc_config_dma(sdmmc_t *sdmmc, u32 *blkcnt_out, sdmmc_req_t *req)
|
||||||
trnmode |= TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_READ;
|
trnmode |= TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_READ;
|
||||||
if (req->is_auto_cmd12)
|
if (req->is_auto_cmd12)
|
||||||
trnmode = (trnmode & 0xFFF3) | TEGRA_MMC_TRNMOD_AUTO_CMD12;
|
trnmode = (trnmode & 0xFFF3) | TEGRA_MMC_TRNMOD_AUTO_CMD12;
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
|
||||||
sdmmc->regs->trnmod = trnmode;
|
sdmmc->regs->trnmod = trnmode;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -855,7 +855,7 @@ static int _sdmmc_update_dma(sdmmc_t *sdmmc)
|
||||||
break;
|
break;
|
||||||
if (intr & TEGRA_MMC_NORINTSTS_XFER_COMPLETE)
|
if (intr & TEGRA_MMC_NORINTSTS_XFER_COMPLETE)
|
||||||
{
|
{
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
|
||||||
return 1; // Transfer complete.
|
return 1; // Transfer complete.
|
||||||
}
|
}
|
||||||
if (intr & TEGRA_MMC_NORINTSTS_DMA_INTERRUPT)
|
if (intr & TEGRA_MMC_NORINTSTS_DMA_INTERRUPT)
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "../libs/fatfs/ff.h"
|
#include "../libs/fatfs/ff.h"
|
||||||
#include "../mem/heap.h"
|
#include "../mem/heap.h"
|
||||||
#include "../sec/se.h"
|
#include "../sec/se.h"
|
||||||
|
#include "../sec/se_t210.h"
|
||||||
#include "../storage/nx_emmc.h"
|
#include "../storage/nx_emmc.h"
|
||||||
#include "../storage/sdmmc.h"
|
#include "../storage/sdmmc.h"
|
||||||
#include "../utils/btn.h"
|
#include "../utils/btn.h"
|
||||||
|
|
|
@ -81,9 +81,9 @@ bpmp_mmu_entry_t mmu_entries[] =
|
||||||
{ NYX_LOAD_ADDR, 0x40040000, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true }
|
{ NYX_LOAD_ADDR, 0x40040000, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true }
|
||||||
};
|
};
|
||||||
|
|
||||||
void bpmp_mmu_maintenance(u32 op)
|
void bpmp_mmu_maintenance(u32 op, bool force)
|
||||||
{
|
{
|
||||||
if (!(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE))
|
if (!force && !(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_CLR_MAINT_DONE;
|
BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_CLR_MAINT_DONE;
|
||||||
|
@ -135,13 +135,13 @@ void bpmp_mmu_enable()
|
||||||
BPMP_CACHE_CTRL(BPMP_CACHE_MMU_CMD) = MMU_CMD_COPY_SHADOW;
|
BPMP_CACHE_CTRL(BPMP_CACHE_MMU_CMD) = MMU_CMD_COPY_SHADOW;
|
||||||
|
|
||||||
// Invalidate cache.
|
// Invalidate cache.
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, true);
|
||||||
|
|
||||||
// Enable cache.
|
// Enable cache.
|
||||||
BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = CFG_ENABLE | CFG_FORCE_WRITE_THROUGH | CFG_TAG_CHK_ABRT_ON_ERR;
|
BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = CFG_ENABLE | CFG_FORCE_WRITE_THROUGH | CFG_TAG_CHK_ABRT_ON_ERR;
|
||||||
|
|
||||||
// HW bug. Invalidate cache again.
|
// HW bug. Invalidate cache again.
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bpmp_mmu_disable()
|
void bpmp_mmu_disable()
|
||||||
|
@ -150,13 +150,10 @@ void bpmp_mmu_disable()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Clean and invalidate cache.
|
// Clean and invalidate cache.
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
|
||||||
|
|
||||||
// Disable cache.
|
// Disable cache.
|
||||||
BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = 0;
|
BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = 0;
|
||||||
|
|
||||||
// HW bug. Invalidate cache again.
|
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const u8 pllc4_divn[] = {
|
const u8 pllc4_divn[] = {
|
||||||
|
|
|
@ -42,7 +42,7 @@ typedef enum
|
||||||
BPMP_CLK_MAX
|
BPMP_CLK_MAX
|
||||||
} bpmp_freq_t;
|
} bpmp_freq_t;
|
||||||
|
|
||||||
void bpmp_mmu_maintenance(u32 op);
|
void bpmp_mmu_maintenance(u32 op, bool force);
|
||||||
void bpmp_mmu_set_entry(int idx, bpmp_mmu_entry_t *entry, bool apply);
|
void bpmp_mmu_set_entry(int idx, bpmp_mmu_entry_t *entry, bool apply);
|
||||||
void bpmp_mmu_enable();
|
void bpmp_mmu_enable();
|
||||||
void bpmp_mmu_disable();
|
void bpmp_mmu_disable();
|
||||||
|
|
|
@ -830,7 +830,7 @@ static int _sdmmc_config_dma(sdmmc_t *sdmmc, u32 *blkcnt_out, sdmmc_req_t *req)
|
||||||
trnmode |= TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_READ;
|
trnmode |= TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_READ;
|
||||||
if (req->is_auto_cmd12)
|
if (req->is_auto_cmd12)
|
||||||
trnmode = (trnmode & 0xFFF3) | TEGRA_MMC_TRNMOD_AUTO_CMD12;
|
trnmode = (trnmode & 0xFFF3) | TEGRA_MMC_TRNMOD_AUTO_CMD12;
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
|
||||||
sdmmc->regs->trnmod = trnmode;
|
sdmmc->regs->trnmod = trnmode;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -855,7 +855,7 @@ static int _sdmmc_update_dma(sdmmc_t *sdmmc)
|
||||||
break;
|
break;
|
||||||
if (intr & TEGRA_MMC_NORINTSTS_XFER_COMPLETE)
|
if (intr & TEGRA_MMC_NORINTSTS_XFER_COMPLETE)
|
||||||
{
|
{
|
||||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY);
|
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
|
||||||
return 1; // Transfer complete.
|
return 1; // Transfer complete.
|
||||||
}
|
}
|
||||||
if (intr & TEGRA_MMC_NORINTSTS_DMA_INTERRUPT)
|
if (intr & TEGRA_MMC_NORINTSTS_DMA_INTERRUPT)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "../gfx/di.h"
|
#include "../gfx/di.h"
|
||||||
#include "../mem/minerva.h"
|
#include "../mem/minerva.h"
|
||||||
#include "../power/max77620.h"
|
#include "../power/max77620.h"
|
||||||
|
#include "../rtc/max77620-rtc.h"
|
||||||
#include "../soc/bpmp.h"
|
#include "../soc/bpmp.h"
|
||||||
#include "../soc/i2c.h"
|
#include "../soc/i2c.h"
|
||||||
#include "../soc/pmc.h"
|
#include "../soc/pmc.h"
|
||||||
|
|
Loading…
Reference in a new issue