Skip to content

Commit

Permalink
mtd: spi-nor: aspeed: set the decoding size to at least 2MB for AST2600
Browse files Browse the repository at this point in the history
In AST2600, the unit of SPI CEx decoding range register is 1MB, and end
address offset is set to the acctual offset - 1MB. If the flash only has
1MB, the end address will has same value as start address, which will
causing unexpected errors.

This patch set the decoding size to at least 2MB to avoid decoding errors.

Tested:
root@bletchley:~# dmesg | grep "aspeed-smc 1e631000.spi: CE0 window"
[   59.328134] aspeed-smc 1e631000.spi: CE0 window resized to 2MB (AST2600 Decoding)
[   59.343001] aspeed-smc 1e631000.spi: CE0 window [ 0x50000000 - 0x50200000 ] 2MB
root@bletchley:~# devmem 0x1e631030
0x00100000

Tested-by: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
[ clg : Ported on new spi-mem driver ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Link: https://lore.kernel.org/r/20220509175616.1089346-12-clg@kaod.org
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Potin Lai authored and Mark Brown committed May 16, 2022
1 parent eeaec1e commit 73ae97e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/spi/spi-aspeed-smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ static int aspeed_spi_set_window(struct aspeed_spi *aspi,
* is correct.
*/
static const struct aspeed_spi_data ast2500_spi_data;
static const struct aspeed_spi_data ast2600_spi_data;
static const struct aspeed_spi_data ast2600_fmc_data;

static int aspeed_spi_chip_adjust_window(struct aspeed_spi_chip *chip,
u32 local_offset, u32 size)
Expand All @@ -497,6 +499,17 @@ static int aspeed_spi_chip_adjust_window(struct aspeed_spi_chip *chip,
chip->cs, size >> 20);
}

/*
* The decoding size of AST2600 SPI controller should set at
* least 2MB.
*/
if ((aspi->data == &ast2600_spi_data || aspi->data == &ast2600_fmc_data) &&
size < SZ_2M) {
size = SZ_2M;
dev_info(aspi->dev, "CE%d window resized to %dMB (AST2600 Decoding)",
chip->cs, size >> 20);
}

aspeed_spi_get_windows(aspi, windows);

/* Adjust this chip window */
Expand Down

0 comments on commit 73ae97e

Please sign in to comment.