Skip to contentSkip to conversation

mx6: Factor out common HDMI setup code

PATCH Superseded Pardeep Kumar Singla 2 participants 3 messages Jul 12, 2013 – Jul 14, 2013

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mx6: Factor out common HDMI setup code

Instead of duplicating HDMI setup code for every mx6 board, factor out the common code

---
 arch/arm/cpu/armv7/mx6/soc.c                  |   51 ++++++++++++++
 arch/arm/include/asm/arch-mx6/mxc_hdmi.h      |    6 ++
 arch/arm/include/asm/arch-mx6/sys_proto.h     |   13 ++++
 board/boundary/nitrogen6x/nitrogen6x.c        |   57 +---------------
 board/freescale/mx6qsabrelite/mx6qsabrelite.c |   60 ++--------------
 board/wandboard/wandboard.c                   |   91 ++++++-------------------
 include/configs/mx6qsabrelite.h               |    8 ++-
 include/configs/nitrogen6x.h                  |    2 +-
 include/configs/wandboard.h                   |    1 +
 9 files changed, 106 insertions(+), 183 deletions(-)
arch/arm/cpu/armv7/mx6/soc.c +51 -0
index fc436fb..6e79310 100644
@@ -32,6 +32,8 @@
 #include <asm/imx-common/boot_mode.h>
 #include <asm/imx-common/dma.h>
 #include <stdbool.h>
+#include <asm/arch/mxc_hdmi.h>
+#include <asm/arch/crm_regs.h>
 
 struct scu_regs {
 	u32	ctrl;
@@ -228,3 +230,52 @@ const struct boot_mode soc_boot_modes[] = {
 void s_init(void)
 {
 }
+
+#ifdef CONFIG_IMX_HDMI
+void imx_enable_hdmi_phy(struct display_info_t const *dev)
+{
+	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 IPU clock */
+	reg = readl(&mxc_ccm->CCGR3);
+	reg |= MXC_CCM_CCGR3_IPU1_IPU_DI0_OFFSET;
+	writel(reg, &mxc_ccm->CCGR3);
+
+	/* 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);
+	 /* clear HDMI PHY reset */
+	 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_CLK_SEL_LDB_DI0
+		 << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET)|
+		 (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
arch/arm/include/asm/arch-mx6/mxc_hdmi.h +6 -0
index 9dccb3f..9e2074b 100644
@@ -21,6 +21,12 @@
 #ifndef __MXC_HDMI_H__
 #define __MXC_HDMI_H__
 
+#ifdef CONFIG_IMX_HDMI
+#include<asm/arch/sys_proto.h>
+void imx_enable_hdmi_phy(struct display_info_t const *dev);
+void imx_setup_hdmi(void);
+#endif
+
 /*
  * Hdmi controller registers
  */
arch/arm/include/asm/arch-mx6/sys_proto.h +13 -0
index 38e4e51..9fb539b 100644
@@ -25,6 +25,9 @@
 #define _SYS_PROTO_H_
 
 #include <asm/imx-common/regs-common.h>
+#include<linux/list.h>
+#include <linux/fb.h>
+#include <i2c.h>
 
 #define MXC_CPU_MX51		0x51
 #define MXC_CPU_MX53		0x53
@@ -34,6 +37,16 @@
 #define MXC_CPU_MX6Q		0x63
 
 #define is_soc_rev(rev)	((get_cpu_rev() & 0xFF) - rev)
+
+struct display_info_t {
+	int        bus;
+	int        addr;
+	int        pixfmt;
+	int        (*detect)(struct display_info_t const *dev);
+	void        (*enable)(struct display_info_t const *dev);
+	struct        fb_videomode mode;
+};
+
 u32 get_cpu_rev(void);
 const char *get_imx_type(u32 imxtype);
 unsigned imx_ddr_size(void);
board/boundary/nitrogen6x/nitrogen6x.c +3 -54

93 lines not on this page · raw message

board/freescale/mx6qsabrelite/mx6qsabrelite.c +5 -55

102 lines not on this page · raw message

board/wandboard/wandboard.c +21 -70

120 lines not on this page · raw message

include/configs/mx6qsabrelite.h +5 -3
index c7db81d..4549f24 100644
@@ -26,6 +26,7 @@
 #define CONFIG_MX6Q
 
 #include "mx6_common.h"
+#include<asm/sizes.h>
 
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
@@ -35,14 +36,14 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/imx-common/gpio.h>
 
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN          (10 * SZ_1M)
+
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_INITRD_TAG
 #define CONFIG_REVISION_TAG
 
-/* Size of malloc() pool */
-#define CONFIG_SYS_MALLOC_LEN		(10 * 1024 * 1024)
-
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_MISC_INIT_R
 #define CONFIG_MXC_GPIO
@@ -141,6 +142,7 @@
 #define CONFIG_BMP_16BPP
 #define CONFIG_VIDEO_LOGO
 #define CONFIG_IPUV3_CLK 260000000
+#define CONFIG_IMX_HDMI
 
 /* allow to overwrite serial and ethaddr */
 #define CONFIG_ENV_OVERWRITE
include/configs/nitrogen6x.h +1 -1
index 74df66c..5a4d06e 100644
@@ -154,7 +154,7 @@
 #define CONFIG_IPUV3_CLK 260000000
 #define CONFIG_CMD_HDMIDETECT
 #define CONFIG_CONSOLE_MUX
-
+#define CONFIG_IMX_HDMI
 /* allow to overwrite serial and ethaddr */
 #define CONFIG_ENV_OVERWRITE
 #define CONFIG_CONS_INDEX	       1
include/configs/wandboard.h +1 -0
index ee6bf21..9282e23 100644
@@ -100,6 +100,7 @@
 #define CONFIG_VIDEO_LOGO
 #define CONFIG_VIDEO_BMP_LOGO
 #define CONFIG_IPUV3_CLK 260000000
+#define CONFIG_IMX_HDMI
 
 #if defined(CONFIG_MX6DL)
 #define CONFIG_DEFAULT_FDT_FILE		"imx6dl-wandboard.dtb"
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/2 mx6qsabresd: Add splash screen support via HDMI

---
 board/freescale/mx6sabresd/mx6sabresd.c |   48 +++++++++++++++++++++++++++++++
 include/configs/mx6sabre_common.h       |    2 +-
 include/configs/mx6sabresd.h            |   18 ++++++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)
board/freescale/mx6sabresd/mx6sabresd.c +48 -0
index 222ee98..fc00063 100644
@@ -29,6 +29,11 @@
 #include <fsl_esdhc.h>
 #include <miiphy.h>
 #include <netdev.h>
+#include <asm/arch/crm_regs.h>
+#include <ipu_pixfmt.h>
+#include <linux/fb.h>
+#include <asm/arch/mxc_hdmi.h>
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -131,6 +136,37 @@ static void setup_iomux_uart(void)
 	imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
 }
 
+#if defined(CONFIG_VIDEO_IPUV3)
+static struct display_info_t const displays = {
+	.pixfmt = IPU_PIX_FMT_RGB24,
+	.enable = imx_enable_hdmi_phy,
+	.mode   = {
+	.name           = "HDMI",
+	.refresh        = 60,
+	.xres           = 1024,
+	.yres           = 768,
+	.pixclock       = 15385,
+	.left_margin    = 220,
+	.right_margin   = 40,
+	.upper_margin   = 21,
+	.lower_margin   = 7,
+	.hsync_len      = 60,
+	.vsync_len      = 10,
+	.sync           = FB_SYNC_EXT,
+	.vmode          = FB_VMODE_NONINTERLACED
+} };
+
+int board_video_skip(void)
+{
+	int ret;
+	ret = ipuv3_fb_init(&displays.mode, 0, displays.pixfmt);
+	if (ret)
+		printf("HDMI cannot be configured: %d\n", ret);
+	displays.enable(&displays);
+	return ret;
+}
+#endif /* CONFIG_VIDEO_IPUV3 */
+
 #ifdef CONFIG_FSL_ESDHC
 struct fsl_esdhc_cfg usdhc_cfg[3] = {
 	{USDHC2_BASE_ADDR},
@@ -255,10 +291,22 @@ int board_eth_init(bd_t *bis)
 int board_early_init_f(void)
 {
 	setup_iomux_uart();
+#if defined(CONFIG_VIDEO_IPUV3)
+	imx_setup_hdmi();
+#endif
 
 	return 0;
 }
 
+/*
+ * Do not overwrite the console
+ * Use always serial for U-Boot console
+ */
+int overwrite_console(void)
+{
+	return 1;
+}
+
 int board_init(void)
 {
 	/* address of boot parameters */
include/configs/mx6sabre_common.h +1 -1
index 53cc559..bb1ac8c 100644
@@ -32,7 +32,7 @@
 #define CONFIG_REVISION_TAG
 
 /* Size of malloc() pool */
-#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 2 * 1024 * 1024)
+#define CONFIG_SYS_MALLOC_LEN         (CONFIG_ENV_SIZE + 2 * 1024 * 1024)
 
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_BOARD_LATE_INIT
include/configs/mx6sabresd.h +18 -0
index 76675f4..3d3ec9f 100644
@@ -25,6 +25,24 @@
 #define PHYS_SDRAM_SIZE		(1u * 1024 * 1024 * 1024)
 
 #include "mx6sabre_common.h"
+#include<asm/sizes.h>
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN           (10 * SZ_1M)
+
+/* Framebuffer */
+#define CONFIG_VIDEO
+#define CONFIG_VIDEO_IPUV3
+#define CONFIG_CFB_CONSOLE
+#define CONFIG_VGA_AS_SINGLE_DEVICE
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV
+#define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
+#define CONFIG_VIDEO_BMP_RLE8
+#define CONFIG_SPLASH_SCREEN
+#define CONFIG_BMP_16BPP
+#define CONFIG_VIDEO_LOGO
+#define CONFIG_IPUV3_CLK 260000000
+#define CONFIG_IMX_HDMI
 
 #define CONFIG_SYS_FSL_USDHC_NUM	3
 #if defined(CONFIG_ENV_IS_IN_MMC)
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/2 mx6: Factor out common HDMI setup code

In reply to Pardeep Kumar Singla

Hi Pardeep,

Quoted 29 lines · Pardeep Kumar Singla

Instead of duplicating HDMI setup code for every mx6 board, factor out the common code

---
  arch/arm/cpu/armv7/mx6/soc.c                  |   51 ++++++++++++++
  arch/arm/include/asm/arch-mx6/mxc_hdmi.h      |    6 ++
  arch/arm/include/asm/arch-mx6/sys_proto.h     |   13 ++++
  board/boundary/nitrogen6x/nitrogen6x.c        |   57 +---------------
  board/freescale/mx6qsabrelite/mx6qsabrelite.c |   60 ++--------------
  board/wandboard/wandboard.c                   |   91 ++++++-------------------
  include/configs/mx6qsabrelite.h               |    8 ++-
  include/configs/nitrogen6x.h                  |    2 +-
  include/configs/wandboard.h                   |    1 +
  9 files changed, 106 insertions(+), 183 deletions(-)
arch/arm/cpu/armv7/mx6/soc.c +2 -0
index fc436fb..6e79310 100644
@@ -32,6 +32,8 @@
  #include <asm/imx-common/boot_mode.h>
  #include <asm/imx-common/dma.h>
  #include <stdbool.h>
+#include <asm/arch/mxc_hdmi.h>
+#include <asm/arch/crm_regs.h>
 
  struct scu_regs {
  	u32	ctrl;

arch/arm/cpu/armv7/mx6/soc.c const struct boot_mode soc_boot_modes[] = { · line 236

Quoted 7 lines
arch/arm/cpu/armv7/mx6/soc.c +4 -0
@@ -228,3 +230,52 @@ const struct boot_mode soc_boot_modes[] = {
  void s_init(void)
  {
  }
+
+#ifdef CONFIG_IMX_HDMI
+void imx_enable_hdmi_phy(struct display_info_t const *dev)
+{

The only reason this has a dev parameter is so it can be used by auto-detect code.

It should be kept out of this code to make the interface clearer.

Boards that support auto-detect (mx6qsabrelite/nitrogen6x) can wrap it.

Quoted 22 lines
arch/arm/cpu/armv7/mx6/soc.c +22 -0
+	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 IPU clock */
+	reg = readl(&mxc_ccm->CCGR3);

arch/arm/cpu/armv7/mx6/soc.c const struct boot_mode soc_boot_modes[] = { · line 268

Quoted 10 lines
arch/arm/cpu/armv7/mx6/soc.c +10 -0
+	reg |= MXC_CCM_CCGR3_IPU1_IPU_DI0_OFFSET;
+	writel(reg, &mxc_ccm->CCGR3);
+
+	/* 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);
+	 /* clear HDMI PHY reset */
+	 writeb(HDMI_MC_PHYRSTZ_DEASSERT, &hdmi->mc_phyrstz);

There's a lot of policy in this register write and some of it isn't really HDMI-specific (LDB clock selects). I'd recommend keeping that in board-specific code:

Quoted 45 lines
arch/arm/cpu/armv7/mx6/soc.c +13 -0
+	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_CLK_SEL_LDB_DI0
+		 << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET)|
+		 (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
arch/arm/include/asm/arch-mx6/mxc_hdmi.h +6 -0
index 9dccb3f..9e2074b 100644
@@ -21,6 +21,12 @@
  #ifndef __MXC_HDMI_H__
  #define __MXC_HDMI_H__
 
+#ifdef CONFIG_IMX_HDMI
+#include<asm/arch/sys_proto.h>
+void imx_enable_hdmi_phy(struct display_info_t const *dev);
+void imx_setup_hdmi(void);
+#endif
+
  /*
   * Hdmi controller registers
   */
arch/arm/include/asm/arch-mx6/sys_proto.h +3 -0
index 38e4e51..9fb539b 100644
@@ -25,6 +25,9 @@
  #define _SYS_PROTO_H_
 
  #include <asm/imx-common/regs-common.h>
+#include<linux/list.h>
+#include <linux/fb.h>
+#include <i2c.h>
 
  #define MXC_CPU_MX51		0x51
  #define MXC_CPU_MX53		0x53

arch/arm/include/asm/arch-mx6/sys_proto.h line 39

Quoted 3 lines
arch/arm/include/asm/arch-mx6/sys_proto.h +0 -0
@@ -34,6 +37,16 @@
  #define MXC_CPU_MX6Q		0x63
 
  #define is_soc_rev(rev)	((get_cpu_rev() & 0xFF) - rev)

This is specific to a couple of boards, and not mx6-specific:

Quoted 19 lines
arch/arm/include/asm/arch-mx6/sys_proto.h +10 -0
+
+struct display_info_t {
+	int        bus;
+	int        addr;
+	int        pixfmt;
+	int        (*detect)(struct display_info_t const *dev);
+	void        (*enable)(struct display_info_t const *dev);
+	struct        fb_videomode mode;
+};
+
 
  u32 get_cpu_rev(void);
  const char *get_imx_type(u32 imxtype);
  unsigned imx_ddr_size(void);
board/boundary/nitrogen6x/nitrogen6x.c +0 -0
index 8f0f9b8..d97d47a 100644

board/boundary/nitrogen6x/nitrogen6x.c static iomux_v3_cfg_t const rgb_pads[] = { · line 484

Quoted 7 lines
board/boundary/nitrogen6x/nitrogen6x.c +0 -2
@@ -464,40 +464,12 @@ static iomux_v3_cfg_t const rgb_pads[] = {
  	MX6_PAD_DISP0_DAT23__IPU1_DISP0_DAT_23,
  };
 
<snip>
 
-static void enable_hdmi(struct display_info_t const *dev)
-{

static void do_enable_hdmi(struct display_info_t const *dev)

{
	return enable_hdmi();
}

Regards,

Eric