mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 19:34:35 +00:00
imx8m: fix reading of DDR4 MR registers
I was trying to employ lpddr4_mr_read() to something similar to what the imx8mm-cl-iot-gate board is doing for auto-detecting the RAM type. However, the version in drivers/ddr/imx/imx8m/ddrphy_utils.c differs from the private one used by that board in how it extracts the byte value, and I was only getting zeroes. Adding a bit of debug printf'ing gives me tmp = 0x00ffff00 tmp = 0x00070700 tmp = 0x00000000 tmp = 0x00101000 and indeed I was expecting a (combined) value of 0xff070010 (0xff being Manufacturer ID for Micron). I can't find any documentation that says how the values are supposed to be read, but clearly the iot-gate definition is the right one, both for its use case as well as my imx8mp-based board. So lift the private definition of lpddr4_mr_read() from the imx8mm-cl-iot-gate board code to ddrphy_utils.c, and add a declaration in the ddr.h header where e.g. get_trained_CDD() is already declared. This has only been compile-tested for the imx8mm-cl-iot-gate board (since I don't have the hardware), but since I've merely moved its definition of lpddr4_mr_read(), I'd be surprised if it changed anything for that board. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Tested-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> Reviewed-by: Fabio Estevam <festevam@denx.de>
This commit is contained in:
parent
c329f9349b
commit
290ffe5788
3 changed files with 8 additions and 29 deletions
|
@ -723,6 +723,7 @@ void ddrphy_init_read_msg_block(enum fw_type type);
|
||||||
|
|
||||||
void update_umctl2_rank_space_setting(unsigned int pstat_num);
|
void update_umctl2_rank_space_setting(unsigned int pstat_num);
|
||||||
void get_trained_CDD(unsigned int fsp);
|
void get_trained_CDD(unsigned int fsp);
|
||||||
|
unsigned int lpddr4_mr_read(unsigned int mr_rank, unsigned int mr_addr);
|
||||||
|
|
||||||
static inline void reg32_write(unsigned long addr, u32 val)
|
static inline void reg32_write(unsigned long addr, u32 val)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,33 +24,6 @@
|
||||||
|
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
|
||||||
static unsigned int lpddr4_mr_read(unsigned int mr_rank, unsigned int mr_addr)
|
|
||||||
{
|
|
||||||
unsigned int tmp;
|
|
||||||
|
|
||||||
reg32_write(DRC_PERF_MON_MRR0_DAT(0), 0x1);
|
|
||||||
do {
|
|
||||||
tmp = reg32_read(DDRC_MRSTAT(0));
|
|
||||||
} while (tmp & 0x1);
|
|
||||||
|
|
||||||
reg32_write(DDRC_MRCTRL0(0), (mr_rank << 4) | 0x1);
|
|
||||||
reg32_write(DDRC_MRCTRL1(0), (mr_addr << 8));
|
|
||||||
reg32setbit(DDRC_MRCTRL0(0), 31);
|
|
||||||
do {
|
|
||||||
tmp = reg32_read(DRC_PERF_MON_MRR0_DAT(0));
|
|
||||||
} while ((tmp & 0x8) == 0);
|
|
||||||
tmp = reg32_read(DRC_PERF_MON_MRR1_DAT(0));
|
|
||||||
reg32_write(DRC_PERF_MON_MRR0_DAT(0), 0x4);
|
|
||||||
while (tmp) { //try to find a significant byte in the word
|
|
||||||
if (tmp & 0xff) {
|
|
||||||
tmp &= 0xff;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tmp >>= 8;
|
|
||||||
}
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct lpddr4_desc {
|
struct lpddr4_desc {
|
||||||
char name[16];
|
char name[16];
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
|
|
|
@ -198,9 +198,14 @@ unsigned int lpddr4_mr_read(unsigned int mr_rank, unsigned int mr_addr)
|
||||||
tmp = reg32_read(DRC_PERF_MON_MRR0_DAT(0));
|
tmp = reg32_read(DRC_PERF_MON_MRR0_DAT(0));
|
||||||
} while ((tmp & 0x8) == 0);
|
} while ((tmp & 0x8) == 0);
|
||||||
tmp = reg32_read(DRC_PERF_MON_MRR1_DAT(0));
|
tmp = reg32_read(DRC_PERF_MON_MRR1_DAT(0));
|
||||||
tmp = tmp & 0xff;
|
|
||||||
reg32_write(DRC_PERF_MON_MRR0_DAT(0), 0x4);
|
reg32_write(DRC_PERF_MON_MRR0_DAT(0), 0x4);
|
||||||
|
while (tmp) { //try to find a significant byte in the word
|
||||||
|
if (tmp & 0xff) {
|
||||||
|
tmp &= 0xff;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tmp >>= 8;
|
||||||
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue