From patchwork Tue Jul 7 07:51:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 492116 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0687E1402AA for ; Tue, 7 Jul 2015 19:32:18 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id E1A591A1A0C for ; Tue, 7 Jul 2015 19:32:17 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org X-Greylist: delayed 3608 seconds by postgrey-1.35 at bilbo; Tue, 07 Jul 2015 19:31:15 AEST Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0137.outbound.protection.outlook.com [65.55.169.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id B552E1A1071 for ; Tue, 7 Jul 2015 19:31:15 +1000 (AEST) Received: from BY2PR03CA048.namprd03.prod.outlook.com (10.141.249.21) by BL2PR03MB145.namprd03.prod.outlook.com (10.255.230.13) with Microsoft SMTP Server (TLS) id 15.1.207.19; Tue, 7 Jul 2015 07:56:25 +0000 Received: from BL2FFO11FD035.protection.gbl (2a01:111:f400:7c09::128) by BY2PR03CA048.outlook.office365.com (2a01:111:e400:2c5d::21) with Microsoft SMTP Server (TLS) id 15.1.213.14 via Frontend Transport; Tue, 7 Jul 2015 07:56:24 +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 BL2FFO11FD035.mail.protection.outlook.com (10.173.161.131) with Microsoft SMTP Server (TLS) id 15.1.201.10 via Frontend Transport; Tue, 7 Jul 2015 07:56:23 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t677uKV6031873; Tue, 7 Jul 2015 00:56:21 -0700 From: Dongsheng Wang To: Subject: [RESEND] powerpc/diu: adjust DIU initialization entry Date: Tue, 7 Jul 2015 15:51:37 +0800 Message-ID: <1436255497-41207-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; BL2FFO11FD035; 1:XFKb2vwMmOSW062jGT7vl8Pr7BopLXHbJrXZoOLgpVzMr7wjK5+nFsHHyyd3H35Mpek2bAb6VZFff6Mmd8kADCcWHNB3V0KZScPBdAl6GhJCAzPKwHCXjfYNjtUwcrfSNeWHe/aL9eI2eeklXWEFOctU2bRM2LQUCZve3JPhVhFTU+55TXtwKmrQng3zGyFK29FV4GiJqvGXKZ+t/QE8U3KC33hTzhjrSvU0b3iQT2+/MPFjY7bkPLdOGA2eOQSiSNUxCl/NvYWr47ifrBV00JcIdJ/PuDLxEyBJ2qR3mN24Isk5xdGZ4YMdhC970sTwxxcHCfJ/x0j9+Pvb25ckKQ== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(46102003)(110136002)(86362001)(107886002)(5001960100002)(77156002)(450100001)(62966003)(189998001)(92566002)(48376002)(50466002)(50986999)(77096005)(36756003)(106466001)(2371004)(47776003)(105606002)(229853001)(50226001)(19580395003)(87936001)(85426001)(33646002)(6806004)(2351001)(104016003)(5003940100001)(19580405001)(4001450100001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR03MB145; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB145; 2:yq9m7mZ8+NnKdLDmDe375emF3x6Pq32eXAvXsA80GBxzTmv6K/XZso1lcYGDWoyx; 3:KdAiR798VSSmbptMX0s37zGLqpJKWLpAW9jprfYbCrpagpdYHqJEr3qV5FhGawxfe9uE1jm4TeIgH6vSNHhMl7flE3fG+uzy0ZS5Ijxor5UPPhgsYnVtbCCrR5YQNS5FNSpg7edR7In63BDpshZPBPNCsmVtInjYwUzAmcqkOWEiPvKy0gJ7Dy6lEEbQQw9wbn72w4YEiX3yTHB5eIXwJbwPwp9KEcDpH5a99C1XQjw=; 25:oz3MRD7DBzUJBfd+sQEVj5ub9WUQDTWWsqyKkNx0y1skkzqc5fJbQFQx25aXs25EigueTAJPotJc9coAs0OkuKFl5If+gna2TbbD1EUj2sMCoH94omlhyA/Ic8MNONtWKAmr3e+98rizLE0iZ1EidlAfZlEEQ1q7MSakXFSFU4NdE0sIj4ncKEFDnEOuK6FAYeshNRNu2fo7ETKya6wGqUT34SqXX7QafRRwrjaeKP+/Stjej54W53qIXH2wpejHrtAwIQm2liwdJp6aFKgQjETT8F+HhY9mYsSrC6rEYmo=; 20:qdOV4efFbCivnhzRfkd3XweGQNaViQIxMMqT77gBo7jn8f8bzEIn6BMnjGE2IUChPBuSy4xEGVdpuW4UDf4dFSI3Sy7PK2paTxOEnG+WLnpvyxZvIWrUgS4Af8pA08ZrUXgZ/JEAj1eF5I1Q1cU9xyGF+CkbT2+cAh07djBXAgZgXUi9PNnh+xAq54rQA/waprTseVTET7HECn1jDYiOWD3qBSsDyebmdx2qEhqMYX5VxvwqK/2/oq04MFAtSckvImieYkse7VIgIZtNE9gzGmIjFwSUOt6cZvfwQv9Pb1IJKO2GFu69F31mwgxSnUZHupvewd8XjRiqSKYJxgVA4qQQfqcSY05LDw5nlxvTuVE= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB145; 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:BL2PR03MB145; BCL:0; PCL:0; RULEID:; SRVR:BL2PR03MB145; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB145; 4:hZ7r3/3exQ6Xyl1tddPhs4Zo7n1juB+MGLi/ASWb79/RU1D+22ACHwrXdQkjresRQP+WbDwsIgphIIJ4KdSQsuqJDa55P5/cH+tuQ2C6c85dSmr5n7TSRpQ/z8h3YTmY1nYJ0eKGybaYRxYkQ1fxkHl72ozS8bemVze7puLTu3zvp6YuPAqmCzDxWdrC8NDUy5Ciy1qhjhnnXgqwYFb5A5uBD+GlXFcwgazu4VaHG/XnNGUjxwW4iAz7X8kDuh/AEnraGg5UczAspoMxK7DPr+1nMqYi/M1m+ESv6X2X5XE= X-Forefront-PRVS: 0630013541 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB145; 23:gg9UmVZW4HZVeE8ZOXIfbpVK2EmOSVt31DhBeOleOY?= =?us-ascii?Q?VIYYqBmgOxuzEUdls9gfumB7jhcmdPfZqXZeBtGPBrsZPyQzNgnHoQJM51co?= =?us-ascii?Q?/VMh54Fr0mhBSxWrBoyV9YFUqg2op3AzQgTn6dh/yeCQA/AQHw5B0b3XbZde?= =?us-ascii?Q?CLR9MSCX6znWMbUPxdyENEZD9h3a8QR9dY7nqxOkJWKpFz5VtyUDNvMYsWqx?= =?us-ascii?Q?2sIRRcODoqcDzyfupARdtf8YyOdIJhRGcKsHBSIS6goDdQTF018rYWOYzURa?= =?us-ascii?Q?DNW1+I413z4bpwX8/irtkZdS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jf5p7cHUxL1J7ZDQg6gPo+sNthyfB0oKYh6HiLZtGaP/jmrTZcOvoRfZKYcKK3Z2xHZUu4Ne2cvOZ6zFNolb+vvNYE8Nu0kOI=; 20:hLs6Rl84c4iGaYclIIlBBvGW39RuLDms7NWF8MixEVbRae0XuIYCYeFH6nAn8tsaXbDumIgEnN14yv8j0BA3JQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2015 07:56:23.2957 (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: BL2PR03MB145 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, Wang Dongsheng , jason.jin@freescale.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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, and the Patchwork state has been modified for the changes requested, I don't know why. So I resend this patch to upstream. 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);