@ -141,6 +141,7 @@ uint32_t freq_specific_reg_array[PHY_DIFF_NUM] = {
spinlock_t dfs_lock ;
spinlock_t dfs_lock ;
static volatile uint32_t core_count ;
static volatile uint32_t core_count ;
static volatile bool in_progress ;
static volatile bool in_progress ;
static volatile bool sys_dvfs ;
static int num_fsp ;
static int num_fsp ;
static void ddr_init ( void )
static void ddr_init ( void )
@ -499,6 +500,8 @@ static void set_ddr_clk(uint32_t ddr_freq)
# define DDR_DFS_GET_FSP_COUNT 0x10
# define DDR_DFS_GET_FSP_COUNT 0x10
# define DDR_BYPASS_DRATE U(400)
# define DDR_BYPASS_DRATE U(400)
extern int upower_pmic_i2c_write ( uint32_t reg_addr , uint32_t reg_val ) ;
/* Normally, we only switch frequency between 1(bypass) and 2(highest) */
/* Normally, we only switch frequency between 1(bypass) and 2(highest) */
int lpddr4_dfs ( uint32_t freq_index )
int lpddr4_dfs ( uint32_t freq_index )
{
{
@ -515,6 +518,14 @@ int lpddr4_dfs(uint32_t freq_index)
return - 1 ;
return - 1 ;
}
}
/*
* increase the voltage to 1.1 V firstly before increase frequency
* and APD enter OD mode
*/
if ( freq_index = = 2U & & sys_dvfs ) {
upower_pmic_i2c_write ( 0x22 , 0x28 ) ;
}
/* Enable LPI_WAKEUP_EN */
/* Enable LPI_WAKEUP_EN */
ddr_ctl_144 = mmio_read_32 ( IMX_DDRC_BASE + DENALI_CTL_144 ) ;
ddr_ctl_144 = mmio_read_32 ( IMX_DDRC_BASE + DENALI_CTL_144 ) ;
mmio_setbits_32 ( IMX_DDRC_BASE + DENALI_CTL_144 , LPI_WAKEUP_EN ) ;
mmio_setbits_32 ( IMX_DDRC_BASE + DENALI_CTL_144 , LPI_WAKEUP_EN ) ;
@ -563,6 +574,13 @@ int lpddr4_dfs(uint32_t freq_index)
return - 1 ;
return - 1 ;
}
}
/* decrease the BUCK3 voltage after frequency changed to lower
* and APD in ND_MODE
*/
if ( freq_index = = 1U & & sys_dvfs ) {
upower_pmic_i2c_write ( 0x22 , 0x20 ) ;
}
/* DFS done successfully */
/* DFS done successfully */
return 0 ;
return 0 ;
}
}
@ -606,6 +624,7 @@ int dram_dvfs_handler(uint32_t smc_fid, void *handle,
/* start lpddr frequency scaling */
/* start lpddr frequency scaling */
in_progress = true ;
in_progress = true ;
sys_dvfs = x3 ? true : false ;
dsb ( ) ;
dsb ( ) ;
/* notify other core wait for scaling done */
/* notify other core wait for scaling done */