From patchwork Wed Jul 8 02:33:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 6740181 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E1D309F38C for ; Wed, 8 Jul 2015 02:53:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B02A620657 for ; Wed, 8 Jul 2015 02:53:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1887220644 for ; Wed, 8 Jul 2015 02:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757329AbbGHCxb (ORCPT ); Tue, 7 Jul 2015 22:53:31 -0400 Received: from mail-bn1bon0134.outbound.protection.outlook.com ([157.56.111.134]:26304 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755533AbbGHCxa (ORCPT ); Tue, 7 Jul 2015 22:53:30 -0400 Received: from CH1PR03CA003.namprd03.prod.outlook.com (10.255.156.148) by CY1PR0301MB1292.namprd03.prod.outlook.com (10.161.213.154) with Microsoft SMTP Server (TLS) id 15.1.201.16; Wed, 8 Jul 2015 02:38:19 +0000 Received: from BL2FFO11OLC002.protection.gbl (10.255.156.132) by CH1PR03CA003.outlook.office365.com (10.255.156.148) with Microsoft SMTP Server (TLS) id 15.1.201.16 via Frontend Transport; Wed, 8 Jul 2015 02:38:18 +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; 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 BL2FFO11OLC002.mail.protection.outlook.com (10.173.161.186) with Microsoft SMTP Server (TLS) id 15.1.213.8 via Frontend Transport; Wed, 8 Jul 2015 02:38:18 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t682cEYH006333; Tue, 7 Jul 2015 19:38:15 -0700 From: Dongsheng Wang To: CC: , , , , , Wang Dongsheng Subject: [RESEND] powerpc/diu: adjust DIU initialization entry Date: Wed, 8 Jul 2015 10:33:26 +0800 Message-ID: <1436322806-8537-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; BL2FFO11OLC002; 1:tkrX43AF+RstN2fh1XJI20cfZxGXI29YkqQ7jnDKIFnLa9ZHLsLvKNDoS01PO0UZ85oMMh3HpMl6cdyE5xbmf3zHzIR8gCh5AOC0zbjHexIen//3RRXYO+zrpy8oiDltVmkmIhNv8wVSrePGhKSdmCk6w/NzpkfZXiwO573axO7RZAiYwUC1zCV0O/jct5zMONJAKT7NLZnAGfsoR7NyraqpzCZtIRtoPWIf1wZGQ9XR5V8Q3s1k8Q0KZJ4zJ7zAen84nvDFTI4f5U8Z1MHhbLgCOMyerdKiiE4v4C1ByvLWPSvHlt6+8Uu4M0eQMef3a75Hyct1rgzSpk19a7V3ZzmCsE8pmkBN6Ixa7bF2Ce4PiOZnn5PWoqIRw9KLGLz8quHH6k8KihER66Hsx8gfgRT/XBK2j2Q81NG5pLVSC8k5MMn90uhumbYC54jdSV/I X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(50466002)(47776003)(19580395003)(189998001)(46102003)(85426001)(19580405001)(110136002)(229853001)(6806004)(62966003)(5001960100002)(107886002)(33646002)(106466001)(50226001)(87936001)(92566002)(86362001)(77156002)(2351001)(105606002)(48376002)(50986999)(36756003)(77096005)(104016003)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB1292; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1292; 2:otZNWyEMTw0l4cF5HGgMAjEeT9Gwqxuus3n5Ge9dzukc/E2p1nfqjx1khExXW7Sr; 3:2ceU4llwItKPaBQCnJ/s6VDMq4DDNb3xWMf4ZUbU9iXCFS6P9WgN3GfEGwR9WEdinS3jWIurgqT2QVwsEmEhA/8nXHKzqVoEpML2Xigi20eJn3zNdLXd8Rx7ArunRD8ndoB0+KBdP7hmZcr9CgvT8ai9w3qp2D4GiRgPQiWsPY0G0YVGBK2O7ThG9lYSN7McH7GoDDEqqc3XMpYw/2wTfXvJQyxFQx8hD/QdYfHuvY4=; 25:hNKbaazvS/ckYRWARsfok6+dFOAjE9IzPF/tKr2M7BgTeX3CE+wnQs3IDyu22iEz130WxIAbmkohV4QJHIo+FVQD+r+mMHe1gLU8Qds4zyFtMKnWdQl8Fl/wQEhn7Mgu47iqfvpbyyeUl/COdweeO5BWJgDSPJyQyFIIAEmni13Wk0hblUsgPcEHA31jZv/mljapVV33EPEaWWOZ1t9DuhcLuc3LE50DYV07v/65VSADpMaAStZztlLdT2x3IgbNHnGFaZHVX5+fvSAYkpPcew==; 20:Q/EhA4nzRhmiwuXYvbiGtQQ7hk3d4SAjLlF+0NY1XA484EkAbaTN+PN5Qkvo928QbdbG1qEERlTWsDlqBqO4NZoN2LXAuCi9zuFxo1K2sCONehx/9qIbZ5ozG5fjbcneo8C9lZerz+MlipMSauZSotmiIYIYdutwuhDmB/F/xHJxqApxt3SNWyJdQT+CQLq9LuCNjXdHYiiI3pkrlk46+bxx0PLOS12PdyZLe+aVKsGkqFbgojzEK2vWb850acFroeOVSILA//fjIqwpBs3+9NFla2vloNE2+1UtBL1IzDOHXUF3jTe8YpR6gmG/EnzpddiIbURlQSEyEOvPYrizhih/p QHx6IPfOLnFrukA7fg= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1292; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:CY1PR0301MB1292; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1292; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1292; 4:awpIOC1fxNHgEeW8qQOrpeH/De/THUJdg8PW+WlfhDmJpJL5jjf6leulLCMgfCwU1a8DrwjCeX+OK3rFxn1+ksi1sRHG227otjyotZHsGkgoHmqhWPa4iI3gsnLuEbYOWNO3jM2OMOoP229FYwQaxMwOVut39KVzSV8myJXIpyA7KlUJwEoOo5BAIJ0mkBXEHf+lD44CO2BbBEhvJifvOMDy0rDMzj0RJhEVyZL+OX3tYeGUo35Me3hr6YTlGR62tgZ7VDNLDQGCEWoxID0UHvNPqIFUdXXpMJEvpNCZiUQ= X-Forefront-PRVS: 0631F0BC3D X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1292; 23:eUef4IPMA0AY1xor+APotxp5Xb88mAvhKTZ6mDyrkrPfS5yYvq/04y/QphxOSDduc7L3GgBzPoBny/H8WfO+Czes7E/7kRD3RCUAud3qp5BRZax2ZOsLal7OBDYc+pxqlkaH+FwZrLrDEXU+5mR8LvwgfmH4m/D67TUFBQz+x+FC6DhK4SoQxBzt8Yuflp96h4Zkw3k0Ch4Grx6P22EwLiQM7Dqj+2dy7OoZpnSDak1zOU9lRWNCdV3ONA9EWlty6cf49aTNHQ+PUVKt2/6QOdotf53X1ape2qSbrV+GsgLbkdnRYC84C9av2LtLc/ybUE7Wi9gFw5RlkjJMHGtUpsyblrP7oMNm/7TBYWqycEgzYhNgWIcSvKhNoGXVU3pcNRE1nbg0f+/1sOIuPxLatf3A7OMko/f1WgxP6UAmPsOhW/Iz1w3oIGe2RmSIAEummnVc3diPazpPZADOyEEK6SqmyvQd/poSFLQXSe9lz29ceD9oUpZPOuOewos+B1rjs42obc/l9xtdm6iuFjB/QTsErF1alX1obyQIzFHWjL0gm/Pmj/p9a1BwaVsm00/7Pa9DalrNFogAsezfaBHwQzvXiwqgjRboT6qFbQCAffSsQiKXv2Vgdta9ZgxxLfE+rxaJL6IMGw44ORFeGTUXMf8wVV6OkidBLKh49Mxi5L/BzU/Z5HUH0ZScklivzSuOu6lTvRrMRN4SQLoiEq/VxkZ14Wi5hJLYdKjFWCw+RigOl44aPgTSEv0bxyI+bc8cKu5Q33SX7OGPMg4pjzoZlOwk1QuPr7ICW1+TRB5i2r8lnsPu56pxNeS1ky/0MO++7TPw+5GWz0PozKdxYYD6Z7tUr3FKfPtAnSOAfN4KmyZ5MomTcKhjJS27zN9k/6Sf X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1292; 5:AKRkRUhUZXUQtWFy9m9zTjed9pO7yO30CCy+65HJushfvJP7whMxFYcYyqg7u0Gq88w8VyLB1Kqe9SHxFbKNW3Laq0pmtlOBeMMBl76pmSbl8YvyPUEKPFsb5FYRsPFfeGRSykEn05WhsuW+6kDoIQ==; 24:Aix08Tc18v7BRD2T1xvzH/CFsBXXxw8dRJJ9gQsEShSsKTY4P8TUkhryyXMW0/hMI8UzBus2WdsUTzy7mnJsaFdVuhtbIphgTC9xIwZwHI0=; 20:v4fgnJxo7iMZAF5MzWm8GTykpDnRHwJTpK628yHdbtQPXT1013Oe7U2vumhEDPUypKVZHxXkRumb5ws2quCFpg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2015 02:38:18.5345 (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: CY1PR0301MB1292 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Move fsl_diu_init into diu probe function, because it should be initialized when system get diu device tree node, not always do initialization. Signed-off-by: Wang Dongsheng --- Changes: Rebase original patch for upstream because fsl-diu-fb.c has moved to fbdev dir. This patch is a long time ago, there is no feedback in powerpc maillist, and the Patchwork state has been modified for the changes requested, I don't know why. So I resend this patch to linux-fbdev@vger.kernel.org. diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c index 7fa2e6f..164e22e 100644 --- a/drivers/video/fbdev/fsl-diu-fb.c +++ b/drivers/video/fbdev/fsl-diu-fb.c @@ -1680,6 +1680,105 @@ 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; + + /* + * 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"); + + if (!diu_ops.set_pixel_clock) { + pr_info("%s: Board not support DIU. Can't dispaly video.\n", + __func__); + return -ENODEV; + } + +#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; @@ -1690,10 +1789,16 @@ static int fsl_diu_probe(struct platform_device *pdev) unsigned int i; int ret; + ret = fsl_diu_perpare(); + if (ret) + goto out_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_perpare; + } data->dma_addr = dma_addr; /* @@ -1819,6 +1924,11 @@ error: iounmap(data->diu_reg); +out_perpare: +#if defined(CONFIG_NOT_COHERENT_CACHE) + if (coherence_data) + vfree(coherence_data); +#endif return ret; } @@ -1837,34 +1947,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 { @@ -1891,88 +1979,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);