Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7AC4C433F5 for ; Tue, 1 Feb 2022 17:45:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9D42C8069C; Tue, 1 Feb 2022 18:45:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="oU5912jZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4CE3B8018F; Tue, 1 Feb 2022 18:45:31 +0100 (CET) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 736098069C for ; Tue, 1 Feb 2022 18:45:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kory.maincent@bootlin.com Received: (Authenticated sender: kory.maincent@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 643E6240007; Tue, 1 Feb 2022 17:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1643737517; 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; bh=wD+5mwUEDLURbxHpldh0HPIHs9McuGIM+dd7MTIqIyc=; b=oU5912jZ7DfdoWW+0EVdJRumOxMD22T+HK58WSqds6g8le/UL5Rf9EFssLHhJn6xelnL5s /tjwlSjjrzoO4cI3vWHjig5/QtJHufCuXKyYqB4IoXlHNlI0wNRnZPCtLZJsWBi7tS2vBv 5hEzBJ71JByXrZRIu2kpAU/SSSz3rlX3hKUAqmsa6PiUiJDbZ7w2cXFNlapnplG8y600Wq 3UZ3D+ylBxsdvsKVTQUy4OtrUD48AQyru+pZGQg1ho1QRHHc8yoKyLegOFKlfuQcUiGL08 IvagmCy9ttzf+CEH0msJez0lkJCquy7ZnUCZoYzE9h89gTSkJkHnFobq/sIBIg== From: Kory Maincent To: u-boot@lists.denx.de Cc: thomas.petazzoni@bootlin.com, miquel.raynal@bootlin.com, Simon Glass , Wolfgang Denk , Patrice Chotard , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH] mtd: nand: Add support to dedicated function to set timings Date: Tue, 1 Feb 2022 18:45:14 +0100 Message-Id: <20220201174514.409429-1-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean With the current code if the board have a NAND ONFI compliant without support to the get and set features, U-boot return an ENOTSUP error and we can not talk to the memory. Indeed onfi_set_features return ENOTSUP error if set/get features is not supported. In the case of timings we should not return ENOTSUP because we can use the default timings, the modification of the NAND timings is optional. Fixed it by adding an intermediate nand_onfi_set_timings function which does nothing if set/get feature is not supported. Signed-off-by: Kory Maincent --- drivers/mtd/nand/raw/nand_base.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index f7616985d9..44fb33776f 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -974,6 +974,22 @@ static int nand_reset_data_interface(struct nand_chip *chip, int chipnr) return ret; } +static int nand_onfi_set_timings(struct mtd_info *mtd, struct nand_chip *chip) +{ + if (!chip->onfi_version || + !(le16_to_cpu(chip->onfi_params.opt_cmd) + & ONFI_OPT_CMD_SET_GET_FEATURES)) + return 0; + + u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = { + chip->onfi_timing_mode_default, + }; + + return chip->onfi_set_features(mtd, chip, + ONFI_FEATURE_ADDR_TIMING_MODE, + tmode_param); +} + /** * nand_setup_data_interface - Setup the best data interface and timings * @chip: The NAND chip @@ -999,17 +1015,9 @@ static int nand_setup_data_interface(struct nand_chip *chip, int chipnr) * Ensure the timing mode has been changed on the chip side * before changing timings on the controller side. */ - if (chip->onfi_version) { - u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = { - chip->onfi_timing_mode_default, - }; - - ret = chip->onfi_set_features(mtd, chip, - ONFI_FEATURE_ADDR_TIMING_MODE, - tmode_param); - if (ret) - goto err; - } + ret = nand_onfi_set_timings(mtd, chip); + if (ret) + goto err; ret = chip->setup_data_interface(mtd, chipnr, chip->data_interface); err: -- 2.25.1