From patchwork Fri Apr 18 08:49:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 340258 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 41CD71401B2 for ; Fri, 18 Apr 2014 18:52:42 +1000 (EST) Received: from ch1outboundpool.messaging.microsoft.com (ch1ehsobe006.messaging.microsoft.com [216.32.181.186]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8684514008E for ; Fri, 18 Apr 2014 18:52:08 +1000 (EST) Received: from mail105-ch1-R.bigfish.com (10.43.68.230) by CH1EHSOBE021.bigfish.com (10.43.70.78) with Microsoft SMTP Server id 14.1.225.22; Fri, 18 Apr 2014 08:51:17 +0000 Received: from mail105-ch1 (localhost [127.0.0.1]) by mail105-ch1-R.bigfish.com (Postfix) with ESMTP id 684B5220717 for ; Fri, 18 Apr 2014 08:51:17 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zzzz1f42h2148h1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6h208chzz1de098h8275bh1de097hz2dh2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh25cch25f6h2605h268bh26d3h10bek1155h) Received: from mail105-ch1 (localhost.localdomain [127.0.0.1]) by mail105-ch1 (MessageSwitch) id 1397811075149951_20647; Fri, 18 Apr 2014 08:51:15 +0000 (UTC) Received: from CH1EHSMHS016.bigfish.com (snatpool2.int.messaging.microsoft.com [10.43.68.230]) by mail105-ch1.bigfish.com (Postfix) with ESMTP id 1EBAC3C0086; Fri, 18 Apr 2014 08:51:15 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS016.bigfish.com (10.43.70.16) with Microsoft SMTP Server (TLS) id 14.16.227.3; Fri, 18 Apr 2014 08:51:15 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.3.174.2; Fri, 18 Apr 2014 08:52:00 +0000 Received: from titan.ap.freescale.net (udp143770uds.ap.freescale.net [10.192.208.233] (may be forged)) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s3I8pu4H014708; Fri, 18 Apr 2014 01:51:57 -0700 From: Dongsheng Wang To: , Subject: [PATCH] powerpc/diu: adjust DIU initialization entry Date: Fri, 18 Apr 2014 16:49:21 +0800 Message-ID: <1397810961-3831-1-git-send-email-dongsheng.wang@freescale.com> X-Mailer: git-send-email 1.8.5 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-FOPE-CONNECTOR: Id%0$Dn%FREESCALE.MAIL.ONMICROSOFT.COM$RO%1$TLS%0$FQDN%$TlsDn% Cc: linuxppc-dev@lists.ozlabs.org, Wang Dongsheng , jason.jin@freescale.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c index e8758b9..75ab20e 100644 --- a/drivers/video/fsl-diu-fb.c +++ b/drivers/video/fsl-diu-fb.c @@ -1680,6 +1680,99 @@ 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 + 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'\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'\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 ret; +} + static int fsl_diu_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1690,10 +1783,14 @@ static int fsl_diu_probe(struct platform_device *pdev) unsigned int i; int ret; + fsl_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_perpare; + } data->dma_addr = dma_addr; /* @@ -1819,6 +1916,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 +1939,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 { @@ -1892,88 +1972,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);