Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…oot-spi

- fix for fsl_qspi read timeout (Thomas)
- spi-mem read data size fix (Ye Li)
- SiFive SPI driver, mmc_spi flags (Bhargav, Anup)
- Micron spi-nor parts (Ashish)
- MT7629 spi-mem driver(Weijie)
  • Loading branch information
trini committed Jul 27, 2019
2 parents bfe28bc + 1f17468 commit 222701e
Show file tree
Hide file tree
Showing 11 changed files with 725 additions and 384 deletions.
2 changes: 1 addition & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ F: drivers/mmc/mtk-sd.c
F: drivers/pinctrl/mediatek/
F: drivers/power/domain/mtk-power-domain.c
F: drivers/ram/mediatek/
F: drivers/spi/mtk_qspi.c
F: drivers/spi/mtk_snfi_spi.c
F: drivers/timer/mtk_timer.c
F: drivers/watchdog/mtk_wdt.c
F: drivers/net/mtk_eth.c
Expand Down
2 changes: 1 addition & 1 deletion configs/mt7629_rfb_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ CONFIG_DM_SERIAL=y
CONFIG_MTK_SERIAL=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_MTK_QSPI=y
CONFIG_MTK_SNFI_SPI=y
CONFIG_SYSRESET=y
CONFIG_SPL_SYSRESET=y
CONFIG_SYSRESET_WATCHDOG=y
Expand Down
4 changes: 3 additions & 1 deletion drivers/mmc/mmc_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int mmc_spi_sendcmd(struct udevice *dev,
cmdo[4] = cmdarg >> 8;
cmdo[5] = cmdarg;
cmdo[6] = (crc7(0, &cmdo[1], 5) << 1) | 0x01;
ret = dm_spi_xfer(dev, sizeof(cmdo) * 8, cmdo, NULL, 0);
ret = dm_spi_xfer(dev, sizeof(cmdo) * 8, cmdo, NULL, SPI_XFER_BEGIN);
if (ret)
return ret;

Expand Down Expand Up @@ -360,6 +360,8 @@ static int dm_mmc_spi_request(struct udevice *dev, struct mmc_cmd *cmd,
}

done:
dm_spi_xfer(dev, 0, NULL, NULL, SPI_XFER_END);

dm_spi_release_bus(dev);

return ret;
Expand Down
4 changes: 4 additions & 0 deletions drivers/mtd/spi/spi-nor-ids.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,15 @@ const struct flash_info spi_nor_ids[] = {
{ INFO("n25q128a13", 0x20ba18, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_QUAD_READ) },
{ INFO("n25q256a", 0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q256ax1", 0x20bb19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO6("mt25qu512a", 0x20bb20, 0x104400, 64 * 1024, 1024,
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q512a", 0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q512ax3", 0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q00", 0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
{ INFO("n25q00a", 0x20bb21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
{ INFO("mt25qu02g", 0x20bb22, 0, 64 * 1024, 4096, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
{ INFO("mt35xu512aba", 0x2c5b1a, 0, 128 * 1024, 512, USE_FSR | SPI_NOR_4B_OPCODES) },
{ INFO("mt35xu02g", 0x2c5b1c, 0, 128 * 1024, 2048, USE_FSR | SPI_NOR_4B_OPCODES) },
#endif
#ifdef CONFIG_SPI_FLASH_SPANSION /* SPANSION */
/* Spansion/Cypress -- single (large) sector size only, at least
Expand Down
21 changes: 15 additions & 6 deletions drivers/spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,14 @@ config MT7621_SPI
the SPI NOR flash on platforms embedding this Ralink / MediaTek
SPI core, like MT7621/7628/7688.

config MTK_QSPI
bool "Mediatek QSPI driver"
imply SPI_FLASH_BAR
config MTK_SNFI_SPI
bool "Mediatek SPI memory controller driver"
depends on SPI_MEM
help
Enable the Mediatek QSPI driver. This driver can be
used to access the SPI NOR flash on platforms embedding this
Mediatek QSPI IP core.
Enable the Mediatek SPI memory controller driver. This driver is
originally based on the MediaTek SNFI IP core. It can only be
used to access SPI memory devices like SPI-NOR or SPI-NAND on
platforms embedding this IP core, like MT7622/M7629.

config MVEBU_A3700_SPI
bool "Marvell Armada 3700 SPI driver"
Expand Down Expand Up @@ -232,6 +233,14 @@ config SANDBOX_SPI
};
};

config SPI_SIFIVE
bool "SiFive SPI driver"
help
This driver supports the SiFive SPI IP. If unsure say N.
Enable the SiFive SPI controller driver.

The SiFive SPI controller driver is found on various SiFive SoCs.

config SPI_SUNXI
bool "Allwinner SoC SPI controllers"
help
Expand Down
3 changes: 2 additions & 1 deletion drivers/spi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o
obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
obj-$(CONFIG_MTK_QSPI) += mtk_qspi.o
obj-$(CONFIG_MTK_SNFI_SPI) += mtk_snfi_spi.o
obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o
obj-$(CONFIG_MSCC_BB_SPI) += mscc_bb_spi.o
obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
Expand All @@ -50,6 +50,7 @@ obj-$(CONFIG_PL022_SPI) += pl022_spi.o
obj-$(CONFIG_RENESAS_RPC_SPI) += renesas_rpc_spi.o
obj-$(CONFIG_ROCKCHIP_SPI) += rk_spi.o
obj-$(CONFIG_SANDBOX_SPI) += sandbox_spi.o
obj-$(CONFIG_SPI_SIFIVE) += spi-sifive.o
obj-$(CONFIG_SPI_SUNXI) += spi-sunxi.o
obj-$(CONFIG_SH_SPI) += sh_spi.o
obj-$(CONFIG_SH_QSPI) += sh_qspi.o
Expand Down
18 changes: 6 additions & 12 deletions drivers/spi/fsl_qspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <spi.h>
#include <asm/io.h>
#include <linux/sizes.h>
#include <linux/iopoll.h>
#include <dm.h>
#include <errno.h>
#include <watchdog.h>
Expand Down Expand Up @@ -150,20 +151,13 @@ static void qspi_write32(u32 flags, u32 *addr, u32 val)
static inline int is_controller_busy(const struct fsl_qspi_priv *priv)
{
u32 val;
const u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK |
QSPI_SR_IP_ACC_MASK;
unsigned int retry = 5;
u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK |
QSPI_SR_IP_ACC_MASK;

do {
val = qspi_read32(priv->flags, &priv->regs->sr);
if (priv->flags & QSPI_FLAG_REGMAP_ENDIAN_BIG)
mask = (u32)cpu_to_be32(mask);

if ((~val & mask) == mask)
return 0;

udelay(1);
} while (--retry);

return -ETIMEDOUT;
return readl_poll_timeout(&priv->regs->sr, val, !(val & mask), 1000);
}

/* QSPI support swapping the flash read/write data
Expand Down
Loading

0 comments on commit 222701e

Please sign in to comment.