From patchwork Wed Jul 11 08:44:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leela Krishna Amudala X-Patchwork-Id: 1181261 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 93C81DF25A for ; Wed, 11 Jul 2012 10:28:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7CA139E848 for ; Wed, 11 Jul 2012 03:28:52 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id 70791A0DA7 for ; Wed, 11 Jul 2012 01:30:54 -0700 (PDT) Received: from epcpsbgm1.samsung.com (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M6Z00GOJMB718A0@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 11 Jul 2012 17:30:53 +0900 (KST) X-AuditID: cbfee61a-b7f616d000004b7e-ed-4ffd39bdef72 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id C0.43.19326.DB93DFF4; Wed, 11 Jul 2012 17:30:53 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M6Z004UMMB2HL60@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 11 Jul 2012 17:30:53 +0900 (KST) From: Leela Krishna Amudala To: dri-devel@lists.freedesktop.org, devicetree-discuss@lists.ozlabs.org Subject: [PATCH V2 1/2] video: drm: exynos: Add device tree support Date: Wed, 11 Jul 2012 14:14:46 +0530 Message-id: <1341996287-14666-2-git-send-email-l.krishna@samsung.com> X-Mailer: git-send-email 1.7.0.4 In-reply-to: <1341996287-14666-1-git-send-email-l.krishna@samsung.com> References: <1341996287-14666-1-git-send-email-l.krishna@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jAd29ln/9DVq2SFtc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujNOHXrIWHLKq+N10i7mBcZ1BFyMnh4SAicTjpf9ZIGwxiQv3 1rN1MXJxCAksYpS4vrSdCcJZzSSxY8NLJpAqNgFjiftzN4PZIgIeEqtnL2UGsZkFyiQW7XzI CGILCzhLvPzVyApiswioSvR0zgCKc3DwCrhKPH7BCLFMQaJ12SF2EJtTwE3i/eoJYHEhoJLJ u7axTWDkXcDIsIpRNLUguaA4KT3XUK84Mbe4NC9dLzk/dxMj2OfPpHYwrmywOMQowMGoxMN7 w+SvvxBrYllxZe4hRgkOZiURXs45f/yFeFMSK6tSi/Lji0pzUosPMUpzsCiJ8xp7f/UXEkhP LEnNTk0tSC2CyTJxcEo1MArU2vFLHQ7bccS8Ps5QTTj30v1Db49GrrU/oGKdt73qu9Cq5S8m ZJ6rltVkPeV6VfLdXJUtKS4nXZOzf8fvcLzptb/omsaGs/dLZERbXUImzn9n4c/hZvfsq4bI jSz+qX5fX1+Nz+Nu1w45/1Hwm/y7L9MqgpcpSfe9VhVRart/n/XK89WLUpVYijMSDbWYi4oT AcZ9yXn1AQAA X-TM-AS-MML: No X-Mailman-Approved-At: Wed, 11 Jul 2012 03:27:41 -0700 Cc: inki.dae@samsung.com, olofj@google.com, laurent.pinchart@ideasonboard.com, joshi@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Add device tree based discovery support for DRM-FIMD driver. Signed-off-by: Leela Krishna Amudala --- Documentation/devicetree/bindings/fb/drm-fimd.txt | 73 +++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_fimd.c | 88 ++++++++++++++++++++- 2 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/fb/drm-fimd.txt diff --git a/Documentation/devicetree/bindings/fb/drm-fimd.txt b/Documentation/devicetree/bindings/fb/drm-fimd.txt new file mode 100644 index 0000000..9a52ddb --- /dev/null +++ b/Documentation/devicetree/bindings/fb/drm-fimd.txt @@ -0,0 +1,73 @@ +* Samsung Display Controller using DRM frame work + +The display controller is used to transfer image data from memory to an +external LCD driver interface. It supports various color formats such as +rgb and yuv. + +Required properties: + - compatible: Should be "samsung,exynos5-drm" for fimd using DRM frame work. + - reg: physical base address of the controller and length of memory + mapped region. + - interrupts: Three interrupts should be specified. The interrupts should be + specified in the following order. + - VSYNC interrupt + - FIFO level interrupt + - FIMD System Interrupt + + - samsung,fimd-display: This property should specify the phandle of the + display device node which holds the video interface timing with the + below mentioned properties. + + - lcd-htiming: Specifies the horizontal timing for the overlay. The + horizontal timing includes four parameters in the following order. + + - horizontal back porch (in number of lcd clocks) + - horizontal front porch (in number of lcd clocks) + - hsync pulse width (in number of lcd clocks) + - Display panels X resolution. + + - lcd-vtiming: Specifies the vertical timing for the overlay. The + vertical timing includes four parameters in the following order. + + - vertical back porch (in number of lcd lines) + - vertical front porch (in number of lcd lines) + - vsync pulse width (in number of lcd clocks) + - Display panels Y resolution. + + + - samsung,default-window: Specifies the default window number of the fimd controller. + + - samsung,fimd-win-bpp: Specifies the bits per pixel. + +Optional properties: + - supports-mipi-panel: Specifies the lcd is mipi panel type + - samsung,fimd-vidout-rgb: Video output format is RGB. + - samsung,fimd-inv-vclk: invert video clock polarity. + - samsung,fimd-frame-rate: Number of video frames per second. + +Example: + + The following is an example for the fimd controller is split into + two portions. The SoC specific portion can be specified in the SoC + specific dts file. The board specific portion can be specified in the + board specific dts file. + + - SoC Specific portion + + lcd_fimd0: lcd_panel0 { + lcd-htiming = <4 4 4 480>; + lcd-vtiming = <4 4 4 320>; + supports-mipi-panel; + }; + + - Board Specific portion + + fimd { + samsung,fimd-display = <&lcd_fimd0>; + samsung,fimd-vidout-rgb; + samsung,fimd-inv-vclk; + samsung,fimd-frame-rate = <60>; + samsung,default-window = <0>; + samsung,fimd-win-bpp = <32>; + }; + diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 29fdbfe..6f06260 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,82 @@ 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(np, "samsung,fimd-frame-rate", + &pd->panel.timing.refresh); + + of_property_read_u32(np, "samsung,default-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 +872,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 +1081,14 @@ 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-drm" }, + {}, +}; +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 +1101,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), }, };