From patchwork Wed May 21 11:20:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 30531 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3C1D920671 for ; Wed, 21 May 2014 11:22:26 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rl12sf8336108iec.2 for ; Wed, 21 May 2014 04:22:25 -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=nL7r1OhsXINEGWHtg6DtWi4PnfTAWjfwHj9OV+7JYzM=; b=bFfx8hv7KpB5Glj2mwFrDW8/wQx8mBEBLRMUhlUsG4CbDtus5Ik0747/bO8eFX/5vJ bTgjG5Eo1YLLfBY4V1Hb3zkjm2KHeny3ZZ+J/9A0eNibMaevMpSmVkmCzzjEBgI1t4nZ y9vlw+C+v3r+uEO5spOH8BYdDCons2eGC2zio4u7Yg9Pr+eQ5QyrSynhZvqeYd9nU30Y Qe99/OJWOkX2hMy6byqvXJCazRCzSq0RU6NW/vrtg5FM68amGtMwkBNhUkadpUpTHHtg 0ZA9yzuGxZaxLx14kTv3rV9l8TBHhJivQpwvhsQ+MYG5s6im4DNG4II1D9pg53J8DQ85 gE/Q== X-Gm-Message-State: ALoCoQm69UA8vFI82C/8AIsHApAfbS8NBMqmNpbvIKiTD4isNyHVg0Mq/MF5NP2HRLU5+q/OfSP2 X-Received: by 10.182.105.41 with SMTP id gj9mr11702697obb.30.1400671345407; Wed, 21 May 2014 04:22:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.173 with SMTP id 42ls690004qgh.27.gmail; Wed, 21 May 2014 04:22:25 -0700 (PDT) X-Received: by 10.52.95.135 with SMTP id dk7mr7784563vdb.38.1400671345310; Wed, 21 May 2014 04:22:25 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id zw17si403906veb.78.2014.05.21.04.22.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 May 2014 04:22:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id la4so2314583vcb.13 for ; Wed, 21 May 2014 04:22:25 -0700 (PDT) X-Received: by 10.52.103.74 with SMTP id fu10mr7869108vdb.7.1400671345189; Wed, 21 May 2014 04:22:25 -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.220.221.72 with SMTP id ib8csp104556vcb; Wed, 21 May 2014 04:22:24 -0700 (PDT) X-Received: by 10.66.136.131 with SMTP id qa3mr56925342pab.77.1400671344444; Wed, 21 May 2014 04:22:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hq3si28727976pad.87.2014.05.21.04.22.23; Wed, 21 May 2014 04:22:23 -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 S1752449AbaEULWD (ORCPT + 27 others); Wed, 21 May 2014 07:22:03 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:36791 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbaEULV7 (ORCPT ); Wed, 21 May 2014 07:21:59 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4LBLbcI014575; Wed, 21 May 2014 06:21:37 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4LBLbmp021124; Wed, 21 May 2014 06:21:37 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 21 May 2014 06:21:37 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4LBLAAb018495; Wed, 21 May 2014 06:21:33 -0500 From: Roger Quadros To: , CC: , , , , , , , , , , , Roger Quadros Subject: [RFC PATCH 06/16] ARM: OMAP2+: gpmc: add NAND specific setup Date: Wed, 21 May 2014 14:20:54 +0300 Message-ID: <1400671264-10702-7-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1400671264-10702-1-git-send-email-rogerq@ti.com> References: <1400671264-10702-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.220.182 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: , Provide NAND specific resources and platform data. Signed-off-by: Roger Quadros --- arch/arm/mach-omap2/gpmc.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 26b26ec..f4ee6e9 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -1629,6 +1629,61 @@ static int gpmc_probe_dt(struct platform_device *pdev) } #endif +static int gpmc_nand_setup(struct platform_device *pdev, + struct gpmc_settings *settings) +{ + struct resource *res; + int rc; + struct omap_nand_platform_data *gpmc_nand_data; + + gpmc_nand_data = pdev->dev.platform_data; + if (!gpmc_nand_data) + return -EINVAL; + + res = pdev->resource; + + /* setup IRQ resources */ + res[1].start = gpmc_get_client_irq(GPMC_IRQ_FIFOEVENTENABLE); + + res[2].start = gpmc_get_client_irq(GPMC_IRQ_COUNT_EVENT); + + settings->device_nand = true; + /* + * Not sure why WP is explicitly turned OFF. we just moved it here + * as is from mach-omap2/gpmc-nand.c + */ + rc = gpmc_configure(GPMC_CONFIG_WP, 0); + if (rc < 0) + return rc; + + /* update register addresses in NAND platform data */ + gpmc_update_nand_reg(&gpmc_nand_data->reg, gpmc_nand_data->cs); + + return 0; +} + +static int gpmc_nand_check_csdata(struct gpmc_omap_cs_data *cs) +{ + struct resource *res; + + if (!cs->pdev) + return -EINVAL; + + res = cs->pdev->resource; + + if (cs->pdev->num_resources < 3) + return -EINVAL; + + if (resource_type(&res[1]) != IORESOURCE_IRQ || + resource_type(&res[2]) != IORESOURCE_IRQ) + return -EINVAL; + + if (!cs->settings) + return -EINVAL; + + return 0; +} + static void gpmc_probe_legacy(struct platform_device *pdev) { int i, rc; @@ -1677,6 +1732,28 @@ static void gpmc_probe_legacy(struct platform_device *pdev) /* FIXME: When do we need to call gpmc_cs_remap()? */ skip_mem: + /* Customized setup based on type */ + switch (cs->type) { + case GPMC_OMAP_TYPE_NAND: + if (gpmc_nand_check_csdata(cs)) { + dev_err(dev, "Invalid NAND config on CS %d\n", + i); + continue; + } + + rc = gpmc_nand_setup(cs->pdev, cs->settings); + if (rc) { + dev_err(dev, "Error setting up NAND on CS %d\n", + i); + continue; + } + break; + case GPMC_OMAP_TYPE_NOR: + case GPMC_OMAP_TYPE_ONENAND: + case GPMC_OMAP_TYPE_GENERIC: + break; + } + if (cs->settings) { if (gpmc_cs_program_settings(i, cs->settings)) { dev_err(dev,