From patchwork Tue Jul 27 04:51:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12401467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77F59C4338F for ; Tue, 27 Jul 2021 05:13:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F5E161058 for ; Tue, 27 Jul 2021 05:13:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3F5E161058 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=CZ2jwkqqGroO7nkfUdTi65XkooVTXxaMHsFaxg2HvVQ=; b=MIFzf+nJD391MZ /Cdkw26Fs+XlJCwugwe/Ysaq2BscPpsqBXhBGoJCDXOFqH3rb9GbYzBpSRf9iW/zItK7Erf4aupxP mJMGb/8iLP49CxcbPiSynFfR4w9ERyfh+TYYdG7fnjLJRIf1o1Tzue+Zd+GS0ydZ6/lIx7wesk+Hy kbaDlkavWD+BLOUly3FwVjsCpStlfaKXleTZboRlDvkkFtpDSXkfrW+On3MxAR/AHk41doYdX5lV5 HRalFROauvrbapUpA3a1wiD9tEr7qfyDrCVtVEkHuay6MC7G/2BSdmg8j/CyWUl0OvP1T0Tld9zwe CLJCky9ij5ywSjOVAxrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8FMM-00DN2V-3b; Tue, 27 Jul 2021 05:10:31 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8F5c-00DHX1-3g; Tue, 27 Jul 2021 04:53:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1627361591; x=1658897591; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W6PtSFtp9YKqjBcoAfppno8q9Rqg4UE5THfHt9mw6j4=; b=fFXmBeHaZQLbLUGr6DLs0aBleNIxTVofdp4WlCHa+0Crv14n2/OeHba3 VMV2377iV2Pj5BHCTUkAunAClZRu/bmwdcC9Zr5qSg87E2fWYjczutv11 UZuh89+OIwYOZNDe4yuJkSjs8zuNOBewvLGCGO5CQoQsv69Ztlc35gzg1 bjr0ZI3lho/o++RBdOfFugfixJjX1bL/W2bIKBsSHmcWmDg2qznqoq5SJ Vb5F04Dab9MXd4WfIgUNBc9RnF36PImZzGcFWQPckd5BgTDT4QYfffwdh x8hu4yJRC5l8xn1hEDkw5XFR2r3e2X2utS31AgAHX8TcCDxJ0CLSKlIyV g==; IronPort-SDR: gZF7Qu8Y7QzSbm/fPqfTG1EMuOqzd/aGljBooSMpqDUrwGzO0coA606m6kG7b474tnst7+iDzL hzm1zMJEtTSzv2wXUXl9vzyjicpEyrLEkVCnZ6/siaBEN8TIpo0cD+N7WyC+/JIJStdF+6V45n EcVswKhV9afaIYu4VoZGbG4fZvT9bRrBQmYbMtFwwDwBSOILVB4fSO1I3KMqESutc6lLzjpGcF fkmggytgHWyfBQ28cW/csADprfKMaYGjH+O67VcxoOgeTgiq05b1LSr6Sw80wWRjXFvQj/VAnZ bBCMQkdMe3HvGviTM3EuRDP8 X-IronPort-AV: E=Sophos;i="5.84,272,1620716400"; d="scan'208";a="130482114" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 26 Jul 2021 21:53:10 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 26 Jul 2021 21:53:10 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Mon, 26 Jul 2021 21:53:05 -0700 From: Tudor Ambarus To: , , Subject: [PATCH v2 08/35] mtd: spi-nor: core: Introduce the ate_init() hook Date: Tue, 27 Jul 2021 07:51:55 +0300 Message-ID: <20210727045222.905056-9-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210727045222.905056-1-tudor.ambarus@microchip.com> References: <20210727045222.905056-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210726_215312_247553_C0D32E95 X-CRM114-Status: GOOD ( 16.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: macromorgan@hotmail.com, jaimeliao@mxic.com.tw, Tudor Ambarus , richard@nod.at, esben@geanix.com, linux@rasmusvillemoes.dk, knaerzche@gmail.com, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, code@reto-schneider.ch, miquel.raynal@bootlin.com, heiko.thiery@gmail.com, sr@denx.de, figgyc@figgyc.uk, mail@david-bauer.net, zhengxunli@mxic.com.tw Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The goal is to get rid of the spaghetti way of initializing the flash parameters and settings. late_init() hook will be used to tweak various parameters that are not defined by the SFDP standard. Can be used by non SFDP compliant flashes in order to tweak flash parameters that are not/shouldn't be handled by the flash_info flags. Will replace the default_init() hook. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/core.c | 15 +++++++++++---- drivers/mtd/spi-nor/core.h | 8 ++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index d30c8f350dc1..15ccc9994215 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2667,11 +2667,18 @@ static void spi_nor_post_sfdp_fixups(struct spi_nor *nor) * spi_nor_late_init_params() - Late initialization of default flash parameters. * @nor: pointer to a 'struct spi_nor' * - * Used to set default flash parameters and settings when the ->default_init() - * hook or the SFDP parser let voids. + * Used to tweak various flash parameters that are not defined by the SFDP + * standard. Can be used by non SFDP compliant flashes in order to tweek flash + * parameters that are not handled by the flash_info flags. */ static void spi_nor_late_init_params(struct spi_nor *nor) { + if (nor->manufacturer && nor->manufacturer->late_init) + nor->manufacturer->late_init(nor); + + if (nor->info->late_init) + nor->info->late_init(nor); + /* * NOR protection support. When locking_ops are not provided, we pick * the default ones. @@ -2713,8 +2720,8 @@ static void spi_nor_late_init_params(struct spi_nor *nor) * wrong). * spi_nor_post_sfdp_fixups() * - * 5/ Late default flash parameters initialization, used when the - * ->default_init() hook or the SFDP parser do not set specific params. + * 5/ Late flash parameters initialization, used to initialize flash + * parameters that are not declared in the JESD216 SFDP standard. * spi_nor_late_init_params() */ static int spi_nor_init_params(struct spi_nor *nor) diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index e9896cd60695..13d5c5edfd27 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -391,6 +391,11 @@ struct flash_info { /* Part specific fixup hooks. */ const struct spi_nor_fixups *fixups; + /* + * Init flash parameters that are not declared in the JESD216 SFDP + * standard. + */ + void (* const late_init)(struct spi_nor *nor); }; /* Used when the "_ext_id" is two bytes at most */ @@ -457,12 +462,15 @@ struct flash_info { * @parts: array of parts supported by this manufacturer * @nparts: number of entries in the parts array * @fixups: hooks called at various points in time during spi_nor_scan() + * @late_init: used to init flash parameters that are not declared in the + * JESD216 SFDP standard. */ struct spi_nor_manufacturer { const char *name; const struct flash_info *parts; unsigned int nparts; const struct spi_nor_fixups *fixups; + void (* const late_init)(struct spi_nor *nor); }; /**