From: Leela Krishna Amudala Subject: [PATCH 1/2] video: drm: exynos: Add device tree support Date: Fri, 06 Jul 2012 17:58:13 +0530 Message-ID: <1341577694-28937-2-git-send-email-l.krishna@samsung.com> References: <1341577694-28937-1-git-send-email-l.krishna@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id 895119EC60 for ; Fri, 6 Jul 2012 05:24:37 -0700 (PDT) Received: from epcpsbgm1.samsung.com (mailout3.samsung.com [203.254.224.33]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M6Q0052PNC9BD21@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 06 Jul 2012 21:14:36 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M6Q00HEONBZZ790@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 06 Jul 2012 21:14:36 +0900 (KST) In-reply-to: <1341577694-28937-1-git-send-email-l.krishna@samsung.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org Cc: inki.dae@samsung.com, olofj@google.com, laurent.pinchart@ideasonboard.com List-Id: dri-devel@lists.freedesktop.org Add device tree based discovery support for DRM-FIMD driver. Signed-off-by: Leela Krishna Amudala diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 29fdbfe..37769cf 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -788,12 +789,84 @@ static int fimd_power_on(struct fimd_context *ctx, bool enable) return 0; } +#ifdef CONFIG_OF +static struct exynos_drm_fimd_pdata *drm_fimd_dt_parse_pdata(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct device_node *disp_np; + struct exynos_drm_fimd_pdata *pd; + u32 data[4]; + + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) { + dev_err(dev, "memory allocation for pdata failed\n"); + return ERR_PTR(-ENOMEM); + } + + if (of_get_property(np, "samsung,fimd-vidout-rgb", NULL)) + pd->vidcon0 |= VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB; + if (of_get_property(np, "samsung,fimd-vidout-tv", NULL)) + pd->vidcon0 |= VIDCON0_VIDOUT_TV; + if (of_get_property(np, "samsung,fimd-inv-hsync", NULL)) + pd->vidcon1 |= VIDCON1_INV_HSYNC; + if (of_get_property(np, "samsung,fimd-inv-vsync", NULL)) + pd->vidcon1 |= VIDCON1_INV_VSYNC; + if (of_get_property(np, "samsung,fimd-inv-vclk", NULL)) + pd->vidcon1 |= VIDCON1_INV_VCLK; + if (of_get_property(np, "samsung,fimd-inv-vden", NULL)) + pd->vidcon1 |= VIDCON1_INV_VDEN; + + disp_np = of_parse_phandle(np, "samsung,fimd-display", 0); + if (!disp_np) { + dev_err(dev, "unable to find display panel info\n"); + return ERR_PTR(-EINVAL); + } + + if (of_property_read_u32_array(disp_np, "lcd-htiming", data, 4)) { + dev_err(dev, "invalid horizontal timing\n"); + return ERR_PTR(-EINVAL); + } + pd->panel.timing.left_margin = data[0]; + pd->panel.timing.right_margin = data[1]; + pd->panel.timing.hsync_len = data[2]; + pd->panel.timing.xres = data[3]; + + if (of_property_read_u32_array(disp_np, "lcd-vtiming", data, 4)) { + dev_err(dev, "invalid vertical timing\n"); + return ERR_PTR(-EINVAL); + } + pd->panel.timing.upper_margin = data[0]; + pd->panel.timing.lower_margin = data[1]; + pd->panel.timing.vsync_len = data[2]; + pd->panel.timing.yres = data[3]; + + of_property_read_u32(disp_np, "lcd-panel-type", &pd->panel_type); + + of_property_read_u32(np, "samsung,fimd-frame-rate", + &pd->panel.timing.refresh); + + of_property_read_u32(np, "samsung, defalut-window", &pd->default_win); + + of_property_read_u32(np, "samsung,fimd-win-bpp", &pd->bpp); + + return pd; +} +#else +static int drm_fimd_dt_parse_pdata(struct device *dev, + struct exynos_drm_fimd_pdata **pdata) +{ + return 0; +} +#endif /* CONFIG_OF */ + +static const struct of_device_id drm_fimd_dt_match[]; + static int __devinit fimd_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct fimd_context *ctx; struct exynos_drm_subdrv *subdrv; - struct exynos_drm_fimd_pdata *pdata; + struct exynos_drm_fimd_pdata *pdata = pdev->dev.platform_data; struct exynos_drm_panel_info *panel; struct resource *res; int win; @@ -801,7 +874,11 @@ static int __devinit fimd_probe(struct platform_device *pdev) DRM_DEBUG_KMS("%s\n", __FILE__); - pdata = pdev->dev.platform_data; + if (pdev->dev.of_node) { + pdata = drm_fimd_dt_parse_pdata(&pdev->dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + } if (!pdata) { dev_err(dev, "no platform data specified\n"); return -EINVAL; @@ -1006,6 +1083,15 @@ static int fimd_runtime_resume(struct device *dev) } #endif +#ifdef CONFIG_OF +static const struct of_device_id drm_fimd_dt_match[] = { + { .compatible = "samsung,exynos5-fb", + .data = (void *)NULL }, + {}, +}; +MODULE_DEVICE_TABLE(of, drm_fimd_dt_match); +#endif + static const struct dev_pm_ops fimd_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume) SET_RUNTIME_PM_OPS(fimd_runtime_suspend, fimd_runtime_resume, NULL) @@ -1018,5 +1104,6 @@ struct platform_driver fimd_driver = { .name = "exynos4-fb", .owner = THIS_MODULE, .pm = &fimd_pm_ops, + .of_match_table = of_match_ptr(drm_fimd_dt_match), }, }; diff --git a/include/drm/exynos_drm.h b/include/drm/exynos_drm.h index 6873358..fecaee8 100644 --- a/include/drm/exynos_drm.h +++ b/include/drm/exynos_drm.h @@ -224,6 +224,11 @@ struct exynos_drm_panel_info { u32 height_mm; }; +enum disp_panel_type { + MIPI_LCD, + DP_LCD +}; + /** * Platform Specific Structure for DRM based FIMD. * @@ -237,6 +242,7 @@ struct exynos_drm_fimd_pdata { u32 vidcon1; unsigned int default_win; unsigned int bpp; + enum disp_panel_type panel_type; }; /** -- 1.7.0.4