Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

risc-v/mpfs: ddr: lock segmentation registers #198

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion arch/risc-v/src/mpfs/mpfs_ddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ static int mpfs_ddr_pll_lock_scb(void)
#define INIT_SETTING_SEG1_6 0x00000000
#define INIT_SETTING_SEG1_7 0x00000000

#define SEG_LOCKED (1 << 31)

/****************************************************************************
* Name: mpfs_setup_ddr_segments
*
Expand Down Expand Up @@ -755,30 +757,43 @@ void mpfs_setup_ddr_segments(enum seg_setup_e option)
}
else
{
/* This is the final configuration that cannot be changed after being
* locked.
*/

/* Segment 0 */

val_l = LIBERO_SETTING_SEG0_0 & 0x7fff;
val_h = LIBERO_SETTING_SEG0_1 & 0x7fff;

val_l |= SEG_LOCKED;
val_h |= SEG_LOCKED;

putreg64((((uint64_t)val_h) << 32) | val_l, MPFS_MPUCFG_SEG0_REG0);

/* Segment 1 */

val_l = LIBERO_SETTING_SEG1_2 & 0x7fff;
val_h = LIBERO_SETTING_SEG1_3 & 0x7fff;

val_l |= SEG_LOCKED;
val_h |= SEG_LOCKED;

putreg64((((uint64_t)val_h) << 32) | val_l, MPFS_MPUCFG_SEG1_REG1);

val_l = LIBERO_SETTING_SEG1_4 & 0x7fff;
val_h = LIBERO_SETTING_SEG1_5 & 0x7fff;

val_l |= SEG_LOCKED;
val_h |= SEG_LOCKED;

putreg64((((uint64_t)val_h) << 32) | val_l, MPFS_MPUCFG_SEG1_REG2);
}

/* Disable ddr blocker: cleared at reset. When written to '1' disables
* the blocker function allowing the L2 cache controller to access the
* DDRC. Once written to '1' the register cannot be written to 0, only
* an devie reset will clear the register.
* an device reset will clear the register.
*/

putreg64((((uint64_t)0x01) << 32) , MPFS_MPUCFG_SEG0_REG3);
Expand Down
Loading