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 9F68CC433F5 for ; Thu, 3 Mar 2022 06:29:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4BCDC83D35; Thu, 3 Mar 2022 07:29:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="YCerwxjo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9CB5783D26; Thu, 3 Mar 2022 07:29:07 +0100 (CET) Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 95D6F83D21 for ; Thu, 3 Mar 2022 07:28:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jaimeliao.tw@gmail.com Received: by mail-pg1-x529.google.com with SMTP id o23so3666966pgk.13 for ; Wed, 02 Mar 2022 22:28:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UpnPw8IgUlEr+7g3eRnevUXXq9lxDjX3TLt/suwRnl0=; b=YCerwxjoNu4r3bNkUJSR8oHCnf7iw8k//LR00efm4Cag8ykYgHJXJKg6TxstEDQsM+ Lr+WXns/yar6ht91PuK+a1PVisY+i10T/4i6a9W2kTtA4sqXnYL2AXnmlnQEqwOOv58h QSCBPzbUeHbL2FlONeh425b7mvkTZToIVZBjBEBNpBK60f4D7obNKpX4vYTm2byaQaCs ZBQ00GcJjv5N/HJnWRKWJOBEnzCQiUM9Fa6U7E2lhMq5vPz4jX7e/G4x9uAkmOTGsgsl izfC6YmcV8RzLgnL4vymGTnhWyOUZdDJMOayldZpbSVfecgqm1eDJlMZxiwKFYCoynJj 6kGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UpnPw8IgUlEr+7g3eRnevUXXq9lxDjX3TLt/suwRnl0=; b=A3OAQlfuzSX7TW738RBrhYRGjlsu0UN3HHlscriqw1UhR2LUAhdhUtDzU4Mp3XYKRJ u/JDTIWupkDXtH5nLQHS1DOTYXkBB1VLtZL+WuXeQ2ByZpDx9Ekp0A/CdYGL0y6SYN5m ayP2oByDsdizwc6IKV2o93jgMC2Htp3etaO3RQ/MYWWlqareVxph4g0/VhvJWKww+7+H YBIwvR3Xrjs+nb7MztfGbeUDQV2L41bwe4fwTXM3hZqjbb90100Glnl0Vrh9v0HrrAw3 LY/krI8EP5WfyXpv9dEjTWt/oGf0t7+cDIJvm+CfW6rDsSEG5i2sTBu18tM12P3m5nMQ TQNA== X-Gm-Message-State: AOAM530CzZrskxbb6nPDchGQJplXumVNUDjvGUQw3gvkiI5xDdheI/8N cIDMUvVNokljhAUKLOZ21DEBYQyHSsY= X-Google-Smtp-Source: ABdhPJyQOdV7NAFnKUUi8PuMZOf+oZaTFrYJgwRtSnBufylKT6dUR4wvBKeoRRAWi/HVm8TKUhk83Q== X-Received: by 2002:a05:6a00:26e0:b0:4e1:7131:de2b with SMTP id p32-20020a056a0026e000b004e17131de2bmr36728144pfw.20.1646288935746; Wed, 02 Mar 2022 22:28:55 -0800 (PST) Received: from localhost.localdomain ([123.51.145.88]) by smtp.gmail.com with ESMTPSA id b21-20020a056a000cd500b004e1e0d3ed18sm1167904pfv.2.2022.03.02.22.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 22:28:55 -0800 (PST) From: JaimeLiao To: u-boot@lists.denx.de, jagan@amarulasolutions.com, vigneshr@ti.com, miquel.raynal@bootlin.com Cc: zhengxunli@mxic.com.tw, p.yadav@ti.com, tudor.ambarus@microchip.com, jaimeliao@mxic.com.tw, JaimeLiao Subject: [PATCH v7 3/4] mtd: spi-nor: Parse SFDP SCCR Map Date: Thu, 3 Mar 2022 14:28:26 +0800 Message-Id: <20220303062827.26664-4-jaimeliao.tw@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220303062827.26664-1-jaimeliao.tw@gmail.com> References: <20220303062827.26664-1-jaimeliao.tw@gmail.com> 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 Parse SCCR 22nd dword and check DTR Octal Mode Enable Volatile bit for Octal DTR enable Signed-off-by: JaimeLiao --- drivers/mtd/spi/spi-nor-core.c | 52 ++++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 1 + 2 files changed, 53 insertions(+) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index b4f1a6985c..ffa168edd2 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -63,6 +63,10 @@ struct sfdp_parameter_header { #define SFDP_SECTOR_MAP_ID 0xff81 /* Sector Map Table */ #define SFDP_SST_ID 0x01bf /* Manufacturer specific Table */ #define SFDP_PROFILE1_ID 0xff05 /* xSPI Profile 1.0 Table */ +#define SFDP_SCCR_MAP_ID 0xff87 /* + * Status, Control and Configuration + * Register Map. + */ #define SFDP_SIGNATURE 0x50444653U #define SFDP_JESD216_MAJOR 1 @@ -172,6 +176,9 @@ struct sfdp_header { #define PROFILE1_DWORD5_DUMMY_100MHZ GENMASK(11, 7) #define PROFILE1_DUMMY_DEFAULT 20 +/* Status, Control and Configuration Register Map(SCCR) */ +#define SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE BIT(31) + struct sfdp_bfpt { u32 dwords[BFPT_DWORD_MAX]; }; @@ -2434,6 +2441,44 @@ out: return ret; } +/** + * spi_nor_parse_sccr() - Parse the Status, Control and Configuration Register + * Map. + * @nor: pointer to a 'struct spi_nor' + * @sccr_header: pointer to the 'struct sfdp_parameter_header' describing + * the SCCR Map table length and version. + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_parse_sccr(struct spi_nor *nor, + const struct sfdp_parameter_header *sccr_header) +{ + u32 *table, addr; + size_t len; + int ret, i; + + len = sccr_header->length * sizeof(*table); + table = kmalloc(len, GFP_KERNEL); + if (!table) + return -ENOMEM; + + addr = SFDP_PARAM_HEADER_PTP(sccr_header); + ret = spi_nor_read_sfdp(nor, addr, len, table); + if (ret) + goto out; + + /* Fix endianness of the table DWORDs. */ + for (i = 0; i < sccr_header->length; i++) + table[i] = le32_to_cpu(table[i]); + + if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE, table[22])) + nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE; + +out: + kfree(table); + return ret; +} + /** * spi_nor_parse_sfdp() - parse the Serial Flash Discoverable Parameters. * @nor: pointer to a 'struct spi_nor' @@ -2540,6 +2585,10 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor, err = spi_nor_parse_profile1(nor, param_header, params); break; + case SFDP_SCCR_MAP_ID: + err = spi_nor_parse_sccr(nor, param_header); + break; + default: break; } @@ -3583,6 +3632,9 @@ static int spi_nor_octal_dtr_enable(struct spi_nor *nor) nor->write_proto == SNOR_PROTO_8_8_8_DTR)) return 0; + if (!(nor->flags & SNOR_F_IO_MODE_EN_VOLATILE)) + return 0; + ret = nor->octal_dtr_enable(nor); if (ret) return ret; diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 8682368f2f..10c7b6e4c3 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -287,6 +287,7 @@ enum spi_nor_option_flags { SNOR_F_USE_CLSR = BIT(5), SNOR_F_BROKEN_RESET = BIT(6), SNOR_F_SOFT_RESET = BIT(7), + SNOR_F_IO_MODE_EN_VOLATILE = BIT(8), }; struct spi_nor; -- 2.17.1