標籤:
在 /board/freescale/t104xrdb/ddr.c檔案的initdram函數中
phys_size_t initdram(int board_type)
{
phys_size_tdram_size;
#if defined(CONFIG_SPL_BUILD) || !defined(CONFIG_RAMBOOT_PBL)
puts("Initializing....usingSPD\n");
dram_size= fsl_ddr_sdram();
dram_size = setup_ddr_tlbs(dram_size / 0x100000);
dram_size*= 0x100000;
#else
dram_size= fsl_ddr_sdram_size();
#endif
returndram_size;
}
從C語言角度來看,擷取spd的過程本質上就是要對dram_size進行賦值的過程。
#############################################################
drivers/ddr/fsl/main.c/fsl_ddr_sdram調用了__fsl_ddr_compute函數
drivers/ddr/fsl/main.c/__fsl_ddr_compute函數中調用樂fsl_ddr_compute函數
fsl_ddr_compute函數中定義了擷取SPD資訊的函數。
case STEP_GET_SPD:
#if defined(CONFIG_DDR_SPD) || defined(CONFIG_SPD_EEPROM)
/*STEP 1: Gather all DIMM SPD data */
for(i = first_ctrl; i <= last_ctrl; i++) {
fsl_ddr_get_spd(pinfo->spd_installed_dimms[i],i,
dimm_slots_per_ctrl);
}
#############################################################
drivers/ddr/fsl/main.c/fsl_ddr_compute函數中調用了
compute_lowest_common_dimm_parameters函數.
compute_lowest_common_dimm_parameters該函數定義於/drivers/ddr/fsl/ls_common_dimm_params.c
在compute_lowest_common_dimm_parameters中定義列印了在uboot啟動時顯示的Detected UDIMM 18KSF51272AZ-1G6K1這句話,具體代碼為:
#ifndef CONFIG_SPL_BUILD
printf("Detected UDIMM %s\n",
dimm_params[i].mpart);
#endif
############################################################
fsl_ddr_sdram_size函數定義在/drivers/ddr/fsl/main.c檔案下:
/*
* fsl_ddr_sdram_size(first_ctrl,last_intlv) - This function only returns the
* sizeof the total memory without setting ddr control registers.
*/
phys_size_t
fsl_ddr_sdram_size(void)
{
fsl_ddr_info_t info;
unsignedlong long total_memory = 0;
memset(&info,0 , sizeof(fsl_ddr_info_t));
info.mem_base = CONFIG_SYS_FSL_DDR_SDRAM_BASE_PHY;
info.first_ctrl= 0;
info.num_ctrls= CONFIG_SYS_FSL_DDR_MAIN_NUM_CTRLS;
info.dimm_slots_per_ctrl= CONFIG_DIMM_SLOTS_PER_CTLR;
info.board_need_mem_reset= NULL;
/* Compute it once normally. */
total_memory= fsl_ddr_compute(&info, STEP_GET_SPD, 1);
returntotal_memory;
}
在同一檔案下定義了fsl_ddr_compute函數,該函數在STEP1時調用了fsl_ddr_get_spd函數對i2c匯流排進行操作,擷取DIMM記憶體條上的spd資訊,具體如下:
/* STEP 1: Gather all DIMM SPD data */
for (i = first_ctrl; i <= last_ctrl; i++){
fsl_ddr_get_spd(pinfo->spd_installed_dimms[i],i,
dimm_slots_per_ctrl);
}
那麼fsl_ddr_get_spd才是移植的時候應該重點關注的函數, 還是在/drivers/ddr/fsl/main.c檔案下定義了fsl_ddr_get_spd函數。
void fsl_ddr_get_spd(generic_spd_eeprom_t *ctrl_dimms_spd,
unsigned int ctrl_num, unsigned int dimm_slots_per_ctrl)
{
}
這個空出來的函數即是需要關注的函數
spd.從DIMM記憶體條I2C裝置移植到扣板NOR_FLASH