Skip to content

Commit

Permalink
common: linux-6.1: add shutdown method for ast2500-spi
Browse files Browse the repository at this point in the history
Summary:
Override patch file #126 with #151 because the new patch (copied from
linux-aspeed-6.0) can be safely applied to all the openbmc platforms.

Test Plan:
1) "bitbake cmm-image" succeeded.
2) rebooted cmm image (running linux 6.1) for a few times: no issue
   found.

Reviewed By: williamspatrick

Differential Revision: D44718621

fbshipit-source-id: eb57a465d9fa8b9cfab86abc35564470b9f01552
  • Loading branch information
tao-ren authored and facebook-github-bot committed Apr 4, 2023
1 parent dd34cee commit 1816d3b
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 68 deletions.

This file was deleted.

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

2 changes: 1 addition & 1 deletion common/recipes-kernel/linux/linux-patches-6.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ SRC_URI:append = " \
"

SRC_URI:append:aspeed-g5 = " \
file://0126-Added-shutdown-path-in-spi_aspeed_smc-driver.patch \
file://0151-spi-aspeed-add-shutdown-path-for-AST25XX-SPI-control.patch \
"

0 comments on commit 1816d3b

Please sign in to comment.