From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751589AbdH1VyJ (ORCPT ); Mon, 28 Aug 2017 17:54:09 -0400 Received: from mail-io0-f182.google.com ([209.85.223.182]:35154 "EHLO mail-io0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751547AbdH1VyF (ORCPT ); Mon, 28 Aug 2017 17:54:05 -0400 MIME-Version: 1.0 In-Reply-To: References: <1503954854-30963-1-git-send-email-mw@semihalf.com> <1503954854-30963-2-git-send-email-mw@semihalf.com> From: Marcin Wojtas Date: Mon, 28 Aug 2017 23:54:03 +0200 Message-ID: Subject: Re: [PATCH 1/2] mtd: spi-nor: add an option to force 3byte adressing mode To: Geert Uytterhoeven Cc: "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , MTD Maling List , linux-spi , Rob Herring , Mark Rutland , Will Deacon , Cyrille Pitchen , Marek Vasut , Mark Brown , Thomas Petazzoni , Gregory Clement , Nadav Haklai , Neta Zur Hershkovits , Omri Itach , Hanna Hawa , Grzegorz Jaszczyk , Tomasz Nowicki Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Geert, >> +- spi-3byte-addressing - Empty property indicating device access to be done >> + only in 3byte addressing mode. > > spi-force-3byte-addressing? I can change it, no problem. I thought of this, but was affraid if the property wouldn't be too long. > >> Some SPI controllers and devices support Dual and Quad SPI transfer mode. >> It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4 >> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c >> index 1413828..029c87d 100644 >> --- a/drivers/mtd/spi-nor/spi-nor.c >> +++ b/drivers/mtd/spi-nor/spi-nor.c >> @@ -2002,7 +2002,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, >> if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || >> info->flags & SPI_NOR_4B_OPCODES) >> spi_nor_set_4byte_opcodes(nor, info); >> - else >> + else if (of_property_read_bool(np, "spi-3byte-addressing")) { >> + /* >> + * Do not enter 4byte mode in order to prevent >> + * the early bootloader to come up on non-default >> + * SPI NOR memory during boot. Limit accessible >> + * size to 16MiB. >> + */ >> + nor->addr_width = 3; >> + mtd->size = 0x1000000; > > What if the device is smaller than 16 MiB? > > mtd->size = min(mtd->size, 0x1000000); Not needed - this code is executed only for mtd->size > 0x1000000. See bigger context: if (info->addr_width) nor->addr_width = info->addr_width; else if (mtd->size > 0x1000000) { /* enable 4-byte addressing if the device exceeds 16MiB */ nor->addr_width = 4; if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || info->flags & SPI_NOR_4B_OPCODES) spi_nor_set_4byte_opcodes(nor, info); else if (of_property_read_bool(np, "spi-3byte-addressing")) { /* * Do not enter 4byte mode in order to prevent * the early bootloader to come up on non-default * SPI NOR memory during boot. Limit accessible * size to 16MiB. */ nor->addr_width = 3; mtd->size = 0x1000000; dev_info(dev, "Force 3B addressing mode\n"); } else set_4byte(nor, info, 1); } else { nor->addr_width = 3; } Best regards, Marcin From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcin Wojtas Subject: Re: [PATCH 1/2] mtd: spi-nor: add an option to force 3byte adressing mode Date: Mon, 28 Aug 2017 23:54:03 +0200 Message-ID: References: <1503954854-30963-1-git-send-email-mw@semihalf.com> <1503954854-30963-2-git-send-email-mw@semihalf.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org" , MTD Maling List , linux-spi , Rob Herring , Mark Rutland , Will Deacon , Cyrille Pitchen , Marek Vasut , Mark Brown , Thomas Petazzoni , Gregory Clement , Nadav Haklai , Neta Zur Hershkovits , Omri Itach , Hanna Hawa , Grzegorz Jaszczyk , Tomasz Now To: Geert Uytterhoeven Return-path: In-Reply-To: Sender: linux-spi-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Hi Geert, >> +- spi-3byte-addressing - Empty property indicating device access to be done >> + only in 3byte addressing mode. > > spi-force-3byte-addressing? I can change it, no problem. I thought of this, but was affraid if the property wouldn't be too long. > >> Some SPI controllers and devices support Dual and Quad SPI transfer mode. >> It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4 >> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c >> index 1413828..029c87d 100644 >> --- a/drivers/mtd/spi-nor/spi-nor.c >> +++ b/drivers/mtd/spi-nor/spi-nor.c >> @@ -2002,7 +2002,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, >> if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || >> info->flags & SPI_NOR_4B_OPCODES) >> spi_nor_set_4byte_opcodes(nor, info); >> - else >> + else if (of_property_read_bool(np, "spi-3byte-addressing")) { >> + /* >> + * Do not enter 4byte mode in order to prevent >> + * the early bootloader to come up on non-default >> + * SPI NOR memory during boot. Limit accessible >> + * size to 16MiB. >> + */ >> + nor->addr_width = 3; >> + mtd->size = 0x1000000; > > What if the device is smaller than 16 MiB? > > mtd->size = min(mtd->size, 0x1000000); Not needed - this code is executed only for mtd->size > 0x1000000. See bigger context: if (info->addr_width) nor->addr_width = info->addr_width; else if (mtd->size > 0x1000000) { /* enable 4-byte addressing if the device exceeds 16MiB */ nor->addr_width = 4; if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || info->flags & SPI_NOR_4B_OPCODES) spi_nor_set_4byte_opcodes(nor, info); else if (of_property_read_bool(np, "spi-3byte-addressing")) { /* * Do not enter 4byte mode in order to prevent * the early bootloader to come up on non-default * SPI NOR memory during boot. Limit accessible * size to 16MiB. */ nor->addr_width = 3; mtd->size = 0x1000000; dev_info(dev, "Force 3B addressing mode\n"); } else set_4byte(nor, info, 1); } else { nor->addr_width = 3; } Best regards, Marcin -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io0-x232.google.com ([2607:f8b0:4001:c06::232]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmRzF-00010W-Gl for linux-mtd@lists.infradead.org; Mon, 28 Aug 2017 21:54:27 +0000 Received: by mail-io0-x232.google.com with SMTP id 81so8354500ioj.5 for ; Mon, 28 Aug 2017 14:54:05 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1503954854-30963-1-git-send-email-mw@semihalf.com> <1503954854-30963-2-git-send-email-mw@semihalf.com> From: Marcin Wojtas Date: Mon, 28 Aug 2017 23:54:03 +0200 Message-ID: Subject: Re: [PATCH 1/2] mtd: spi-nor: add an option to force 3byte adressing mode To: Geert Uytterhoeven Cc: "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , MTD Maling List , linux-spi , Rob Herring , Mark Rutland , Will Deacon , Cyrille Pitchen , Marek Vasut , Mark Brown , Thomas Petazzoni , Gregory Clement , Nadav Haklai , Neta Zur Hershkovits , Omri Itach , Hanna Hawa , Grzegorz Jaszczyk , Tomasz Nowicki Content-Type: text/plain; charset="UTF-8" List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hi Geert, >> +- spi-3byte-addressing - Empty property indicating device access to be done >> + only in 3byte addressing mode. > > spi-force-3byte-addressing? I can change it, no problem. I thought of this, but was affraid if the property wouldn't be too long. > >> Some SPI controllers and devices support Dual and Quad SPI transfer mode. >> It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4 >> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c >> index 1413828..029c87d 100644 >> --- a/drivers/mtd/spi-nor/spi-nor.c >> +++ b/drivers/mtd/spi-nor/spi-nor.c >> @@ -2002,7 +2002,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, >> if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || >> info->flags & SPI_NOR_4B_OPCODES) >> spi_nor_set_4byte_opcodes(nor, info); >> - else >> + else if (of_property_read_bool(np, "spi-3byte-addressing")) { >> + /* >> + * Do not enter 4byte mode in order to prevent >> + * the early bootloader to come up on non-default >> + * SPI NOR memory during boot. Limit accessible >> + * size to 16MiB. >> + */ >> + nor->addr_width = 3; >> + mtd->size = 0x1000000; > > What if the device is smaller than 16 MiB? > > mtd->size = min(mtd->size, 0x1000000); Not needed - this code is executed only for mtd->size > 0x1000000. See bigger context: if (info->addr_width) nor->addr_width = info->addr_width; else if (mtd->size > 0x1000000) { /* enable 4-byte addressing if the device exceeds 16MiB */ nor->addr_width = 4; if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || info->flags & SPI_NOR_4B_OPCODES) spi_nor_set_4byte_opcodes(nor, info); else if (of_property_read_bool(np, "spi-3byte-addressing")) { /* * Do not enter 4byte mode in order to prevent * the early bootloader to come up on non-default * SPI NOR memory during boot. Limit accessible * size to 16MiB. */ nor->addr_width = 3; mtd->size = 0x1000000; dev_info(dev, "Force 3B addressing mode\n"); } else set_4byte(nor, info, 1); } else { nor->addr_width = 3; } Best regards, Marcin From mboxrd@z Thu Jan 1 00:00:00 1970 From: mw@semihalf.com (Marcin Wojtas) Date: Mon, 28 Aug 2017 23:54:03 +0200 Subject: [PATCH 1/2] mtd: spi-nor: add an option to force 3byte adressing mode In-Reply-To: References: <1503954854-30963-1-git-send-email-mw@semihalf.com> <1503954854-30963-2-git-send-email-mw@semihalf.com> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Geert, >> +- spi-3byte-addressing - Empty property indicating device access to be done >> + only in 3byte addressing mode. > > spi-force-3byte-addressing? I can change it, no problem. I thought of this, but was affraid if the property wouldn't be too long. > >> Some SPI controllers and devices support Dual and Quad SPI transfer mode. >> It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4 >> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c >> index 1413828..029c87d 100644 >> --- a/drivers/mtd/spi-nor/spi-nor.c >> +++ b/drivers/mtd/spi-nor/spi-nor.c >> @@ -2002,7 +2002,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, >> if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || >> info->flags & SPI_NOR_4B_OPCODES) >> spi_nor_set_4byte_opcodes(nor, info); >> - else >> + else if (of_property_read_bool(np, "spi-3byte-addressing")) { >> + /* >> + * Do not enter 4byte mode in order to prevent >> + * the early bootloader to come up on non-default >> + * SPI NOR memory during boot. Limit accessible >> + * size to 16MiB. >> + */ >> + nor->addr_width = 3; >> + mtd->size = 0x1000000; > > What if the device is smaller than 16 MiB? > > mtd->size = min(mtd->size, 0x1000000); Not needed - this code is executed only for mtd->size > 0x1000000. See bigger context: if (info->addr_width) nor->addr_width = info->addr_width; else if (mtd->size > 0x1000000) { /* enable 4-byte addressing if the device exceeds 16MiB */ nor->addr_width = 4; if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || info->flags & SPI_NOR_4B_OPCODES) spi_nor_set_4byte_opcodes(nor, info); else if (of_property_read_bool(np, "spi-3byte-addressing")) { /* * Do not enter 4byte mode in order to prevent * the early bootloader to come up on non-default * SPI NOR memory during boot. Limit accessible * size to 16MiB. */ nor->addr_width = 3; mtd->size = 0x1000000; dev_info(dev, "Force 3B addressing mode\n"); } else set_4byte(nor, info, 1); } else { nor->addr_width = 3; } Best regards, Marcin