From patchwork Wed Jun 11 08:56:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 31744 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7FEF4203C2 for ; Wed, 11 Jun 2014 09:02:20 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id uz6sf19621190obc.4 for ; Wed, 11 Jun 2014 02:02:20 -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=XGJBnxfcEHTMgg6ERyocPBgSYJxBSm8cjzIxZTmp8U4=; b=FgITYmzieZ+CWh7+dy3ZDK1A4xgWCC+pmew+eizp68b+NI+Ky7SLEffCeJd+DF/0/N U9MG1TmSgzqQhvRDEkKDhkVbAv8CY7h7AcnJ3YORd84GhkzPZXrUeQl3wAgpoBf3XGV6 7heco0Pgs+oGrsDBi1sw4Bru5s8KCyoiEn2i5Em79h2wPOMKwpWqDcmbxVYJl9YBc2uM vwy29D34PkL4GMYVgG70J4r3cOkFyqchOJNeXXQoiUuwbhMr2LrxCnVrJazc0LanBj2C rmD4eLcVWO9he9Ku0JvygsjFDgwnwZtngN4uI/68MTHT0EUvB1PvX2N1OX2zFZUhdNB/ pGvg== X-Gm-Message-State: ALoCoQnMjxk8Eur9h+Fmmo1qBmd5VP9VOBhoQyggr08zYCcqfuGW0GWYFwUrK7Vi0hOACgcib7Ya X-Received: by 10.182.135.167 with SMTP id pt7mr8390104obb.14.1402477340130; Wed, 11 Jun 2014 02:02:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.115 with SMTP id c106ls2473757qge.55.gmail; Wed, 11 Jun 2014 02:02:20 -0700 (PDT) X-Received: by 10.52.96.8 with SMTP id do8mr2235786vdb.4.1402477339976; Wed, 11 Jun 2014 02:02:19 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id 5si13985095vdy.104.2014.06.11.02.02.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Jun 2014 02:02:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jz11so6180297veb.17 for ; Wed, 11 Jun 2014 02:02:19 -0700 (PDT) X-Received: by 10.52.125.198 with SMTP id ms6mr2247446vdb.28.1402477339819; Wed, 11 Jun 2014 02:02:19 -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 vs6csp286718vcb; Wed, 11 Jun 2014 02:02:19 -0700 (PDT) X-Received: by 10.140.96.68 with SMTP id j62mr46509458qge.5.1402477339319; Wed, 11 Jun 2014 02:02:19 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id e10si29526550qcd.14.2014.06.11.02.02.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jun 2014 02:02:19 -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 1WueNc-0003iH-G7; Wed, 11 Jun 2014 08:59:36 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueMY-0002Ji-W0; Wed, 11 Jun 2014 08:58:32 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5B8wAJU027774; Wed, 11 Jun 2014 03:58:10 -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 s5B8wAIW009512; Wed, 11 Jun 2014 03:58:10 -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:10 -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 s5B8uiSv020510; Wed, 11 Jun 2014 03:58:07 -0500 From: Roger Quadros To: , , Subject: [PATCH 23/36] ARM: OMAP2+: gpmc: use platform data to configure CS space and poplulate device Date: Wed, 11 Jun 2014 11:56:28 +0300 Message-ID: <1402477001-31132-24-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_015831_152124_22D405EB 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 ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.47.26.153 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.153 listed in list.dnswl.org] -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.172 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 Add gpmc_probe_legacy() that will be called for non DT boots. This function will use platform data to setup each chip select and populate the child platform device for each of the chip selects. Signed-off-by: Roger Quadros --- arch/arm/mach-omap2/gpmc.c | 129 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 111 insertions(+), 18 deletions(-) diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index d3a64ed..c26ba3f 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -1302,11 +1302,6 @@ static int gpmc_probe_dt(struct platform_device *pdev) { int ret; struct device_node *child; - const struct of_device_id *of_id = - of_match_device(gpmc_dt_ids, &pdev->dev); - - if (!of_id) - return 0; ret = of_property_read_u32(pdev->dev.of_node, "gpmc,num-cs", &gpmc_cs_num); @@ -1355,11 +1350,106 @@ static int gpmc_probe_dt(struct platform_device *pdev) } #endif +static void gpmc_probe_legacy(struct platform_device *pdev) +{ + int i, rc; + struct device *dev = &pdev->dev; + struct gpmc_omap_platform_data *gpmc_pdata; + + gpmc_pdata = dev->platform_data; + gpmc_cs_num = GPMC_CS_NUM; + gpmc_nr_waitpins = GPMC_NR_WAITPINS; + + if (!gpmc_pdata) + return; + + for (i = 0; i < GPMC_CS_NUM; i++) { + struct resource *mem_res; + unsigned long cs_base; + resource_size_t size; + struct gpmc_timings gpmc_timings; + struct gpmc_omap_cs_data *cs; + + cs = &gpmc_pdata->cs[i]; + if (!cs->valid) + continue; + + /* + * Request a CS space. Use size from + * platform device's MEM resource + */ + if (!cs->pdev) + goto skip_mem; + + mem_res = cs->pdev->resource; + if (cs->pdev->num_resources < 1 || + resource_type(mem_res) != IORESOURCE_MEM) { + dev_err(dev, "Invalid IOMEM resource for CS %d\n", i); + continue; + } + + size = mem_res->end - mem_res->start + 1; + if (gpmc_cs_request(i, size, &cs_base)) { + dev_err(dev, "Couldn't request resource for CS %d\n", + i); + continue; + } + + mem_res->start = cs_base; + mem_res->end = cs_base + size - 1; + + /* FIXME: When do we need to call gpmc_cs_remap()? */ +skip_mem: + + if (cs->settings) { + if (gpmc_cs_program_settings(i, cs->settings)) { + dev_err(dev, + "Couldn't program settings for CS %d\n", + i); + continue; + } + } + + /* give device_timings priority over gpmc_timings */ + if (cs->device_timings) { + gpmc_calc_timings(&gpmc_timings, cs->settings, + cs->device_timings); + + if (gpmc_cs_set_timings(i, &gpmc_timings)) { + dev_err(dev, + "Couldn't program timings for CS %d\n", + i); + continue; + } + } else if (cs->gpmc_timings) { + if (gpmc_cs_set_timings(i, cs->gpmc_timings)) { + dev_err(dev, + "Couldn't program timings for CS %d\n", + i); + continue; + } + } + + if (!cs->pdev) + continue; + + cs->pdev->dev.parent = dev; + rc = platform_device_register(cs->pdev); + if (rc < 0) { + dev_err(dev, + "Failed to register device %s on CS %d\n", + cs->pdev->name, i); + continue; + } + } +} + static int gpmc_probe(struct platform_device *pdev) { int rc; u32 l; struct resource *res; + struct device *dev = &pdev->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) @@ -1390,7 +1480,7 @@ static int gpmc_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); - gpmc_dev = &pdev->dev; + gpmc_dev = dev; l = gpmc_read_reg(GPMC_REVISION); @@ -1410,7 +1500,7 @@ static int gpmc_probe(struct platform_device *pdev) gpmc_capability = GPMC_HAS_WR_ACCESS | GPMC_HAS_WR_DATA_MUX_BUS; if (GPMC_REVISION_MAJOR(l) > 0x5) gpmc_capability |= GPMC_HAS_MUX_AAD; - dev_info(gpmc_dev, "GPMC revision %d.%d\n", GPMC_REVISION_MAJOR(l), + dev_info(dev, "GPMC revision %d.%d\n", GPMC_REVISION_MAJOR(l), GPMC_REVISION_MINOR(l)); gpmc_mem_init(); @@ -1418,20 +1508,23 @@ static int gpmc_probe(struct platform_device *pdev) /* Now the GPMC is initialised, unreserve the chip-selects */ gpmc_cs_map = 0; - if (!pdev->dev.of_node) { - gpmc_cs_num = GPMC_CS_NUM; - gpmc_nr_waitpins = GPMC_NR_WAITPINS; - } - - rc = gpmc_probe_dt(pdev); - if (rc < 0) { - pm_runtime_put_sync(&pdev->dev); - clk_put(gpmc_l3_clk); - dev_err(gpmc_dev, "failed to probe DT parameters\n"); - return rc; + if (dev->of_node) { + rc = gpmc_probe_dt(pdev); + if (rc) { + dev_err(dev, "gpmc_probe_dt() failed\n"); + goto error; + } + } else { + /* Legacy probing based on platform data */ + gpmc_probe_legacy(pdev); } return 0; + +error: + pm_runtime_put_sync(dev); + clk_put(gpmc_l3_clk); + return rc; } static int gpmc_remove(struct platform_device *pdev)