Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp259038ybm; Thu, 28 May 2020 22:38:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVvZUH+ZL0rbHpVAS16XPcCYnrIRxp9H3u+3K9eLIFcyxO/jNJAYWsF/lSjuSiF6krYeof X-Received: by 2002:a05:6402:16d6:: with SMTP id r22mr6263567edx.289.1590730702713; Thu, 28 May 2020 22:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590730702; cv=none; d=google.com; s=arc-20160816; b=EI+KujbzMeytIHntXfnnhgZSmRW+22zPjUODhVVAWnwDqCbg6JACbAwOYS7FHKmTK6 tvbt9/SWFLbpQF62DAuKS4qorlXykF/7K0CTrwoudzK0TsNelIZTc/OazBRB78OJ4rfj 4KglYwUoBBH94HoCX285Hd4QJn1l+i2EVuOT8UVJ579iMkAatE6TYeQA2Z6stWwDkU+5 N8rTd6/1rZRCSFOk3kfN+b48KjOeVvPgjh2Ai4lJzbKGPvfOwQUem7c+ucD226D6dSb0 5YSDLq/ka+2G6ZMyGmgMG14t6rkFz0KovpdLAMexTVHo+r7TbKsoyd2aY5seHLYU3lKj EAig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=x4b+tZnudnBGkz8ZbHyrknDO2Gxw7ig76WcHpFOy6Bg=; b=XX8GBZSuh/03DFXmkAXWP+5whUsA60dGsGSK3xGZq53EoN/zdC3L8/xSiZigMrHA7R 6G3UedxTyQM0JsrOSutSWmlVsLSgJC7Yv51qiaGwpuAKAuEytm8wcU2e33uC/bJBekto Yd6oh5LQblTNmOLQ4VZt8iOGqkP0fMHoGeI2o3rd9Zb2Vo7ov4qaPJnP0tWuRg2aD+Fx vJFp4gWnqoEAYBgGQURPPbk3UypQgcmGsIzD+i8tZJs4ksgJx7xodeRmGOlW3kl6N+GT RQSPyA3+FNRtv0qNaTta+bKlREi65x5rWJoE+6GNySsQI+WZl9CMQPgZ5iuCtIIWlhXm 1akg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r13si5367469edc.201.2020.05.28.22.37.59; Thu, 28 May 2020 22:38:22 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726041AbgE2FgK (ORCPT + 99 others); Fri, 29 May 2020 01:36:10 -0400 Received: from mga14.intel.com ([192.55.52.115]:3675 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbgE2FgI (ORCPT ); Fri, 29 May 2020 01:36:08 -0400 IronPort-SDR: VYBQpytP0low8wbaM9K1kZITtXCc1zpeFGM7xLF+4YQ+9uH2zWyTYeAdr8pzYnKH2+acsWBMSG HnpsIO+oU2gA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 22:36:04 -0700 IronPort-SDR: tFxe2BIxiPncpHrnHQKfWj9p753Jl38BkPgEowEyCCXBfhuxe0OTUteghpYeL/ARwT5aZQMPBN 8jDENjB0GgZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,447,1583222400"; d="scan'208";a="376607924" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.163]) by fmsmga001.fm.intel.com with SMTP; 28 May 2020 22:36:00 -0700 Received: by lahna (sSMTP sendmail emulation); Fri, 29 May 2020 08:36:00 +0300 Date: Fri, 29 May 2020 08:36:00 +0300 From: Mika Westerberg To: Vignesh Raghavendra Cc: Daniel Walker , Andrew Morton , Bobby Liu , xe-linux-external@cisco.com, Tudor Ambarus , Miquel Raynal , Richard Weinberger , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mtd: spi-nor: create/Export parameter softwareseq for intel-spi driver to user Message-ID: <20200529053600.GG247495@lahna.fi.intel.com> References: <20200518175930.10948-1-danielwa@cisco.com> <589a2ef5-e086-766d-44b3-1d2b990f1f67@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <589a2ef5-e086-766d-44b3-1d2b990f1f67@ti.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I wonder if we can "generalize" this a bit and use SW sequencer to run commands HW sequencer does not support? The BIOS can then setup the allowed SW sequencer opcodes and lock the thing down if needed. There are couple of other commands related to FSR register where this could be useful. On Thu, May 28, 2020 at 04:16:38PM +0530, Vignesh Raghavendra wrote: > +Mika Westerberg original author of the driver > > On 18/05/20 11:29 pm, Daniel Walker wrote: > > From: Bobby Liu > > > > How to use: > > append softwareseq=1 while probe the driver. > > example: > > modprobe intel-spi writeable=1 softwareseq=1 > > it will let driver use software sequence to write register for opt=EN4B > > by default it's 0 if not specified, driver will do usual HW cycle > > > > Could some one from Intel please review this patch? > > Regards > Vignesh > > > Why this parameter is posted to user: > > Intel PCH provides two groups of registers for SPI flash operation, > > Hard Sequence registers and Software Sequence registers, > > corresponding to intel_spi_hw_cycle() and intel_spi_sw_cycle() > > respectively in driver code. But HW sequence register won't send EN4B > > opcode to SPI flash. BIOS code use SW register to send EN4B. > > > > On some Cisco routers, two 32M SPI flashes, which require 4-byte address mode enabled, > > are physically connected to an FPGA, one flash is active and one is inactive. > > When we do BIOS upgrade, we need switch to the inactive one, > > but unfortunately, this one is still 3-byte address mode as default, > > after we do real-time switch, we need reload SPI driver to send EN4B code to > > enable 4-byte address mode. > > > > Refering to our BIOS code, Software sequence register is processed > > while sending EN4B opcode. So here we use sw_cycle in driver for EN4B as well. > > > > Why I don't just easily use software sequence for all: > > 1.It will impact all flash operation, include flash W/R, high risk > > 2.The only SPI type I can use is INTEL_SPI_BXT according to datasheet, > > this will require using hw seq. > > I tried to specify other SPI type, it couldn't work with Intel PCH. > > If I force SW seq for all, during boot up, sw_cycle fails to read > > vendor ID. > > > > In conclusion, I only use SW cycle for EN4B opcode to minimize impact. > > It won't impact other users as well. > > > > Why the default flash can work at 4-byte address mode: > > BIOS sets 4-byte address mode for the current active SPI flash with SW seq registers. > > So we don't need append softwareseq=1 for normal boot up script, > > it will only be used in BIOS upgrade script. > > > > Cc: xe-linux-external@cisco.com > > Signed-off-by: Bobby Liu > > [ danielwa: edited the commit message a little. ] > > Signed-off-by: Daniel Walker > > --- > > drivers/mtd/spi-nor/controllers/intel-spi.c | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/drivers/mtd/spi-nor/controllers/intel-spi.c b/drivers/mtd/spi-nor/controllers/intel-spi.c > > index 61d2a0ad2131..e5a3d51a2e4d 100644 > > --- a/drivers/mtd/spi-nor/controllers/intel-spi.c > > +++ b/drivers/mtd/spi-nor/controllers/intel-spi.c > > @@ -163,6 +163,10 @@ static bool writeable; > > module_param(writeable, bool, 0); > > MODULE_PARM_DESC(writeable, "Enable write access to SPI flash chip (default=0)"); > > > > +static bool softwareseq; > > +module_param(softwareseq, bool, 0); > > +MODULE_PARM_DESC(softwareseq, "Use software sequence for register write (default=0)"); > > + > > static void intel_spi_dump_regs(struct intel_spi *ispi) > > { > > u32 value; > > @@ -619,6 +623,18 @@ static int intel_spi_write_reg(struct spi_nor *nor, u8 opcode, const u8 *buf, > > if (ret) > > return ret; > > > > + /* > > + * Intel Skylake will not send EN4B to SPI flash if we use HW sequence > > + * Here export one interface "softwareseq" to OS, > > + * let driver user decide if use SW sequence or not > > + */ > > + if (opcode == SPINOR_OP_EN4B && softwareseq) { > > + dev_info(ispi->dev, > > + "Write register opcode is SPINOR_OP_EN4B, do SW cycle\n"); > > + return intel_spi_sw_cycle(ispi, opcode, len, > > + OPTYPE_WRITE_NO_ADDR); > > + } > > + > > if (ispi->swseq_reg) > > return intel_spi_sw_cycle(ispi, opcode, len, > > OPTYPE_WRITE_NO_ADDR); > >