summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorCédric Le Goater <clg@kaod.org>2018-06-22 09:09:37 +0200
committerJoel Stanley <joel@jms.id.au>2019-03-20 15:13:32 +1030
commitfe628d8df1bc09574da3156d77aed22da83164d4 (patch)
treede90938009781358a2a901dddda62ffc8f6cc231 /drivers/mtd
parentd4f9680d6c8be5a1ca220f103b8e1b227e72935c (diff)
downloadblackbird-obmc-linux-fe628d8df1bc09574da3156d77aed22da83164d4.tar.gz
blackbird-obmc-linux-fe628d8df1bc09574da3156d77aed22da83164d4.zip
mtd: spi-nor: aspeed: limit the maximum SPI frequency
The optimize read algo can choose a 100MHz SPI frequency which might be a bit too high for dual output IO on some chips, for the W25Q256 on palmetto for instance. The MX66L1G45G on witherspoon should be fine though. Also, the second chip of the FMC controller does not get any optimize settings for reads. Only the first is configured by U-Boot. To fix these two issues, we introduce a "spi-max-frequency" property in the device tree which will be used to cap the optimize read algorithm and we run the algo on the FMC controller chips as well. By default, the frequency setting is 50MHz. OpenBMC-Staging-Count: 4 Signed-off-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Joel Stanley <joel@jms.id.au>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/spi-nor/aspeed-smc.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
index 58fe8f0a647a..ddf7ae78aa0a 100644
--- a/drivers/mtd/spi-nor/aspeed-smc.c
+++ b/drivers/mtd/spi-nor/aspeed-smc.c
@@ -62,6 +62,7 @@ static const struct aspeed_smc_info fmc_2400_info = {
.ctl0 = 0x10,
.timing = 0x94,
.set_4b = aspeed_smc_chip_set_4b,
+ .optimize_read = aspeed_smc_optimize_read,
};
static const struct aspeed_smc_info spi_2400_info = {
@@ -83,6 +84,7 @@ static const struct aspeed_smc_info fmc_2500_info = {
.ctl0 = 0x10,
.timing = 0x94,
.set_4b = aspeed_smc_chip_set_4b,
+ .optimize_read = aspeed_smc_optimize_read,
};
static const struct aspeed_smc_info spi_2500_info = {
@@ -114,6 +116,7 @@ struct aspeed_smc_chip {
u32 ctl_val[smc_max]; /* control settings */
enum aspeed_smc_flash_type type; /* what type of flash */
struct spi_nor nor;
+ u32 clk_rate;
};
struct aspeed_smc_controller {
@@ -130,6 +133,8 @@ struct aspeed_smc_controller {
struct aspeed_smc_chip *chips[0]; /* pointers to attached chips */
};
+#define ASPEED_SPI_DEFAULT_FREQ 50000000
+
/*
* SPI Flash Configuration Register (AST2500 SPI)
* or
@@ -993,11 +998,8 @@ static int aspeed_smc_chip_setup_finish(struct aspeed_smc_chip *chip)
dev_info(controller->dev, "read control register: %08x\n",
chip->ctl_val[smc_read]);
- /*
- * TODO: get max freq from chip
- */
if (optimize_read && info->optimize_read)
- info->optimize_read(chip, 104000000);
+ info->optimize_read(chip, chip->clk_rate);
return 0;
}
@@ -1051,6 +1053,13 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
break;
}
+ if (of_property_read_u32(child, "spi-max-frequency",
+ &chip->clk_rate)) {
+ chip->clk_rate = ASPEED_SPI_DEFAULT_FREQ;
+ }
+ dev_info(dev, "Using %d MHz SPI frequency\n",
+ chip->clk_rate / 1000000);
+
chip->controller = controller;
chip->ctl = controller->regs + info->ctl0 + cs * 4;
chip->cs = cs;
OpenPOWER on IntegriCloud