static int dump_out_ddr(struct seq_file *m, void *v) { int len = 0; int i = 0; len += seq_printf(m ,"--------------------dump the DDRC1---------------\n"); len += seq_printf(m ,"DDRC_STATUS\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_STATUS),DDRC_BASE + DDRC_STATUS); len += seq_printf(m ,"DDRC_CFG\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_CFG),DDRC_BASE + DDRC_CFG); len += seq_printf(m ,"DDRC_CTRL\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_CTRL),DDRC_BASE + DDRC_CTRL); len += seq_printf(m ,"DDRC_LMR\t:0x%08x\taddress\t:0x%08x\n",ddr_readl(DDRC_LMR),DDRC_BASE + DDRC_LMR); len += seq_printf(m ,"DDRC_TIMING1\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_TIMING(1)),DDRC_BASE + DDRC_TIMING(1)); len += seq_printf(m ,"DDRC_TIMING2\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_TIMING(2)),DDRC_BASE + DDRC_TIMING(2)); len += seq_printf(m ,"DDRC_TIMING3\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_TIMING(3)),DDRC_BASE + DDRC_TIMING(3)); len += seq_printf(m ,"DDRC_TIMING4\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_TIMING(4)),DDRC_BASE + DDRC_TIMING(4)); len += seq_printf(m ,"DDRC_TIMING5\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_TIMING(5)),DDRC_BASE + DDRC_TIMING(5)); len += seq_printf(m ,"DDRC_TIMING6\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_TIMING(6)),DDRC_BASE + DDRC_TIMING(6)); len += seq_printf(m ,"DDRC_REFCNT\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REFCNT),DDRC_BASE + DDRC_REFCNT); len += seq_printf(m ,"DDRC_MMAP0\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_MMAP0),DDRC_BASE + DDRC_MMAP0); len += seq_printf(m ,"DDRC_MMAP1\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_MMAP1),DDRC_BASE + DDRC_MMAP1); len += seq_printf(m ,"DDRC_REMAP1\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(1)),DDRC_BASE + DDRC_REMAP(1)); len += seq_printf(m ,"DDRC_REMAP2\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(2)),DDRC_BASE + DDRC_REMAP(2)); len += seq_printf(m ,"DDRC_REMAP3\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(3)),DDRC_BASE + DDRC_REMAP(3)); len += seq_printf(m ,"DDRC_REMAP4\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(4)),DDRC_BASE + DDRC_REMAP(4)); len += seq_printf(m ,"DDRC_REMAP5\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(5)),DDRC_BASE + DDRC_REMAP(5)); len += seq_printf(m ,"DDRC_AUTOSR_EN\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_AUTOSR_EN),DDRC_BASE + DDRC_AUTOSR_EN); len += seq_printf(m ,"--------------------dump the DDRP---------------\n"); len += seq_printf(m ,"DDRP_PIR\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_PIR),DDRC_BASE + DDRP_PIR); len += seq_printf(m ,"DDRP_PGCR\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_PGCR),DDRC_BASE + DDRP_PGCR); len += seq_printf(m ,"DDRP_PGSR\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_PGSR),DDRC_BASE + DDRP_PGSR); len += seq_printf(m ,"DDRP_PTR0\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_PTR0),DDRC_BASE + DDRP_PTR0); len += seq_printf(m ,"DDRP_PTR1\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_PTR1),DDRC_BASE + DDRP_PTR1); len += seq_printf(m ,"DDRP_PTR2\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_PTR2),DDRC_BASE + DDRP_PTR2); len += seq_printf(m ,"DDRP_DSGCR\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_DSGCR),DDRC_BASE + DDRP_DSGCR); len += seq_printf(m ,"DDRP_DCR\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_DCR),DDRC_BASE + DDRP_DCR); len += seq_printf(m ,"DDRP_DTPR0\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_DTPR0),DDRC_BASE + DDRP_DTPR0); len += seq_printf(m ,"DDRP_DTPR1\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_DTPR1),DDRC_BASE + DDRP_DTPR1); len += seq_printf(m ,"DDRP_DTPR2\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_DTPR2),DDRC_BASE + DDRP_DTPR2); len += seq_printf(m ,"DDRP_MR0\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_MR0),DDRC_BASE + DDRP_MR0); len += seq_printf(m ,"DDRP_MR1\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_MR1),DDRC_BASE + DDRP_MR1); len += seq_printf(m ,"DDRP_MR2\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_MR2),DDRC_BASE + DDRP_MR2); len += seq_printf(m ,"DDRP_MR3\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_MR3),DDRC_BASE + DDRP_MR3); len += seq_printf(m ,"DDRP_ODTCR\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRP_ODTCR),DDRC_BASE + DDRP_ODTCR); for(i=0;i<4;i++) { len += seq_printf(m ,"DX%dGSR0 \t:0x%08x\taddress\t:0x%08x\n", i, ddr_readl(DDRP_DXGSR0(i)),DDRC_BASE + DDRP_DXGSR0(i)); len += seq_printf(m ,"@pas:DXDQSTR(%d)\t:0x%08x\taddress\t:0x%08x\n", i,ddr_readl(DDRP_DXDQSTR(i)),DDRC_BASE + DDRP_DXDQSTR(i)); } return len; }
static int __init init_ddr_proc(void) { struct proc_dir_entry *p; #ifdef CONFIG_DDR_DEBUG register int bypassmode = 0; register int AutoSR_en = 0; bypassmode = ddr_readl(DDRP_PIR) & DDRP_PIR_DLLBYP; if(bypassmode) { printk("the ddr is in bypass mode\n"); }else{ printk("the ddr it not in bypass mode\n"); } AutoSR_en = ddr_readl(DDRC_AUTOSR_EN) & DDRC_AUTOSR_ENABLE; if(AutoSR_en) { printk("the ddr self_refresh is enable\n"); }else{ printk("the ddr self_refrese is not enable\n"); } printk("the ddr remap register is\n"); printk("DDRC_REMAP1\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(1)),DDRC_BASE + DDRC_REMAP(1)); printk("DDRC_REMAP2\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(2)),DDRC_BASE + DDRC_REMAP(2)); printk("DDRC_REMAP3\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(3)),DDRC_BASE + DDRC_REMAP(3)); printk("DDRC_REMAP4\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(4)),DDRC_BASE + DDRC_REMAP(4)); printk("DDRC_REMAP5\t:0x%08x\taddress\t:0x%08x\n", ddr_readl(DDRC_REMAP(5)),DDRC_BASE + DDRC_REMAP(5)); #endif printk("%d,%s\n",__LINE__,__func__); p = jz_proc_mkdir("ddr"); if (!p) { pr_warning("create_proc_entry for common ddr failed.\n"); return -ENODEV; } proc_create_data("ddr_Register", 0444, p, &ddr_register_proc_fops, 0); proc_create_data("ddr_monitor1", 0444, p, &ddr_mon1_proc_fops, 0); proc_create_data("ddr_monitor2", 0444, p, &ddr_mon2_proc_fops, 0); proc_create_data("ddr_monitor3", 0444, p, &ddr_mon3_proc_fops, 0); return 0; }
static void remap_swap(int a, int b) { uint32_t remmap[2], tmp[2]; remmap[0] = ddr_readl(DDRC_REMAP(a / 4 + 1)); remmap[1] = ddr_readl(DDRC_REMAP(b / 4 + 1)); #define BIT(bit) ((bit % 4) * 8) #define MASK(bit) (0x1f << BIT(bit)) tmp[0] = (remmap[0] & MASK(a)) >> BIT(a); tmp[1] = (remmap[1] & MASK(b)) >> BIT(b); remmap[0] &= ~MASK(a); remmap[1] &= ~MASK(b); ddr_writel(remmap[0] | (tmp[1] << BIT(a)), DDRC_REMAP(a / 4 + 1)); ddr_writel(remmap[1] | (tmp[0] << BIT(b)), DDRC_REMAP(b / 4 + 1)); #undef BIT #undef MASK }
static void dump_ddrc_register(void) { #ifdef CONFIG_DWC_DEBUG printf("DDRC_STATUS 0x%x\n", ddr_readl(DDRC_STATUS)); printf("DDRC_CFG 0x%x\n", ddr_readl(DDRC_CFG)); printf("DDRC_CTRL 0x%x\n", ddr_readl(DDRC_CTRL)); printf("DDRC_LMR 0x%x\n", ddr_readl(DDRC_LMR)); printf("DDRC_TIMING1 0x%x\n", ddr_readl(DDRC_TIMING(1))); printf("DDRC_TIMING2 0x%x\n", ddr_readl(DDRC_TIMING(2))); printf("DDRC_TIMING3 0x%x\n", ddr_readl(DDRC_TIMING(3))); printf("DDRC_TIMING4 0x%x\n", ddr_readl(DDRC_TIMING(4))); printf("DDRC_TIMING5 0x%x\n", ddr_readl(DDRC_TIMING(5))); printf("DDRC_TIMING6 0x%x\n", ddr_readl(DDRC_TIMING(6))); printf("DDRC_REFCNT 0x%x\n", ddr_readl(DDRC_REFCNT)); printf("DDRC_MMAP0 0x%x\n", ddr_readl(DDRC_MMAP0)); printf("DDRC_MMAP1 0x%x\n", ddr_readl(DDRC_MMAP1)); printf("DDRC_REMAP1 0x%x\n", ddr_readl(DDRC_REMAP(1))); printf("DDRC_REMAP2 0x%x\n", ddr_readl(DDRC_REMAP(2))); printf("DDRC_REMAP3 0x%x\n", ddr_readl(DDRC_REMAP(3))); printf("DDRC_REMAP4 0x%x\n", ddr_readl(DDRC_REMAP(4))); printf("DDRC_REMAP5 0x%x\n", ddr_readl(DDRC_REMAP(5))); #endif }