Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4073035ybl; Mon, 26 Aug 2019 05:11:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGdVqBU73T7bAWRUmN19NcHk6UVZr8Mv1Msu4GHxtCwIyNXFSLo1h4E6Tfe6v3pYmzofVL X-Received: by 2002:a17:902:ac86:: with SMTP id h6mr18868685plr.79.1566821471462; Mon, 26 Aug 2019 05:11:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1566821471; cv=pass; d=google.com; s=arc-20160816; b=MXYiS/GvvlesbnNLbkzqPM1YFxkKHGgRyW1UuHPU9qnzE7Txrz+lUJ49mGOYgDfDxN DOqtscZK/z4GrOY1SH5lnPGzETplUo/Lg0IGh3NYLzGZ/+EgggFnWCB4Hv1HlWNuT4QJ E338YKU+0kQPTWbUi1CZAp1Qm4C2faSSCXPl3YLr+ojfyVpxtD54Hp9bBvP1XGLujOd4 FMSR43hNaiIgyYEeVlShueu/jLAsGOrj6oxTc9jH5YhK7odd4Jg7kcKZgqEpgEQ4Zi36 d3DTvJMYUqe7F6UusmHO+8D5ILuEkRtHtCFIb9W2LnlpVjBiw76vXlwt3hl2fpHiJB7N RRUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :ironport-sdr; bh=wzKEj7C2oecdyIVgmS+q8nCE1Ab6V9iG0C1/KPjXWOM=; b=jpgJdt0R5ZrguZ9Nj8TFRNn88gvZCs1oy2vSqgkJpoA7KgbGG6S77Imx6KUtZ5rl+H ROOGKpjFgXPQRLYrZOet5zPfPpOBKHovmoV/t0fPlpC74beYp1EZpnUnRv4AU7V8O6Qy hxwDw1JpUBIzqqWtlwHgCW4Ni3/My8y9d96WpDPleQzuuxgH8z2oiDjMFRut/oHC8xjo fj2kZM4e7g19mYkwARwsBBaS/+o/fbXjg/RVLm0wpdp/eC8tw3m1kATArOBYKRzfsAh3 tcGrHKwBKW5rGhN8Vo+iUSHAeKqiAvmykTp81j60FvFTg+siFw9t42jL7Cc+ivXchDzq fpww== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchiptechnology.onmicrosoft.com header.s=selector2-microchiptechnology-onmicrosoft-com header.b=qL+PSksg; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si9133880plm.295.2019.08.26.05.10.55; Mon, 26 Aug 2019 05:11:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microchiptechnology.onmicrosoft.com header.s=selector2-microchiptechnology-onmicrosoft-com header.b=qL+PSksg; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731771AbfHZMJJ (ORCPT + 99 others); Mon, 26 Aug 2019 08:09:09 -0400 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:24951 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731740AbfHZMJG (ORCPT ); Mon, 26 Aug 2019 08:09:06 -0400 Received-SPF: Pass (esa6.microchip.iphmx.com: domain of Tudor.Ambarus@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="Tudor.Ambarus@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa6.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Tudor.Ambarus@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa6.microchip.iphmx.com; spf=Pass smtp.mailfrom=Tudor.Ambarus@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: 9AN7mdAyIVI+BLr/A5368/qRTb1/PC8sEOBnth8BDsDYAOxRoCj0BFc77ZgWsQDMGRsIcOKh/i 1UXhutQvZ/Hk02ZR7bZBj/rcH9Jvv+0dM8g1F7xArgX5luAXyJ4CfyYKLIucIdAJrhABQLGkix n1VhWRiAZD2uIGdvMCwXBqq7T89a7T9VCKg3YXFrnpt+gE3cza0tlgcvLiUrvY2DCG4kiMPgaT ZfPf/CopUeZHnmqnx0/pwDgkzmZJDk1T7ZzVGURKv9hgHu3uPwS9TqkLvvMTuGtMRLk3q+yide 6j8= X-IronPort-AV: E=Sophos;i="5.64,433,1559545200"; d="scan'208";a="43686984" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 26 Aug 2019 05:09:06 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 26 Aug 2019 05:09:05 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 26 Aug 2019 05:09:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hB1+dT+Ad32QCxxPOJ1NR5cVBp0XDeZ51+mM/ljh8qbIG9gldNW/9aXyovNAjh5C//t7Wel7TdRtADt9zPGSvuLJBAtMon2NVGWYOQbOybdkVu9V9DIKEeu0hsYrl9+EKMLfwXtNRVHXjKRf34ta0lsbwdPSS3zVmOWVdmqYwhfCNXo4prVi8K1AlLy0cjlLy7AW9zeMBZKGydbLGPX3bU+wFNs4aHlvpQwQ83DNFTWEclT4zibwYS1Z5WjvTEurrsFk9PpZLSJFvT/c4CAYn8uaHbmPqU8/frcBiDZmZMXjZ6EJ2+LeLU2h49BTYamL+RL5d99U7MKWg7BPKTr5Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wzKEj7C2oecdyIVgmS+q8nCE1Ab6V9iG0C1/KPjXWOM=; b=Wm7xBvNy9fy/grFY3uS/eCkNO8H3yBIbpRWnL9DNXzNXSTr0A+INKlrQohQlkYbsei1HpjpyT7UU1fne+l/CsTJ32Oh9EX9RrhTIjyd4VMsd1X7BPmSXx7zsTPXFJTorKoCiduIGzpRwNiTJHIAv3Z36v08sho7Cepj4M/Vc3qz8HoM5A/fbJa9oHRbiqcKc8brpic1jgGP5eSx4fsZJYuGL0ZDI1yxunWu9+esyZwyEuq2bUYy2nOC6TOc5kpC96dnLoeBdgiWwC7U0c75cLvjp98ntIxEcPSCzJT6wXci6IFYIX0wJQ01DIDB0reOrEcF3bGOysmWgw4M+k3parQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wzKEj7C2oecdyIVgmS+q8nCE1Ab6V9iG0C1/KPjXWOM=; b=qL+PSksgUkyFPX6/ead0wIuN6zETiyp1Gs+Kn3nLBTLM/wjGmDu/fqBA756jlHKdc9LOhN4hPYw4Kq4baBVTn4c4KZNfwjLcpxj6Gcc+LE5ApnHwqVUPffKn37nRsLGFPc95ujv2GbAaZApiakr/ai12VUXbv98uGeD2v5bScHs= Received: from MN2PR11MB4448.namprd11.prod.outlook.com (52.135.39.157) by MN2PR11MB3678.namprd11.prod.outlook.com (20.178.252.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.21; Mon, 26 Aug 2019 12:09:03 +0000 Received: from MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::70c3:e929:4da2:60a5]) by MN2PR11MB4448.namprd11.prod.outlook.com ([fe80::70c3:e929:4da2:60a5%7]) with mapi id 15.20.2199.021; Mon, 26 Aug 2019 12:09:03 +0000 From: To: , , , , , , CC: , Subject: [RESEND PATCH v3 11/20] mtd: spi-nor: Add post_sfdp() hook to tweak flash config Thread-Topic: [RESEND PATCH v3 11/20] mtd: spi-nor: Add post_sfdp() hook to tweak flash config Thread-Index: AQHVXAcGVLYagwCSlEah3QOflpgycw== Date: Mon, 26 Aug 2019 12:08:52 +0000 Message-ID: <20190826120821.16351-12-tudor.ambarus@microchip.com> References: <20190826120821.16351-1-tudor.ambarus@microchip.com> In-Reply-To: <20190826120821.16351-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR09CA0046.eurprd09.prod.outlook.com (2603:10a6:802:28::14) To MN2PR11MB4448.namprd11.prod.outlook.com (2603:10b6:208:193::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 56c54d9c-bd66-4bfd-1e3d-08d72a1e28d3 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:MN2PR11MB3678; x-ms-traffictypediagnostic: MN2PR11MB3678: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 01415BB535 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(39860400002)(346002)(366004)(396003)(376002)(199004)(189003)(486006)(2616005)(476003)(6666004)(107886003)(316002)(14454004)(386003)(6506007)(76176011)(99286004)(52116002)(54906003)(110136005)(478600001)(102836004)(4326008)(25786009)(36756003)(446003)(26005)(11346002)(50226002)(81156014)(66066001)(8676002)(53936002)(81166006)(8936002)(6512007)(6486002)(6436002)(3846002)(6116002)(186003)(86362001)(305945005)(2201001)(7736002)(2906002)(64756008)(66446008)(1076003)(71190400001)(5660300002)(71200400001)(256004)(14444005)(66946007)(66556008)(66476007)(2501003);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB3678;H:MN2PR11MB4448.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: r2aopq3PFWxQPQGIySJrtXM987ZOsA+ZA5xZ5SMS+Hw/CtzwX0mI6Yipy+4kGHk++apI1PSU4C7su+wt42tKcKpkY5nh87wdqWC0YH2F7fJkqs2vLZi8fskPaPzXk8/883rYdqAgKXDOtBFSC8F0ogaPDlt8R2kjmS/sUX9M2Hh7w6PakDIcIBrRRkJ0WJ9INdxHNO2srARm8ck5rXryb95jrFovjqxw43aChRJpXPgYqgnmSIxgMGqRg8QiDHxZSLvx+JUTh5qAx/XAPePwiy3IX7v3LaqcLVCBfDsSWd5xKp/LQtq0PGTPf/XnpFG6q6YeqAsto8rgJzvlZLmp2/IY5Tvwuc0JSHU+/Z8jN60e4XFPlBXxfPn7l+Im1bgY7RTeRyIQM67kzzBUbPeaCKkKoLXPXC/F5dyPkGs9aWc= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 56c54d9c-bd66-4bfd-1e3d-08d72a1e28d3 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Aug 2019 12:08:52.0933 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: p3CIlEY5nZJJrx4peh0VKdAGzPmfb0ZmPTWCcdtTFsE1DMVkzfj5KTNkJSnFh8u2DOtaEOvlhxoSScZ9CNXoF3Z2pkRMbLQQdYuDw//lPFU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3678 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boris Brezillon SFDP tables are sometimes wrong and we need a way to override the config chosen by the SFDP parsing logic without discarding all of it. Add a new hook called after the SFDP parsing has taken place to deal with such problems. Signed-off-by: Boris Brezillon Signed-off-by: Tudor Ambarus --- v3: no changes, rebase on previous commits drivers/mtd/spi-nor/spi-nor.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 3f997797fa9d..b8caf5171ff5 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -158,6 +158,11 @@ struct sfdp_bfpt { * flash parameters when information provided by the flash_= info * table is incomplete or wrong. * @post_bfpt: called after the BFPT table has been parsed + * @post_sfdp: called after SFDP has been parsed (is also called for SPI N= ORs + * that do not support RDSFDP). Typically used to tweak variou= s + * parameters that could not be extracted by other means (i.e. + * when information provided by the SFDP/flash_info tables are + * incomplete or wrong). * * Those hooks can be used to tweak the SPI NOR configuration when the SFD= P * table is broken or not available. @@ -168,6 +173,7 @@ struct spi_nor_fixups { const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt, struct spi_nor_flash_parameter *params); + void (*post_sfdp)(struct spi_nor *nor); }; =20 struct flash_info { @@ -4299,6 +4305,22 @@ static void spi_nor_info_init_params(struct spi_nor = *nor) } =20 /** + * spi_nor_post_sfdp_fixups() - Updates the flash's parameters and setting= s + * after SFDP has been parsed (is also called for SPI NORs that do not + * support RDSFDP). + * @nor: pointer to a 'struct spi_nor' + * + * Typically used to tweak various parameters that could not be extracted = by + * other means (i.e. when information provided by the SFDP/flash_info tabl= es + * are incomplete or wrong). + */ +static void spi_nor_post_sfdp_fixups(struct spi_nor *nor) +{ + if (nor->info->fixups && nor->info->fixups->post_sfdp) + nor->info->fixups->post_sfdp(nor); +} + +/** * spi_nor_late_init_params() - Late initialization of default flash param= eters. * @nor: pointer to a 'struct spi_nor' * @@ -4341,7 +4363,14 @@ static void spi_nor_late_init_params(struct spi_nor = *nor) * flash parameters and settings imediately after parsing the Basic Fla= sh * Parameter Table. * - * 4/ Late default flash parameters initialization, used when the + * which can be overwritten by: + * 4/ Post SFDP flash parameters initialization. Used to tweak various + * parameters that could not be extracted by other means (i.e. when + * information provided by the SFDP/flash_info tables are incomplete or + * 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. * spi_nor_late_init_params() */ @@ -4355,6 +4384,8 @@ static void spi_nor_init_params(struct spi_nor *nor) !(nor->info->flags & SPI_NOR_SKIP_SFDP)) spi_nor_sfdp_init_params(nor); =20 + spi_nor_post_sfdp_fixups(nor); + spi_nor_late_init_params(nor); } =20 --=20 2.9.5