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: 358556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 70DB51400AB for ; Wed, 11 Jun 2014 19:01:49 +1000 (EST) 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: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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