2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-11-03 12:57:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Soeren Moch <smoch@web.de>
|
|
|
|
*/
|
|
|
|
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2014-11-03 12:57:01 +00:00
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/imx-regs.h>
|
|
|
|
#include <asm/arch/iomux.h>
|
|
|
|
#include <asm/arch/mx6-pins.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2016-09-21 02:28:55 +00:00
|
|
|
#include <linux/errno.h>
|
2014-11-03 12:57:01 +00:00
|
|
|
#include <asm/gpio.h>
|
2017-06-29 08:16:06 +00:00
|
|
|
#include <asm/mach-imx/iomux-v3.h>
|
|
|
|
#include <asm/mach-imx/boot_mode.h>
|
|
|
|
#include <asm/mach-imx/video.h>
|
2014-11-03 12:57:01 +00:00
|
|
|
#include <mmc.h>
|
2019-06-21 03:42:28 +00:00
|
|
|
#include <fsl_esdhc_imx.h>
|
2014-11-03 12:57:01 +00:00
|
|
|
#include <asm/arch/mxc_hdmi.h>
|
|
|
|
#include <asm/arch/crm_regs.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
int dram_init(void)
|
|
|
|
{
|
|
|
|
gd->ram_size = 2048ul * 1024 * 1024;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-21 03:42:28 +00:00
|
|
|
#ifdef CONFIG_FSL_ESDHC_IMX
|
2016-02-04 13:41:16 +00:00
|
|
|
/* set environment device to boot device when booting from SD */
|
|
|
|
int board_mmc_get_env_dev(int devno)
|
|
|
|
{
|
|
|
|
return devno - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_mmc_get_env_part(int devno)
|
|
|
|
{
|
|
|
|
return (devno == 3) ? 1 : 0; /* part 0 for SD2 / SD3, part 1 for eMMC */
|
|
|
|
}
|
2019-06-21 03:42:28 +00:00
|
|
|
#endif /* CONFIG_FSL_ESDHC_IMX */
|
2014-11-03 12:57:01 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_VIDEO_IPUV3
|
|
|
|
static void do_enable_hdmi(struct display_info_t const *dev)
|
|
|
|
{
|
|
|
|
imx_enable_hdmi_phy();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct display_info_t const displays[] = {{
|
|
|
|
.bus = -1,
|
|
|
|
.addr = 0,
|
|
|
|
.pixfmt = IPU_PIX_FMT_RGB24,
|
|
|
|
.detect = detect_hdmi,
|
|
|
|
.enable = do_enable_hdmi,
|
|
|
|
.mode = {
|
|
|
|
.name = "HDMI",
|
|
|
|
/* 1024x768@60Hz (VESA)*/
|
|
|
|
.refresh = 60,
|
|
|
|
.xres = 1024,
|
|
|
|
.yres = 768,
|
|
|
|
.pixclock = 15384,
|
|
|
|
.left_margin = 160,
|
|
|
|
.right_margin = 24,
|
|
|
|
.upper_margin = 29,
|
|
|
|
.lower_margin = 3,
|
|
|
|
.hsync_len = 136,
|
|
|
|
.vsync_len = 6,
|
|
|
|
.sync = FB_SYNC_EXT,
|
|
|
|
.vmode = FB_VMODE_NONINTERLACED
|
|
|
|
} } };
|
|
|
|
size_t display_count = ARRAY_SIZE(displays);
|
|
|
|
|
|
|
|
static void setup_display(void)
|
|
|
|
{
|
|
|
|
struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
|
|
|
|
int reg;
|
|
|
|
s32 timeout = 100000;
|
|
|
|
|
|
|
|
enable_ipu_clock();
|
|
|
|
imx_setup_hdmi();
|
|
|
|
|
|
|
|
/* set video pll to 455MHz (24MHz * (37+11/12) / 2) */
|
|
|
|
reg = readl(&ccm->analog_pll_video);
|
|
|
|
reg |= BM_ANADIG_PLL_VIDEO_POWERDOWN;
|
|
|
|
writel(reg, &ccm->analog_pll_video);
|
|
|
|
|
|
|
|
reg &= ~BM_ANADIG_PLL_VIDEO_DIV_SELECT;
|
|
|
|
reg |= BF_ANADIG_PLL_VIDEO_DIV_SELECT(37);
|
|
|
|
reg &= ~BM_ANADIG_PLL_VIDEO_POST_DIV_SELECT;
|
|
|
|
reg |= BF_ANADIG_PLL_VIDEO_POST_DIV_SELECT(1);
|
|
|
|
writel(reg, &ccm->analog_pll_video);
|
|
|
|
|
|
|
|
writel(BF_ANADIG_PLL_VIDEO_NUM_A(11), &ccm->analog_pll_video_num);
|
|
|
|
writel(BF_ANADIG_PLL_VIDEO_DENOM_B(12), &ccm->analog_pll_video_denom);
|
|
|
|
|
|
|
|
reg &= ~BM_ANADIG_PLL_VIDEO_POWERDOWN;
|
|
|
|
writel(reg, &ccm->analog_pll_video);
|
|
|
|
|
|
|
|
while (timeout--)
|
|
|
|
if (readl(&ccm->analog_pll_video) & BM_ANADIG_PLL_VIDEO_LOCK)
|
|
|
|
break;
|
|
|
|
if (timeout < 0)
|
|
|
|
printf("Warning: video pll lock timeout!\n");
|
|
|
|
|
|
|
|
reg = readl(&ccm->analog_pll_video);
|
|
|
|
reg |= BM_ANADIG_PLL_VIDEO_ENABLE;
|
|
|
|
reg &= ~BM_ANADIG_PLL_VIDEO_BYPASS;
|
|
|
|
writel(reg, &ccm->analog_pll_video);
|
|
|
|
|
2015-01-23 18:03:37 +00:00
|
|
|
/* gate ipu1_di0_clk */
|
|
|
|
reg = readl(&ccm->CCGR3);
|
|
|
|
reg &= ~MXC_CCM_CCGR3_LDB_DI0_MASK;
|
|
|
|
writel(reg, &ccm->CCGR3);
|
2014-11-03 12:57:01 +00:00
|
|
|
|
2015-01-23 18:03:37 +00:00
|
|
|
/* select video_pll clock / 7 for ipu1_di0_clk -> 65MHz pixclock */
|
2014-11-03 12:57:01 +00:00
|
|
|
reg = readl(&ccm->chsccdr);
|
2015-01-23 18:03:37 +00:00
|
|
|
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 |= (2 << MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_OFFSET) |
|
|
|
|
(6 << MXC_CCM_CHSCCDR_IPU1_DI0_PODF_OFFSET) |
|
|
|
|
(0 << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
|
2014-11-03 12:57:01 +00:00
|
|
|
writel(reg, &ccm->chsccdr);
|
2015-01-23 18:03:37 +00:00
|
|
|
|
|
|
|
/* enable ipu1_di0_clk */
|
|
|
|
reg = readl(&ccm->CCGR3);
|
|
|
|
reg |= MXC_CCM_CCGR3_LDB_DI0_MASK;
|
|
|
|
writel(reg, &ccm->CCGR3);
|
2014-11-03 12:57:01 +00:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_VIDEO_IPUV3 */
|
|
|
|
|
|
|
|
#ifdef CONFIG_CMD_BMODE
|
|
|
|
static const struct boot_mode board_boot_modes[] = {
|
|
|
|
/* 4 bit bus width */
|
|
|
|
{"sd2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)},
|
|
|
|
{"sd3", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)},
|
|
|
|
/* 8 bit bus width */
|
2016-02-09 15:53:27 +00:00
|
|
|
{"emmc", MAKE_CFGVAL(0x60, 0x58, 0x00, 0x00)},
|
2014-11-03 12:57:01 +00:00
|
|
|
{NULL, 0},
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
/* address of boot parameters */
|
|
|
|
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
|
|
|
|
|
|
|
|
#ifdef CONFIG_VIDEO_IPUV3
|
|
|
|
setup_display();
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CMD_BMODE
|
|
|
|
add_board_boot_modes(board_boot_modes);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|