[PATCH 2/3] mtd: spi-nor: aspeed: Disable zero size segments on the AST2600

Cédric Le Goater clg at kaod.org
Mon Sep 30 20:05:55 AEST 2019


A disabled segment for a CS should have a zero value in its segment
register. The driver was generating an incorrect value which
overlapped with segment CS0. Accesses to the flash were blocked and
Linux hung.

Fixes: 3635b880313a ("mtd: spi-nor: aspeed: add initial support for ast2600")
Signed-off-by: Cédric Le Goater <clg at kaod.org>
---
 drivers/mtd/spi-nor/aspeed-smc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
index ad9e04fdb8ad..ff367c70001d 100644
--- a/drivers/mtd/spi-nor/aspeed-smc.c
+++ b/drivers/mtd/spi-nor/aspeed-smc.c
@@ -347,8 +347,12 @@ static u32 aspeed_smc_segment_end_ast2600(
 static u32 aspeed_smc_segment_reg_ast2600(
 	struct aspeed_smc_controller *controller, u32 start, u32 end)
 {
-    return ((start & AST2600_SEG_ADDR_MASK) >> 16) |
-	    ((end - 1) & AST2600_SEG_ADDR_MASK);
+	/* disable zero size segments */
+	if (start == end)
+		return 0;
+
+	return ((start & AST2600_SEG_ADDR_MASK) >> 16) |
+		((end - 1) & AST2600_SEG_ADDR_MASK);
 }
 
 /*
-- 
2.21.0



More information about the openbmc mailing list