X-Received: by 2002:a17:902:8d84:b0:14f:83f2:8c0d with SMTP id v4-20020a1709028d8400b0014f83f28c0dmr266966plo.110.1645632063972; Wed, 23 Feb 2022 08:01:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645632063; cv=none; d=google.com; s=arc-20160816; b=O8gOPbpnOwRXU3Y90Kau8fpso+kTIu2zd1Pbc244sfa7V8Nl9/xBIWlzvKsVAcknnV ZNA2kTBtCW4BBPo6y8vTL//GvJRIL8DHEn6DSCE2uREaxb3Und3dRfvIHFCyf/UiFVHb Y3NX5wXq5aXyueXXlIIktWulXChI3g5f6Qz1+KYYXG3yA5ciFqM189Gs1Qlh759NQaUN nt1iRMulM1PGU2nItSMUG9hpcPoarrN65cHNF9/7ct7ogOhPVldtpSZUAQXU6/90bQM5 PZeWS0JyH+l63pMl/QXrWMCn49wtWe5k22wfaBN/rYo4lkbgulwvyJSUQCZnrsWXaMYe TJdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hXOPL5cPITB5pX8C9uT9seIIQT64+6BMqwNdfPuDNQU=; b=oXBFL2vCi4Io1v9riwLIdzUL5Ee/l42VZyIP0DnnCoqYfURYKC2UetAsltuQNY41oD HIAh6EHp18TlFckwhAnWmXIDHoBOPS46PNQ6QIdfscyPTIVBag7yuGN613si1l8uK4Ec /e32iBpC2sI4kRBpjIQHiHZBQ3S3Hcrcy7ooDOjKzqBmHBfOJGEbsn6a8GZKQo97FjAp f/Pcbih5InuLYUS4RaaMCJ8bbu012TVG1zm9MEqjZFGC23MdkQMJvf++m56hJAIxLSN2 kdlMUzySmZECVMiZ3oNSaKqbmuXlVF4oNbU0tkINzPty8sX2GCDnjLdW/dyUCzxCWWvb FqTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=DbjKo8ds; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm10si14636pgb.446.2022.02.23.08.00.45; Wed, 23 Feb 2022 08:01:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=DbjKo8ds; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241219AbiBWNp1 (ORCPT + 99 others); Wed, 23 Feb 2022 08:45:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241078AbiBWNov (ORCPT ); Wed, 23 Feb 2022 08:44:51 -0500 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C4ACAC922 for ; Wed, 23 Feb 2022 05:44:14 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 355182245C; Wed, 23 Feb 2022 14:44:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1645623852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hXOPL5cPITB5pX8C9uT9seIIQT64+6BMqwNdfPuDNQU=; b=DbjKo8dsPWkQtCCu8eWB0m8tXqheMabXvmk9yM+ZiobdO+1SZnfq6BqoZZOSBLFCYgaSjY gNz6EVsTw/6KpAiqjyBG1ic4PbZLpahUxPQ/8iZwXUTOuNOVKNR4diOQXGnOX/UUczbp6n 3sBevsMWo+gLNLamEUChQQruhMUfYuU= From: Michael Walle To: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , yaliang.wang@windriver.com, Michael Walle Subject: [PATCH v5 18/32] mtd: spi-nor: allow a flash to define its own ready() function Date: Wed, 23 Feb 2022 14:43:44 +0100 Message-Id: <20220223134358.1914798-19-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220223134358.1914798-1-michael@walle.cc> References: <20220223134358.1914798-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xilinx and Micron flashes have their own implementation of the spi_nor_ready() function. At the moment, the core will figure out which one to call according to some flags. Lay the foundation to make it possible that a flash can register its own ready() function. Signed-off-by: Michael Walle Reviewed-by: Tudor Ambarus Reviewed-by: Pratyush Yadav --- drivers/mtd/spi-nor/core.c | 4 ++++ drivers/mtd/spi-nor/core.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 4d2036cdce42..390a9ab413b7 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -794,6 +794,10 @@ static int spi_nor_ready(struct spi_nor *nor) { int sr, fsr; + /* Flashes might override the standard routine. */ + if (nor->params->ready) + return nor->params->ready(nor); + if (nor->flags & SNOR_F_READY_XSR_RDY) sr = spi_nor_xsr_ready(nor); else diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 4fe16b5aa3f5..fdc8c0f31f5c 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -261,6 +261,9 @@ struct spi_nor_otp { * SPI NOR flashes that have peculiarities to the SPI NOR * standard e.g. different opcodes, specific address * calculation, page size, etc. + * @ready: (optional) flashes might use a different mechanism + * than reading the status register to indicate they + * are ready for a new command * @locking_ops: SPI NOR locking methods. */ struct spi_nor_flash_parameter { @@ -282,6 +285,7 @@ struct spi_nor_flash_parameter { int (*set_4byte_addr_mode)(struct spi_nor *nor, bool enable); u32 (*convert_addr)(struct spi_nor *nor, u32 addr); int (*setup)(struct spi_nor *nor, const struct spi_nor_hwcaps *hwcaps); + int (*ready)(struct spi_nor *nor); const struct spi_nor_locking_ops *locking_ops; }; -- 2.30.2