Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp402697pxk; Fri, 11 Sep 2020 09:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEl5VQBJfTeSZ1GCl/B9bfc/nSlrgJ9x6z7jXYuNwfwGQxTZulUIU3Y20uQvC6/GT2is2g X-Received: by 2002:a17:906:eced:: with SMTP id qt13mr2864691ejb.357.1599843475422; Fri, 11 Sep 2020 09:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599843475; cv=none; d=google.com; s=arc-20160816; b=Lt+ioIWRKgWUPVKZo7+YKbC+gAxudsd8K1umhvo1mOtALG0Om1MwOIKg45qsjdbDuL XPjlvhvy5j4rY0C1rtLg0L4HhYaSL8XV8V493UU2K4jlx9/KIgoBzebmVeM7LfjQcvRk wV+jkV8udtOv0MbGK6jyR4Ry1G02CFbfhII1DBZLNM0kBnRbjhA5mmDTi+xyYkf0+6Xc vXMrBrgHl14ukoiRVGA0e0SoCtc0sskqT6PzxbnU7VuyPOG/rEIYKi7DyLqGmMMcKPAi i2yziYWGTJGiJyGdRv6KHIorJeaVKDSMDn6KeUR15d7Dd52vehaNtotT04vjG9WCJDHm h6Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7KEdxcoL02/nJFFXbiITwAhoSaam89A/GTsxuqztJsY=; b=cp60zzuD4U4XcCN2VRMYeMn83REtBHDoK3c0Pa5lu9faWD+ociwkHrG2eK/SmhhpO1 AsNHplpsOe0+e425PIaXXvJeM/2JsiISRJcdouXI3yD2HFMyS2HNPHUCNwoHjm6gUUTa 1/Z34NPfh7Vm8DWltya3a+QYxbLKuESgnDT2unj8MzvhwwARTFelxHbqBvthvJIgrgM8 8MuvB43MtI/ELfrcB2vOPgF/hjUCJLT4v4FYs5vSbInFpemUYzeNifNj+XR62bfse7Qh AdioZp9PL7xIwbCWOB1CCx6jnQJJfoMRHdS9zKUwFZ++fayZQJINBJ4IGZwLOgLn60eu B09Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si1739165edn.39.2020.09.11.09.57.32; Fri, 11 Sep 2020 09:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726074AbgIKQyz (ORCPT + 99 others); Fri, 11 Sep 2020 12:54:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725951AbgIKPGM (ORCPT ); Fri, 11 Sep 2020 11:06:12 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23228C0612EE for ; Fri, 11 Sep 2020 07:47:21 -0700 (PDT) Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGkKU-0006Pv-NW; Fri, 11 Sep 2020 16:47:10 +0200 Received: from mfe by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGkKP-0006nd-40; Fri, 11 Sep 2020 16:47:05 +0200 From: Marco Felsch To: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sergei.shtylyov@cogentembedded.com, boris.brezillon@collabora.com, michael@walle.cc, j.neuschaefer@gmx.net Cc: linux-mtd@lists.infradead.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mtd: spi-nor: sst: add missing write_enable Date: Fri, 11 Sep 2020 16:47:02 +0200 Message-Id: <20200911144703.25409-3-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911144703.25409-1-m.felsch@pengutronix.de> References: <20200911144703.25409-1-m.felsch@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According the datasheet [1] the WEL is automatically reset after the Byte-Program instruction completion. So if we program the device with byte-size set to 32 and starting from an odd address only the first and the last byte is written. Fix this by (re-)anble the write support for the first SPINOR_OP_AAI_WP sequence. [1] http://ww1.microchip.com/downloads/en/DeviceDoc/20005044C.pdf; "4.3.2 WRITE ENABLE LATCH (WEL)" Signed-off-by: Marco Felsch --- drivers/mtd/spi-nor/sst.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c index e0af6d25d573..644252e27a2a 100644 --- a/drivers/mtd/spi-nor/sst.c +++ b/drivers/mtd/spi-nor/sst.c @@ -79,6 +79,13 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, /* Write out most of the data here. */ for (; actual < len - 1; actual += 2) { + /* Enable write support if odd address was written before */ + if (actual == 1) { + ret = spi_nor_write_enable(nor); + if (ret) + goto out; + } + nor->program_opcode = SPINOR_OP_AAI_WP; /* write two bytes. */ -- 2.20.1