From patchwork Tue Oct 13 04:09:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 7381351 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3B187BEEA4 for ; Tue, 13 Oct 2015 04:15:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DEDD2051A for ; Tue, 13 Oct 2015 04:15:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F6FE2050B for ; Tue, 13 Oct 2015 04:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750852AbbJMEPw (ORCPT ); Tue, 13 Oct 2015 00:15:52 -0400 Received: from mail-by2on0120.outbound.protection.outlook.com ([207.46.100.120]:34279 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750856AbbJMEPv (ORCPT ); Tue, 13 Oct 2015 00:15:51 -0400 Received: from BN3PR0301CA0068.namprd03.prod.outlook.com (10.160.152.164) by BN3PR03MB1479.namprd03.prod.outlook.com (10.163.35.142) with Microsoft SMTP Server (TLS) id 15.1.293.16; Tue, 13 Oct 2015 04:15:47 +0000 Received: from BY2FFO11FD047.protection.gbl (2a01:111:f400:7c0c::142) by BN3PR0301CA0068.outlook.office365.com (2a01:111:e400:401e::36) with Microsoft SMTP Server (TLS) id 15.1.293.16 via Frontend Transport; Tue, 13 Oct 2015 04:15:48 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD047.mail.protection.outlook.com (10.1.15.175) with Microsoft SMTP Server (TLS) id 15.1.293.9 via Frontend Transport; Tue, 13 Oct 2015 04:15:47 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t9D4FiSe011840; Mon, 12 Oct 2015 21:15:45 -0700 From: Dongsheng Wang To: CC: , , , Wang Dongsheng Subject: [PATCH] video: fbdev: fsl: Split DIU initialization entry Date: Tue, 13 Oct 2015 12:09:15 +0800 Message-ID: <1444709355-8905-1-git-send-email-dongsheng.wang@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD047; 1:0yNxGCP3z8VvQeiNl+2cSsuOvXFSUHKxWnFp7Vi9DFZOxTKaZ7Igcr5J2R0qxY78NYwAfoyiXNRqUu7c7nFfeWP3ibhObofdWGAN40+Swz2S92vGFXgroJMz/fg+nZci1zVJYFZu+vqARuoKJ0hWAZkICt1UwWYMV2FDxBUC9MKfHSyvKSwgr06QH93LooymeJzqm0KqgczG0QGuschIMZasu5knOmiwxM/TZGteapvoSEF34gHCpdyUwi/+bDe/AEdPoz2KupJjySP3pA0zl7NZfC0KhAv4uqBEVR6nR9ZntUiRdjxmXqW+poakZsY1UoBr3AKUiX7kIbUSRrvvtNAjnLtvwWMmlCjGBGXiTRMbHOfIjMF2WWLr2s17CqGHptbqWkXQDr2A3eTY2nF+8A== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(5008740100001)(33646002)(50986999)(36756003)(106466001)(6806005)(19580405001)(77096005)(2351001)(50226001)(5007970100001)(92566002)(69596002)(107886002)(48376002)(97736004)(110136002)(189998001)(47776003)(5001960100002)(81156007)(19580395003)(64706001)(5003940100001)(46102003)(85426001)(50466002)(86362001)(229853001)(105606002)(104016004)(87936001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR03MB1479; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1479; 2:iILZCehTv7n9ITRnFvfF7ugq8eEu4laFXJNVlxMoR8EWB3DWCLD0YXpRM6t3prOqDYyzeuUMI6amUlQdUwR04z5+gyfeSFyVP72xPKtfAD5DmFHIopZWsxIHaN6eg/HmHHALtGBj5AJO/1sjoMDsL/gjHHuxKYcfgW6CJdCBzq8=; 3:Kt9yCWjipa8NVMJoFIjH180WhAkNVRojLAhbgC9oIDA5WrBJo39zAwGtsFmDYIgMdO2r8lFImEP4ihrOdbFB9cQh9xWW9trEMdewI8YTYKZ17pdRp8VYmPu0ZVIGzxgh8jaL8P6pn1i+cSzD4LdHyZNFqtTxFf5/EpD9Glh7/QQaPORa6ulSvF+k6iv8C1tqD3VK7Nq8HBAgcvdVmgWuPckVgr6OxQzEvOqfE8lEziI=; 25:SYiIeW2FK/BcICN1ASrhjVoMhI+IO9BbbdgfJtQWRWK4x20ZVNLfqz+BjVFIrJb27r2hk8REtXh2cTN4+/0Eal84Owhwf8EbUSgXbz/lHZ73yT//TNktb2b5TqsJ1vMnzGus2SyIhdlb8kKx/dwQenFTDDtx/ii5q459Lg+qJR7Yx3KbKkKo00ri5dacVTeXo4oP8v9V5UCK1Qpu/HnhwyTz9jIxC0NLnJDOJXsjSjCyVgl/AtSKfw44ohAQVMG79t4UnJoRjEAb3xOs4T21tA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1479; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1479; 20:fJzCQWZGgU3K/l1D+ZPwkbuPTXBs1wpp/77DGEAE/FLPsv9PlvfVsMWnT85EHLADU3pxHeTyAHvBI9vAlNuHS+ncNh2hCaC22IVN7Nre4m859GEe+Ff63YeR3BcDA/Gp4iTzyPQ5imPvtxZL7ZykR5QimNYrgah1V0qTcaeg5Y9dmeDcQmZaP51wbV4BaXeEYdq/jYvzWjxMstegtklUDIPy6aILPX/VN07tYaVKHF5iibh5SGXMWJrNjxcZR61U6iYBqeIylbeBHjtTwtOfekbQMhTVZ7yvsGPNEA0+okIWGOkWfaSjpzt35dsmblxsVED/xVD4n49clZvDl4YCFE2G+bIBXoAAgKo2bNtJhbo=; 4:eZvTGHgZq05jgtST91xRLw/RpgD0zzZ3ab1n/7j/vExXzqNsxCGXOUlybH6HRMQVbuexTMwgWsq+jqbHZKHo0LapF47t+V9haiKUC/DFRcN32iyz81AYpgmQdJuFqIwcQZdjn1kvwiyfev3YRiS2BxBxzMp68QoDs0XHCuIHklZ0BLiNMg8bmCnw9eB3PUeGX7afYgO4E0TtPlKGgzbpGX/ISt+mcy8G9lJV3Pu2qefbmmKdXQUrK8/UGwq9vt+xKMveMfsZS5VAyk4sDb3rKiZ++xft9jSmXODHfQnmOEhCAVx/LdkoNxOMgswQRm/xJAjAULejVWv9xvbQMfEVnWvSMSgYqGUqG6yhsgNbxu8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001); SRVR:BN3PR03MB1479; BCL:0; PCL:0; RULEID:; SRVR:BN3PR03MB1479; X-Forefront-PRVS: 07283408BE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB1479; 23:OeDcpmE57RwrbL4XJcPBz1OHhrQONfu56WrgqKSf/?= =?us-ascii?Q?zdmM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ag0J?= =?us-ascii?Q?OnnP+wxrlQhZO6dTX/v3xbTpODJvo711JGq7ns71iDfUW5317N3UHStKCgVd?= =?us-ascii?Q?6WC4aVA+ExH1lPwbrGxPjEA+Xspz16d0+VXAmJuzECA9P8+cDfaASAdCO35I?= =?us-ascii?Q?dmCG8q1AlSQBnkol9kcKSjEiFA2?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1479; 5:1RRfr1sgEe+jiO/0vhb/rKVBVIs6CU6Bvh/UgnK+yejpMHS7S9aHuXkIQbOROxmpjSnO/PPrE7qBCzaKKiEi/G6uGNKFH2YbWJhkecfRh4bnK6BKAZZVKqwIDGi9vSfANU7HUCqTzbiH/kV0QyMvMA==; 24:nTIolb+HkmxBwCl0Ce87A8YtVk6iGRfEebFobTDc40+TJouBG1ZTLqXEdVm0yogZeJXd5YyoBqXJO3/WaR9DibPiPp/aVrbNm1OzTv0fq6M=; 20:vIoJuQeRy8Dcq1Xyy0vJOKtEdmmVGbBSGa5xDty4fqfz1RgXmpS+6kzLI/nhA+O0n8pzY4yA/2ZFbRmnWk+F3w== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2015 04:15:47.5650 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1479 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Dongsheng Split diu initialize from fsl_diu_init into diu probe function, because it should be initialized when get the diu device tree node, not always do initialization. Signed-off-by: Wang Dongsheng diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c index b335c1a..1969863 100644 --- a/drivers/video/fbdev/fsl-diu-fb.c +++ b/drivers/video/fbdev/fsl-diu-fb.c @@ -1687,6 +1687,104 @@ static ssize_t show_monitor(struct device *device, return 0; } +#ifndef MODULE +static int __init fsl_diu_setup(char *options) +{ + char *opt; + unsigned long val; + + if (!options || !*options) + return 0; + + while ((opt = strsep(&options, ",")) != NULL) { + if (!*opt) + continue; + if (!strncmp(opt, "monitor=", 8)) { + monitor_port = fsl_diu_name_to_port(opt + 8); + } else if (!strncmp(opt, "bpp=", 4)) { + if (!kstrtoul(opt + 4, 10, &val)) + default_bpp = val; + } else { + fb_mode = opt; + } + } + + return 0; +} +#endif + +static int fsl_diu_perpare(void) +{ +#ifdef CONFIG_NOT_COHERENT_CACHE + struct device_node *np; + const u32 *prop; +#endif +#ifndef MODULE + char *option; +#endif + + if (!diu_ops.set_pixel_clock) + return -ENODEV; + +#ifndef MODULE + /* + * For kernel boot options (in 'video=xxxfb:' format) + */ + if (fb_get_options("fslfb", &option)) + return -ENODEV; + fsl_diu_setup(option); +#else + monitor_port = fsl_diu_name_to_port(monitor_string); +#endif + pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n"); + +#ifdef CONFIG_NOT_COHERENT_CACHE + np = of_find_node_by_type(NULL, "cpu"); + if (!np) { + pr_err("fsl-diu-fb: can't find 'cpu' device node\n"); + return -ENODEV; + } + + prop = of_get_property(np, "d-cache-size", NULL); + if (!prop) { + pr_err("fsl-diu-fb: missing 'd-cache-size'\n"); + of_node_put(np); + return -ENODEV; + } + + /* + * Freescale PLRU requires 13/8 times the cache size to do a proper + * displacement flush + */ + coherence_data_size = be32_to_cpup(prop) * 13; + coherence_data_size /= 8; + + pr_debug("fsl-diu-fb: coherence data size is %zu bytes\n", + coherence_data_size); + + prop = of_get_property(np, "d-cache-line-size", NULL); + if (!prop) { + pr_err("fsl-diu-fb: missing 'd-cache-line-size'\n"); + of_node_put(np); + return -ENODEV; + } + d_cache_line_size = be32_to_cpup(prop); + + pr_debug("fsl-diu-fb: cache lines size is %u bytes\n", + d_cache_line_size); + + of_node_put(np); + coherence_data = vmalloc(coherence_data_size); + if (!coherence_data) { + pr_err("fsl-diu-fb: could not allocate coherence data\n"); + pr_err("coherence_data_size=%zu)\n", coherence_data_size); + return -ENOMEM; + } + +#endif + return 0; +} + static int fsl_diu_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1697,10 +1795,16 @@ static int fsl_diu_probe(struct platform_device *pdev) unsigned int i; int ret; + ret = fsl_diu_perpare(); + if (ret) + goto out_diu_perpare; + data = dmam_alloc_coherent(&pdev->dev, sizeof(struct fsl_diu_data), &dma_addr, GFP_DMA | __GFP_ZERO); - if (!data) - return -ENOMEM; + if (!data) { + ret = -ENOMEM; + goto out_diu_perpare; + } data->dma_addr = dma_addr; /* @@ -1826,6 +1930,11 @@ error: iounmap(data->diu_reg); +out_diu_perpare: +#if defined(CONFIG_NOT_COHERENT_CACHE) + if (coherence_data) + vfree(coherence_data); +#endif return ret; } @@ -1844,34 +1953,12 @@ static int fsl_diu_remove(struct platform_device *pdev) iounmap(data->diu_reg); +#if defined(CONFIG_NOT_COHERENT_CACHE) + vfree(coherence_data); +#endif return 0; } -#ifndef MODULE -static int __init fsl_diu_setup(char *options) -{ - char *opt; - unsigned long val; - - if (!options || !*options) - return 0; - - while ((opt = strsep(&options, ",")) != NULL) { - if (!*opt) - continue; - if (!strncmp(opt, "monitor=", 8)) { - monitor_port = fsl_diu_name_to_port(opt + 8); - } else if (!strncmp(opt, "bpp=", 4)) { - if (!kstrtoul(opt + 4, 10, &val)) - default_bpp = val; - } else - fb_mode = opt; - } - - return 0; -} -#endif - static struct of_device_id fsl_diu_match[] = { #ifdef CONFIG_PPC_MPC512x { @@ -1898,88 +1985,12 @@ static struct platform_driver fsl_diu_driver = { static int __init fsl_diu_init(void) { -#ifdef CONFIG_NOT_COHERENT_CACHE - struct device_node *np; - const u32 *prop; -#endif - int ret; -#ifndef MODULE - char *option; - - /* - * For kernel boot options (in 'video=xxxfb:' format) - */ - if (fb_get_options("fslfb", &option)) - return -ENODEV; - fsl_diu_setup(option); -#else - monitor_port = fsl_diu_name_to_port(monitor_string); -#endif - pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n"); - -#ifdef CONFIG_NOT_COHERENT_CACHE - np = of_find_node_by_type(NULL, "cpu"); - if (!np) { - pr_err("fsl-diu-fb: can't find 'cpu' device node\n"); - return -ENODEV; - } - - prop = of_get_property(np, "d-cache-size", NULL); - if (prop == NULL) { - pr_err("fsl-diu-fb: missing 'd-cache-size' property' " - "in 'cpu' node\n"); - of_node_put(np); - return -ENODEV; - } - - /* - * Freescale PLRU requires 13/8 times the cache size to do a proper - * displacement flush - */ - coherence_data_size = be32_to_cpup(prop) * 13; - coherence_data_size /= 8; - - pr_debug("fsl-diu-fb: coherence data size is %zu bytes\n", - coherence_data_size); - - prop = of_get_property(np, "d-cache-line-size", NULL); - if (prop == NULL) { - pr_err("fsl-diu-fb: missing 'd-cache-line-size' property' " - "in 'cpu' node\n"); - of_node_put(np); - return -ENODEV; - } - d_cache_line_size = be32_to_cpup(prop); - - pr_debug("fsl-diu-fb: cache lines size is %u bytes\n", - d_cache_line_size); - - of_node_put(np); - coherence_data = vmalloc(coherence_data_size); - if (!coherence_data) { - pr_err("fsl-diu-fb: could not allocate coherence data " - "(size=%zu)\n", coherence_data_size); - return -ENOMEM; - } - -#endif - - ret = platform_driver_register(&fsl_diu_driver); - if (ret) { - pr_err("fsl-diu-fb: failed to register platform driver\n"); -#if defined(CONFIG_NOT_COHERENT_CACHE) - vfree(coherence_data); -#endif - } - return ret; + return platform_driver_register(&fsl_diu_driver); } static void __exit fsl_diu_exit(void) { platform_driver_unregister(&fsl_diu_driver); -#if defined(CONFIG_NOT_COHERENT_CACHE) - vfree(coherence_data); -#endif } module_init(fsl_diu_init);