From patchwork Wed Jul 18 23:57:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10533487 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E34CF601D2 for ; Thu, 19 Jul 2018 00:00:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1B0D2993D for ; Thu, 19 Jul 2018 00:00:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C58D229944; Thu, 19 Jul 2018 00:00:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6FFBD2993D for ; Thu, 19 Jul 2018 00:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=pF654SG2uTpvPnipwm7ojJ+szrLFCjXhBnUoNtZ1H9Q=; b=dvAnCjjN+eEZ/Yld9Vw9T8TB28 FybAz6avFwsG8edZbmghQsPLUcLQTcSk495bJaBXjnWRByDXEFb0piOp2AdPRtPM34a6gQVJEBc2q E5PEpunWeu2rulQ3FdU/hzd6yXbDJ0ie0JDEj/dfHDVBkROUtJrRv1FMWCtx1bRMgNYop3IXTI+BO 6uZen/wdZhueXcTZR1qz0oCCnowS+f/yLpqba+Q+BS0CYbYaAlO4zmjYyz5DMGnJA+JK1AjyWHRTz Kq6bNYq7vtb53m403ULK7dncYUY/aslLD1ezoKtxJQYgY6kg1CHBgR4KeomLyIBD/Sa+LPAqS3Tb8 NiWQWT8w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffwMR-0000j9-Mp; Wed, 18 Jul 2018 23:59:59 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffwJc-0005mT-AI; Wed, 18 Jul 2018 23:57:06 +0000 Received: by mail-lj1-x241.google.com with SMTP id p10-v6so5614910ljg.2; Wed, 18 Jul 2018 16:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BycCmm8Gq6/0A/A3AdvDrsfmkVSIr0emCY8Ur1J9Y78=; b=KoNrOqAkK56tdHLli02jtgsoFdXZ5koETC7WXacVnuPtdQ/+oNk7yG6+gqb3obnn3o VxCPvnE418o6Jg2pd02CT2y+5I6ONQkU9cINvIp7jxKK2K3N6gDR26MtcPcN+HExqfRE 0Eb1WFUuf7gH4HQw+LssoL7gocsPVoxPnIBxIHU4JorCehpkq3GnIUQNRRSCbaYH4SE1 hzKuCApgwWohEeCMyYLmwEmd6G1f5ByyPTpzkV/ra0ao57DzZDXbsdMXyJHNI7p3aJSB A5/IGOePuobIVLqcazQNcKWNkbMnthbVA5tHagCa0xKqKA4kCuuamZNxkgm7f9MHGkRZ ECxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BycCmm8Gq6/0A/A3AdvDrsfmkVSIr0emCY8Ur1J9Y78=; b=S+XQSWIGVVbEzBXduzsD3HaKBomCPcsxr3dEosZ5eGFchyLT7/c+amInkgk1Wb91h/ 9RHccnu04TAGxpVq9+aQi7x8ThS0DvCP9X0Su3foooVqq0dOYnKuUZKdHw5sXn8cBdwt lgSzrKnMepy6iQYCqjRCJ1PGJLge8mC3OFBBCTjL+Rx9XPBo78JhQ2HMntDf04XOIBor RfYZFR3/pNJw9haNzEmDc11luEemRZap9OVbbS/NrT2cVjXkRP+Mwvq1HL7md5Y4wR2W lisLLKTi3A8nkKuhorYNZjU1crEvWxUDDN2Biish/EJn8cy/QSXxgN0PIceBE3DbW61O g5gQ== X-Gm-Message-State: AOUpUlE80THTUhLEQok2VDikV9g6/GHEUxBsQed8ABkyxNvdMl0hnAvo QyKbt+BbZD5zgodliNTp0DY= X-Google-Smtp-Source: AAOMgpePfj+3pVjxiIMv2HBi82aJ2vjCr6FGwAwVkOS73Y6sOqSaQCnL75rRTSiJ01KeKFwfOd+pOQ== X-Received: by 2002:a2e:59d1:: with SMTP id g78-v6mr6093135ljf.79.1531958212445; Wed, 18 Jul 2018 16:56:52 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id h7-v6sm826584ljk.27.2018.07.18.16.56.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 16:56:51 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Miquel Raynal Subject: [RFC PATCH 2/8] mtd: rawnand: ams-delta: Write protect device during probe Date: Thu, 19 Jul 2018 01:57:04 +0200 Message-Id: <20180718235710.18242-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180718235710.18242-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180718_165704_407497_7A84CCBC X-CRM114-Status: GOOD ( 14.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Grygorii Strashko , Kevin Hilman , Tony Lindgren , Richard Weinberger , Linus Walleij , Aaro Koskinen , Artem Bityutskiy , linux-kernel@vger.kernel.org, Marek Vasut , linux-omap@vger.kernel.org, Janusz Krzysztofik , linux-mtd@lists.infradead.org, linux-gpio@vger.kernel.org, Santosh Shilimkar , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Initialize NWP GPIO pin low to protect the device from hazard during probe. Release write protection as soon as the device is under control. Signed-off-by: Janusz Krzysztofik --- drivers/mtd/nand/raw/ams-delta.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index 48233d638d2a..6ac38e9cfa1a 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -219,8 +219,8 @@ static int ams_delta_init(struct platform_device *pdev) platform_set_drvdata(pdev, priv); - /* Set chip enabled, but */ - priv->gpiod_nwp = devm_gpiod_get(&pdev->dev, "nwp", GPIOD_OUT_HIGH); + /* Set chip enabled but write protected */ + priv->gpiod_nwp = devm_gpiod_get(&pdev->dev, "nwp", GPIOD_OUT_LOW); if (IS_ERR(priv->gpiod_nwp)) { err = PTR_ERR(priv->gpiod_nwp); dev_err(&pdev->dev, "NWP GPIO request failed (%d)\n", err); @@ -267,6 +267,9 @@ static int ams_delta_init(struct platform_device *pdev) if (err) goto out_mtd; + /* As soon as the device is found, release write protection */ + gpiod_set_value(priv->gpiod_nwp, 1); + /* Register the partitions */ mtd_device_register(mtd, partition_info, ARRAY_SIZE(partition_info)); @@ -288,6 +291,9 @@ static int ams_delta_cleanup(struct platform_device *pdev) struct mtd_info *mtd = nand_to_mtd(&priv->nand_chip); void __iomem *io_base = priv->io_base; + /* Apply write protection */ + gpiod_set_value(priv->gpiod_nwp, 0); + /* Release resources, unregister device */ nand_release(mtd);