From patchwork Mon Feb 1 23:35:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 576751 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 54AC7140C1F for ; Tue, 2 Feb 2016 10:35:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=mnmOuVs+; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F3487A757A; Tue, 2 Feb 2016 00:35:39 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bO1pzXbEYgCJ; Tue, 2 Feb 2016 00:35:39 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 35CAAA7544; Tue, 2 Feb 2016 00:35:39 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8A365A7544 for ; Tue, 2 Feb 2016 00:35:31 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nODPG61EOpOx for ; Tue, 2 Feb 2016 00:35:31 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f68.google.com (mail-pa0-f68.google.com [209.85.220.68]) by theia.denx.de (Postfix) with ESMTPS id 151B3A750D for ; Tue, 2 Feb 2016 00:35:26 +0100 (CET) Received: by mail-pa0-f68.google.com with SMTP id gi1so7794752pac.2 for ; Mon, 01 Feb 2016 15:35:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iWx7+pTQSfo6JDoJ7tgJi+k3t5UYxyislajZ86g+2uQ=; b=mnmOuVs+GFf0u7ccP3KyLz/MYcKUsKCrbVuspgS2zrt6DUntZqoHeWJXajBD2xdC04 iHB53wQUzawLJZza9JpZZsVePES304LS7CYijBKHwtgX5yKrsJH1vwJTGnGtFmZtDK/e msne1NpbxOYZ2v14ar1/cgiFyaDWv1ZvFpGq/bP2IQw80XkddnsmitMxJQS8k3AdyfrU TmSEcZIeIMsGJyQOoLzm+2UOIkreRm8+/ebKT+SJg4y5xugTlFmmRZYH6q6/gMl3IgTN KNbi5tRkhRn7VWJUrAb83NMiJHgm+NuE+jZTC/MkEHL0LElah+g8nXspq+C5/uWyebsN DZCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iWx7+pTQSfo6JDoJ7tgJi+k3t5UYxyislajZ86g+2uQ=; b=ih0PtmMTB9vsDtMjW7eE+TS0FmHddDZT28Q/XQ4Ld2bEf3CGN+2bvAs8PW7ouOf2cg RQ/al0VXeflBoH5M/i8U4gAcxvo8yjxMfAfkPZxUUxpAFSdLdsdtIL3WQR6+Y7eVUzrW RCKVkrX6LGF2aF6GS3Kst9CBOwMtv8E3yORwwPqwkLgkT91Hw4D6cmYWq5ZgpXqpC+RY ebpxkoL/L/1aBuREIdKqJBRoCdyTNthRCBy4nHxq2+helg+Lbb/Sk3aC7EX6PYZ165tm BCk960f74+eialYIXei/ZMiSP0fXFxorUzRyNXIc+aNlgzPsSw9ptJgwuFIsJ11LoXhR +n8g== X-Gm-Message-State: AG10YOSC1m43DUkZP9NG5GulQInac8OR0YEOkrS3i8lR8knHBKiHns5/zLt4wyX0AXSyUg== X-Received: by 10.67.1.164 with SMTP id bh4mr42905604pad.118.1454369724584; Mon, 01 Feb 2016 15:35:24 -0800 (PST) Received: from chrisp-dl.ws.atlnz.lc (2-163-36-202-static.alliedtelesis.co.nz. [202.36.163.2]) by smtp.gmail.com with ESMTPSA id q20sm19876379pfa.70.2016.02.01.15.35.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Feb 2016 15:35:24 -0800 (PST) From: Chris Packham To: u-boot@lists.denx.de, Scott Wood , Prafulla Wadaskar , Luka Perkov Date: Tue, 2 Feb 2016 12:35:09 +1300 Message-Id: <1454369709-5459-1-git-send-email-judge.packham@gmail.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: References: Cc: Chris Packham Subject: [U-Boot] [PATCH v2] kirkwood_nand: claim MPP pins on the fly X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Claim the MPP pins for the NAND flash controller only when it's actually being used. This allows the pins to be shared with the SPI interface which already supports an equivalent on-access MPP reconfiguration. Reviewed-by: Mark Tomlinson Signed-off-by: Chris Packham Acked-by: Scott Wood --- I haven't wrapped this with a configuration option because I think it should be safe to enable by default. It will either re-apply the same MPP configuration that has already been done in the board init or put the MPP pins into the correct mode to access NAND. I've only got access to one kirkwood based board with NAND flash so I'd appreciate some feedback from someone with access to a few different boards. From the datasheets I have access to it looks like there is only one possible MPP configuration for NF_IO[0-7] so that is what I've implemented. I'm not aware of anything using this driver that needs a different MPP config. Changes in v2: - make nand_config static const drivers/mtd/nand/kirkwood_nand.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/mtd/nand/kirkwood_nand.c b/drivers/mtd/nand/kirkwood_nand.c index 4fc34d6..d734113 100644 --- a/drivers/mtd/nand/kirkwood_nand.c +++ b/drivers/mtd/nand/kirkwood_nand.c @@ -9,6 +9,7 @@ #include #include #include +#include #include /* NAND Flash Soc registers */ @@ -22,6 +23,8 @@ struct kwnandf_registers { static struct kwnandf_registers *nf_reg = (struct kwnandf_registers *)KW_NANDF_BASE; +static u32 nand_mpp_backup[9] = { 0 }; + /* * hardware specific access to control-lines/bits */ @@ -49,6 +52,22 @@ static void kw_nand_hwcontrol(struct mtd_info *mtd, int cmd, void kw_nand_select_chip(struct mtd_info *mtd, int chip) { u32 data; + static const u32 nand_config[] = { + MPP0_NF_IO2, + MPP1_NF_IO3, + MPP2_NF_IO4, + MPP3_NF_IO5, + MPP4_NF_IO6, + MPP5_NF_IO7, + MPP18_NF_IO0, + MPP19_NF_IO1, + 0 + }; + + if (chip >= 0) + kirkwood_mpp_conf(nand_config, nand_mpp_backup); + else + kirkwood_mpp_conf(nand_mpp_backup, NULL); data = readl(&nf_reg->ctrl); data |= NAND_ACTCEBOOT_BIT;