Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp323592ybm; Thu, 28 May 2020 03:49:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDhjh4DnVnr+g9UuCh42U6oX1KV0ugpR1/gU/mtcb6zwVthrXYfrY6CXNS5/tBcnyju9YS X-Received: by 2002:a17:906:70d:: with SMTP id y13mr2279286ejb.99.1590662959859; Thu, 28 May 2020 03:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590662959; cv=none; d=google.com; s=arc-20160816; b=wwohc3Co6T7Pu5gvcUAJDk//1oEHLte9+ASuPmwXf93UNY04b6hX5ylN3GVEN5lE5b 0+p2X4FV2VXp/X+yn+3jZ8L3VZ5zdW7fuLJ6wSqDErRGXjnWjfd2aX/a2rt2zhebOWBm Cka+D29dW6zrSgiy4YtyQ3HrNvZStQdbChLzxQtP9ZQdFYXQWi+PxraHT1maL79ljMot otuovJKKwibRjVl53lQWvMyMjXXy72/N+HlmrRMCGTtKU2/ZHGLeS32WXrn3Hfs9YexG u7Yg6HIiWqlr7jpph0ssKej3tC/Z3OFdAqKqABXW8GYc50XpnVL2jbJvAl8qWedMOmxp fZ6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=ZPjFAkrhohtOWysHkDufv/up5EjeMBFf0vptLVKfvv8=; b=bu+gRt2f+jS4y5/FcqnJA0wbdkhRJUrUXl3InsSMkz/9nT3C+xPUm/Mb56Gi4+VOjC IFpnlu9O/DTb81KWwYB4l2ezlu/gVbEYnsAqcM0g2X8BMeKRimRJa6yq9VcuHFRNXJ8q 8lEGmz9U5GITsz+seMorJhEY6xx/gl0zIh8JpId9bqbIKqwDlQq5FFMfc8njxSX/5bQH +QI1NNhjPVhMaF48kdq0EGKlIxvAfor54LWgf32Jo6NKMP6t19y+koADvnFNAPz1CSvU 6FUid2Bej9ZR98igQxJ3Py7TQ0NnclKAiZxBlW8raz6Mp4x25UNT9hCjm1HECelxEuT9 ksXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VKqdkfJw; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d6si3271967edv.364.2020.05.28.03.48.56; Thu, 28 May 2020 03:49:19 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VKqdkfJw; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387956AbgE1KrG (ORCPT + 99 others); Thu, 28 May 2020 06:47:06 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:58334 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387907AbgE1KrG (ORCPT ); Thu, 28 May 2020 06:47:06 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 04SAkhE8004770; Thu, 28 May 2020 05:46:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1590662803; bh=ZPjFAkrhohtOWysHkDufv/up5EjeMBFf0vptLVKfvv8=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=VKqdkfJw+vMDIUfjPknI8oiw+BLVIbXKLkbP+DA7UwJEC/5nb/94Nzj3gr79TdwLt JCvVPgveTO7cnAOc/iAaTJ+Kl0bjxb64nxUaL2+3PYNcUeGNlIZG80hOYEdFsVFWpm 7iPQCeW2tkdgKFeI//rFS78DBr9F6Zv8pJtOlsCY= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 04SAkhP5115978 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 28 May 2020 05:46:43 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 28 May 2020 05:46:42 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 28 May 2020 05:46:43 -0500 Received: from [10.250.234.195] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 04SAkcw4106483; Thu, 28 May 2020 05:46:39 -0500 Subject: Re: [PATCH 1/2] mtd: spi-nor: create/Export parameter softwareseq for intel-spi driver to user To: Daniel Walker , Andrew Morton CC: Bobby Liu , , Tudor Ambarus , Miquel Raynal , Richard Weinberger , , , Mika Westerberg References: <20200518175930.10948-1-danielwa@cisco.com> From: Vignesh Raghavendra Message-ID: <589a2ef5-e086-766d-44b3-1d2b990f1f67@ti.com> Date: Thu, 28 May 2020 16:16:38 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200518175930.10948-1-danielwa@cisco.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +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); >