static void rfbi_transfer_area(struct omap_dss_device *dssdev, u16 width, u16 height, void (*callback)(void *data), void *data) { u32 l; BUG_ON(callback == 0); // printk(KERN_INFO "rfbi_transfer_area %dx%d\n", width, height); DSSDBG("rfbi_transfer_area %dx%d\n", width, height); // dispc_disable_sidle(); dss_start_update(dssdev); rfbi.framedone_callback = callback; rfbi.framedone_callback_data = data; rfbi_write_reg(RFBI_PIXEL_CNT, width * height); l = rfbi_read_reg(RFBI_CONTROL); l = FLD_MOD(l, 1, 0, 0); // enable l = FLD_MOD(l, 0, 4, 4); // ITE rfbi_write_reg(RFBI_CONTROL, l); l = rfbi_read_reg(RFBI_CONTROL); if (!rfbi.te_enabled) l = FLD_MOD(l, 1, 4, 4); // ITE rfbi_write_reg(RFBI_CONTROL, l); }
static int rfbi_transfer_area(struct omap_dss_device *dssdev, void (*callback)(void *data), void *data) { u32 l; int r; struct omap_overlay_manager *mgr = rfbi.output.manager; u16 width = rfbi.timings.x_res; u16 height = rfbi.timings.y_res; /*BUG_ON(callback == 0);*/ BUG_ON(rfbi.framedone_callback != NULL); DSSDBG("rfbi_transfer_area %dx%d\n", width, height); dss_mgr_set_timings(mgr, &rfbi.timings); r = dss_mgr_enable(mgr); if (r) return r; rfbi.framedone_callback = callback; rfbi.framedone_callback_data = data; rfbi_write_reg(RFBI_PIXEL_CNT, width * height); l = rfbi_read_reg(RFBI_CONTROL); l = FLD_MOD(l, 1, 0, 0); /* enable */ if (!rfbi.te_enabled) l = FLD_MOD(l, 1, 4, 4); /* ITE */ rfbi_write_reg(RFBI_CONTROL, l); return 0; }
static void rfbi_transfer_area(struct omap_dss_device *dssdev, u16 width, u16 height, void (*callback)(void *data), void *data) { u32 l; /*BUG_ON(callback == 0);*/ BUG_ON(rfbi.framedone_callback != NULL); DSSDBG("rfbi_transfer_area %dx%d\n", width, height); dispc_mgr_set_lcd_size(dssdev->manager->id, width, height); dispc_mgr_enable(dssdev->manager->id, true); rfbi.framedone_callback = callback; rfbi.framedone_callback_data = data; rfbi_write_reg(RFBI_PIXEL_CNT, width * height); l = rfbi_read_reg(RFBI_CONTROL); l = FLD_MOD(l, 1, 0, 0); /* enable */ if (!rfbi.te_enabled) l = FLD_MOD(l, 1, 4, 4); /* ITE */ rfbi_write_reg(RFBI_CONTROL, l); }
void rfbi_transfer_area(u16 width, u16 height, void (callback)(void *data), void *data) { u32 l; /*BUG_ON(callback == 0);*/ BUG_ON(rfbi.framedone_callback != NULL); DSSDBG("rfbi_transfer_area %dx%d\n", width, height); dispc_set_lcd_size(width, height); dispc_enable_channel(OMAP_DSS_CHANNEL_LCD, true); rfbi.framedone_callback = callback; rfbi.framedone_callback_data = data; rfbi_enable_clocks(1); rfbi_write_reg(RFBI_PIXEL_CNT, width * height); l = rfbi_read_reg(RFBI_CONTROL); l = FLD_MOD(l, 1, 0, 0); /* enable */ if (!rfbi.te_enabled) l = FLD_MOD(l, 1, 4, 4); /* ITE */ rfbi_write_reg(RFBI_CONTROL, l); }
void dss_select_clk_source(bool dsi, bool dispc) { u32 r; r = dss_read_reg(DSS_CONTROL); r = FLD_MOD(r, dsi, 1, 1); /* DSI_CLK_SWITCH */ r = FLD_MOD(r, dispc, 0, 0); /* DISPC_CLK_SWITCH */ dss_write_reg(DSS_CONTROL, r); }
static int rfbi_transfer_area(struct omap_dss_device *dssdev, u16 width, u16 height, void (*callback)(void *data), void *data) { u32 l; int r; struct omap_video_timings timings = { .hsw = 1, .hfp = 1, .hbp = 1, .vsw = 1, .vfp = 0, .vbp = 0, .x_res = width, .y_res = height, }; /*BUG_ON(callback == 0);*/ BUG_ON(rfbi.framedone_callback != NULL); DSSDBG("rfbi_transfer_area %dx%d\n", width, height); dss_mgr_set_timings(dssdev->manager, &timings); r = dss_mgr_enable(dssdev->manager); if (r) return r; rfbi.framedone_callback = callback; rfbi.framedone_callback_data = data; rfbi_write_reg(RFBI_PIXEL_CNT, width * height); l = rfbi_read_reg(RFBI_CONTROL); l = FLD_MOD(l, 1, 0, 0); /* enable */ if (!rfbi.te_enabled) l = FLD_MOD(l, 1, 4, 4); /* ITE */ rfbi_write_reg(RFBI_CONTROL, l); return 0; } static void framedone_callback(void *data, u32 mask) { void (*callback)(void *data); DSSDBG("FRAMEDONE\n"); REG_FLD_MOD(RFBI_CONTROL, 0, 0, 0); callback = rfbi.framedone_callback; rfbi.framedone_callback = NULL; if (callback != NULL) callback(rfbi.framedone_callback_data); }
void dss_select_clk_source(bool dsi, bool dispc) { u32 r; r = dss_read_reg(DSS_CONTROL); r = FLD_MOD(r, dsi, 1, 1); /* DSI_CLK_SWITCH */ if (cpu_is_omap44xx()) r = FLD_MOD(r, dsi, 10, 10); /* DSI2_CLK_SWITCH */ r = FLD_MOD(r, dispc, 0, 0); /* DISPC_CLK_SWITCH */ /* TODO: extend for LCD2 and HDMI */ dss_write_reg(DSS_CONTROL, r); }
void dss_select_clk_source_dsi(enum dsi lcd_ix, bool dsi, bool lcd) { u32 r; r = dss_read_reg(DSS_CONTROL); if (lcd_ix == dsi1) { r = FLD_MOD(r, dsi, 1, 1); /* DSI_CLK_SWITCH */ r = FLD_MOD(r, lcd, 0, 0); /* LCD1_CLK_SWITCH */ } else { r = FLD_MOD(r, dsi, 10, 10); /* DSI2_CLK_SWITCH */ r = FLD_MOD(r, lcd, 12, 12); /* LCD2_CLK_SWITCH */ } dss_write_reg(DSS_CONTROL, r); }
void hdmi_wp_video_config_interface(struct hdmi_wp_data *wp, struct videomode *vm) { u32 r; bool vsync_pol, hsync_pol; DSSDBG("Enter hdmi_wp_video_config_interface\n"); vsync_pol = !!(vm->flags & DISPLAY_FLAGS_VSYNC_HIGH); hsync_pol = !!(vm->flags & DISPLAY_FLAGS_HSYNC_HIGH); r = hdmi_read_reg(wp->base, HDMI_WP_VIDEO_CFG); r = FLD_MOD(r, vsync_pol, 7, 7); r = FLD_MOD(r, hsync_pol, 6, 6); r = FLD_MOD(r, !!(vm->flags & DISPLAY_FLAGS_INTERLACED), 3, 3); r = FLD_MOD(r, 1, 1, 0); /* HDMI_TIMING_MASTER_24BIT */ hdmi_write_reg(wp->base, HDMI_WP_VIDEO_CFG, r); }
void hdmi_wp_video_config_interface(struct hdmi_wp_data *wp, struct omap_video_timings *timings) { u32 r; bool vsync_pol, hsync_pol; DSSDBG("Enter hdmi_wp_video_config_interface\n"); vsync_pol = timings->vsync_level == OMAPDSS_SIG_ACTIVE_HIGH; hsync_pol = timings->hsync_level == OMAPDSS_SIG_ACTIVE_HIGH; r = hdmi_read_reg(wp->base, HDMI_WP_VIDEO_CFG); r = FLD_MOD(r, vsync_pol, 7, 7); r = FLD_MOD(r, hsync_pol, 6, 6); r = FLD_MOD(r, timings->interlace, 3, 3); r = FLD_MOD(r, 1, 1, 0); /* HDMI_TIMING_MASTER_24BIT */ hdmi_write_reg(wp->base, HDMI_WP_VIDEO_CFG, r); }
void hdmi_wp_audio_config_dma(struct hdmi_wp_data *wp, struct hdmi_audio_dma *aud_dma) { u32 r; DSSDBG("Enter hdmi_wp_audio_config_dma\n"); r = hdmi_read_reg(wp->base, HDMI_WP_AUDIO_CFG2); r = FLD_MOD(r, aud_dma->transfer_size, 15, 8); r = FLD_MOD(r, aud_dma->block_size, 7, 0); hdmi_write_reg(wp->base, HDMI_WP_AUDIO_CFG2, r); r = hdmi_read_reg(wp->base, HDMI_WP_AUDIO_CTRL); r = FLD_MOD(r, aud_dma->mode, 9, 9); r = FLD_MOD(r, aud_dma->fifo_threshold, 8, 0); hdmi_write_reg(wp->base, HDMI_WP_AUDIO_CTRL, r); }
static void rfbi_enable_config(int enable1, int enable2) { u32 l; int cs = 0; if (enable1) cs |= 1<<0; if (enable2) cs |= 1<<1; rfbi_enable_clocks(1); l = rfbi_read_reg(RFBI_CONTROL); l = FLD_MOD(l, cs, 3, 2); l = FLD_MOD(l, 0, 1, 1); rfbi_write_reg(RFBI_CONTROL, l); l = rfbi_read_reg(RFBI_CONFIG(0)); l = FLD_MOD(l, 0, 3, 2); /* TRIGGERMODE: ITE */ /*l |= FLD_VAL(2, 8, 7); */ /* L4FORMAT, 2pix/L4 */ /*l |= FLD_VAL(0, 8, 7); */ /* L4FORMAT, 1pix/L4 */ l = FLD_MOD(l, 0, 16, 16); /* A0POLARITY */ l = FLD_MOD(l, 1, 20, 20); /* TE_VSYNC_POLARITY */ l = FLD_MOD(l, 1, 21, 21); /* HSYNCPOLARITY */ l = FLD_MOD(l, OMAP_DSS_RFBI_PARALLELMODE_8, 1, 0); rfbi_write_reg(RFBI_CONFIG(0), l); rfbi_enable_clocks(0); }
static irqreturn_t hdmi_irq_handler(int irq, void *data) { struct hdmi_wp_data *wp = data; u32 irqstatus; irqstatus = hdmi_wp_get_irqstatus(wp); hdmi_wp_set_irqstatus(wp, irqstatus); if ((irqstatus & HDMI_IRQ_LINK_CONNECT) && irqstatus & HDMI_IRQ_LINK_DISCONNECT) { u32 v; /* * If we get both connect and disconnect interrupts at the same * time, turn off the PHY, clear interrupts, and restart, which * raises connect interrupt if a cable is connected, or nothing * if cable is not connected. */ hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_OFF); /* * We always get bogus CONNECT & DISCONNECT interrupts when * setting the PHY to LDOON. To ignore those, we force the RXDET * line to 0 until the PHY power state has been changed. */ v = hdmi_read_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL); v = FLD_MOD(v, 1, 15, 15); /* FORCE_RXDET_HIGH */ v = FLD_MOD(v, 0, 14, 7); /* RXDET_LINE */ hdmi_write_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v); hdmi_wp_set_irqstatus(wp, HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT); hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON); REG_FLD_MOD(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15); } else if (irqstatus & HDMI_IRQ_LINK_CONNECT) { hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_TXON); } else if (irqstatus & HDMI_IRQ_LINK_DISCONNECT) { hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON); } return IRQ_HANDLED; }
/*----------------------------------------------------------------------------- * Function: hdcp_lib_set_av_mute *----------------------------------------------------------------------------- */ void hdcp_lib_set_av_mute(enum av_mute av_mute_state) { unsigned long flags; DBG("hdcp_lib_set_av_mute() av_mute=%d", av_mute_state); spin_lock_irqsave(&hdcp.spinlock, flags); { u8 RegVal, TimeOutCount = 64; RegVal = RD_REG_32(hdcp.hdmi_wp_base_addr + HDMI_CORE_AV_BASE, HDMI_CORE_AV_PB_CTRL2); /* PRguide-GPC: To change the content of the CP_BYTE1 register, * CP_EN must be zero * set PB_CTRL2 :: CP_RPT = 0 */ WR_FIELD_32(hdcp.hdmi_wp_base_addr + HDMI_CORE_AV_BASE, HDMI_CORE_AV_PB_CTRL2, 2, 2, 0); /* Set/clear AV mute state */ WR_REG_32(hdcp.hdmi_wp_base_addr + HDMI_CORE_AV_BASE, HDMI_CORE_AV_CP_BYTE1, av_mute_state); /* FIXME: This loop should be removed */ while (TimeOutCount--) { /* Continue in this loop till CP_EN becomes 0, * prior to TimeOutCount becoming 0 */ if (!RD_FIELD_32(hdcp.hdmi_wp_base_addr + HDMI_CORE_AV_BASE, HDMI_CORE_AV_PB_CTRL2, 3, 3)) break; } DBG(" timeoutcount=%d", TimeOutCount); /* FIXME: why is this if condition required?, according to prg, * this shall be unconditioanlly */ if (TimeOutCount) { /* set PB_CTRL2 :: CP_EN = 1 & CP_RPT = 1 */ RegVal = FLD_MOD(RegVal, 0x3, 3, 2); WR_REG_32(hdcp.hdmi_wp_base_addr + HDMI_CORE_AV_BASE, HDMI_CORE_AV_PB_CTRL2, RegVal); } } spin_unlock_irqrestore(&hdcp.spinlock, flags); }
void hdmi_wp_audio_config_format(struct hdmi_wp_data *wp, struct hdmi_audio_format *aud_fmt) { u32 r; DSSDBG("Enter hdmi_wp_audio_config_format\n"); r = hdmi_read_reg(wp->base, HDMI_WP_AUDIO_CFG); r = FLD_MOD(r, aud_fmt->stereo_channels, 26, 24); r = FLD_MOD(r, aud_fmt->active_chnnls_msk, 23, 16); r = FLD_MOD(r, aud_fmt->en_sig_blk_strt_end, 5, 5); r = FLD_MOD(r, aud_fmt->type, 4, 4); r = FLD_MOD(r, aud_fmt->justification, 3, 3); r = FLD_MOD(r, aud_fmt->sample_order, 2, 2); r = FLD_MOD(r, aud_fmt->samples_per_word, 1, 1); r = FLD_MOD(r, aud_fmt->sample_size, 0, 0); hdmi_write_reg(wp->base, HDMI_WP_AUDIO_CFG, r); }
void dss_sdi_init(u8 datapairs) { u32 l; BUG_ON(datapairs > 3 || datapairs < 1); l = dss_read_reg(DSS_SDI_CONTROL); l = FLD_MOD(l, 0xf, 19, 15); /* SDI_PDIV */ l = FLD_MOD(l, datapairs-1, 3, 2); /* SDI_PRSEL */ l = FLD_MOD(l, 2, 1, 0); /* SDI_BWSEL */ dss_write_reg(DSS_SDI_CONTROL, l); l = dss_read_reg(DSS_PLL_CONTROL); l = FLD_MOD(l, 0x7, 25, 22); /* SDI_PLL_FREQSEL */ l = FLD_MOD(l, 0xb, 16, 11); /* SDI_PLL_REGN */ l = FLD_MOD(l, 0xb4, 10, 1); /* SDI_PLL_REGM */ dss_write_reg(DSS_PLL_CONTROL, l); }
void hdmi_wp_video_config_interface(struct hdmi_wp_data *wp, struct videomode *vm) { u32 r; bool vsync_inv, hsync_inv; DSSDBG("Enter hdmi_wp_video_config_interface\n"); vsync_inv = !!(vm->flags & DISPLAY_FLAGS_VSYNC_LOW); hsync_inv = !!(vm->flags & DISPLAY_FLAGS_HSYNC_LOW); r = hdmi_read_reg(wp->base, HDMI_WP_VIDEO_CFG); r = FLD_MOD(r, 1, 7, 7); /* VSYNC_POL to dispc active high */ r = FLD_MOD(r, 1, 6, 6); /* HSYNC_POL to dispc active high */ r = FLD_MOD(r, vsync_inv, 5, 5); /* CORE_VSYNC_INV */ r = FLD_MOD(r, hsync_inv, 4, 4); /* CORE_HSYNC_INV */ r = FLD_MOD(r, !!(vm->flags & DISPLAY_FLAGS_INTERLACED), 3, 3); r = FLD_MOD(r, 1, 1, 0); /* HDMI_TIMING_MASTER_24BIT */ hdmi_write_reg(wp->base, HDMI_WP_VIDEO_CFG, r); }
void dss_sdi_init(int datapairs) { u32 l; BUG_ON(datapairs > 3 || datapairs < 1); l = dss_read_reg(DSS_SDI_CONTROL); l = FLD_MOD(l, 0xf, 19, 15); /* SDI_PDIV */ l = FLD_MOD(l, datapairs-1, 3, 2); /* SDI_PRSEL */ l = FLD_MOD(l, 2, 1, 0); /* SDI_BWSEL */ dss_write_reg(DSS_SDI_CONTROL, l); l = dss_read_reg(DSS_PLL_CONTROL); l = FLD_MOD(l, 0x7, 25, 22); /* SDI_PLL_FREQSEL */ l = FLD_MOD(l, 0xb, 16, 11); /* SDI_PLL_REGN */ l = FLD_MOD(l, 0xb4, 10, 1); /* SDI_PLL_REGM */ dss_write_reg(DSS_PLL_CONTROL, l); /* Reset SDI PLL */ REG_FLD_MOD(DSS_PLL_CONTROL, 1, 18, 18); /* SDI_PLL_SYSRESET */ udelay(1); /* wait 2x PCLK */ /* Lock SDI PLL */ REG_FLD_MOD(DSS_PLL_CONTROL, 1, 28, 28); /* SDI_PLL_GOBIT */ /* Waiting for PLL lock request to complete */ while (dss_read_reg(DSS_SDI_STATUS) & (1 << 6)) ; /* Clearing PLL_GO bit */ REG_FLD_MOD(DSS_PLL_CONTROL, 0, 28, 28); /* Waiting for PLL to lock */ while (!(dss_read_reg(DSS_SDI_STATUS) & (1 << 5))) ; dispc_lcd_enable_signal(1); /* Waiting for SDI reset to complete */ while (!(dss_read_reg(DSS_SDI_STATUS) & (1 << 5))) ; }
int dss_pll_write_config_type_a(struct dss_pll *pll, const struct dss_pll_clock_info *cinfo) { const struct dss_pll_hw *hw = pll->hw; void __iomem *base = pll->base; int r = 0; u32 l; l = 0; if (hw->has_stopmode) l = FLD_MOD(l, 1, 0, 0); /* PLL_STOPMODE */ l = FLD_MOD(l, cinfo->n - 1, hw->n_msb, hw->n_lsb); /* PLL_REGN */ l = FLD_MOD(l, cinfo->m, hw->m_msb, hw->m_lsb); /* PLL_REGM */ /* M4 */ l = FLD_MOD(l, cinfo->mX[0] ? cinfo->mX[0] - 1 : 0, hw->mX_msb[0], hw->mX_lsb[0]); /* M5 */ l = FLD_MOD(l, cinfo->mX[1] ? cinfo->mX[1] - 1 : 0, hw->mX_msb[1], hw->mX_lsb[1]); writel_relaxed(l, base + PLL_CONFIGURATION1); l = 0; /* M6 */ l = FLD_MOD(l, cinfo->mX[2] ? cinfo->mX[2] - 1 : 0, hw->mX_msb[2], hw->mX_lsb[2]); /* M7 */ l = FLD_MOD(l, cinfo->mX[3] ? cinfo->mX[3] - 1 : 0, hw->mX_msb[3], hw->mX_lsb[3]); writel_relaxed(l, base + PLL_CONFIGURATION3); l = readl_relaxed(base + PLL_CONFIGURATION2); if (hw->has_freqsel) { u32 f = cinfo->fint < 1000000 ? 0x3 : cinfo->fint < 1250000 ? 0x4 : cinfo->fint < 1500000 ? 0x5 : cinfo->fint < 1750000 ? 0x6 : 0x7; l = FLD_MOD(l, f, 4, 1); /* PLL_FREQSEL */ } else if (hw->has_selfreqdco) { u32 f = cinfo->clkdco < hw->clkdco_low ? 0x2 : 0x4; l = FLD_MOD(l, f, 3, 1); /* PLL_SELFREQDCO */ } l = FLD_MOD(l, 1, 13, 13); /* PLL_REFEN */ l = FLD_MOD(l, 0, 14, 14); /* PHY_CLKINEN */ l = FLD_MOD(l, 0, 16, 16); /* M4_CLOCK_EN */ l = FLD_MOD(l, 0, 18, 18); /* M5_CLOCK_EN */ l = FLD_MOD(l, 1, 20, 20); /* HSDIVBYPASS */ if (hw->has_refsel) l = FLD_MOD(l, 3, 22, 21); /* REFSEL = sysclk */ l = FLD_MOD(l, 0, 23, 23); /* M6_CLOCK_EN */ l = FLD_MOD(l, 0, 25, 25); /* M7_CLOCK_EN */ writel_relaxed(l, base + PLL_CONFIGURATION2); writel_relaxed(1, base + PLL_GO); /* PLL_GO */ if (wait_for_bit_change(base + PLL_GO, 0, 0) != 0) { DSSERR("DSS DPLL GO bit not going down.\n"); r = -EIO; goto err; } if (wait_for_bit_change(base + PLL_STATUS, 1, 1) != 1) { DSSERR("cannot lock DSS DPLL\n"); r = -EIO; goto err; } l = readl_relaxed(base + PLL_CONFIGURATION2); l = FLD_MOD(l, 1, 14, 14); /* PHY_CLKINEN */ l = FLD_MOD(l, cinfo->mX[0] ? 1 : 0, 16, 16); /* M4_CLOCK_EN */ l = FLD_MOD(l, cinfo->mX[1] ? 1 : 0, 18, 18); /* M5_CLOCK_EN */ l = FLD_MOD(l, 0, 20, 20); /* HSDIVBYPASS */ l = FLD_MOD(l, cinfo->mX[2] ? 1 : 0, 23, 23); /* M6_CLOCK_EN */ l = FLD_MOD(l, cinfo->mX[3] ? 1 : 0, 25, 25); /* M7_CLOCK_EN */ writel_relaxed(l, base + PLL_CONFIGURATION2); r = dss_wait_hsdiv_ack(pll, (cinfo->mX[0] ? BIT(7) : 0) | (cinfo->mX[1] ? BIT(8) : 0) | (cinfo->mX[2] ? BIT(10) : 0) | (cinfo->mX[3] ? BIT(11) : 0)); if (r) { DSSERR("failed to enable HSDIV clocks\n"); goto err; } err: return r; }
int dss_pll_write_config_type_b(struct dss_pll *pll, const struct dss_pll_clock_info *cinfo) { const struct dss_pll_hw *hw = pll->hw; void __iomem *base = pll->base; u32 l; l = 0; l = FLD_MOD(l, cinfo->m, 20, 9); /* PLL_REGM */ l = FLD_MOD(l, cinfo->n - 1, 8, 1); /* PLL_REGN */ writel_relaxed(l, base + PLL_CONFIGURATION1); l = readl_relaxed(base + PLL_CONFIGURATION2); l = FLD_MOD(l, 0x0, 12, 12); /* PLL_HIGHFREQ divide by 2 */ l = FLD_MOD(l, 0x1, 13, 13); /* PLL_REFEN */ l = FLD_MOD(l, 0x0, 14, 14); /* PHY_CLKINEN */ if (hw->has_refsel) l = FLD_MOD(l, 0x3, 22, 21); /* REFSEL = SYSCLK */ /* PLL_SELFREQDCO */ if (cinfo->clkdco > hw->clkdco_low) l = FLD_MOD(l, 0x4, 3, 1); else l = FLD_MOD(l, 0x2, 3, 1); writel_relaxed(l, base + PLL_CONFIGURATION2); l = readl_relaxed(base + PLL_CONFIGURATION3); l = FLD_MOD(l, cinfo->sd, 17, 10); /* PLL_REGSD */ writel_relaxed(l, base + PLL_CONFIGURATION3); l = readl_relaxed(base + PLL_CONFIGURATION4); l = FLD_MOD(l, cinfo->mX[0], 24, 18); /* PLL_REGM2 */ l = FLD_MOD(l, cinfo->mf, 17, 0); /* PLL_REGM_F */ writel_relaxed(l, base + PLL_CONFIGURATION4); writel_relaxed(1, base + PLL_GO); /* PLL_GO */ if (wait_for_bit_change(base + PLL_GO, 0, 0) != 0) { DSSERR("DSS DPLL GO bit not going down.\n"); return -EIO; } if (wait_for_bit_change(base + PLL_STATUS, 1, 1) != 1) { DSSERR("cannot lock DSS DPLL\n"); return -ETIMEDOUT; } return 0; }
static int hdmi_pll_config(struct hdmi_pll_data *pll) { u32 r; struct hdmi_pll_info *fmt = &pll->info; /* PLL start always use manual mode */ REG_FLD_MOD(pll->base, PLLCTRL_PLL_CONTROL, 0x0, 0, 0); r = hdmi_read_reg(pll->base, PLLCTRL_CFG1); r = FLD_MOD(r, fmt->regm, 20, 9); /* CFG1_PLL_REGM */ r = FLD_MOD(r, fmt->regn - 1, 8, 1); /* CFG1_PLL_REGN */ hdmi_write_reg(pll->base, PLLCTRL_CFG1, r); r = hdmi_read_reg(pll->base, PLLCTRL_CFG2); r = FLD_MOD(r, 0x0, 12, 12); /* PLL_HIGHFREQ divide by 2 */ r = FLD_MOD(r, 0x1, 13, 13); /* PLL_REFEN */ r = FLD_MOD(r, 0x0, 14, 14); /* PHY_CLKINEN de-assert during locking */ r = FLD_MOD(r, fmt->refsel, 22, 21); /* REFSEL */ if (fmt->dcofreq) r = FLD_MOD(r, 0x4, 3, 1); /* 1000MHz and 2000MHz */ else r = FLD_MOD(r, 0x2, 3, 1); /* 500MHz and 1000MHz */ hdmi_write_reg(pll->base, PLLCTRL_CFG2, r); REG_FLD_MOD(pll->base, PLLCTRL_CFG3, fmt->regsd, 17, 10); r = hdmi_read_reg(pll->base, PLLCTRL_CFG4); r = FLD_MOD(r, fmt->regm2, 24, 18); r = FLD_MOD(r, fmt->regmf, 17, 0); hdmi_write_reg(pll->base, PLLCTRL_CFG4, r); /* go now */ REG_FLD_MOD(pll->base, PLLCTRL_PLL_GO, 0x1, 0, 0); /* wait for bit change */ if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_GO, 0, 0, 0) != 0) { DSSERR("PLL GO bit not clearing\n"); return -ETIMEDOUT; } /* Wait till the lock bit is set in PLL status */ if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_STATUS, 1, 1, 1) != 1) { DSSERR("cannot lock PLL\n"); DSSERR("CFG1 0x%x\n", hdmi_read_reg(pll->base, PLLCTRL_CFG1)); DSSERR("CFG2 0x%x\n", hdmi_read_reg(pll->base, PLLCTRL_CFG2)); DSSERR("CFG4 0x%x\n", hdmi_read_reg(pll->base, PLLCTRL_CFG4)); return -ETIMEDOUT; } DSSDBG("PLL locked!\n"); return 0; }
int rfbi_configure(int rfbi_module, int bpp, int lines) { u32 l; int cycle1 = 0, cycle2 = 0, cycle3 = 0; enum omap_rfbi_cycleformat cycleformat; enum omap_rfbi_datatype datatype; enum omap_rfbi_parallelmode parallelmode; switch (bpp) { case 12: datatype = OMAP_DSS_RFBI_DATATYPE_12; break; case 16: datatype = OMAP_DSS_RFBI_DATATYPE_16; break; case 18: datatype = OMAP_DSS_RFBI_DATATYPE_18; break; case 24: datatype = OMAP_DSS_RFBI_DATATYPE_24; break; default: BUG(); return 1; } rfbi.datatype = datatype; switch (lines) { case 8: parallelmode = OMAP_DSS_RFBI_PARALLELMODE_8; break; case 9: parallelmode = OMAP_DSS_RFBI_PARALLELMODE_9; break; case 12: parallelmode = OMAP_DSS_RFBI_PARALLELMODE_12; break; case 16: parallelmode = OMAP_DSS_RFBI_PARALLELMODE_16; break; default: BUG(); return 1; } rfbi.parallelmode = parallelmode; if ((bpp % lines) == 0) { switch (bpp / lines) { case 1: cycleformat = OMAP_DSS_RFBI_CYCLEFORMAT_1_1; break; case 2: cycleformat = OMAP_DSS_RFBI_CYCLEFORMAT_2_1; break; case 3: cycleformat = OMAP_DSS_RFBI_CYCLEFORMAT_3_1; break; default: BUG(); return 1; } } else if ((2 * bpp % lines) == 0) { if ((2 * bpp / lines) == 3) cycleformat = OMAP_DSS_RFBI_CYCLEFORMAT_3_2; else { BUG(); return 1; } } else { BUG(); return 1; } switch (cycleformat) { case OMAP_DSS_RFBI_CYCLEFORMAT_1_1: cycle1 = lines; break; case OMAP_DSS_RFBI_CYCLEFORMAT_2_1: cycle1 = lines; cycle2 = lines; break; case OMAP_DSS_RFBI_CYCLEFORMAT_3_1: cycle1 = lines; cycle2 = lines; cycle3 = lines; break; case OMAP_DSS_RFBI_CYCLEFORMAT_3_2: cycle1 = lines; cycle2 = (lines / 2) | ((lines / 2) << 16); cycle3 = (lines << 16); break; } rfbi_enable_clocks(1); REG_FLD_MOD(RFBI_CONTROL, 0, 3, 2); /* clear CS */ l = 0; l |= FLD_VAL(parallelmode, 1, 0); l |= FLD_VAL(0, 3, 2); /* TRIGGERMODE: ITE */ l |= FLD_VAL(0, 4, 4); /* TIMEGRANULARITY */ l |= FLD_VAL(datatype, 6, 5); /* l |= FLD_VAL(2, 8, 7); */ /* L4FORMAT, 2pix/L4 */ l |= FLD_VAL(0, 8, 7); /* L4FORMAT, 1pix/L4 */ l |= FLD_VAL(cycleformat, 10, 9); l |= FLD_VAL(0, 12, 11); /* UNUSEDBITS */ l |= FLD_VAL(0, 16, 16); /* A0POLARITY */ l |= FLD_VAL(0, 17, 17); /* REPOLARITY */ l |= FLD_VAL(0, 18, 18); /* WEPOLARITY */ l |= FLD_VAL(0, 19, 19); /* CSPOLARITY */ l |= FLD_VAL(1, 20, 20); /* TE_VSYNC_POLARITY */ l |= FLD_VAL(1, 21, 21); /* HSYNCPOLARITY */ rfbi_write_reg(RFBI_CONFIG(rfbi_module), l); rfbi_write_reg(RFBI_DATA_CYCLE1(rfbi_module), cycle1); rfbi_write_reg(RFBI_DATA_CYCLE2(rfbi_module), cycle2); rfbi_write_reg(RFBI_DATA_CYCLE3(rfbi_module), cycle3); l = rfbi_read_reg(RFBI_CONTROL); l = FLD_MOD(l, rfbi_module+1, 3, 2); /* Select CSx */ l = FLD_MOD(l, 0, 1, 1); /* clear bypass */ rfbi_write_reg(RFBI_CONTROL, l); DSSDBG("RFBI config: bpp %d, lines %d, cycles: 0x%x 0x%x 0x%x\n", bpp, lines, cycle1, cycle2, cycle3); rfbi_enable_clocks(0); return 0; }
/* HDMI_CORE_VIDEO_CONFIG */ static void hdmi_core_video_config(struct hdmi_core_data *core, struct hdmi_core_video_config *cfg) { u32 r = 0; void __iomem *core_sys_base = core->base; void __iomem *core_av_base = hdmi_av_base(core); /* sys_ctrl1 default configuration not tunable */ r = hdmi_read_reg(core_sys_base, HDMI_CORE_SYS_SYS_CTRL1); r = FLD_MOD(r, HDMI_CORE_SYS_SYS_CTRL1_VEN_FOLLOWVSYNC, 5, 5); r = FLD_MOD(r, HDMI_CORE_SYS_SYS_CTRL1_HEN_FOLLOWHSYNC, 4, 4); r = FLD_MOD(r, HDMI_CORE_SYS_SYS_CTRL1_BSEL_24BITBUS, 2, 2); r = FLD_MOD(r, HDMI_CORE_SYS_SYS_CTRL1_EDGE_RISINGEDGE, 1, 1); hdmi_write_reg(core_sys_base, HDMI_CORE_SYS_SYS_CTRL1, r); REG_FLD_MOD(core_sys_base, HDMI_CORE_SYS_VID_ACEN, cfg->ip_bus_width, 7, 6); /* Vid_Mode */ r = hdmi_read_reg(core_sys_base, HDMI_CORE_SYS_VID_MODE); /* dither truncation configuration */ if (cfg->op_dither_truc > HDMI_OUTPUTTRUNCATION_12BIT) { r = FLD_MOD(r, cfg->op_dither_truc - 3, 7, 6); r = FLD_MOD(r, 1, 5, 5); } else { r = FLD_MOD(r, cfg->op_dither_truc, 7, 6); r = FLD_MOD(r, 0, 5, 5); } hdmi_write_reg(core_sys_base, HDMI_CORE_SYS_VID_MODE, r); /* HDMI_Ctrl */ r = hdmi_read_reg(core_av_base, HDMI_CORE_AV_HDMI_CTRL); r = FLD_MOD(r, cfg->deep_color_pkt, 6, 6); r = FLD_MOD(r, cfg->pkt_mode, 5, 3); r = FLD_MOD(r, cfg->hdmi_dvi, 0, 0); hdmi_write_reg(core_av_base, HDMI_CORE_AV_HDMI_CTRL, r); /* TMDS_CTRL */ REG_FLD_MOD(core_sys_base, HDMI_CORE_SYS_TMDS_CTRL, cfg->tclk_sel_clkmult, 6, 5); }