Index: drivers/media/video/samsung/tv20/tv_clock_s5pv210.c |
diff --git a/drivers/media/video/samsung/tv20/tv_clock_s5pv210.c b/drivers/media/video/samsung/tv20/tv_clock_s5pv210.c |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a10832e7c37d21482a73823ae267b3a3020f0dfb |
--- /dev/null |
+++ b/drivers/media/video/samsung/tv20/tv_clock_s5pv210.c |
@@ -0,0 +1,133 @@ |
+/* linux/drivers/media/video/samsung/tv20/tv_clock_s5pv210.c |
+* |
+* Copyright (c) 2010 Samsung Electronics Co., Ltd. |
+* http://www.samsung.com/ |
+* |
+* S5PV210 - clock raw ftn file for Samsung TVOut driver |
+* |
+* 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/module.h> |
+#include <linux/kernel.h> |
+#include <linux/delay.h> |
+#include <linux/platform_device.h> |
+#include <linux/clk.h> |
+ |
+#include <linux/uaccess.h> |
+#include <linux/io.h> |
+ |
+#include <mach/map.h> |
+#include <mach/regs-clock.h> |
+ |
+#include "tv_out_s5pv210.h" |
+#include <mach/regs-hdmi_clock.h> |
+ |
+#ifdef CONFIG_TVOUT_RAW_DBG |
+#define S5P_TVOUT_CLK_DEBUG 1 |
+#endif |
+ |
+#ifdef S5P_TVOUT_CLK_DEBUG |
+#define TVCLKPRINTK(fmt, args...) \ |
+ printk(KERN_INFO "\t\t[TVCLK] %s: " fmt, __func__ , ## args) |
+#else |
+#define TVCLKPRINTK(fmt, args...) |
+#endif |
+ |
+ |
+void tv_clk_init_hpll(unsigned int lock_time, |
+ bool vsel, |
+ unsigned int mdiv, |
+ unsigned int pdiv, |
+ unsigned int sdiv) |
+{ |
+ u32 temp; |
+ |
+ TVCLKPRINTK("%d,%d,%d,%d\n\r", lock_time, mdiv, pdiv, sdiv); |
+ |
+ temp = readl(S5P_VPLL_CON); |
+ |
+ temp &= ~VPLL_ENABLE; |
+ |
+ writel(temp, S5P_VPLL_CON); |
+ |
+ temp = 0; |
+ |
+ if (vsel) |
+ temp |= VCO_FREQ_SEL; |
+ |
+ temp |= VPLL_ENABLE; |
+ temp |= MDIV(mdiv) | PDIV(pdiv) | SDIV(sdiv); |
+ |
+ writel(VPLL_LOCKTIME(lock_time), S5P_VPLL_LOCK); |
+ writel(temp, S5P_VPLL_CON); |
+ |
+ while (!VPLL_LOCKED(readl(S5P_VPLL_CON))) |
+ ; |
+ |
+ TVCLKPRINTK("0x%08x,0x%08x\n\r", |
+ readl(S5P_VPLL_LOCK), readl(S5P_VPLL_CON)); |
+} |
+ |
+/* prevent hdmi hang-up when reboot */ |
+int tv_clk_change_internal(void) |
+{ |
+ u32 reg = readl(S5P_CLK_SRC1); |
+ /* set to SCLK_DAC */ |
+ reg &= HDMI_SEL_MASK; |
+ /* set to SCLK_PIXEL */ |
+ reg &= VMIXER_SEL_MASK; |
+ |
+ writel(reg, S5P_CLK_SRC1); |
+ |
+ return 0; |
+} |
+ |
+enum s5p_tv_clk_err tv_clk_init_mout_hpll(enum s5p_tv_clk_mout_hpll mout_hpll) |
+{ |
+ TVCLKPRINTK("(%d)\n\r", mout_hpll); |
+ |
+ writel(readl(S5P_CLK_SRC1) | HDMI_SEL_HDMIPHY, S5P_CLK_SRC1); |
+ |
+ TVCLKPRINTK("S5P_CLK_SRC1 :0x%08x\n", readl(S5P_CLK_SRC1)); |
+ return S5P_TV_CLK_ERR_NO_ERROR; |
+} |
+ |
+enum s5p_tv_clk_err tv_clk_init_video_mixer( |
+ enum s5p_tv_clk_vmiexr_srcclk src_clk) |
+{ |
+ switch (src_clk) { |
+ |
+ /* for analog tv out 0:SCLK_DAC */ |
+ case TVOUT_CLK_VMIXER_SRCCLK_VCLK_54: |
+ writel(readl(S5P_CLK_SRC1) & VMIXER_SEL_MASK, S5P_CLK_SRC1); |
+ break; |
+ |
+ /* for digital hdmi_phy 1: SCLK_HDMI */ |
+ case TVOUT_CLK_VMIXER_SRCCLK_MOUT_HPLL: |
+ writel(readl(S5P_CLK_SRC1) | VMIXER_SEL_MOUT_VPLL, |
+ S5P_CLK_SRC1); |
+ break; |
+ |
+ default: |
+ TVCLKPRINTK("[ERR] invalid src_clk parameter = %d\n", src_clk); |
+ return S5P_TV_CLK_ERR_INVALID_PARAM; |
+ } |
+ |
+ TVCLKPRINTK("S5P_CLK_SRC1 :0x%08x\n", readl(S5P_CLK_SRC1)); |
+ |
+ return S5P_TV_CLK_ERR_NO_ERROR; |
+} |
+ |
+void tv_clk_init_hdmi_ratio(unsigned int clk_div) |
+{ |
+ TVCLKPRINTK("(%d)\n\r", clk_div); |
+ |
+ writel((readl(S5P_CLK_DIV1) & HDMI_DIV_RATIO_MASK) | |
+ HDMI_DIV_RATIO(clk_div), S5P_CLK_DIV1); |
+ |
+ TVCLKPRINTK("(0x%08x)\n\r", readl(S5P_CLK_DIV3)); |
+} |
+ |