-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aspeed: linux-6.0: add shutdown method for ast2500-spi
Summary: Originally the patch file #0520 (adding shutdown method for aspeed-spi) is only applied to wedge400 to fix the reboot hang problem, but recently we found the similar failure on minipack, thus we decide to move the patch to meta-aspeed layer (applied to all platforms). The original patch is "improved" to make sure it's no-op in AST24XX and AST26XX, because: - ASPEED confirmed the patch was not needed on AST26XX. - We have never seen reboot hang problem on AST24XX, and we are not sure if it's safe to apply the logic to AST24XX, either. Test Plan: 1) "bitbake wedge400-image" succeeded. 2) "bitbake minipack-image" succeeded. 3) "bitbake fuji-image" succceeded. 4) rebooted fuji image for a few times: no issue found. 5) rebooted minipack image for a few times: no issue found. Reviewed By: williamspatrick Differential Revision: D44658087 fbshipit-source-id: 943590cda5b421e3d7f49c59b7fc9363c26d7960
- Loading branch information
1 parent
760263e
commit dd34cee
Showing
3 changed files
with
104 additions
and
68 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
...ernel/linux/files/patches/0151-spi-aspeed-add-shutdown-path-for-AST25XX-SPI-control.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
From fd31e7de61b461797f7f1827fb227ed45e1314f1 Mon Sep 17 00:00:00 2001 | ||
From: dhineskumareswaran <dhineskumar.eswaran@celestica.com> | ||
Date: Mon, 5 Dec 2022 12:17:20 +0000 | ||
Subject: [PATCH] spi: aspeed: add shutdown path for AST25XX SPI controller | ||
|
||
Summary: | ||
Restoring the register back to default state by adding shutdown | ||
path in spi-aspeed-smc driver. | ||
|
||
Problem statement: | ||
On the AST25XX chip, sometimes the flash gets stuck during the | ||
reset state (reboot). | ||
|
||
Root Cause: | ||
Some timing issues are happening in flash reset logic. | ||
|
||
Solution: | ||
In reset path, restoring all FMC related register back to default state. | ||
--- | ||
drivers/spi/spi-aspeed-smc.c | 26 ++++++++++++++++++++++++++ | ||
1 file changed, 26 insertions(+) | ||
|
||
diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c | ||
index faf877e52bfe..1bc9fd4382f0 100644 | ||
--- a/drivers/spi/spi-aspeed-smc.c | ||
+++ b/drivers/spi/spi-aspeed-smc.c | ||
@@ -46,6 +46,8 @@ | ||
|
||
/* CEx Address Decoding Range Register */ | ||
#define CE0_SEGMENT_ADDR_REG 0x30 | ||
+#define CE1_SEGMENT_ADDR_REG 0x34 | ||
+#define CE2_SEGMENT_ADDR_REG 0x38 | ||
|
||
/* CEx Read timing compensation register */ | ||
#define CE0_TIMING_COMPENSATION_REG 0x94 | ||
@@ -84,6 +86,7 @@ struct aspeed_spi_data { | ||
u32 (*segment_reg)(struct aspeed_spi *aspi, u32 start, u32 end); | ||
int (*calibrate)(struct aspeed_spi_chip *chip, u32 hdiv, | ||
const u8 *golden_buf, u8 *test_buf); | ||
+ void (*shutdown)(struct aspeed_spi *aspi); | ||
}; | ||
|
||
#define ASPEED_SPI_MAX_NUM_CS 5 | ||
@@ -800,6 +803,14 @@ static int aspeed_spi_remove(struct platform_device *pdev) | ||
return 0; | ||
} | ||
|
||
+static void aspeed_spi_shutdown(struct platform_device *pdev) | ||
+{ | ||
+ struct aspeed_spi *aspi = platform_get_drvdata(pdev); | ||
+ | ||
+ if (aspi->data->shutdown) | ||
+ aspi->data->shutdown(aspi); | ||
+} | ||
+ | ||
/* | ||
* AHB mappings | ||
*/ | ||
@@ -1105,6 +1116,18 @@ static int aspeed_spi_ast2600_calibrate(struct aspeed_spi_chip *chip, u32 hdiv, | ||
return -1; | ||
} | ||
|
||
+static void aspeed_spi_ast2500_shutdown(struct aspeed_spi *aspi) | ||
+{ | ||
+ /* restoring the register which we used before to default*/ | ||
+ writel(0x8000002A, aspi->regs + CONFIG_REG); | ||
+ writel(0x700, aspi->regs + CE_CTRL_REG); | ||
+ writel(0x0, aspi->regs + CE0_CTRL_REG); | ||
+ writel(0x50400000, aspi->regs + CE0_SEGMENT_ADDR_REG); | ||
+ writel(0x54500000, aspi->regs + CE1_SEGMENT_ADDR_REG); | ||
+ writel(0x58540000, aspi->regs + CE2_SEGMENT_ADDR_REG); | ||
+ writel(0x0, aspi->regs + CE0_TIMING_COMPENSATION_REG); | ||
+} | ||
+ | ||
/* | ||
* Platform definitions | ||
*/ | ||
@@ -1146,6 +1169,7 @@ static const struct aspeed_spi_data ast2500_fmc_data = { | ||
.segment_start = aspeed_spi_segment_start, | ||
.segment_end = aspeed_spi_segment_end, | ||
.segment_reg = aspeed_spi_segment_reg, | ||
+ .shutdown = aspeed_spi_ast2500_shutdown, | ||
}; | ||
|
||
static const struct aspeed_spi_data ast2500_spi_data = { | ||
@@ -1160,6 +1184,7 @@ static const struct aspeed_spi_data ast2500_spi_data = { | ||
.segment_start = aspeed_spi_segment_start, | ||
.segment_end = aspeed_spi_segment_end, | ||
.segment_reg = aspeed_spi_segment_reg, | ||
+ .shutdown = aspeed_spi_ast2500_shutdown, | ||
}; | ||
|
||
static const struct aspeed_spi_data ast2600_fmc_data = { | ||
@@ -1206,6 +1231,7 @@ MODULE_DEVICE_TABLE(of, aspeed_spi_matches); | ||
static struct platform_driver aspeed_spi_driver = { | ||
.probe = aspeed_spi_probe, | ||
.remove = aspeed_spi_remove, | ||
+ .shutdown = aspeed_spi_shutdown, | ||
.driver = { | ||
.name = DEVICE_NAME, | ||
.of_match_table = aspeed_spi_matches, | ||
-- | ||
2.34.1 | ||
|
67 changes: 0 additions & 67 deletions
67
.../recipes-kernel/linux/files/patches/0520-add-shutdown-path-in-spi-aspeed-smc-driver.patch
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters