[PATCH linux dev-4.7 8/8] mtd: spi-nor: aspeed: use command mode for reads
Cédric Le Goater
clg at kaod.org
Sat Nov 5 04:00:47 AEDT 2016
When accessing flash contents, let use the "command mode" for read.
Signed-off-by: Cédric Le Goater <clg at kaod.org>
---
drivers/mtd/spi-nor/aspeed-smc.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
index 88cbfe7c4340..89085d84b4b5 100644
--- a/drivers/mtd/spi-nor/aspeed-smc.c
+++ b/drivers/mtd/spi-nor/aspeed-smc.c
@@ -522,8 +522,8 @@ static void aspeed_smc_send_cmd_addr(struct spi_nor *nor, u8 cmd, u32 addr)
}
}
-static int aspeed_smc_read_user(struct spi_nor *nor, loff_t from, size_t len,
- size_t *retlen, u_char *read_buf)
+static int aspeed_smc_read(struct spi_nor *nor, loff_t from, size_t len,
+ size_t *retlen, u_char *read_buf)
{
struct aspeed_smc_chip *chip = nor->priv;
int ret;
@@ -542,10 +542,10 @@ static int aspeed_smc_read_user(struct spi_nor *nor, loff_t from, size_t len,
dev_err(chip->nor.dev, "DMA read failed: %d", ret);
}
- aspeed_smc_start_user(nor);
- aspeed_smc_send_cmd_addr(nor, nor->read_opcode, from);
- aspeed_smc_from_ahb(read_buf, chip->base, len);
- aspeed_smc_stop_user(nor);
+ /*
+ * we are in read or fread mode by default
+ */
+ aspeed_smc_from_ahb(read_buf, chip->base + from, len);
out:
mutex_unlock(&chip->controller->mutex);
@@ -861,6 +861,7 @@ static int aspeed_smc_chip_setup_finish(struct aspeed_smc_chip *chip)
}
chip->ctl_val[smc_read] |= cmd |
+ spi_control_fill_opcode(chip->nor.read_opcode) |
CONTROL_SPI_IO_DUMMY_CYCLES_SET(chip->nor.read_dummy / 8);
dev_dbg(controller->dev, "base control register: %08x\n",
@@ -956,7 +957,7 @@ static int aspeed_smc_probe(struct platform_device *pdev)
chip->nor.priv = chip;
spi_nor_set_flash_node(&chip->nor, child);
chip->nor.mtd.name = of_get_property(child, "label", NULL);
- chip->nor.read = aspeed_smc_read_user;
+ chip->nor.read = aspeed_smc_read;
chip->nor.write = aspeed_smc_write_user;
chip->nor.read_reg = aspeed_smc_read_reg;
chip->nor.write_reg = aspeed_smc_write_reg;
--
2.7.4
More information about the openbmc
mailing list