2011-11-25 00:18:02 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2007
|
|
|
|
* Sascha Hauer, Pengutronix
|
|
|
|
*
|
|
|
|
* (C) Copyright 2009 Freescale Semiconductor, Inc.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2011-11-25 00:18:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/errno.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/imx-regs.h>
|
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
2012-08-15 10:31:20 +00:00
|
|
|
#include <asm/imx-common/boot_mode.h>
|
2013-04-15 21:14:12 +00:00
|
|
|
#include <asm/imx-common/dma.h>
|
2013-02-07 06:45:23 +00:00
|
|
|
#include <stdbool.h>
|
2013-07-25 17:12:13 +00:00
|
|
|
#include <asm/arch/mxc_hdmi.h>
|
|
|
|
#include <asm/arch/crm_regs.h>
|
2011-11-25 00:18:02 +00:00
|
|
|
|
2012-10-23 10:57:46 +00:00
|
|
|
struct scu_regs {
|
|
|
|
u32 ctrl;
|
|
|
|
u32 config;
|
|
|
|
u32 status;
|
|
|
|
u32 invalidate;
|
|
|
|
u32 fpga_rev;
|
|
|
|
};
|
|
|
|
|
2011-11-25 00:18:02 +00:00
|
|
|
u32 get_cpu_rev(void)
|
|
|
|
{
|
2012-03-20 04:21:45 +00:00
|
|
|
struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR;
|
2012-10-23 10:57:46 +00:00
|
|
|
u32 reg = readl(&anatop->digprog_sololite);
|
|
|
|
u32 type = ((reg >> 16) & 0xff);
|
2012-03-20 04:21:45 +00:00
|
|
|
|
2012-10-23 10:57:46 +00:00
|
|
|
if (type != MXC_CPU_MX6SL) {
|
|
|
|
reg = readl(&anatop->digprog);
|
|
|
|
type = ((reg >> 16) & 0xff);
|
|
|
|
if (type == MXC_CPU_MX6DL) {
|
|
|
|
struct scu_regs *scu = (struct scu_regs *)SCU_BASE_ADDR;
|
|
|
|
u32 cfg = readl(&scu->config) & 3;
|
2011-11-25 00:18:02 +00:00
|
|
|
|
2012-10-23 10:57:46 +00:00
|
|
|
if (!cfg)
|
|
|
|
type = MXC_CPU_MX6SOLO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reg &= 0xff; /* mx6 silicon revision */
|
|
|
|
return (type << 12) | (reg + 0x10);
|
2011-11-25 00:18:02 +00:00
|
|
|
}
|
|
|
|
|
2013-03-27 07:36:55 +00:00
|
|
|
#ifdef CONFIG_REVISION_TAG
|
|
|
|
u32 __weak get_board_rev(void)
|
|
|
|
{
|
|
|
|
u32 cpurev = get_cpu_rev();
|
|
|
|
u32 type = ((cpurev >> 12) & 0xff);
|
|
|
|
if (type == MXC_CPU_MX6SOLO)
|
|
|
|
cpurev = (MXC_CPU_MX6DL) << 12 | (cpurev & 0xFFF);
|
|
|
|
|
|
|
|
return cpurev;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-25 00:18:02 +00:00
|
|
|
void init_aips(void)
|
|
|
|
{
|
2012-01-10 00:52:59 +00:00
|
|
|
struct aipstz_regs *aips1, *aips2;
|
|
|
|
|
|
|
|
aips1 = (struct aipstz_regs *)AIPS1_BASE_ADDR;
|
|
|
|
aips2 = (struct aipstz_regs *)AIPS2_BASE_ADDR;
|
2011-11-25 00:18:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set all MPROTx to be non-bufferable, trusted for R/W,
|
|
|
|
* not forced to user-mode.
|
|
|
|
*/
|
2012-01-10 00:52:59 +00:00
|
|
|
writel(0x77777777, &aips1->mprot0);
|
|
|
|
writel(0x77777777, &aips1->mprot1);
|
|
|
|
writel(0x77777777, &aips2->mprot0);
|
|
|
|
writel(0x77777777, &aips2->mprot1);
|
2011-11-25 00:18:02 +00:00
|
|
|
|
2012-01-10 00:52:59 +00:00
|
|
|
/*
|
|
|
|
* Set all OPACRx to be non-bufferable, not require
|
|
|
|
* supervisor privilege level for access,allow for
|
|
|
|
* write access and untrusted master access.
|
|
|
|
*/
|
|
|
|
writel(0x00000000, &aips1->opacr0);
|
|
|
|
writel(0x00000000, &aips1->opacr1);
|
|
|
|
writel(0x00000000, &aips1->opacr2);
|
|
|
|
writel(0x00000000, &aips1->opacr3);
|
|
|
|
writel(0x00000000, &aips1->opacr4);
|
|
|
|
writel(0x00000000, &aips2->opacr0);
|
|
|
|
writel(0x00000000, &aips2->opacr1);
|
|
|
|
writel(0x00000000, &aips2->opacr2);
|
|
|
|
writel(0x00000000, &aips2->opacr3);
|
|
|
|
writel(0x00000000, &aips2->opacr4);
|
2011-11-25 00:18:02 +00:00
|
|
|
}
|
|
|
|
|
2012-05-02 02:12:17 +00:00
|
|
|
/*
|
|
|
|
* Set the VDDSOC
|
|
|
|
*
|
|
|
|
* Mask out the REG_CORE[22:18] bits (REG2_TRIG) and set
|
|
|
|
* them to the specified millivolt level.
|
|
|
|
* Possible values are from 0.725V to 1.450V in steps of
|
|
|
|
* 0.025V (25mV).
|
|
|
|
*/
|
|
|
|
void set_vddsoc(u32 mv)
|
|
|
|
{
|
|
|
|
struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR;
|
|
|
|
u32 val, reg = readl(&anatop->reg_core);
|
|
|
|
|
|
|
|
if (mv < 725)
|
|
|
|
val = 0x00; /* Power gated off */
|
|
|
|
else if (mv > 1450)
|
|
|
|
val = 0x1F; /* Power FET switched full on. No regulation */
|
|
|
|
else
|
|
|
|
val = (mv - 700) / 25;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mask out the REG_CORE[22:18] bits (REG2_TRIG)
|
|
|
|
* and set them to the calculated value (0.7V + val * 0.25V)
|
|
|
|
*/
|
|
|
|
reg = (reg & ~(0x1F << 18)) | (val << 18);
|
|
|
|
writel(reg, &anatop->reg_core);
|
|
|
|
}
|
|
|
|
|
2013-02-07 06:45:23 +00:00
|
|
|
static void imx_set_wdog_powerdown(bool enable)
|
|
|
|
{
|
|
|
|
struct wdog_regs *wdog1 = (struct wdog_regs *)WDOG1_BASE_ADDR;
|
|
|
|
struct wdog_regs *wdog2 = (struct wdog_regs *)WDOG2_BASE_ADDR;
|
|
|
|
|
|
|
|
/* Write to the PDE (Power Down Enable) bit */
|
|
|
|
writew(enable, &wdog1->wmcr);
|
|
|
|
writew(enable, &wdog2->wmcr);
|
|
|
|
}
|
|
|
|
|
2011-11-25 00:18:02 +00:00
|
|
|
int arch_cpu_init(void)
|
|
|
|
{
|
|
|
|
init_aips();
|
|
|
|
|
2012-05-02 02:12:17 +00:00
|
|
|
set_vddsoc(1200); /* Set VDDSOC to 1.2V */
|
|
|
|
|
2013-02-07 06:45:23 +00:00
|
|
|
imx_set_wdog_powerdown(false); /* Disable PDE bit of WMCR register */
|
2013-04-15 21:14:12 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_APBH_DMA
|
|
|
|
/* Start APBH DMA */
|
|
|
|
mxs_dma_init();
|
|
|
|
#endif
|
|
|
|
|
2011-11-25 00:18:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-04 11:47:38 +00:00
|
|
|
#ifndef CONFIG_SYS_DCACHE_OFF
|
|
|
|
void enable_caches(void)
|
|
|
|
{
|
|
|
|
/* Enable D-cache. I-cache is already enabled in start.S */
|
|
|
|
dcache_enable();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-25 00:18:02 +00:00
|
|
|
#if defined(CONFIG_FEC_MXC)
|
2011-12-20 05:46:31 +00:00
|
|
|
void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
|
2011-11-25 00:18:02 +00:00
|
|
|
{
|
2013-04-23 10:17:38 +00:00
|
|
|
struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
|
|
|
|
struct fuse_bank *bank = &ocotp->bank[4];
|
2011-11-25 00:18:02 +00:00
|
|
|
struct fuse_bank4_regs *fuse =
|
|
|
|
(struct fuse_bank4_regs *)bank->fuse_regs;
|
|
|
|
|
2011-12-19 02:38:13 +00:00
|
|
|
u32 value = readl(&fuse->mac_addr_high);
|
|
|
|
mac[0] = (value >> 8);
|
|
|
|
mac[1] = value ;
|
2011-11-25 00:18:02 +00:00
|
|
|
|
2011-12-19 02:38:13 +00:00
|
|
|
value = readl(&fuse->mac_addr_low);
|
|
|
|
mac[2] = value >> 24 ;
|
|
|
|
mac[3] = value >> 16 ;
|
|
|
|
mac[4] = value >> 8 ;
|
|
|
|
mac[5] = value ;
|
2011-11-25 00:18:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2012-08-15 10:31:20 +00:00
|
|
|
|
|
|
|
void boot_mode_apply(unsigned cfg_val)
|
|
|
|
{
|
|
|
|
unsigned reg;
|
2012-09-18 15:26:32 +00:00
|
|
|
struct src *psrc = (struct src *)SRC_BASE_ADDR;
|
2012-08-15 10:31:20 +00:00
|
|
|
writel(cfg_val, &psrc->gpr9);
|
|
|
|
reg = readl(&psrc->gpr10);
|
|
|
|
if (cfg_val)
|
|
|
|
reg |= 1 << 28;
|
|
|
|
else
|
|
|
|
reg &= ~(1 << 28);
|
|
|
|
writel(reg, &psrc->gpr10);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* cfg_val will be used for
|
|
|
|
* Boot_cfg4[7:0]:Boot_cfg3[7:0]:Boot_cfg2[7:0]:Boot_cfg1[7:0]
|
|
|
|
* After reset, if GPR10[28] is 1, ROM will copy GPR9[25:0]
|
|
|
|
* to SBMR1, which will determine the boot device.
|
|
|
|
*/
|
|
|
|
const struct boot_mode soc_boot_modes[] = {
|
|
|
|
{"normal", MAKE_CFGVAL(0x00, 0x00, 0x00, 0x00)},
|
|
|
|
/* reserved value should start rom usb */
|
|
|
|
{"usb", MAKE_CFGVAL(0x01, 0x00, 0x00, 0x00)},
|
|
|
|
{"sata", MAKE_CFGVAL(0x20, 0x00, 0x00, 0x00)},
|
|
|
|
{"escpi1:0", MAKE_CFGVAL(0x30, 0x00, 0x00, 0x08)},
|
|
|
|
{"escpi1:1", MAKE_CFGVAL(0x30, 0x00, 0x00, 0x18)},
|
|
|
|
{"escpi1:2", MAKE_CFGVAL(0x30, 0x00, 0x00, 0x28)},
|
|
|
|
{"escpi1:3", MAKE_CFGVAL(0x30, 0x00, 0x00, 0x38)},
|
|
|
|
/* 4 bit bus width */
|
|
|
|
{"esdhc1", MAKE_CFGVAL(0x40, 0x20, 0x00, 0x00)},
|
|
|
|
{"esdhc2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)},
|
|
|
|
{"esdhc3", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)},
|
|
|
|
{"esdhc4", MAKE_CFGVAL(0x40, 0x38, 0x00, 0x00)},
|
|
|
|
{NULL, 0},
|
|
|
|
};
|
2013-02-26 12:28:29 +00:00
|
|
|
|
|
|
|
void s_init(void)
|
|
|
|
{
|
|
|
|
}
|
2013-07-25 17:12:13 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_IMX_HDMI
|
|
|
|
void imx_enable_hdmi_phy(void)
|
|
|
|
{
|
|
|
|
struct hdmi_regs *hdmi = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR;
|
|
|
|
u8 reg;
|
|
|
|
reg = readb(&hdmi->phy_conf0);
|
|
|
|
reg |= HDMI_PHY_CONF0_PDZ_MASK;
|
|
|
|
writeb(reg, &hdmi->phy_conf0);
|
|
|
|
udelay(3000);
|
|
|
|
reg |= HDMI_PHY_CONF0_ENTMDS_MASK;
|
|
|
|
writeb(reg, &hdmi->phy_conf0);
|
|
|
|
udelay(3000);
|
|
|
|
reg |= HDMI_PHY_CONF0_GEN2_TXPWRON_MASK;
|
|
|
|
writeb(reg, &hdmi->phy_conf0);
|
|
|
|
writeb(HDMI_MC_PHYRSTZ_ASSERT, &hdmi->mc_phyrstz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void imx_setup_hdmi(void)
|
|
|
|
{
|
|
|
|
struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
|
|
|
|
struct hdmi_regs *hdmi = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR;
|
|
|
|
int reg;
|
|
|
|
|
|
|
|
/* Turn on HDMI PHY clock */
|
|
|
|
reg = readl(&mxc_ccm->CCGR2);
|
|
|
|
reg |= MXC_CCM_CCGR2_HDMI_TX_IAHBCLK_MASK|
|
|
|
|
MXC_CCM_CCGR2_HDMI_TX_ISFRCLK_MASK;
|
|
|
|
writel(reg, &mxc_ccm->CCGR2);
|
|
|
|
writeb(HDMI_MC_PHYRSTZ_DEASSERT, &hdmi->mc_phyrstz);
|
|
|
|
reg = readl(&mxc_ccm->chsccdr);
|
|
|
|
reg &= ~(MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_MASK|
|
|
|
|
MXC_CCM_CHSCCDR_IPU1_DI0_PODF_MASK|
|
|
|
|
MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_MASK);
|
|
|
|
reg |= (CHSCCDR_PODF_DIVIDE_BY_3
|
|
|
|
<< MXC_CCM_CHSCCDR_IPU1_DI0_PODF_OFFSET)
|
|
|
|
|(CHSCCDR_IPU_PRE_CLK_540M_PFD
|
|
|
|
<< MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_OFFSET);
|
|
|
|
writel(reg, &mxc_ccm->chsccdr);
|
|
|
|
}
|
|
|
|
#endif
|