From 8481b02bd4b208ef8bd86e283ec1ed963a406563 Mon Sep 17 00:00:00 2001 From: Zheng Yang Date: Fri, 1 Aug 2014 16:42:06 +0800 Subject: [PATCH] rk312x tve: display is ok. --- arch/arm/boot/dts/rk312x.dtsi | 2 +- drivers/video/rockchip/tve/rk3036/Kconfig | 4 +-- .../video/rockchip/tve/rk3036/rk3036_tve.c | 36 ++++++++++++++----- .../video/rockchip/tve/rk3036/rk3036_tve.h | 1 + 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/arch/arm/boot/dts/rk312x.dtsi b/arch/arm/boot/dts/rk312x.dtsi index 4835f0f6df6b..8908a437f381 100755 --- a/arch/arm/boot/dts/rk312x.dtsi +++ b/arch/arm/boot/dts/rk312x.dtsi @@ -644,7 +644,7 @@ tve: tve{ compatible = "rockchip,rk312x-tve"; - reg = <0x1011e200 0x100>; + reg = <0x1010e200 0x100>; status = "disabled"; }; diff --git a/drivers/video/rockchip/tve/rk3036/Kconfig b/drivers/video/rockchip/tve/rk3036/Kconfig index 1f0231166518..eadde36e659d 100644 --- a/drivers/video/rockchip/tve/rk3036/Kconfig +++ b/drivers/video/rockchip/tve/rk3036/Kconfig @@ -1,6 +1,6 @@ config RK3036_TV_ENCODER - bool "rk3036 tv encoder support" - depends on LCDC_RK3036 && RK_TVENCODER + bool "rk3036/3128 tv encoder support" + depends on (LCDC_RK3036 || LCDC_RK312X) && RK_TVENCODER default n help Support RK3036 output CVBS. diff --git a/drivers/video/rockchip/tve/rk3036/rk3036_tve.c b/drivers/video/rockchip/tve/rk3036/rk3036_tve.c index 11095bfc1275..03c0cf91ef67 100644 --- a/drivers/video/rockchip/tve/rk3036/rk3036_tve.c +++ b/drivers/video/rockchip/tve/rk3036/rk3036_tve.c @@ -52,7 +52,8 @@ static void dac_enable(bool enable) mask = m_VBG_EN | m_DAC_EN; val = 0; } - grf_writel(RK3036_GRF_SOC_CON3, (mask << 16) | val); + grf_writel(rk3036_tve->grfreg, (mask << 16) | val); + grf_writel(RK312X_GRF_TVE_CON, (mask << 16) | val); } static void tve_set_mode(int mode) @@ -294,17 +295,42 @@ static struct rk_display_driver display_cvbs = { .probe = display_cvbs_probe, }; +#if defined(CONFIG_OF) +static const struct of_device_id rk3036_tve_dt_ids[] = { + {.compatible = "rockchip,rk3036-tve",}, + {.compatible = "rockchip,rk312x-tve",}, + {} +}; +#endif + static int rk3036_tve_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; struct resource *res; + const struct of_device_id *match; int i; + match = of_match_node(rk3036_tve_dt_ids, np); + if (!match) + return PTR_ERR(match); + rk3036_tve = devm_kzalloc(&pdev->dev, sizeof(struct rk3036_tve), GFP_KERNEL); if (!rk3036_tve) { dev_err(&pdev->dev, "rk3036 tv encoder device kmalloc fail!"); return -ENOMEM; } + + if (!strcmp(match->compatible, "rockchip,rk3036-tve")) { + rk3036_tve->grfreg = RK3036_GRF_SOC_CON3; + } else if (!strcmp(match->compatible, "rockchip,rk312x-tve")) { + rk3036_tve->grfreg = RK312X_GRF_TVE_CON; + } else { + dev_err(&pdev->dev, "It is not a valid tv encoder!"); + kfree(rk3036_tve); + return -ENOMEM; + } + platform_set_drvdata(pdev, rk3036_tve); rk3036_tve->dev = &pdev->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -334,14 +360,6 @@ static void rk3036_tve_shutdown(struct platform_device *pdev) { } -#if defined(CONFIG_OF) -static const struct of_device_id rk3036_tve_dt_ids[] = { - {.compatible = "rockchip,rk3036-tve",}, - {.compatible = "rockchip,rk312x-tve",}, - {} -}; -#endif - static struct platform_driver rk3036_tve_driver = { .probe = rk3036_tve_probe, .remove = NULL, diff --git a/drivers/video/rockchip/tve/rk3036/rk3036_tve.h b/drivers/video/rockchip/tve/rk3036/rk3036_tve.h index 25ebd2190520..c5cbf52c58c0 100644 --- a/drivers/video/rockchip/tve/rk3036/rk3036_tve.h +++ b/drivers/video/rockchip/tve/rk3036/rk3036_tve.h @@ -95,6 +95,7 @@ struct rk3036_tve { void __iomem *regbase; u32 reg_phy_base; u32 len; + int grfreg; struct rk_display_device *ddev; unsigned int enable; -- 2.34.1