From patchwork Wed Jun 11 08:56:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 31749 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4C6AA203C2 for ; Wed, 11 Jun 2014 09:03:01 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id s7sf12947694qap.6 for ; Wed, 11 Jun 2014 02:03:01 -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:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=5o1IrjCYNG6jUqK0MpWwodR/q0iw2u8rzsJCLpe68x4=; b=VOAOmUe3QDwvh4xdALJkYTH7jUzUjPIo4dc+kvmH6ZxO0wOpo13vNVhUZ3gBGAoOeg LU7a9Y80m/eUI9PC+gkb/cR+fluLkFX2FXxk/fJWi98XstuuKW3GuwGkYmN72rGYVEcs z30kJSqzEdEV74d9EGFtBv0sWiwolsbjTbLI5+WNBjiSgRTgSZw7dAwbTWSX6xjJTpf4 FkL8VnB7NENykYMovthazTMqAN90+iDPh0YPDn3U53cg97vmuD14tWkk67mX3IrqSqJ0 f12wEjU4KQlk6lcKwSmQRJOKOXhSm7GHAYhZxNdVlW2f7yAZkY5yYXcABb9go2K0iGuB 1C5Q== X-Gm-Message-State: ALoCoQmnIU3wk56cdNtGizUDFS3pVNV4q3lwVy1TARizuFgd2qM+zLlS7W1AYjLY/OsokqljnR66 X-Received: by 10.58.247.202 with SMTP id yg10mr1351562vec.1.1402477381085; Wed, 11 Jun 2014 02:03:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.74 with SMTP id w68ls2464543qgw.53.gmail; Wed, 11 Jun 2014 02:03:01 -0700 (PDT) X-Received: by 10.52.230.34 with SMTP id sv2mr423794vdc.57.1402477380989; Wed, 11 Jun 2014 02:03:00 -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 fa6si14039359veb.20.2014.06.11.02.03.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Jun 2014 02:03:00 -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 jz11so6181744veb.17 for ; Wed, 11 Jun 2014 02:03:00 -0700 (PDT) X-Received: by 10.52.125.198 with SMTP id ms6mr2250188vdb.28.1402477380840; Wed, 11 Jun 2014 02:03:00 -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 vs6csp286771vcb; Wed, 11 Jun 2014 02:03:00 -0700 (PDT) X-Received: by 10.66.218.36 with SMTP id pd4mr11781102pac.141.1402477380065; Wed, 11 Jun 2014 02:03:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dz4si5878024pab.125.2014.06.11.02.02.59; Wed, 11 Jun 2014 02:02:59 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755276AbaFKJCr (ORCPT + 27 others); Wed, 11 Jun 2014 05:02:47 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:56384 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755798AbaFKI7F (ORCPT ); Wed, 11 Jun 2014 04:59:05 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5B8wZLr028062; Wed, 11 Jun 2014 03:58:35 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5B8wZg9022242; Wed, 11 Jun 2014 03:58:35 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Wed, 11 Jun 2014 03:58:35 -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 s5B8uiT4020510; Wed, 11 Jun 2014 03:58:32 -0500 From: Roger Quadros To: , , CC: , , , , , , , , , Roger Quadros Subject: [PATCH 30/36] ARM: OMAP2+: gpmc-smsc911x: Use gpmc_generic_init() Date: Wed, 11 Jun 2014 11:56:35 +0300 Message-ID: <1402477001-31132-31-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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Don't access any GPMC registers here. Use gpmc_generic_init() to pass GPMC Chip Select settings, platform device and platform data to the GPMC driver. Some boards use multiple smsc911x devices, so we dynamically allocate pdev and pdata. Signed-off-by: Roger Quadros --- arch/arm/mach-omap2/gpmc-smsc911x.c | 76 ++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/arch/arm/mach-omap2/gpmc-smsc911x.c b/arch/arm/mach-omap2/gpmc-smsc911x.c index 2757504..9492db0 100644 --- a/arch/arm/mach-omap2/gpmc-smsc911x.c +++ b/arch/arm/mach-omap2/gpmc-smsc911x.c @@ -19,19 +19,11 @@ #include #include #include +#include #include "gpmc.h" #include "gpmc-smsc911x.h" -static struct resource gpmc_smsc911x_resources[] = { - [0] = { - .flags = IORESOURCE_MEM, - }, - [1] = { - .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, - }, -}; - static struct smsc911x_platform_config gpmc_smsc911x_config = { .phy_interface = PHY_INTERFACE_MODE_MII, .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, @@ -45,24 +37,43 @@ static struct smsc911x_platform_config gpmc_smsc911x_config = { */ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *gpmc_cfg) { - struct platform_device *pdev; - unsigned long cs_mem_base; int ret; + struct platform_device *pdev; + struct resource *res; + + /* + * This function can be called multiple times per board so the platform + * device and resources have to be allocated separately for each + * device. + */ + pdev = kzalloc(sizeof(*pdev), GFP_KERNEL); + if (!pdev) + goto fail; + + /* needs 2 resources */ + res = kzalloc(2 * sizeof(*res), GFP_KERNEL); + if (!res) + goto free1; - if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) { - pr_err("Failed to request GPMC mem region\n"); - return; - } + pdev->name = "smsc911x"; + pdev->id = gpmc_cfg->id; + pdev->dev.platform_data = &gpmc_smsc911x_config, + pdev->num_resources = 2; + pdev->resource = res; + + /* res[0] Will be relocated by GPMC driver, see gpmc_probe_legacy() */ + res[0].flags = IORESOURCE_MEM; + res[0].start = 0; + res[0].end = 0xff; - gpmc_smsc911x_resources[0].start = cs_mem_base + 0x0; - gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff; if (gpio_request_one(gpmc_cfg->gpio_irq, GPIOF_IN, "smsc911x irq")) { pr_err("Failed to request IRQ GPIO%d\n", gpmc_cfg->gpio_irq); - goto free1; + goto free2; } - gpmc_smsc911x_resources[1].start = gpio_to_irq(gpmc_cfg->gpio_irq); + res[1].start = gpio_to_irq(gpmc_cfg->gpio_irq); + res[1].flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL; if (gpio_is_valid(gpmc_cfg->gpio_reset)) { ret = gpio_request_one(gpmc_cfg->gpio_reset, @@ -70,7 +81,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *gpmc_cfg) if (ret) { pr_err("Failed to request reset GPIO%d\n", gpmc_cfg->gpio_reset); - goto free2; + goto free3; } gpio_set_value(gpmc_cfg->gpio_reset, 0); @@ -80,21 +91,26 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *gpmc_cfg) gpmc_smsc911x_config.flags = gpmc_cfg->flags ? : SMSC911X_USE_16BIT; - pdev = platform_device_register_resndata(NULL, "smsc911x", gpmc_cfg->id, - gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources), - &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config)); - if (IS_ERR(pdev)) { - pr_err("Unable to register platform device\n"); - gpio_free(gpmc_cfg->gpio_reset); - goto free2; + ret = gpmc_generic_init(gpmc_cfg->cs, false, + NULL, NULL, NULL, + pdev, + sizeof(gpmc_smsc911x_config)); + if (ret) { + pr_err("%s: gpmc_generic_init() failed %d\n", __func__, ret); + goto free4; } return; -free2: +free4: + if (gpio_is_valid(gpmc_cfg->gpio_reset)) + gpio_free(gpmc_cfg->gpio_reset); +free3: gpio_free(gpmc_cfg->gpio_irq); +free2: + kfree(res); free1: - gpmc_cs_free(gpmc_cfg->cs); - + kfree(pdev); +fail: pr_err("Could not initialize smsc911x device\n"); }