From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Nelson Date: Wed, 24 Jul 2013 10:02:12 -0700 Subject: [U-Boot] [PATCH v2 1/2] mx6: Factor out common HDMI setup code In-Reply-To: <1374683502-30523-1-git-send-email-b45784@freescale.com> References: <1374683502-30523-1-git-send-email-b45784@freescale.com> Message-ID: <51F00894.1090708@boundarydevices.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Pardeep, On 07/24/2013 09:31 AM, Pardeep Kumar Singla wrote: > Instead of duplicating HDMI setup code for every mx6 board, factor out the common code > > Signed-off-by: Pardeep Kumar Singla > --- > Changes since v1: > Remove dev paramter from imx_enable_hdmi_phy function to make interface clearer. > Boards that support auto-detect (mx6qsabrelite/nitrogen6x) are wrapping it. > > arch/arm/cpu/armv7/mx6/soc.c | 48 +++++++++++++++++++++++++ > arch/arm/include/asm/arch-mx6/mxc_hdmi.h | 6 ++++ > board/boundary/nitrogen6x/nitrogen6x.c | 43 ++++------------------ > board/freescale/mx6qsabrelite/mx6qsabrelite.c | 45 ++++------------------- > board/wandboard/wandboard.c | 43 ++-------------------- > include/configs/mx6qsabrelite.h | 1 + > include/configs/nitrogen6x.h | 1 + > include/configs/wandboard.h | 1 + > 8 files changed, 73 insertions(+), 115 deletions(-) > > diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c > index fc436fb..2c89c59 100644 > --- a/arch/arm/cpu/armv7/mx6/soc.c > +++ b/arch/arm/cpu/armv7/mx6/soc.c > @@ -32,6 +32,8 @@ > #include > #include > #include > +#include > +#include > > struct scu_regs { > u32 ctrl; > @@ -228,3 +230,49 @@ const struct boot_mode soc_boot_modes[] = { > void s_init(void) > { > } > + > +#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; > + This should probably not go here, or at least should be visible elsewhere because it's needed for boards which don't have HDMI exposed: > + /* Turn on IPU clock */ > + reg = readl(&mxc_ccm->CCGR3); > + reg |= MXC_CCM_CCGR3_IPU1_IPU_DI0_OFFSET; > + writel(reg, &mxc_ccm->CCGR3); > + If (when) someone builds a board file that doesn't have HDMI, they'll probably search a while for the We probably want an 'enable_ipu_clock()' routine in .../cpu/mx6/clock.c. > + /* 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 > diff --git a/arch/arm/include/asm/arch-mx6/mxc_hdmi.h b/arch/arm/include/asm/arch-mx6/mxc_hdmi.h > index 9dccb3f..06e2bc4 100644 > --- a/arch/arm/include/asm/arch-mx6/mxc_hdmi.h > +++ b/arch/arm/include/asm/arch-mx6/mxc_hdmi.h > @@ -21,6 +21,12 @@ > #ifndef __MXC_HDMI_H__ > #define __MXC_HDMI_H__ > > +#ifdef CONFIG_IMX_HDMI Why sys_proto.h? > +#include > +void imx_enable_hdmi_phy(void); > +void imx_setup_hdmi(void); > +#endif > + The rest looks good to me. Regards, Eric