Beispiel #1
0
void config_ddr(short ddr_type)
{
	int ddr_pll, ioctrl_val;
	const struct emif_regs *emif_regs;
	const struct ddr_data *ddr_data;
	const struct cmd_control *cmd_ctrl_data;

	if (ddr_type == EMIF_REG_SDRAM_TYPE_DDR2) {
		ddr_pll = 266;
		cmd_ctrl_data = &ddr2_cmd_ctrl_data;
		ddr_data = &ddr2_data;
		ioctrl_val = DDR2_IOCTRL_VALUE;
		emif_regs = &ddr2_emif_reg_data;
	} else if (ddr_type == EMIF_REG_SDRAM_TYPE_DDR3) {
		ddr_pll = 303;
		ioctrl_val = DDR3_IOCTRL_VALUE;
		cmd_ctrl_data = &ddr3_cmd_ctrl_data;
		if (board_is_evm_15_or_later()) {
			ddr_data = &ddr3_evm_data;
			emif_regs = &ddr3_evm_emif_reg_data;
		} else {
			ddr_data = &ddr3_data;
			emif_regs = &ddr3_emif_reg_data;
		}
	} else {
		puts("Unknown memory type");
		hang();
	}

	enable_emif_clocks();
	ddr_pll_config(ddr_pll);
	config_vtp();
	config_cmd_ctrl(cmd_ctrl_data);

	config_ddr_data(0, ddr_data);
	config_ddr_data(1, ddr_data);

	config_io_ctrl(ioctrl_val);

	/* Set CKE to be controlled by EMIF/DDR PHY */
	writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);

	/* Program EMIF instance */
	config_ddr_phy(emif_regs);
	set_sdram_timings(emif_regs);
	config_sdram(emif_regs);
}
Beispiel #2
0
void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs,
                const struct ddr_data *data, const struct cmd_control *ctrl,
                const struct emif_regs *regs, int nr)
{
    ddr_pll_config(pll);
#ifndef CONFIG_TI816X
    config_vtp(nr);
#endif
    config_cmd_ctrl(ctrl, nr);

    config_ddr_data(data, nr);
#ifdef CONFIG_AM33XX
    config_io_ctrl(ioregs);

    /* Set CKE to be controlled by EMIF/DDR PHY */
    writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);

#endif
#ifdef CONFIG_AM43XX
    writel(readl(&cm_device->cm_dll_ctrl) & ~0x1, &cm_device->cm_dll_ctrl);
    while ((readl(&cm_device->cm_dll_ctrl) & CM_DLL_READYST) == 0)
        ;

    config_io_ctrl(ioregs);

    /* Set CKE to be controlled by EMIF/DDR PHY */
    writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);

    /* Allow EMIF to control DDR_RESET */
    writel(0x00000000, &ddrctrl->ddrioctrl);
#endif

    /* Program EMIF instance */
    config_ddr_phy(regs, nr);
    set_sdram_timings(regs, nr);
    if (get_emif_rev(EMIF1_BASE) == EMIF_4D5)
        config_sdram_emif4d5(regs, nr);
    else
        config_sdram(regs, nr);
}
Beispiel #3
0
void config_ddr(unsigned int pll, unsigned int ioctrl,
		const struct ddr_data *data, const struct cmd_control *ctrl,
		const struct emif_regs *regs)
{
	enable_emif_clocks();
	ddr_pll_config(pll);
	config_vtp();
	config_cmd_ctrl(ctrl);

	config_ddr_data(0, data);
	config_ddr_data(1, data);

	config_io_ctrl(ioctrl);

	/* Set CKE to be controlled by EMIF/DDR PHY */
	writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);

	/* Program EMIF instance */
	config_ddr_phy(regs);
	set_sdram_timings(regs);
	config_sdram(regs);
}
Beispiel #4
0
/*********************************************************************
 * Init DDR3 on TI816X EVM
 *********************************************************************/
static void ddr_init_settings(const struct cmd_control *ctrl, int emif)
{
	/*
	 * setup use_rank_delays to 1.  This is only necessary when
	 * multiple ranks are in use.  Though the EVM does not have
	 * multiple ranks, this is a good value to set.
	 */
	writel(1, DDRPHY_CONFIG_BASE + 0x134); // DATA0_REG_PHY_USE_RANK0_DELAYS
	writel(1, DDRPHY_CONFIG_BASE + 0x1d8); // DATA1_REG_PHY_USE_RANK0_DELAYS
	writel(1, DDRPHY_CONFIG_BASE + 0x27c); // DATA2_REG_PHY_USE_RANK0_DELAYS
	writel(1, DDRPHY_CONFIG_BASE + 0x320); // DATA3_REG_PHY_USE_RANK0_DELAYS

	config_cmd_ctrl(ctrl, emif);

	/* for ddr3 this needs to be set to 1 */
	writel(0x1, DDRPHY_CONFIG_BASE + 0x0F8); /* init mode */
	writel(0x1, DDRPHY_CONFIG_BASE + 0x104);
	writel(0x1, DDRPHY_CONFIG_BASE + 0x19C);
	writel(0x1, DDRPHY_CONFIG_BASE + 0x1A8);
	writel(0x1, DDRPHY_CONFIG_BASE + 0x240);
	writel(0x1, DDRPHY_CONFIG_BASE + 0x24C);
	writel(0x1, DDRPHY_CONFIG_BASE + 0x2E4);
	writel(0x1, DDRPHY_CONFIG_BASE + 0x2F0);

	/*
	 * This represents the initial value for the leveling process.  The
	 * value is a ratio - so 0x100 represents one cycle.  The real delay
	 * is determined through the leveling process.
	 *
	 * During the leveling process, 0x20 is subtracted from the value, so
	 * we have added that to the value we want to set.  We also set the
	 * values such that byte3 completes leveling after byte2 and byte1
	 * after byte0.
	 */
	writel((0x20 << 10) | 0x20, DDRPHY_CONFIG_BASE + 0x0F0); /*  data0 writelvl init ratio */
	writel(0x0, DDRPHY_CONFIG_BASE + 0x0F4);   /*   */
	writel((0x20 << 10) | 0x20, DDRPHY_CONFIG_BASE + 0x194); /*  data1 writelvl init ratio */
	writel(0x0, DDRPHY_CONFIG_BASE + 0x198);   /*   */
	writel((0x20 << 10) | 0x20, DDRPHY_CONFIG_BASE + 0x238); /*  data2 writelvl init ratio */
	writel(0x0, DDRPHY_CONFIG_BASE + 0x23c);   /*   */
	writel((0x20 << 10) | 0x20, DDRPHY_CONFIG_BASE + 0x2dc); /*  data3 writelvl init ratio */
	writel(0x0, DDRPHY_CONFIG_BASE + 0x2e0);   /*   */


	writel((0x20 << 10) | 0x20, DDRPHY_CONFIG_BASE + 0x0FC); /*  data0 gatelvl init ratio */
	writel(0x0, DDRPHY_CONFIG_BASE + 0x100);
	writel((0x20 << 10) | 0x20, DDRPHY_CONFIG_BASE + 0x1A0); /*  data1 gatelvl init ratio */
	writel(0x0, DDRPHY_CONFIG_BASE + 0x1A4);
	writel((0x20 << 10) | 0x20, DDRPHY_CONFIG_BASE + 0x244); /*  data2 gatelvl init ratio */
	writel(0x0, DDRPHY_CONFIG_BASE + 0x248);
	writel((0x20 << 10) | 0x20, DDRPHY_CONFIG_BASE + 0x2E8); /*  data3 gatelvl init ratio */
	writel(0x0, DDRPHY_CONFIG_BASE + 0x2EC);

	writel(0x5, DDRPHY_CONFIG_BASE + 0x00C);     /* cmd0 io config - output impedance of pad */
	writel(0x5, DDRPHY_CONFIG_BASE + 0x010);     /* cmd0 io clk config - output impedance of pad */
	writel(0x5, DDRPHY_CONFIG_BASE + 0x040);     /* cmd1 io config - output impedance of pad */
	writel(0x5, DDRPHY_CONFIG_BASE + 0x044);     /* cmd1 io clk config - output impedance of pad */
	writel(0x5, DDRPHY_CONFIG_BASE + 0x074);     /* cmd2 io config - output impedance of pad */
	writel(0x5, DDRPHY_CONFIG_BASE + 0x078);     /* cmd2 io clk config - output impedance of pad */
	writel(0x4, DDRPHY_CONFIG_BASE + 0x0A8);     /* data0 io config - output impedance of pad */
	writel(0x4, DDRPHY_CONFIG_BASE + 0x0AC);     /* data0 io clk config - output impedance of pad */
	writel(0x4, DDRPHY_CONFIG_BASE + 0x14C);     /* data1 io config - output impedance of pa     */
	writel(0x4, DDRPHY_CONFIG_BASE + 0x150);     /* data1 io clk config - output impedance of pad */
	writel(0x4, DDRPHY_CONFIG_BASE + 0x1F0);     /* data2 io config - output impedance of pa */
	writel(0x4, DDRPHY_CONFIG_BASE + 0x1F4);     /* data2 io clk config - output impedance of pad */
	writel(0x4, DDRPHY_CONFIG_BASE + 0x294);     /* data3 io config - output impedance of pa */
	writel(0x4, DDRPHY_CONFIG_BASE + 0x298);     /* data3 io clk config - output impedance of pad */
}