From patchwork Wed Jun 11 08:56:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 31745 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DE14D203C2 for ; Wed, 11 Jun 2014 09:02:26 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id n16sf13625290oag.2 for ; Wed, 11 Jun 2014 02:02:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=IWGRQP0DdvCPdIFIXk+XzCqO6vuKjQM/AYcTvAJX9Yw=; b=Of4Ugo2V9Cg2oR8SDIMBpTgd+kfuU3aR5WLJv0As9EVHiltcN8TrxIfZ4NxctXgB1R IBOb+3Zw5o6xhPF91vEBhJCsQvDvnO3/csfLRTRb7n/0tJ8oK3CIks6G0zbvS4gH5Lyo YBvJcfvhnE8HR6AL4Z8AaENedgslJc9B/vXBlv+KTGbGCOWO6eNCg3YdrtGBiQYw95eu LL2YxxP2p6JDcwZmclpOfw0XD5UvMpt53S0iyrNPGdEXmBb9csYznXi2gpwXqux+sRwm CF8XvEEsQ75pfGLBILbvCyor7kA6atH3JTju7LIH42WQtnXv2lHxxXtKvTbnYCkTIX7i CeQg== X-Gm-Message-State: ALoCoQnDBYqnhxMKeKNidggLoGNii3U0NuxOf4/tHgZBp7rOOVMZOyg++HBqU8S37HvTf/sr96RV X-Received: by 10.42.203.138 with SMTP id fi10mr884490icb.6.1402477346406; Wed, 11 Jun 2014 02:02:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.100.179 with SMTP id s48ls2324797qge.17.gmail; Wed, 11 Jun 2014 02:02:26 -0700 (PDT) X-Received: by 10.58.188.37 with SMTP id fx5mr38805185vec.17.1402477346277; Wed, 11 Jun 2014 02:02:26 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id xn7si12749874vcb.105.2014.06.11.02.02.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Jun 2014 02:02:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id db11so4849949veb.4 for ; Wed, 11 Jun 2014 02:02:26 -0700 (PDT) X-Received: by 10.52.232.133 with SMTP id to5mr1989931vdc.16.1402477346180; Wed, 11 Jun 2014 02:02:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp286729vcb; Wed, 11 Jun 2014 02:02:25 -0700 (PDT) X-Received: by 10.224.98.197 with SMTP id r5mr50361537qan.57.1402477345669; Wed, 11 Jun 2014 02:02:25 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id t5si29804694qgd.30.2014.06.11.02.02.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jun 2014 02:02:25 -0700 (PDT) Received-SPF: none (google.com: linux-mtd-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueOU-0005eC-Bm; Wed, 11 Jun 2014 09:00:30 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueMq-0002cN-BW; Wed, 11 Jun 2014 08:58:49 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5B8wSBN004964; Wed, 11 Jun 2014 03:58:28 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5B8wSXx009804; Wed, 11 Jun 2014 03:58:28 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Wed, 11 Jun 2014 03:58:28 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5B8uiT2020510; Wed, 11 Jun 2014 03:58:25 -0500 From: Roger Quadros To: , , Subject: [PATCH 28/36] ARM: OMAP2+: nand: Update gpmc_nand_init() to use generic_gpmc_init() Date: Wed, 11 Jun 2014 11:56:33 +0300 Message-ID: <1402477001-31132-29-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1402477001-31132-1-git-send-email-rogerq@ti.com> References: <1402477001-31132-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140611_015848_529225_8237C4DA X-CRM114-Status: GOOD ( 16.29 ) X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.94.94.40 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [192.94.94.40 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: devicetree@vger.kernel.org, nsekhar@ti.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, linux-mtd@lists.infradead.org, pekon@ti.com, ezequiel.garcia@free-electrons.com, javier@dowhile0.org, linux-omap@vger.kernel.org, Roger Quadros X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rogerq@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This function should only be called by board init code for legacy boot. Re-arrange init order so that gpmc device is created after the gpmc platform data is initialized by board files. i.e. move omap_gpmc_init() to subsys_initcall. Load gpmc platform driver later in the boot process. i.e. move gpmc_init() to module_initcall. NOTE: this will break legacy boot since they call gpmc_cs_*() functions before gpmc_mem_init() is called. They will eventually be fixed. Signed-off-by: Roger Quadros --- arch/arm/mach-omap2/gpmc-nand.c | 51 ++++++++--------------------------------- arch/arm/mach-omap2/gpmc.c | 17 +++++++++----- 2 files changed, 21 insertions(+), 47 deletions(-) diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c index f7491d0..42371e3 100644 --- a/arch/arm/mach-omap2/gpmc-nand.c +++ b/arch/arm/mach-omap2/gpmc-nand.c @@ -25,9 +25,12 @@ #define NAND_IO_SIZE 4 static struct resource gpmc_nand_resource[] = { +/* GPMC driver will fixup all the resources, see gpmc_probe_legacy () */ { /* GPMC I/O space */ .flags = IORESOURCE_MEM, + .start = 0, + .end = NAND_IO_SIZE - 1, }, { /* GPMC register space */ @@ -95,61 +98,27 @@ int gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data, { int err = 0; struct gpmc_settings s; - struct device *dev = &gpmc_nand_device.dev; - struct resource res; memset(&s, 0, sizeof(struct gpmc_settings)); gpmc_nand_device.dev.platform_data = gpmc_nand_data; - err = gpmc_cs_request(gpmc_nand_data->cs, NAND_IO_SIZE, - (unsigned long *)&gpmc_nand_resource[0].start); - if (err < 0) { - dev_err(dev, "Cannot request GPMC CS %d, error %d\n", - gpmc_nand_data->cs, err); - return err; - } - - gpmc_nand_resource[0].end = gpmc_nand_resource[0].start + - NAND_IO_SIZE - 1; - - gpmc_get_mem_resource(&res); - gpmc_nand_resource[1].start = res.start; - gpmc_nand_resource[1].end = res.end; - - gpmc_nand_resource[2].start = gpmc_get_irq(); - - if (gpmc_t) { - err = gpmc_cs_set_timings(gpmc_nand_data->cs, gpmc_t); - if (err < 0) { - dev_err(dev, "Unable to set gpmc timings: %d\n", err); - return err; - } - } - gpmc_set_legacy(gpmc_nand_data, &s); s.device_nand = true; - err = gpmc_cs_program_settings(gpmc_nand_data->cs, &s); - if (err < 0) - goto out_free_cs; - if (!gpmc_hwecc_bch_capable(gpmc_nand_data->ecc_opt)) { - dev_err(dev, "Unsupported NAND ECC scheme selected\n"); + pr_err("%s: Unsupported NAND ECC scheme selected\n", __func__); return -EINVAL; } - err = platform_device_register(&gpmc_nand_device); - if (err < 0) { - dev_err(dev, "Unable to register NAND device\n"); - goto out_free_cs; + err = gpmc_generic_init(gpmc_nand_data->cs, true, + &s, NULL, gpmc_t, + &gpmc_nand_device, sizeof(*gpmc_nand_data)); + if (err) { + pr_err("%s: gpmc_generic_init() failed %d\n", __func__, err); + return err; } return 0; - -out_free_cs: - gpmc_cs_free(gpmc_nand_data->cs); - - return err; } diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 34545ca..7a667ca 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -1401,9 +1401,6 @@ static void gpmc_probe_legacy(struct platform_device *pdev) gpmc_cs_num = GPMC_CS_NUM; gpmc_nr_waitpins = GPMC_NR_WAITPINS; - if (!gpmc_pdata) - return; - for (i = 0; i < GPMC_CS_NUM; i++) { cs = &gpmc_pdata->cs[i]; if (!cs->valid) @@ -1609,6 +1606,12 @@ static int gpmc_probe(struct platform_device *pdev) } } else { /* Legacy probing based on platform data */ + if (!dev->platform_data) { + dev_err(dev, "No platform data\n"); + rc = -EINVAL; + goto error; + } + gpmc_probe_legacy(pdev); } @@ -1669,7 +1672,7 @@ static __exit void gpmc_exit(void) } -omap_postcore_initcall(gpmc_init); +module_init(gpmc_init); module_exit(gpmc_exit); static int __init omap_gpmc_init(void) @@ -1691,12 +1694,14 @@ static int __init omap_gpmc_init(void) return -ENODEV; } - pdev = omap_device_build(DEVICE_NAME, -1, oh, NULL, 0); + pdev = omap_device_build(DEVICE_NAME, -1, oh, (void *)&gpmc_pdata, + sizeof(gpmc_pdata)); WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name); return PTR_RET(pdev); } -omap_postcore_initcall(omap_gpmc_init); +/* must run after machine_init code. i.e. arch_init */ +omap_subsys_initcall(omap_gpmc_init); /** * gpmc_generic_init - Initialize platform data for a Chip Select