omapdss: hdmi: Add support for hdmi on OMAP5 and DRA7x SoCs
cover omapdss: hdmi: Add support for hdmi on OMAP5 and DRA7x SoCs
The HDMI IP on OMAP5/DRA7xx has very similar wrapper, PLL and PHY sub blocks found in OMAP4 DSS. However, the HDMI core IP(which implements the HDMI protocol) is completely new.
Create a library for configuring the new HDMI core IP, make minor modifications in PLL and PHY. And finally, add a hdmi5 driver. This driver can eventually be merged with the hdmi4 driver such that both of them use the same driver, we would need to create core IP ops for that, we've left that for later.
Archit Taneja (6):
omapdss: hdmi: support larger register offsets for OMAP5 HDMI core
omapdss: hdmi: Add initial OMAP5/DRA7x HDMI core IP library
omapdss: hdmi phy: Incorporate changes for OMAP5/DRA7x
omapdss: hdmi pll: Incorporate changes for OMAP5/DRA7x
omapdss: hdmi: add OMAP5/DRA7x hdmi driver
omapdss: hdmi4/hdmi5: set regulator voltage to required level
drivers/video/omap2/dss/Kconfig | 10 + drivers/video/omap2/dss/Makefile | 2 + drivers/video/omap2/dss/core.c | 6 + drivers/video/omap2/dss/dss.h | 3 + drivers/video/omap2/dss/hdmi.h | 7 +- drivers/video/omap2/dss/hdmi4.c | 5 + drivers/video/omap2/dss/hdmi5.c | 704 ++++++++++++++++++++++++++++++ drivers/video/omap2/dss/hdmi5_core.c | 812 +++++++++++++++++++++++++++++++++++ drivers/video/omap2/dss/hdmi5_core.h | 298 +++++++++++++ drivers/video/omap2/dss/hdmi_phy.c | 94 +++- drivers/video/omap2/dss/hdmi_pll.c | 74 +++- drivers/video/omap2/dss/hdmi_wp.c | 2 +- 12 files changed, 2008 insertions(+), 9 deletions(-) create mode 100644 drivers/video/omap2/dss/hdmi5.c create mode 100644 drivers/video/omap2/dss/hdmi5_core.c create mode 100644 drivers/video/omap2/dss/hdmi5_core.h
Signature · 1 line
1.8.1.2
PATCH 1/6 omapdss: hdmi: support larger register offsets for OMAP5 HDMI core
The HDMI core IP on OMAP5 has a wider register address range. The offsets for these registers can't fit into the u16 type currently used for hdmi register read and write functions. Use u32 for offsets instead.
--- drivers/video/omap2/dss/hdmi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/omap2/dss/hdmi.h +2 -2
@@ -360,13 +360,13 @@ struct hdmi_core_data {struct hdmi_core_infoframe_avi avi_cfg; }; -static inline void hdmi_write_reg (void __iomem *base_addr,const u16 idx, +static inline void hdmi_write_reg (void __iomem *base_addr,const u32 idx,u32 val) {__raw_writel (val, base_addr + idx); } -static inline u32 hdmi_read_reg (void __iomem *base_addr,const u16 idx) +static inline u32 hdmi_read_reg (void __iomem *base_addr,const u32 idx) {return __raw_readl (base_addr + idx); }
Signature · 1 line
1.8.1.2
PATCH 2/6 omapdss: hdmi: Add initial OMAP5/DRA7x HDMI core IP library
In reply to Archit TanejaAdd the OMAP5 HDMI core IP library. This will used by the hdmi5 driver to configure the HDMI core sub block found on OMAP5/DRA7x.
The new HDMI core IP consists of the video composing sub blocks: video sampler, color space converter, video packetizer and frame composer. These are connected to each other serially. There is an i2c/ddc master sub block which is responsible for reading EDID info.
Each of the video sub block is programmed in hdmi5_configure. Currenlty, only the minimal features for each sub block are exposed. We can configure the core only in 24 bit color mode. As we add more features, the register programming to configure the serial sub blocks will increase in complexity.
The register configurations for enabling and clearing interrupts are provided, but interrupts themselves aren't used at the moment. One place where they will come in use to read the hdmi ddc block's register which recieves a byte of data from the slave. We currently just read the register after every millisecond.
--- drivers/video/omap2/dss/hdmi5_core.c | 812 +++++++++++++++++++++++++++++++++++ drivers/video/omap2/dss/hdmi5_core.h | 298 +++++++++++++ 2 files changed, 1110 insertions(+) create mode 100644 drivers/video/omap2/dss/hdmi5_core.c create mode 100644 drivers/video/omap2/dss/hdmi5_core.h
drivers/video/omap2/dss/hdmi5_core.c new file +812 -0
@@ -0,0 +1,812 @@ +/* +* OMAP5 HDMI CORE IP driver Library +* Copyright (C) 2013 Texas Instruments Incorporated +* Author: Mythri pk <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published by +* the Free Software Foundation. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/delay.h> +#include <linux/string.h> +#include <linux/seq_file.h> +#include <drm/drm_edid.h> +#if defined(CONFIG_OMAP5_DSS_HDMI_AUDIO ) +#include <sound/asound.h> +#include <sound/asoundef.h> +#endif + +#include "hdmi5_core.h" + +/* only 24 bit color depth used for now */ +static const struct csc_table csc_table_deepcolor[] = { +/* HDMI_DEEP_COLOR_24BIT */ + [0 ] = {7036 ,0 ,0 ,32 ,0 ,7036 ,0 ,32 ,0 ,0 ,7036 ,32 , }, +/* HDMI_DEEP_COLOR_30BIT */ + [1 ] = {7015 ,0 ,0 ,128 ,0 ,7015 ,0 ,128 ,0 ,0 ,7015 ,128 , }, +/* HDMI_DEEP_COLOR_36BIT */ + [2 ] = {7010 ,0 ,0 ,512 ,0 ,7010 ,0 ,512 ,0 ,0 ,7010 ,512 , }, +/* FULL RANGE */ + [3 ] = {8192 ,0 ,0 ,0 ,0 ,8192 ,0 ,0 ,0 ,0 ,8192 ,0 , }, +}; + +static void hdmi_core_ddc_req_addr (struct hdmi_core_data *core,u8 addr,u8 ext) +{ +void __iomem *base = core->base; +u8 seg_ptr = ext /2 ; +u8 edidaddr = ((ext %2 ) *0x80 ) + addr; + +REG_FLD_MOD (base,HDMI_CORE_I2CM_ADDRESS , edidaddr,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_SEGPTR , seg_ptr,7 ,0 ); + +if (seg_ptr) +REG_FLD_MOD (base,HDMI_CORE_I2CM_OPERATION ,1 ,1 ,1 ); +else +REG_FLD_MOD (base,HDMI_CORE_I2CM_OPERATION ,1 ,0 ,0 ); +} + +static void hdmi_core_ddc_init (struct hdmi_core_data *core) +{ +void __iomem *base = core->base; + +REG_FLD_MOD (base,HDMI_CORE_I2CM_SDA_HOLD_ADDR ,0x18 ,7 ,0 ); + +/* mask the i2c interrupts */ +REG_FLD_MOD (base,HDMI_CORE_I2CM_CTLINT ,0x0 ,2 ,2 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_CTLINT ,0x0 ,6 ,6 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_INT ,0x0 ,2 ,2 ); + +/* Master clock division */ +REG_FLD_MOD (base,HDMI_CORE_I2CM_DIV ,0x5 ,3 ,0 ); + +/* Standard speed counter */ +REG_FLD_MOD (base,HDMI_CORE_I2CM_SS_SCL_HCNT_1_ADDR ,0x00 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_SS_SCL_HCNT_0_ADDR ,0x6c ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_SS_SCL_LCNT_1_ADDR ,0x00 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_SS_SCL_LCNT_0_ADDR ,0x7f ,7 ,0 ); + +/* Fast speed counter */ +REG_FLD_MOD (base,HDMI_CORE_I2CM_FS_SCL_HCNT_1_ADDR ,0x0 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_FS_SCL_HCNT_0_ADDR ,0x0f ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_FS_SCL_LCNT_1_ADDR ,0x0 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_FS_SCL_LCNT_0_ADDR ,0x21 ,7 ,0 ); + +REG_FLD_MOD (base,HDMI_CORE_I2CM_SLAVE ,0x50 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_SEGADDR ,0x30 ,6 ,0 ); +} + +static int hdmi_core_ddc_edid (struct hdmi_core_data *core,u8 *pedid,u8 ext) +{ +void __iomem *base = core->base; +u8 cur_addr =0 ; + +hdmi_core_ddc_req_addr (core, cur_addr, ext); + +/* unmask the i2c interrupts */ +REG_FLD_MOD (base,HDMI_CORE_I2CM_CTLINT ,0x1 ,2 ,2 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_CTLINT ,0x1 ,6 ,6 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_INT ,0x1 ,2 ,2 ); + +/* +* FIXME: We read 128 bytes of data here with a msleep. Ideally, we +* should read based on a completion interrupt, the completion +* interrupt doesn't seem to work, so we just sleep for around a +* millisecond instead. +*/ +while (cur_addr <128 ) { +usleep_range (1000 ,1500 ); + pedid[cur_addr++] =REG_GET (base,HDMI_CORE_I2CM_DATAI ,7 ,0 ); +hdmi_core_ddc_req_addr (core, cur_addr, ext); + } + +return 0 ; +} + +int hdmi5_read_edid (struct hdmi_core_data *core,u8 *edid,int len) +{ +int r, n, i; +int max_ext_blocks = (len /128 ) -1 ; + +if (len <128 ) +return -EINVAL ; + +hdmi_core_ddc_init (core); + + r =hdmi_core_ddc_edid (core, edid,0 ); +if (r) { +return r; + }else { + n = edid[0x7e ]; + +if (n > max_ext_blocks) + n = max_ext_blocks; + +for (i =1 ; i <= n; i++) { + r =hdmi_core_ddc_edid (core, edid + i *EDID_LENGTH , i); +if (r) +return r; + } + } + +return 0 ; +} + +void hdmi5_core_dump (struct hdmi_core_data *core,struct seq_file *s) +{ + +#define DUMPCORE (r) seq_printf(s, "%-35s %08x\n", #r,\ + hdmi_read_reg(core->base, r)) + +DUMPCORE (HDMI_CORE_FC_INVIDCONF ); +DUMPCORE (HDMI_CORE_FC_INHACTIV0 ); +DUMPCORE (HDMI_CORE_FC_INHACTIV1 ); +DUMPCORE (HDMI_CORE_FC_INHBLANK0 ); +DUMPCORE (HDMI_CORE_FC_INHBLANK1 ); +DUMPCORE (HDMI_CORE_FC_INVACTIV0 ); +DUMPCORE (HDMI_CORE_FC_INVACTIV1 ); +DUMPCORE (HDMI_CORE_FC_INVBLANK ); +DUMPCORE (HDMI_CORE_FC_HSYNCINDELAY0 ); +DUMPCORE (HDMI_CORE_FC_HSYNCINDELAY1 ); +DUMPCORE (HDMI_CORE_FC_HSYNCINWIDTH0 ); +DUMPCORE (HDMI_CORE_FC_HSYNCINWIDTH1 ); +DUMPCORE (HDMI_CORE_FC_VSYNCINDELAY ); +DUMPCORE (HDMI_CORE_FC_VSYNCINWIDTH ); +DUMPCORE (HDMI_CORE_FC_CTRLDUR ); +DUMPCORE (HDMI_CORE_FC_EXCTRLDUR ); +DUMPCORE (HDMI_CORE_FC_EXCTRLSPAC ); +DUMPCORE (HDMI_CORE_FC_CH0PREAM ); +DUMPCORE (HDMI_CORE_FC_CH1PREAM ); +DUMPCORE (HDMI_CORE_FC_CH2PREAM ); +DUMPCORE (HDMI_CORE_FC_AVICONF0 ); +DUMPCORE (HDMI_CORE_FC_AVICONF1 ); +DUMPCORE (HDMI_CORE_FC_AVICONF2 ); +DUMPCORE (HDMI_CORE_FC_AVIVID ); +DUMPCORE (HDMI_CORE_FC_PRCONF ); + +DUMPCORE (HDMI_CORE_MC_CLKDIS ); +DUMPCORE (HDMI_CORE_MC_SWRSTZREQ ); +DUMPCORE (HDMI_CORE_MC_FLOWCTRL ); +DUMPCORE (HDMI_CORE_MC_PHYRSTZ ); +DUMPCORE (HDMI_CORE_MC_LOCKONCLOCK ); + +DUMPCORE (HDMI_CORE_I2CM_SLAVE ); +DUMPCORE (HDMI_CORE_I2CM_ADDRESS ); +DUMPCORE (HDMI_CORE_I2CM_DATAO ); +DUMPCORE (HDMI_CORE_I2CM_DATAI ); +DUMPCORE (HDMI_CORE_I2CM_OPERATION ); +DUMPCORE (HDMI_CORE_I2CM_INT ); +DUMPCORE (HDMI_CORE_I2CM_CTLINT ); +DUMPCORE (HDMI_CORE_I2CM_DIV ); +DUMPCORE (HDMI_CORE_I2CM_SEGADDR ); +DUMPCORE (HDMI_CORE_I2CM_SOFTRSTZ ); +DUMPCORE (HDMI_CORE_I2CM_SEGPTR ); +DUMPCORE (HDMI_CORE_I2CM_SS_SCL_HCNT_1_ADDR ); +DUMPCORE (HDMI_CORE_I2CM_SS_SCL_HCNT_0_ADDR ); +DUMPCORE (HDMI_CORE_I2CM_SS_SCL_LCNT_1_ADDR ); +DUMPCORE (HDMI_CORE_I2CM_SS_SCL_LCNT_0_ADDR ); +DUMPCORE (HDMI_CORE_I2CM_FS_SCL_HCNT_1_ADDR ); +DUMPCORE (HDMI_CORE_I2CM_FS_SCL_HCNT_0_ADDR ); +DUMPCORE (HDMI_CORE_I2CM_FS_SCL_LCNT_1_ADDR ); +DUMPCORE (HDMI_CORE_I2CM_FS_SCL_LCNT_0_ADDR ); + +#undef DUMPCORE +} + +static void hdmi_core_init (struct hdmi_core_vid_config *video_cfg, +struct hdmi_core_infoframe_avi *avi_cfg, +struct hdmi_config *cfg) +{ +DSSDBG ("hdmi_core_init\n" ); + +/* video core */ + video_cfg->data_enable_pol =1 ;/* It is always 1*/ + video_cfg->v_fc_config.timings.hsync_level = cfg->timings.hsync_level; + video_cfg->v_fc_config.timings.x_res = cfg->timings.x_res; + video_cfg->v_fc_config.timings.hsw = cfg->timings.hsw -1 ; + video_cfg->v_fc_config.timings.hbp = cfg->timings.hbp; + video_cfg->v_fc_config.timings.hfp = cfg->timings.hfp; + video_cfg->hblank = cfg->timings.hfp + + cfg->timings.hbp + cfg->timings.hsw -1 ; + video_cfg->v_fc_config.timings.vsync_level = cfg->timings.vsync_level; + video_cfg->v_fc_config.timings.y_res = cfg->timings.y_res; + video_cfg->v_fc_config.timings.vsw = cfg->timings.vsw; + video_cfg->v_fc_config.timings.vfp = cfg->timings.vfp; + video_cfg->v_fc_config.timings.vbp = cfg->timings.vbp; + video_cfg->vblank_osc =0 ;/* Always 0 - need to confirm */ + video_cfg->vblank = cfg->timings.vsw + + cfg->timings.vfp + cfg->timings.vbp; + video_cfg->v_fc_config.cm.mode = cfg->cm.mode; + video_cfg->v_fc_config.timings.interlace = cfg->timings.interlace; + +/* info frame */ + avi_cfg->db1_format =0 ; + avi_cfg->db1_active_info =0 ; + avi_cfg->db1_bar_info_dv =0 ; + avi_cfg->db1_scan_info =0 ; + avi_cfg->db2_colorimetry =0 ; + avi_cfg->db2_aspect_ratio =0 ; + avi_cfg->db2_active_fmt_ar =0 ; + avi_cfg->db3_itc =0 ; + avi_cfg->db3_ec =0 ; + avi_cfg->db3_q_range =0 ; + avi_cfg->db3_nup_scaling =0 ; + avi_cfg->db4_videocode =0 ; + avi_cfg->db5_pixel_repeat =0 ; + avi_cfg->db6_7_line_eoftop =0 ; + avi_cfg->db8_9_line_sofbottom =0 ; + avi_cfg->db10_11_pixel_eofleft =0 ; + avi_cfg->db12_13_pixel_sofright =0 ; +} + +static void hdmi_core_config_fc (struct hdmi_core_data *core, +struct hdmi_core_vid_config *cfg) +{ +void __iomem *base = core->base; +unsigned char r =0 ; +bool vsync_pol, hsync_pol; + + vsync_pol = + cfg->v_fc_config.timings.vsync_level ==OMAPDSS_SIG_ACTIVE_HIGH ; + hsync_pol = + cfg->v_fc_config.timings.hsync_level ==OMAPDSS_SIG_ACTIVE_HIGH ; + +/* Set hsync, vsync and data-enable polarity */ + r =hdmi_read_reg (base,HDMI_CORE_FC_INVIDCONF ); + r =FLD_MOD (r, vsync_pol,6 ,6 ); + r =FLD_MOD (r, hsync_pol,5 ,5 ); + r =FLD_MOD (r, cfg->data_enable_pol,4 ,4 ); + r =FLD_MOD (r, cfg->vblank_osc,1 ,1 ); + r =FLD_MOD (r, cfg->v_fc_config.timings.interlace,0 ,0 ); +hdmi_write_reg (base,HDMI_CORE_FC_INVIDCONF , r); + +/* set x resolution */ +REG_FLD_MOD (base,HDMI_CORE_FC_INHACTIV1 , + cfg->v_fc_config.timings.x_res >>8 ,4 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_INHACTIV0 , + cfg->v_fc_config.timings.x_res &0xff ,7 ,0 ); + +/* set y resolution */ +REG_FLD_MOD (base,HDMI_CORE_FC_INVACTIV1 , + cfg->v_fc_config.timings.y_res >>8 ,4 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_INVACTIV0 , + cfg->v_fc_config.timings.y_res &0xff ,7 ,0 ); + +/* set horizontal blanking pixels */ +REG_FLD_MOD (base,HDMI_CORE_FC_INHBLANK1 , cfg->hblank >>8 ,4 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_INHBLANK0 , cfg->hblank &0xff ,7 ,0 ); + +/* set vertial blanking pixels */ +REG_FLD_MOD (base,HDMI_CORE_FC_INVBLANK , cfg->vblank,7 ,0 ); + +/* set horizontal sync offset */ +REG_FLD_MOD (base,HDMI_CORE_FC_HSYNCINDELAY1 , + cfg->v_fc_config.timings.hfp >>8 ,4 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_HSYNCINDELAY0 , + cfg->v_fc_config.timings.hfp &0xff ,7 ,0 ); + +/* set vertical sync offset */ +REG_FLD_MOD (base,HDMI_CORE_FC_VSYNCINDELAY , + cfg->v_fc_config.timings.vfp,7 ,0 ); + +/* set horizontal sync pulse width */ +REG_FLD_MOD (base,HDMI_CORE_FC_HSYNCINWIDTH1 , + (cfg->v_fc_config.timings.hsw >>8 ),1 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_HSYNCINWIDTH0 , + cfg->v_fc_config.timings.hsw &0xff ,7 ,0 ); + +/* set vertical sync pulse width */ +REG_FLD_MOD (base,HDMI_CORE_FC_VSYNCINWIDTH , + cfg->v_fc_config.timings.vsw,5 ,0 ); + +/* select DVI mode */ +REG_FLD_MOD (base,HDMI_CORE_FC_INVIDCONF , + cfg->v_fc_config.cm.mode,3 ,3 ); +} + +static void hdmi_core_config_video_packetizer (struct hdmi_core_data *core) +{ +void __iomem *base = core->base; +int clr_depth =0 ;/* 24 bit color depth */ + +/* COLOR_DEPTH */ +REG_FLD_MOD (base,HDMI_CORE_VP_PR_CD , clr_depth,7 ,4 ); +/* BYPASS_EN */ +REG_FLD_MOD (base,HDMI_CORE_VP_CONF , clr_depth ?0 :1 ,6 ,6 ); +/* PP_EN */ +REG_FLD_MOD (base,HDMI_CORE_VP_CONF , clr_depth ?1 :0 ,5 ,5 ); +/* YCC422_EN */ +REG_FLD_MOD (base,HDMI_CORE_VP_CONF ,0 ,3 ,3 ); +/* PP_STUFFING */ +REG_FLD_MOD (base,HDMI_CORE_VP_STUFF , clr_depth ?1 :0 ,1 ,1 ); +/* YCC422_STUFFING */ +REG_FLD_MOD (base,HDMI_CORE_VP_STUFF ,1 ,2 ,2 ); +/* OUTPUT_SELECTOR */ +REG_FLD_MOD (base,HDMI_CORE_VP_CONF , clr_depth ?0 :2 ,1 ,0 ); +} + +static void hdmi_core_config_csc (struct hdmi_core_data *core) +{ +void __iomem *base = core->base; +int clr_depth; +struct csc_table csc_coeff = {0 }; + +/* support limited range with 24 bit color depth for now */ + csc_coeff = csc_table_deepcolor[0 ]; + clr_depth =0 ; + core->avi_cfg.db3_q_range =HDMI_INFOFRAME_AVI_DB3Q_LR ; + +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_A1_MSB , csc_coeff.a1 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_A1_LSB , csc_coeff.a1,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_A2_MSB , csc_coeff.a2 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_A2_LSB , csc_coeff.a2,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_A3_MSB , csc_coeff.a3 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_A3_LSB , csc_coeff.a3,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_A4_MSB , csc_coeff.a4 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_A4_LSB , csc_coeff.a4,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_B1_MSB , csc_coeff.b1 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_B1_LSB , csc_coeff.b1,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_B2_MSB , csc_coeff.b2 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_B2_LSB , csc_coeff.b2,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_B3_MSB , csc_coeff.b3 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_B3_LSB , csc_coeff.b3,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_B4_MSB , csc_coeff.b4 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_B4_LSB , csc_coeff.b4,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_C1_MSB , csc_coeff.c1 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_C1_LSB , csc_coeff.c1,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_C2_MSB , csc_coeff.c2 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_C2_LSB , csc_coeff.c2,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_C3_MSB , csc_coeff.c3 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_C3_LSB , csc_coeff.c3,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_C4_MSB , csc_coeff.c4 >>8 ,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CSC_COEF_C4_LSB , csc_coeff.c4,7 ,0 ); + +/* CSC_FEED_THROUGH_OFF */ +REG_FLD_MOD (base,HDMI_CORE_MC_FLOWCTRL ,0x1 ,0 ,0 ); + +/* CSC_COLORDEPTH */ +REG_FLD_MOD (base,HDMI_CORE_CSC_SCALE , clr_depth,7 ,4 ); +} + +static void hdmi_core_config_video_sampler (struct hdmi_core_data *core) +{ +int video_mapping =1 ;/* for 24 bit color depth */ + +/* VIDEO_MAPPING */ +REG_FLD_MOD (core->base,HDMI_CORE_TX_INVID0 , video_mapping,4 ,0 ); +} + +static void hdmi_core_config_fc_aux_infoframe_avi (struct hdmi_core_data *core) +{ +void __iomem *base = core->base; +struct hdmi_core_infoframe_avi avi = core->avi_cfg; + +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF0 , avi.db1_format,1 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF0 , avi.db1_active_info,6 ,6 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF0 , avi.db1_bar_info_dv,3 ,2 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF0 , avi.db1_scan_info,5 ,4 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF1 , avi.db2_colorimetry,7 ,6 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF1 , avi.db2_aspect_ratio,5 ,4 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF1 , avi.db2_active_fmt_ar,3 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF2 , avi.db3_itc,7 ,7 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF2 , avi.db3_ec,6 ,4 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF2 , avi.db3_q_range,3 ,2 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVICONF2 , avi.db3_nup_scaling,1 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AVIVID , avi.db4_videocode,6 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_PRCONF , avi.db5_pixel_repeat,3 ,0 ); +} + +static void hdmi_core_enable_video_path (struct hdmi_core_data *core) +{ +void __iomem *base = core->base; + +DSSDBG ("hdmi_core_enable_video_path\n" ); + +REG_FLD_MOD (base,HDMI_CORE_FC_CTRLDUR ,0x0C ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_EXCTRLDUR ,0x20 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_EXCTRLSPAC ,0x01 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_CH0PREAM ,0x0B ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_CH1PREAM ,0x16 ,5 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_CH2PREAM ,0x21 ,5 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_MC_CLKDIS ,0x00 ,0 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_MC_CLKDIS ,0x00 ,1 ,1 ); +} + +static void hdmi_core_mask_interrupts (struct hdmi_core_data *core) +{ +void __iomem *base = core->base; + +REG_FLD_MOD (base,HDMI_CORE_VP_MASK ,0x0 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_MASK0 ,0x0 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_MASK1 ,0x0 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_MASK2 ,0x0 ,1 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_PHY_MASK0 ,0x0 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_PHY_I2CM_INT_ADDR ,0x8 ,3 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_PHY_I2CM_CTLINT_ADDR ,0x88 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_AUD_INT ,0xa3 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_AUD_CC08 ,0x0 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_AUD_D010 ,0x0 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_AUD_GP_MASK ,0x3 ,1 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_HDCP_MASK ,0x0 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_CEC_MASK ,0xff ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_INT ,0x1 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_I2CM_CTLINT ,0xff ,7 ,0 ); +} + +static void hdmi_core_enable_interrupts (struct hdmi_core_data *core) +{ +/* Unmute interrupts */ +REG_FLD_MOD (core->base,HDMI_CORE_IH_MUTE ,0x0 ,1 ,0 ); +} + +int hdmi5_core_handle_irqs (struct hdmi_core_data *core) +{ +void __iomem *base = core->base; + +REG_FLD_MOD (base,HDMI_CORE_IH_FC_STAT0 ,0xff ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_IH_FC_STAT1 ,0xff ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_IH_FC_STAT2 ,0xff ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_IH_AS_STAT0 ,0xff ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_IH_PHY_STAT0 ,0xff ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_IH_I2CM_STAT0 ,0xff ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_IH_CEC_STAT0 ,0xff ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_IH_VP_STAT0 ,0xff ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_IH_I2CMPHY_STAT0 ,0xff ,7 ,0 ); + +return 0 ; +} + +void hdmi5_configure (struct hdmi_core_data *core,struct hdmi_wp_data *wp, +struct hdmi_config *cfg) +{ +struct omap_video_timings video_timing; +struct hdmi_video_format video_format; +struct hdmi_core_vid_config v_core_cfg; +struct hdmi_core_infoframe_avi *avi_cfg = &core->avi_cfg; + +hdmi_core_mask_interrupts (core); + +hdmi_core_init (&v_core_cfg, avi_cfg, cfg); + +hdmi_wp_init_vid_fmt_timings (&video_format, &video_timing, cfg); + +hdmi_wp_video_config_timing (wp, &video_timing); + +/* video config */ + video_format.packing_mode = HDMI_PACK_24b_RGB_YUV444_YUV422; + +hdmi_wp_video_config_format (wp, &video_format); + +hdmi_wp_video_config_interface (wp, &video_timing); + +/* +* configure core video path, set software reset in the core +*/ + v_core_cfg.packet_mode =HDMI_PACKETMODE24BITPERPIXEL ; + +hdmi_core_config_fc (core, &v_core_cfg); +hdmi_core_config_video_packetizer (core); +hdmi_core_config_csc (core); +hdmi_core_config_video_sampler (core); + +/* +* configure packet info frame video according to CEA861-D +*/ + avi_cfg->db1_format =HDMI_INFOFRAME_AVI_DB1Y_RGB ; + avi_cfg->db1_active_info = +HDMI_INFOFRAME_AVI_DB1A_ACTIVE_FORMAT_OFF ; + avi_cfg->db1_bar_info_dv =HDMI_INFOFRAME_AVI_DB1B_NO ; + avi_cfg->db1_scan_info =HDMI_INFOFRAME_AVI_DB1S_0 ; + avi_cfg->db2_colorimetry =HDMI_INFOFRAME_AVI_DB2C_NO ; + avi_cfg->db2_aspect_ratio =HDMI_INFOFRAME_AVI_DB2M_NO ; + avi_cfg->db2_active_fmt_ar =HDMI_INFOFRAME_AVI_DB2R_SAME ; + avi_cfg->db3_itc =HDMI_INFOFRAME_AVI_DB3ITC_NO ; + avi_cfg->db3_ec =HDMI_INFOFRAME_AVI_DB3EC_XVYUV601 ; + avi_cfg->db3_q_range =HDMI_INFOFRAME_AVI_DB3Q_DEFAULT ; + avi_cfg->db3_nup_scaling =HDMI_INFOFRAME_AVI_DB3SC_NO ; + avi_cfg->db4_videocode = cfg->cm.code; + avi_cfg->db5_pixel_repeat =HDMI_INFOFRAME_AVI_DB5PR_NO ; + avi_cfg->db6_7_line_eoftop =0 ; + avi_cfg->db8_9_line_sofbottom =0 ; + avi_cfg->db10_11_pixel_eofleft =0 ; + avi_cfg->db12_13_pixel_sofright =0 ; + +hdmi_core_config_fc_aux_infoframe_avi (core); + +hdmi_core_enable_video_path (core); + +hdmi_core_enable_interrupts (core); +} + + +#if defined(CONFIG_OMAP5_DSS_HDMI_AUDIO ) + +static void hdmi5_core_audio_config (struct hdmi_core_data *core, +struct hdmi_core_audio_config *cfg) +{ +void __iomem *base = core->base; +u8 val; + +/* Mute audio before configuring */ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCONF ,0xf ,7 ,4 ); + +/* Set the N parameter */ +REG_FLD_MOD (base,HDMI_CORE_AUD_N1 , cfg->n,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_AUD_N2 , cfg->n >>8 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_AUD_N3 , cfg->n >>16 ,3 ,0 ); + +/* +* CTS manual mode. Automatic mode is not supported when using audio +* parallel interface. +*/ +REG_FLD_MOD (base,HDMI_CORE_AUD_CTS3 ,1 ,4 ,4 ); +REG_FLD_MOD (base,HDMI_CORE_AUD_CTS1 , cfg->cts,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_AUD_CTS2 , cfg->cts >>8 ,7 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_AUD_CTS3 , cfg->cts >>16 ,3 ,0 ); + +/* Layout of Audio Sample Packets: 2-channel or multichannels */ +if (cfg->layout ==HDMI_AUDIO_LAYOUT_2CH ) +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCONF ,0 ,0 ,0 ); +else +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCONF ,1 ,0 ,0 ); + +/* Configure IEC-609580 Validity bits */ +/* Channel 0 is valid */ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSV ,0 ,0 ,0 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSV ,0 ,4 ,4 ); + +if (cfg->layout ==HDMI_AUDIO_LAYOUT_2CH ) + val =1 ; +else + val =0 ; + +/* Channels 1, 2 setting */ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSV , val,1 ,1 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSV , val,5 ,5 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSV , val,2 ,2 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSV , val,6 ,6 ); +/* Channel 3 setting */ +if (cfg->layout ==HDMI_AUDIO_LAYOUT_6CH ) + val =1 ; +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSV , val,3 ,3 ); +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSV , val,7 ,7 ); + +/* Configure IEC-60958 User bits */ +/* TODO: should be set by user. */ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSU ,0 ,7 ,0 ); + +/* Configure IEC-60958 Channel Status word */ +/* CGMSA */ + val = cfg->iec60958_cfg->status[5 ] &IEC958_AES5_CON_CGMSA ; +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (0 ), val,5 ,4 ); + +/* Copyright */ + val = (cfg->iec60958_cfg->status[0 ] & +IEC958_AES0_CON_NOT_COPYRIGHT ) >>2 ; +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (0 ), val,0 ,0 ); + +/* Category */ +hdmi_write_reg (base,HDMI_CORE_FC_AUDSCHNLS (1 ), + cfg->iec60958_cfg->status[1 ]); + +/* PCM audio mode */ + val = (cfg->iec60958_cfg->status[0 ] &IEC958_AES0_CON_MODE ) >>6 ; +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (2 ), val,6 ,4 ); + +/* Source number */ + val = cfg->iec60958_cfg->status[2 ] &IEC958_AES2_CON_SOURCE ; +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (2 ), val,3 ,4 ); + +/* Channel number right 0 */ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (3 ),2 ,3 ,0 ); +/* Channel number right 1*/ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (3 ),4 ,7 ,4 ); +/* Channel number right 2 */ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (4 ),6 ,3 ,0 ); +/* Channel number right 3*/ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (4 ),8 ,7 ,4 ); +/* Channel number left 0 */ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (5 ),1 ,3 ,0 ); +/* Channel number left 1*/ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (5 ),3 ,7 ,4 ); +/* Channel number left 2 */ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (6 ),5 ,3 ,0 ); +/* Channel number left 3*/ +REG_FLD_MOD (base,HDMI_CORE_FC_AUDSCHNLS (6 ),7 ,7 ,4 ); + +/* Clock accuracy and sample rate */ +hdmi_write_reg (base,HDMI_CORE_FC_AUDSCHNLS (7 ), + cfg->iec60958_cfg->status[3 ]); + +/* Original sample rate and word length */ +hdmi_write_reg (base,HDMI_CORE_FC_AUDSCHNLS (8 ), + cfg->iec60958_cfg->status[4 ]); + +/* Enable FIFO empty and full interrupts */ +REG_FLD_MOD (base,HDMI_CORE_AUD_INT ,3 ,3 ,2 ); + +/* Configure GPA */ +/* select HBR/SPDIF interfaces */ +if (cfg->layout ==HDMI_AUDIO_LAYOUT_2CH ) { +/* select HBR/SPDIF interfaces */ +REG_FLD_MOD (base,HDMI_CORE_AUD_CONF0 ,0 ,5 ,5 ); +/* enable two channels in GPA */ +REG_FLD_MOD (base,HDMI_CORE_AUD_GP_CONF1 ,3 ,7 ,0 ); + }else if (cfg->layout ==HDMI_AUDIO_LAYOUT_6CH ) { +/* select HBR/SPDIF interfaces */ +REG_FLD_MOD (base,HDMI_CORE_AUD_CONF0 ,0 ,5 ,5 ); +/* enable six channels in GPA */ +REG_FLD_MOD (base,HDMI_CORE_AUD_GP_CONF1 ,0x3f ,7 ,0 ); + }else { +/* select HBR/SPDIF interfaces */ +REG_FLD_MOD (base,HDMI_CORE_AUD_CONF0 ,0 ,5 ,5 ); +/* enable eight channels in GPA */ +REG_FLD_MOD (base,HDMI_CORE_AUD_GP_CONF1 ,0xff ,7 ,0 ); + } + +/* disable HBR */ +REG_FLD_MOD (base,HDMI_CORE_AUD_GP_CONF2 ,0 ,0 ,0 ); +/* enable PCUV */ +REG_FLD_MOD (base,HDMI_CORE_AUD_GP_CONF2 ,1 ,1 ,1 ); +/* enable GPA FIFO full and empty mask */ +REG_FLD_MOD (base,HDMI_CORE_AUD_GP_MASK ,3 ,1 ,0 ); +/* set polarity of GPA FIFO empty interrupts */ +REG_FLD_MOD (base,HDMI_CORE_AUD_GP_POL ,1 ,0 ,0 ); + +/* unmute audio */ +REG_FLD_MOD (core_sys_base,HDMI_CORE_FC_AUDSCONF ,0 ,7 ,4 ); +} + +static void hdmi5_core_audio_infoframe_cfg (struct hdmi_core_data *core, +struct snd_cea_861_aud_if *info_aud) +{ +void __iomem *base = core->base; + +/* channel count and coding type fields in AUDICONF0 are swapped */ +hdmi_write_reg (base,HDMI_CORE_FC_AUDICONF0 , + (info_aud->db1_ct_cc &CEA861_AUDIO_INFOFRAME_DB1CC ) <<4 | + (info_aud->db1_ct_cc &CEA861_AUDIO_INFOFRAME_DB1CT ) >>4 ); + +hdmi_write_reg (base,HDMI_CORE_FC_AUDICONF1 , info_aud->db2_sf_ss); +hdmi_write_reg (base,HDMI_CORE_FC_AUDICONF2 , info_aud->db4_ca); +hdmi_write_reg (base,HDMI_CORE_FC_AUDICONF3 , info_aud->db5_dminh_lsv); +} + +int hdmi5_audio_config (struct hdmi_core_data *core,struct hdmi_wp_data *wp, +struct omap_dss_audio *audio,u32 pclk) +{ +struct hdmi_audio_format audio_format; +struct hdmi_audio_dma audio_dma; +struct hdmi_core_audio_config core_cfg; +int err, n, cts, channel_count; +unsigned int fs_nr; +bool word_length_16b = false; + +if (!audio || !audio->iec || !audio->cea || !core) +return -EINVAL ; + + core_cfg.iec60958_cfg = audio->iec; + +if (!(audio->iec->status[4 ] &IEC958_AES4_CON_MAX_WORDLEN_24 ) && + (audio->iec->status[4 ] &IEC958_AES4_CON_WORDLEN_20_16 )) + word_length_16b = true; + +/* only 16-bit word length supported atm */ +if (!word_length_16b) +return -EINVAL ; + +switch (audio->iec->status[3 ] &IEC958_AES3_CON_FS ) { +case IEC958_AES3_CON_FS_32000 : + fs_nr =32000 ; +break ; +case IEC958_AES3_CON_FS_44100 : + fs_nr =44100 ; +break ; +case IEC958_AES3_CON_FS_48000 : + fs_nr =48000 ; +break ; +case IEC958_AES3_CON_FS_88200 : + fs_nr =88200 ; +break ; +case IEC958_AES3_CON_FS_96000 : + fs_nr =96000 ; +break ; +case IEC958_AES3_CON_FS_176400 : + fs_nr =176400 ; +break ; +case IEC958_AES3_CON_FS_192000 : + fs_nr =192000 ; +break ; +default : +return -EINVAL ; + } + + err =hdmi_compute_acr (pclk, fs_nr, &n, &cts); + core_cfg.n = n; + core_cfg.cts = cts; + +/* Audio channels settings */ + channel_count = (audio->cea->db1_ct_cc &CEA861_AUDIO_INFOFRAME_DB1CC ) + +1 ; + +if (channel_count ==2 ) + core_cfg.layout =HDMI_AUDIO_LAYOUT_2CH ; +else if (channel_count ==6 ) + core_cfg.layout =HDMI_AUDIO_LAYOUT_6CH ; +else + core_cfg.layout =HDMI_AUDIO_LAYOUT_8CH ; + +/* DMA settings */ +if (word_length_16b) + audio_dma.transfer_size =0x10 ; +else + audio_dma.transfer_size =0x20 ; + audio_dma.block_size =0xc0 ; + audio_dma.mode =HDMI_AUDIO_TRANSF_DMA ; + audio_dma.fifo_threshold =0x20 ;/* in number of samples */ + +/* audio FIFO format settings for 16-bit samples*/ + audio_format.samples_per_word =HDMI_AUDIO_ONEWORD_TWOSAMPLES ; + audio_format.sample_size =HDMI_AUDIO_SAMPLE_16BITS ; + audio_format.justification =HDMI_AUDIO_JUSTIFY_LEFT ; + +/* only LPCM atm */ + audio_format.type =HDMI_AUDIO_TYPE_LPCM ; + +/* disable start/stop signals of IEC 60958 blocks */ + audio_format.en_sig_blk_strt_end =HDMI_AUDIO_BLOCK_SIG_STARTEND_ON ; + +/* configure DMA and audio FIFO format*/ +hdmi_wp_audio_config_dma (wp, &audio_dma); +hdmi_wp_audio_config_format (wp, &audio_format); + +/* configure the core */ +hdmi5_core_audio_config (core, &core_cfg); + +/* configure CEA 861 audio infoframe */ +hdmi5_core_audio_infoframe_cfg (core, audio->cea); + +return 0 ; +} +#endif + +#define CORE_OFFSET 0x20000 +#define CORE_SIZE 0x17900 + +int hdmi5_core_init (struct platform_device *pdev,struct hdmi_core_data *core) +{ +struct resource *res; +struct resource temp_res; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"hdmi_core" ); +if (!res) { +DSSDBG ("can't get CORE mem resource by name\n" ); +/* +* if hwmod/DT doesn't have the memory resource information +* split into HDMI sub blocks by name, we try again by getting +* the platform's first resource. this code will be removed when +* the driver can get the mem resources by name +*/ + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +DSSERR ("can't get CORE mem resource\n" ); +return -EINVAL ; + } + + temp_res.start = res->start +CORE_OFFSET ; + temp_res.end = temp_res.start +CORE_SIZE -1 ; + res = &temp_res; + } + + core->base =devm_ioremap (&pdev->dev, res->start,resource_size (res)); +if (!core->base) { +DSSERR ("can't ioremap CORE\n" ); +return -ENOMEM ; + } + +return 0 ; +}
drivers/video/omap2/dss/hdmi5_core.h new file +298 -0
298 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 3/6 omapdss: hdmi phy: Incorporate changes for OMAP5/DRA7x
In reply to Archit TanejaOMAP5/DRA7x HDMI PHY has some differences compared to OMAP4 HDMI PHY.
Create a features struct which help the diagram configure the PHY based on what SoC it is.
--- drivers/video/omap2/dss/hdmi.h | 1 + drivers/video/omap2/dss/hdmi_phy.c | 94 +++++++++++++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 2 deletions(-)
drivers/video/omap2/dss/hdmi.h +1 -0
@@ -80,6 +80,7 @@#define HDMI_TXPHY_DIGITAL_CTRL 0x4#define HDMI_TXPHY_POWER_CTRL 0x8#define HDMI_TXPHY_PAD_CFG_CTRL 0xC +#define HDMI_TXPHY_BIST_CONTROL 0x1Cenum hdmi_pll_pwr {HDMI_PLLPWRCMD_ALLOFF =0 ,
drivers/video/omap2/dss/hdmi_phy.c +92 -2
149 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 4/6 omapdss: hdmi pll: Incorporate changes for OMAP5/DRA7x
In reply to Archit TanejaAdd a features struct to differentiate between the HDMI PLLs on OMAP4 and OMAP5/DRA7x.
The OMAP5/DRA7x PLL are more sensitive compared to the PLL on OMAP4 when it comes to locking. We need to ensure that the DCO freq calculated isn't too low for lower pixel clocks. If not followed, the PLL doesn't lock for lower frequencies.
Modify the PLL computation slightly to ensure the HDMI PLL locks for lower frequencies. This will be replaced by a more complex computation which makes sure all the PLL constraints are met.
--- drivers/video/omap2/dss/hdmi_pll.c | 74 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-)
drivers/video/omap2/dss/hdmi_pll.c +71 -3
@@ -21,6 +21,13 @@#define HDMI_DEFAULT_REGN 16#define HDMI_DEFAULT_REGM2 1 +struct hdmi_pll_features { +bool sys_reset; +bool bound_dcofreq; +}; + +static const struct hdmi_pll_features *pll_feat; +void hdmi_pll_dump (struct hdmi_pll_data *pll,struct seq_file *s) {#define DUMPPLL (r) seq_printf(s, "%-35s %08x\n", #r,\
@@ -55,7 +62,17 @@ void hdmi_pll_compute(struct hdmi_pll_data *pll, unsigned long clkin, int phy) refclk = clkin / pi->regn; - pi->regm2 =HDMI_DEFAULT_REGM2 ; +/* +* HACK: the HDMI PLL on omap5/dra7x doesn't lock if the required +* DCOFREQ is lesser than the minimum value of the DCO's lower frequency +* range. For now, we just make sure that low pixel clock rates also +* generate a high enough DCOFREQ by setting the M2 post divider to a +* higher value +*/ +if (pll_feat->bound_dcofreq && phy <=65000 ) + pi->regm2 =3 ; +else + pi->regm2 =HDMI_DEFAULT_REGM2 ;/* * multiplier is pixel_clk/ref_clk
@@ -151,8 +168,12 @@ static int hdmi_pll_config(struct hdmi_pll_data *pll)static int hdmi_pll_reset (struct hdmi_pll_data *pll) { -/* SYSRESET controlled by power FSM */ -REG_FLD_MOD (pll->base,PLLCTRL_PLL_CONTROL ,0x0 ,3 ,3 ); +/* +* SYSRESET controlled by power FSM. +* SYSRESETN needs to be set for omap5/dra7x, but cleared for omap4 +* HDMI PLL +*/ +REG_FLD_MOD (pll->base,PLLCTRL_PLL_CONTROL , pll_feat->sys_reset,3 ,3 );/* READ 0x0 reset is in progress */ if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_STATUS, 0, 0, 1)
@@ -195,11 +216,58 @@ void hdmi_pll_disable(struct hdmi_pll_data *pll, struct hdmi_wp_data *wp)#define PLL_OFFSET 0x200#define PLL_SIZE 0x100 +static const struct hdmi_pll_features omap44xx_pll_feats = { + .sys_reset = false, + .bound_dcofreq = false, +}; + +static const struct hdmi_pll_features omap54xx_pll_feats = { + .sys_reset = true, + .bound_dcofreq = true, +}; + +static int __init hdmi_pll_init_features (struct platform_device *pdev) +{ +struct hdmi_pll_features *dst; +const struct hdmi_pll_features *src; + + dst =devm_kzalloc (&pdev->dev,sizeof (*dst),GFP_KERNEL ); +if (!dst) { +dev_err (&pdev->dev,"Failed to allocate HDMI PHY Features\n" ); +return -ENOMEM ; + } + +switch (omapdss_get_version ()) { +case OMAPDSS_VER_OMAP4430_ES1 : +case OMAPDSS_VER_OMAP4430_ES2 : +case OMAPDSS_VER_OMAP4 : + src = &omap44xx_pll_feats; +break ; + +case OMAPDSS_VER_OMAP5 : + src = &omap54xx_pll_feats; +break ; + +default : +return -ENODEV ; + } + +memcpy (dst, src,sizeof (*dst)); + pll_feat = dst; + +return 0 ; +} +int hdmi_pll_init (struct platform_device *pdev,struct hdmi_pll_data *pll) { +int r;struct resource *res;struct resource temp_res; + r =hdmi_pll_init_features (pdev); +if (r) +return r; + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"hdmi_pllctrl" );if (!res) {DSSDBG ("can't get PLL mem resource by name\n" );
Signature · 1 line
1.8.1.2
PATCH 5/6 omapdss: hdmi: add OMAP5/DRA7x hdmi driver
In reply to Archit TanejaThe HDMI IP on OMAP5/DRA7x has a different core sub block compared to the one one OMAP4. The rest of the IPs are the same. Add a hdmi5 platform driver which calls hdmi5_core.c apis. The rest of the driver uses the same api's for wrapper, pll and phy, and the common helper funcs for timings.
--- drivers/video/omap2/dss/Kconfig | 10 + drivers/video/omap2/dss/Makefile | 2 + drivers/video/omap2/dss/core.c | 6 + drivers/video/omap2/dss/dss.h | 3 + drivers/video/omap2/dss/hdmi.h | 2 +- drivers/video/omap2/dss/hdmi5.c | 699 ++++++++++++++++++++++++++++++++++++++ drivers/video/omap2/dss/hdmi_wp.c | 2 +- 7 files changed, 722 insertions(+), 2 deletions(-) create mode 100644 drivers/video/omap2/dss/hdmi5.c
drivers/video/omap2/dss/Kconfig +10 -0
@@ -69,6 +69,16 @@ config OMAP4_DSS_HDMI config OMAP4_DSS_HDMI_AUDIO bool +config OMAP5_DSS_HDMI + bool "OMAP5 HDMI support" + default y + help + HDMI Interface for OMAP5 and SoCs containing the same HDMI core IP. + +config OMAP5_DSS_HDMI_AUDIO + depends on OMAP5_DSS_HDMI + bool + config OMAP2_DSS_SDI bool "SDI support" default n
drivers/video/omap2/dss/Makefile +2 -0
@@ -12,4 +12,6 @@ omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o omapdss-$(CONFIG_OMAP2_DSS_DSI) += dsi.o omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi4.o hdmi_common.o hdmi_wp.o hdmi_pll.o \ hdmi_phy.o hdmi4_core.o +omapdss-$(CONFIG_OMAP5_DSS_HDMI) += hdmi5.o hdmi_common.o hdmi_wp.o hdmi_pll.o \ + hdmi_phy.o hdmi5_core.o ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
drivers/video/omap2/dss/core.c +6 -0
@@ -268,6 +268,9 @@ static int (*dss_output_drv_reg_funcs[])(void) __initdata = {#ifdef CONFIG_OMAP4_DSS_HDMI hdmi4_init_platform_driver,#endif +#ifdef CONFIG_OMAP5_DSS_HDMI + hdmi5_init_platform_driver, +#endif };static void (*dss_output_drv_unreg_funcs[])(void ) __exitdata = {
@@ -289,6 +292,9 @@ static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = {#ifdef CONFIG_OMAP4_DSS_HDMI hdmi4_uninit_platform_driver,#endif +#ifdef CONFIG_OMAP5_DSS_HDMI + hdmi5_uninit_platform_driver, +#endif };static bool dss_output_drv_loaded[ARRAY_SIZE (dss_output_drv_reg_funcs)];
drivers/video/omap2/dss/dss.h +3 -0
@@ -430,6 +430,9 @@ void venc_uninit_platform_driver(void) __exit;int hdmi4_init_platform_driver (void )__init ; void hdmi4_uninit_platform_driver(void) __exit; +int hdmi5_init_platform_driver (void )__init ; +void hdmi5_uninit_platform_driver(void) __exit; +/* RFBI */ int rfbi_init_platform_driver (void )__init ; void rfbi_uninit_platform_driver(void) __exit;
drivers/video/omap2/dss/hdmi.h +1 -1
@@ -429,7 +429,7 @@ const struct hdmi_config *hdmi_default_timing(void);const struct hdmi_config *hdmi_get_timings (int mode,int code);struct hdmi_cm hdmi_get_code (struct omap_video_timings *timing); -#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO ) +#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO ) || defined(CONFIG_OMAP5_DSS_HDMI_AUDIO )int hdmi_compute_acr (u32 pclk,u32 sample_freq,u32 *n,u32 *cts);int hdmi_wp_audio_enable (struct hdmi_wp_data *wp,bool enable);int hdmi_wp_audio_core_req_enable (struct hdmi_wp_data *wp,bool enable);
drivers/video/omap2/dss/hdmi5.c new file +699 -0
699 lines not on this page · raw message
drivers/video/omap2/dss/hdmi_wp.c +1 -1
@@ -181,7 +181,7 @@ void hdmi_wp_init_vid_fmt_timings(struct hdmi_video_format *video_fmt, timings->interlace = param->timings.interlace; } -#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO ) +#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO ) || defined(CONFIG_OMAP5_DSS_HDMI_AUDIO )void hdmi_wp_audio_config_format (struct hdmi_wp_data *wp,struct hdmi_audio_format *aud_fmt) {
Signature · 1 line
1.8.1.2
PATCH 6/6 omapdss: hdmi4/hdmi5: set regulator voltage to required level
In reply to Archit TanejaIt's not sufficient to request the regulator. We need to set the IO voltage as well if the min and max voltage values of the regulator differ.
However, if the regulator on a platform doesn't permit the range we requested for, or is a fixed voltage regulator, we just give a warning that we didn't get voltage range we requested for. The recommended voltage range for vdda_hdmi as per the HDMI PHY spec is 1.8V to 1.98V for OMAP4 and 1.5V to 1.8V for OMAP5.
Originally worked on by Somnath Mukherjee <[email protected]>
--- drivers/video/omap2/dss/hdmi4.c | 5 +++++ drivers/video/omap2/dss/hdmi5.c | 5 +++++ 2 files changed, 10 insertions(+)
drivers/video/omap2/dss/hdmi4.c +5 -0
@@ -83,6 +83,7 @@ static void hdmi_runtime_put(void)static int hdmi_init_regulator (void ) { +int r;struct regulator *reg;if (hdmi.vdda_hdmi_dac_reg !=NULL )
@@ -99,6 +100,10 @@ static int hdmi_init_regulator(void)return PTR_ERR (reg); } + r =regulator_set_voltage (reg,1800000 ,1980000 ); +if (r) +DSSWARN ("can't set regulator voltage" ); + hdmi.vdda_hdmi_dac_reg = reg;return 0 ;
drivers/video/omap2/dss/hdmi5.c +5 -0
@@ -85,6 +85,7 @@ static void hdmi_runtime_put(void)static int hdmi_init_regulator (void ) { +int r;struct regulator *reg;if (hdmi.vdda_hdmi_dac_reg !=NULL )
@@ -96,6 +97,10 @@ static int hdmi_init_regulator(void)return PTR_ERR (reg); } + r =regulator_set_voltage (reg,1500000 ,1800000 ); +if (r) +DSSWARN ("can't set regulator voltage" ); + hdmi.vdda_hdmi_dac_reg = reg;return 0 ;
Signature · 1 line
1.8.1.2