2014-05-06 01:13:01 +00:00
|
|
|
/*
|
2015-04-01 03:10:40 +00:00
|
|
|
* Copyright 2013-2015 Freescale Semiconductor, Inc.
|
2014-05-06 01:13:01 +00:00
|
|
|
*
|
|
|
|
* Freescale Quad Serial Peripheral Interface (QSPI) driver
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <spi.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <linux/sizes.h>
|
2015-04-01 03:10:40 +00:00
|
|
|
#include <dm.h>
|
|
|
|
#include <errno.h>
|
2015-11-04 08:19:10 +00:00
|
|
|
#include <watchdog.h>
|
2014-05-06 01:13:01 +00:00
|
|
|
#include "fsl_qspi.h"
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2014-05-06 01:13:01 +00:00
|
|
|
#define RX_BUFFER_SIZE 0x80
|
2014-12-31 03:01:38 +00:00
|
|
|
#ifdef CONFIG_MX6SX
|
|
|
|
#define TX_BUFFER_SIZE 0x200
|
|
|
|
#else
|
2014-05-06 01:13:01 +00:00
|
|
|
#define TX_BUFFER_SIZE 0x40
|
2014-12-31 03:01:38 +00:00
|
|
|
#endif
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-12-14 10:26:25 +00:00
|
|
|
#define OFFSET_BITS_MASK GENMASK(23, 0)
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
#define FLASH_STATUS_WEL 0x02
|
|
|
|
|
|
|
|
/* SEQID */
|
|
|
|
#define SEQID_WREN 1
|
|
|
|
#define SEQID_FAST_READ 2
|
|
|
|
#define SEQID_RDSR 3
|
|
|
|
#define SEQID_SE 4
|
|
|
|
#define SEQID_CHIP_ERASE 5
|
|
|
|
#define SEQID_PP 6
|
|
|
|
#define SEQID_RDID 7
|
2014-12-31 03:01:39 +00:00
|
|
|
#define SEQID_BE_4K 8
|
2015-01-04 09:07:14 +00:00
|
|
|
#ifdef CONFIG_SPI_FLASH_BAR
|
|
|
|
#define SEQID_BRRD 9
|
|
|
|
#define SEQID_BRWR 10
|
|
|
|
#define SEQID_RDEAR 11
|
|
|
|
#define SEQID_WREAR 12
|
|
|
|
#endif
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2014-12-31 03:01:36 +00:00
|
|
|
/* QSPI CMD */
|
|
|
|
#define QSPI_CMD_PP 0x02 /* Page program (up to 256 bytes) */
|
|
|
|
#define QSPI_CMD_RDSR 0x05 /* Read status register */
|
|
|
|
#define QSPI_CMD_WREN 0x06 /* Write enable */
|
|
|
|
#define QSPI_CMD_FAST_READ 0x0b /* Read data bytes (high frequency) */
|
2014-12-31 03:01:39 +00:00
|
|
|
#define QSPI_CMD_BE_4K 0x20 /* 4K erase */
|
2014-12-31 03:01:36 +00:00
|
|
|
#define QSPI_CMD_CHIP_ERASE 0xc7 /* Erase whole flash chip */
|
|
|
|
#define QSPI_CMD_SE 0xd8 /* Sector erase (usually 64KiB) */
|
|
|
|
#define QSPI_CMD_RDID 0x9f /* Read JEDEC ID */
|
|
|
|
|
2015-01-04 09:07:14 +00:00
|
|
|
/* Used for Micron, winbond and Macronix flashes */
|
|
|
|
#define QSPI_CMD_WREAR 0xc5 /* EAR register write */
|
|
|
|
#define QSPI_CMD_RDEAR 0xc8 /* EAR reigster read */
|
|
|
|
|
|
|
|
/* Used for Spansion flashes only. */
|
|
|
|
#define QSPI_CMD_BRRD 0x16 /* Bank register read */
|
|
|
|
#define QSPI_CMD_BRWR 0x17 /* Bank register write */
|
|
|
|
|
2014-12-31 03:01:36 +00:00
|
|
|
/* 4-byte address QSPI CMD - used on Spansion and some Macronix flashes */
|
|
|
|
#define QSPI_CMD_FAST_READ_4B 0x0c /* Read data bytes (high frequency) */
|
|
|
|
#define QSPI_CMD_PP_4B 0x12 /* Page program (up to 256 bytes) */
|
|
|
|
#define QSPI_CMD_SE_4B 0xdc /* Sector erase (usually 64KiB) */
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
/* fsl_qspi_platdata flags */
|
2015-10-22 20:07:18 +00:00
|
|
|
#define QSPI_FLAG_REGMAP_ENDIAN_BIG BIT(0)
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
/* default SCK frequency, unit: HZ */
|
|
|
|
#define FSL_QSPI_DEFAULT_SCK_FREQ 50000000
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
/* QSPI max chipselect signals number */
|
|
|
|
#define FSL_QSPI_MAX_CHIPSELECT_NUM 4
|
|
|
|
|
|
|
|
#ifdef CONFIG_DM_SPI
|
|
|
|
/**
|
|
|
|
* struct fsl_qspi_platdata - platform data for Freescale QSPI
|
|
|
|
*
|
|
|
|
* @flags: Flags for QSPI QSPI_FLAG_...
|
|
|
|
* @speed_hz: Default SCK frequency
|
|
|
|
* @reg_base: Base address of QSPI registers
|
|
|
|
* @amba_base: Base address of QSPI memory mapping
|
|
|
|
* @amba_total_size: size of QSPI memory mapping
|
|
|
|
* @flash_num: Number of active slave devices
|
|
|
|
* @num_chipselect: Number of QSPI chipselect signals
|
|
|
|
*/
|
|
|
|
struct fsl_qspi_platdata {
|
|
|
|
u32 flags;
|
|
|
|
u32 speed_hz;
|
|
|
|
u32 reg_base;
|
|
|
|
u32 amba_base;
|
|
|
|
u32 amba_total_size;
|
|
|
|
u32 flash_num;
|
|
|
|
u32 num_chipselect;
|
|
|
|
};
|
2014-12-31 03:01:38 +00:00
|
|
|
#endif
|
2015-04-01 03:10:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct fsl_qspi_priv - private data for Freescale QSPI
|
|
|
|
*
|
|
|
|
* @flags: Flags for QSPI QSPI_FLAG_...
|
|
|
|
* @bus_clk: QSPI input clk frequency
|
|
|
|
* @speed_hz: Default SCK frequency
|
|
|
|
* @cur_seqid: current LUT table sequence id
|
|
|
|
* @sf_addr: flash access offset
|
|
|
|
* @amba_base: Base address of QSPI memory mapping of every CS
|
|
|
|
* @amba_total_size: size of QSPI memory mapping
|
|
|
|
* @cur_amba_base: Base address of QSPI memory mapping of current CS
|
|
|
|
* @flash_num: Number of active slave devices
|
|
|
|
* @num_chipselect: Number of QSPI chipselect signals
|
|
|
|
* @regs: Point to QSPI register structure for I/O access
|
|
|
|
*/
|
|
|
|
struct fsl_qspi_priv {
|
|
|
|
u32 flags;
|
|
|
|
u32 bus_clk;
|
|
|
|
u32 speed_hz;
|
|
|
|
u32 cur_seqid;
|
|
|
|
u32 sf_addr;
|
|
|
|
u32 amba_base[FSL_QSPI_MAX_CHIPSELECT_NUM];
|
|
|
|
u32 amba_total_size;
|
|
|
|
u32 cur_amba_base;
|
|
|
|
u32 flash_num;
|
|
|
|
u32 num_chipselect;
|
|
|
|
struct fsl_qspi_regs *regs;
|
2014-05-06 01:13:01 +00:00
|
|
|
};
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
#ifndef CONFIG_DM_SPI
|
2014-05-06 01:13:01 +00:00
|
|
|
struct fsl_qspi {
|
|
|
|
struct spi_slave slave;
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_priv priv;
|
2014-05-06 01:13:01 +00:00
|
|
|
};
|
2015-04-01 03:10:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static u32 qspi_read32(u32 flags, u32 *addr)
|
|
|
|
{
|
|
|
|
return flags & QSPI_FLAG_REGMAP_ENDIAN_BIG ?
|
|
|
|
in_be32(addr) : in_le32(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qspi_write32(u32 flags, u32 *addr, u32 val)
|
|
|
|
{
|
|
|
|
flags & QSPI_FLAG_REGMAP_ENDIAN_BIG ?
|
|
|
|
out_be32(addr, val) : out_le32(addr, val);
|
|
|
|
}
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
/* QSPI support swapping the flash read/write data
|
|
|
|
* in hardware for LS102xA, but not for VF610 */
|
|
|
|
static inline u32 qspi_endian_xchg(u32 data)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_VF610
|
|
|
|
return swab32(data);
|
|
|
|
#else
|
|
|
|
return data;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
static void qspi_set_lut(struct fsl_qspi_priv *priv)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
2014-05-06 01:13:01 +00:00
|
|
|
u32 lut_base;
|
|
|
|
|
|
|
|
/* Unlock the LUT */
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lutkey, LUT_KEY_VALUE);
|
|
|
|
qspi_write32(priv->flags, ®s->lckcr, QSPI_LCKCR_UNLOCK);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
/* Write Enable */
|
|
|
|
lut_base = SEQID_WREN * 4;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_WREN) |
|
2014-05-06 01:13:01 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD));
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 1], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 2], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 3], 0);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
/* Fast Read */
|
|
|
|
lut_base = SEQID_FAST_READ * 4;
|
2015-01-04 09:07:14 +00:00
|
|
|
#ifdef CONFIG_SPI_FLASH_BAR
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base],
|
|
|
|
OPRND0(QSPI_CMD_FAST_READ) | PAD0(LUT_PAD1) |
|
|
|
|
INSTR0(LUT_CMD) | OPRND1(ADDR24BIT) |
|
2015-01-04 09:07:14 +00:00
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_ADDR));
|
|
|
|
#else
|
2014-05-06 01:13:01 +00:00
|
|
|
if (FSL_QSPI_FLASH_SIZE <= SZ_16M)
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base],
|
|
|
|
OPRND0(QSPI_CMD_FAST_READ) | PAD0(LUT_PAD1) |
|
|
|
|
INSTR0(LUT_CMD) | OPRND1(ADDR24BIT) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_ADDR));
|
2014-05-06 01:13:01 +00:00
|
|
|
else
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base],
|
2014-12-31 03:01:36 +00:00
|
|
|
OPRND0(QSPI_CMD_FAST_READ_4B) |
|
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) |
|
|
|
|
OPRND1(ADDR32BIT) | PAD1(LUT_PAD1) |
|
|
|
|
INSTR1(LUT_ADDR));
|
2015-01-04 09:07:14 +00:00
|
|
|
#endif
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 1],
|
|
|
|
OPRND0(8) | PAD0(LUT_PAD1) | INSTR0(LUT_DUMMY) |
|
|
|
|
OPRND1(RX_BUFFER_SIZE) | PAD1(LUT_PAD1) |
|
|
|
|
INSTR1(LUT_READ));
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 2], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 3], 0);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
/* Read Status */
|
|
|
|
lut_base = SEQID_RDSR * 4;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_RDSR) |
|
2014-05-06 01:13:01 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) | OPRND1(1) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_READ));
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 1], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 2], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 3], 0);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
/* Erase a sector */
|
|
|
|
lut_base = SEQID_SE * 4;
|
2015-01-04 09:07:14 +00:00
|
|
|
#ifdef CONFIG_SPI_FLASH_BAR
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_SE) |
|
2015-01-04 09:07:14 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) | OPRND1(ADDR24BIT) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_ADDR));
|
|
|
|
#else
|
2014-05-06 01:13:01 +00:00
|
|
|
if (FSL_QSPI_FLASH_SIZE <= SZ_16M)
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base],
|
|
|
|
OPRND0(QSPI_CMD_SE) | PAD0(LUT_PAD1) |
|
|
|
|
INSTR0(LUT_CMD) | OPRND1(ADDR24BIT) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_ADDR));
|
2014-05-06 01:13:01 +00:00
|
|
|
else
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base],
|
|
|
|
OPRND0(QSPI_CMD_SE_4B) | PAD0(LUT_PAD1) |
|
|
|
|
INSTR0(LUT_CMD) | OPRND1(ADDR32BIT) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_ADDR));
|
2015-01-04 09:07:14 +00:00
|
|
|
#endif
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 1], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 2], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 3], 0);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
/* Erase the whole chip */
|
|
|
|
lut_base = SEQID_CHIP_ERASE * 4;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base],
|
|
|
|
OPRND0(QSPI_CMD_CHIP_ERASE) |
|
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD));
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 1], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 2], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 3], 0);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
/* Page Program */
|
|
|
|
lut_base = SEQID_PP * 4;
|
2015-01-04 09:07:14 +00:00
|
|
|
#ifdef CONFIG_SPI_FLASH_BAR
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_PP) |
|
2015-01-04 09:07:14 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) | OPRND1(ADDR24BIT) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_ADDR));
|
|
|
|
#else
|
2014-05-06 01:13:01 +00:00
|
|
|
if (FSL_QSPI_FLASH_SIZE <= SZ_16M)
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base],
|
|
|
|
OPRND0(QSPI_CMD_PP) | PAD0(LUT_PAD1) |
|
|
|
|
INSTR0(LUT_CMD) | OPRND1(ADDR24BIT) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_ADDR));
|
2014-05-06 01:13:01 +00:00
|
|
|
else
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base],
|
|
|
|
OPRND0(QSPI_CMD_PP_4B) | PAD0(LUT_PAD1) |
|
|
|
|
INSTR0(LUT_CMD) | OPRND1(ADDR32BIT) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_ADDR));
|
2015-01-04 09:07:14 +00:00
|
|
|
#endif
|
2014-12-31 03:01:38 +00:00
|
|
|
#ifdef CONFIG_MX6SX
|
|
|
|
/*
|
|
|
|
* To MX6SX, OPRND0(TX_BUFFER_SIZE) can not work correctly.
|
|
|
|
* So, Use IDATSZ in IPCR to determine the size and here set 0.
|
|
|
|
*/
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 1], OPRND0(0) |
|
2014-12-31 03:01:38 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_WRITE));
|
|
|
|
#else
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 1],
|
|
|
|
OPRND0(TX_BUFFER_SIZE) |
|
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_WRITE));
|
2014-12-31 03:01:38 +00:00
|
|
|
#endif
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 2], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 3], 0);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
/* READ ID */
|
|
|
|
lut_base = SEQID_RDID * 4;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_RDID) |
|
2014-05-06 01:13:01 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) | OPRND1(8) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_READ));
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 1], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 2], 0);
|
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base + 3], 0);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2014-12-31 03:01:39 +00:00
|
|
|
/* SUB SECTOR 4K ERASE */
|
|
|
|
lut_base = SEQID_BE_4K * 4;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_BE_4K) |
|
2014-12-31 03:01:39 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) | OPRND1(ADDR24BIT) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_ADDR));
|
|
|
|
|
2015-01-04 09:07:14 +00:00
|
|
|
#ifdef CONFIG_SPI_FLASH_BAR
|
|
|
|
/*
|
|
|
|
* BRRD BRWR RDEAR WREAR are all supported, because it is hard to
|
|
|
|
* dynamically check whether to set BRRD BRWR or RDEAR WREAR during
|
|
|
|
* initialization.
|
|
|
|
*/
|
|
|
|
lut_base = SEQID_BRRD * 4;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_BRRD) |
|
2015-01-04 09:07:14 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) | OPRND1(1) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_READ));
|
|
|
|
|
|
|
|
lut_base = SEQID_BRWR * 4;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_BRWR) |
|
2015-01-04 09:07:14 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) | OPRND1(1) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_WRITE));
|
|
|
|
|
|
|
|
lut_base = SEQID_RDEAR * 4;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_RDEAR) |
|
2015-01-04 09:07:14 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) | OPRND1(1) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_READ));
|
|
|
|
|
|
|
|
lut_base = SEQID_WREAR * 4;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lut[lut_base], OPRND0(QSPI_CMD_WREAR) |
|
2015-01-04 09:07:14 +00:00
|
|
|
PAD0(LUT_PAD1) | INSTR0(LUT_CMD) | OPRND1(1) |
|
|
|
|
PAD1(LUT_PAD1) | INSTR1(LUT_WRITE));
|
|
|
|
#endif
|
2014-05-06 01:13:01 +00:00
|
|
|
/* Lock the LUT */
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->lutkey, LUT_KEY_VALUE);
|
|
|
|
qspi_write32(priv->flags, ®s->lckcr, QSPI_LCKCR_LOCK);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
#if defined(CONFIG_SYS_FSL_QSPI_AHB)
|
|
|
|
/*
|
|
|
|
* If we have changed the content of the flash by writing or erasing,
|
|
|
|
* we need to invalidate the AHB buffer. If we do not do so, we may read out
|
|
|
|
* the wrong data. The spec tells us reset the AHB domain and Serial Flash
|
|
|
|
* domain at the same time.
|
|
|
|
*/
|
2015-04-01 03:10:40 +00:00
|
|
|
static inline void qspi_ahb_invalid(struct fsl_qspi_priv *priv)
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
u32 reg;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
reg = qspi_read32(priv->flags, ®s->mcr);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
reg |= QSPI_MCR_SWRSTHD_MASK | QSPI_MCR_SWRSTSD_MASK;
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, reg);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The minimum delay : 1 AHB + 2 SFCK clocks.
|
|
|
|
* Delay 1 us is enough.
|
|
|
|
*/
|
|
|
|
udelay(1);
|
|
|
|
|
|
|
|
reg &= ~(QSPI_MCR_SWRSTHD_MASK | QSPI_MCR_SWRSTSD_MASK);
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, reg);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read out the data from the AHB buffer. */
|
2015-04-01 03:10:40 +00:00
|
|
|
static inline void qspi_ahb_read(struct fsl_qspi_priv *priv, u8 *rxbuf, int len)
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
u32 mcr_reg;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
mcr_reg = qspi_read32(priv->flags, ®s->mcr);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
QSPI_MCR_CLR_RXF_MASK | QSPI_MCR_CLR_TXF_MASK |
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
QSPI_MCR_RESERVED_MASK | QSPI_MCR_END_CFD_LE);
|
|
|
|
|
|
|
|
/* Read out the data directly from the AHB buffer. */
|
2015-04-01 03:10:40 +00:00
|
|
|
memcpy(rxbuf, (u8 *)(priv->cur_amba_base + priv->sf_addr), len);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, mcr_reg);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
static void qspi_enable_ddr_mode(struct fsl_qspi_priv *priv)
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
{
|
|
|
|
u32 reg, reg2;
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
reg = qspi_read32(priv->flags, ®s->mcr);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
/* Disable the module */
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, reg | QSPI_MCR_MDIS_MASK);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
|
|
|
|
/* Set the Sampling Register for DDR */
|
2015-04-01 03:10:40 +00:00
|
|
|
reg2 = qspi_read32(priv->flags, ®s->smpr);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
reg2 &= ~QSPI_SMPR_DDRSMP_MASK;
|
|
|
|
reg2 |= (2 << QSPI_SMPR_DDRSMP_SHIFT);
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->smpr, reg2);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
|
|
|
|
/* Enable the module again (enable the DDR too) */
|
|
|
|
reg |= QSPI_MCR_DDR_EN_MASK;
|
|
|
|
/* Enable bit 29 for imx6sx */
|
2015-10-22 20:07:18 +00:00
|
|
|
reg |= BIT(29);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, reg);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There are two different ways to read out the data from the flash:
|
|
|
|
* the "IP Command Read" and the "AHB Command Read".
|
|
|
|
*
|
|
|
|
* The IC guy suggests we use the "AHB Command Read" which is faster
|
|
|
|
* then the "IP Command Read". (What's more is that there is a bug in
|
|
|
|
* the "IP Command Read" in the Vybrid.)
|
|
|
|
*
|
|
|
|
* After we set up the registers for the "AHB Command Read", we can use
|
|
|
|
* the memcpy to read the data directly. A "missed" access to the buffer
|
|
|
|
* causes the controller to clear the buffer, and use the sequence pointed
|
|
|
|
* by the QUADSPI_BFGENCR[SEQID] to initiate a read from the flash.
|
|
|
|
*/
|
2015-04-01 03:10:40 +00:00
|
|
|
static void qspi_init_ahb_read(struct fsl_qspi_priv *priv)
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
|
|
|
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
/* AHB configuration for access buffer 0/1/2 .*/
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->buf0cr, QSPI_BUFXCR_INVALID_MSTRID);
|
|
|
|
qspi_write32(priv->flags, ®s->buf1cr, QSPI_BUFXCR_INVALID_MSTRID);
|
|
|
|
qspi_write32(priv->flags, ®s->buf2cr, QSPI_BUFXCR_INVALID_MSTRID);
|
|
|
|
qspi_write32(priv->flags, ®s->buf3cr, QSPI_BUF3CR_ALLMST_MASK |
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
(0x80 << QSPI_BUF3CR_ADATSZ_SHIFT));
|
|
|
|
|
|
|
|
/* We only use the buffer3 */
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->buf0ind, 0);
|
|
|
|
qspi_write32(priv->flags, ®s->buf1ind, 0);
|
|
|
|
qspi_write32(priv->flags, ®s->buf2ind, 0);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the default lut sequence for AHB Read.
|
|
|
|
* Parallel mode is disabled.
|
|
|
|
*/
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->bfgencr,
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
SEQID_FAST_READ << QSPI_BFGENCR_SEQID_SHIFT);
|
|
|
|
|
|
|
|
/*Enable DDR Mode*/
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_enable_ddr_mode(priv);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-04 09:07:14 +00:00
|
|
|
#ifdef CONFIG_SPI_FLASH_BAR
|
|
|
|
/* Bank register read/write, EAR register read/write */
|
2015-04-01 03:10:40 +00:00
|
|
|
static void qspi_op_rdbank(struct fsl_qspi_priv *priv, u8 *rxbuf, u32 len)
|
2015-01-04 09:07:14 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
2015-01-04 09:07:14 +00:00
|
|
|
u32 reg, mcr_reg, data, seqid;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
mcr_reg = qspi_read32(priv->flags, ®s->mcr);
|
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
QSPI_MCR_CLR_RXF_MASK | QSPI_MCR_CLR_TXF_MASK |
|
2015-01-04 09:07:14 +00:00
|
|
|
QSPI_MCR_RESERVED_MASK | QSPI_MCR_END_CFD_LE);
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->rbct, QSPI_RBCT_RXBRD_USEIPS);
|
2015-01-04 09:07:14 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->sfar, priv->cur_amba_base);
|
2015-01-04 09:07:14 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
if (priv->cur_seqid == QSPI_CMD_BRRD)
|
2015-01-04 09:07:14 +00:00
|
|
|
seqid = SEQID_BRRD;
|
|
|
|
else
|
|
|
|
seqid = SEQID_RDEAR;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
|
|
|
(seqid << QSPI_IPCR_SEQID_SHIFT) | len);
|
2015-01-04 09:07:14 +00:00
|
|
|
|
|
|
|
/* Wait previous command complete */
|
2015-04-01 03:10:40 +00:00
|
|
|
while (qspi_read32(priv->flags, ®s->sr) & QSPI_SR_BUSY_MASK)
|
2015-01-04 09:07:14 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
while (1) {
|
2015-04-01 03:10:40 +00:00
|
|
|
reg = qspi_read32(priv->flags, ®s->rbsr);
|
2015-01-04 09:07:14 +00:00
|
|
|
if (reg & QSPI_RBSR_RDBFL_MASK) {
|
2015-04-01 03:10:40 +00:00
|
|
|
data = qspi_read32(priv->flags, ®s->rbdr[0]);
|
2015-01-04 09:07:14 +00:00
|
|
|
data = qspi_endian_xchg(data);
|
|
|
|
memcpy(rxbuf, &data, len);
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
qspi_read32(priv->flags, ®s->mcr) |
|
2015-01-04 09:07:14 +00:00
|
|
|
QSPI_MCR_CLR_RXF_MASK);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, mcr_reg);
|
2015-01-04 09:07:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
static void qspi_op_rdid(struct fsl_qspi_priv *priv, u32 *rxbuf, u32 len)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
2014-05-06 01:13:01 +00:00
|
|
|
u32 mcr_reg, rbsr_reg, data;
|
|
|
|
int i, size;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
mcr_reg = qspi_read32(priv->flags, ®s->mcr);
|
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
QSPI_MCR_CLR_RXF_MASK | QSPI_MCR_CLR_TXF_MASK |
|
|
|
|
QSPI_MCR_RESERVED_MASK | QSPI_MCR_END_CFD_LE);
|
|
|
|
qspi_write32(priv->flags, ®s->rbct, QSPI_RBCT_RXBRD_USEIPS);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->sfar, priv->cur_amba_base);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
|
|
|
(SEQID_RDID << QSPI_IPCR_SEQID_SHIFT) | 0);
|
|
|
|
while (qspi_read32(priv->flags, ®s->sr) & QSPI_SR_BUSY_MASK)
|
2014-05-06 01:13:01 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
size = len;
|
|
|
|
while ((RX_BUFFER_SIZE >= size) && (size > 0)) {
|
2015-04-01 03:10:40 +00:00
|
|
|
rbsr_reg = qspi_read32(priv->flags, ®s->rbsr);
|
2014-05-06 01:13:01 +00:00
|
|
|
if (rbsr_reg & QSPI_RBSR_RDBFL_MASK) {
|
2015-04-01 03:10:40 +00:00
|
|
|
data = qspi_read32(priv->flags, ®s->rbdr[i]);
|
2014-05-06 01:13:01 +00:00
|
|
|
data = qspi_endian_xchg(data);
|
|
|
|
memcpy(rxbuf, &data, 4);
|
|
|
|
rxbuf++;
|
|
|
|
size -= 4;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, mcr_reg);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
#ifndef CONFIG_SYS_FSL_QSPI_AHB
|
|
|
|
/* If not use AHB read, read data from ip interface */
|
2015-04-01 03:10:40 +00:00
|
|
|
static void qspi_op_read(struct fsl_qspi_priv *priv, u32 *rxbuf, u32 len)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
2014-05-06 01:13:01 +00:00
|
|
|
u32 mcr_reg, data;
|
|
|
|
int i, size;
|
|
|
|
u32 to_or_from;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
mcr_reg = qspi_read32(priv->flags, ®s->mcr);
|
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
QSPI_MCR_CLR_RXF_MASK | QSPI_MCR_CLR_TXF_MASK |
|
|
|
|
QSPI_MCR_RESERVED_MASK | QSPI_MCR_END_CFD_LE);
|
|
|
|
qspi_write32(priv->flags, ®s->rbct, QSPI_RBCT_RXBRD_USEIPS);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
to_or_from = priv->sf_addr + priv->cur_amba_base;
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
while (len > 0) {
|
2015-11-04 08:19:10 +00:00
|
|
|
WATCHDOG_RESET();
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->sfar, to_or_from);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
size = (len > RX_BUFFER_SIZE) ?
|
|
|
|
RX_BUFFER_SIZE : len;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
|
|
|
(SEQID_FAST_READ << QSPI_IPCR_SEQID_SHIFT) |
|
|
|
|
size);
|
|
|
|
while (qspi_read32(priv->flags, ®s->sr) & QSPI_SR_BUSY_MASK)
|
2014-05-06 01:13:01 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
to_or_from += size;
|
|
|
|
len -= size;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while ((RX_BUFFER_SIZE >= size) && (size > 0)) {
|
2015-04-01 03:10:40 +00:00
|
|
|
data = qspi_read32(priv->flags, ®s->rbdr[i]);
|
2014-05-06 01:13:01 +00:00
|
|
|
data = qspi_endian_xchg(data);
|
|
|
|
memcpy(rxbuf, &data, 4);
|
|
|
|
rxbuf++;
|
|
|
|
size -= 4;
|
|
|
|
i++;
|
|
|
|
}
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
qspi_read32(priv->flags, ®s->mcr) |
|
|
|
|
QSPI_MCR_CLR_RXF_MASK);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, mcr_reg);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
#endif
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
static void qspi_op_write(struct fsl_qspi_priv *priv, u8 *txbuf, u32 len)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
2015-01-04 09:07:14 +00:00
|
|
|
u32 mcr_reg, data, reg, status_reg, seqid;
|
2014-05-06 01:13:01 +00:00
|
|
|
int i, size, tx_size;
|
|
|
|
u32 to_or_from = 0;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
mcr_reg = qspi_read32(priv->flags, ®s->mcr);
|
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
QSPI_MCR_CLR_RXF_MASK | QSPI_MCR_CLR_TXF_MASK |
|
|
|
|
QSPI_MCR_RESERVED_MASK | QSPI_MCR_END_CFD_LE);
|
|
|
|
qspi_write32(priv->flags, ®s->rbct, QSPI_RBCT_RXBRD_USEIPS);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
status_reg = 0;
|
|
|
|
while ((status_reg & FLASH_STATUS_WEL) != FLASH_STATUS_WEL) {
|
2015-11-04 08:19:10 +00:00
|
|
|
WATCHDOG_RESET();
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
|
|
|
(SEQID_WREN << QSPI_IPCR_SEQID_SHIFT) | 0);
|
|
|
|
while (qspi_read32(priv->flags, ®s->sr) & QSPI_SR_BUSY_MASK)
|
2014-05-06 01:13:01 +00:00
|
|
|
;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
|
|
|
(SEQID_RDSR << QSPI_IPCR_SEQID_SHIFT) | 1);
|
|
|
|
while (qspi_read32(priv->flags, ®s->sr) & QSPI_SR_BUSY_MASK)
|
2014-05-06 01:13:01 +00:00
|
|
|
;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
reg = qspi_read32(priv->flags, ®s->rbsr);
|
2014-05-06 01:13:01 +00:00
|
|
|
if (reg & QSPI_RBSR_RDBFL_MASK) {
|
2015-04-01 03:10:40 +00:00
|
|
|
status_reg = qspi_read32(priv->flags, ®s->rbdr[0]);
|
2014-05-06 01:13:01 +00:00
|
|
|
status_reg = qspi_endian_xchg(status_reg);
|
|
|
|
}
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
qspi_read32(priv->flags, ®s->mcr) |
|
|
|
|
QSPI_MCR_CLR_RXF_MASK);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-01-04 09:07:14 +00:00
|
|
|
/* Default is page programming */
|
|
|
|
seqid = SEQID_PP;
|
|
|
|
#ifdef CONFIG_SPI_FLASH_BAR
|
2015-04-01 03:10:40 +00:00
|
|
|
if (priv->cur_seqid == QSPI_CMD_BRWR)
|
2015-01-04 09:07:14 +00:00
|
|
|
seqid = SEQID_BRWR;
|
2015-04-01 03:10:40 +00:00
|
|
|
else if (priv->cur_seqid == QSPI_CMD_WREAR)
|
2015-01-04 09:07:14 +00:00
|
|
|
seqid = SEQID_WREAR;
|
|
|
|
#endif
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
to_or_from = priv->sf_addr + priv->cur_amba_base;
|
2015-01-04 09:07:14 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->sfar, to_or_from);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
tx_size = (len > TX_BUFFER_SIZE) ?
|
|
|
|
TX_BUFFER_SIZE : len;
|
|
|
|
|
2015-01-04 09:07:14 +00:00
|
|
|
size = tx_size / 4;
|
2014-05-06 01:13:01 +00:00
|
|
|
for (i = 0; i < size; i++) {
|
2015-01-04 09:07:14 +00:00
|
|
|
memcpy(&data, txbuf, 4);
|
|
|
|
data = qspi_endian_xchg(data);
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->tbdr, data);
|
2015-01-04 09:07:14 +00:00
|
|
|
txbuf += 4;
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-01-04 09:07:14 +00:00
|
|
|
size = tx_size % 4;
|
|
|
|
if (size) {
|
|
|
|
data = 0;
|
|
|
|
memcpy(&data, txbuf, size);
|
|
|
|
data = qspi_endian_xchg(data);
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->tbdr, data);
|
2015-01-04 09:07:14 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
|
|
|
(seqid << QSPI_IPCR_SEQID_SHIFT) | tx_size);
|
|
|
|
while (qspi_read32(priv->flags, ®s->sr) & QSPI_SR_BUSY_MASK)
|
2014-05-06 01:13:01 +00:00
|
|
|
;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, mcr_reg);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
static void qspi_op_rdsr(struct fsl_qspi_priv *priv, u32 *rxbuf)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
2014-05-06 01:13:01 +00:00
|
|
|
u32 mcr_reg, reg, data;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
mcr_reg = qspi_read32(priv->flags, ®s->mcr);
|
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
QSPI_MCR_CLR_RXF_MASK | QSPI_MCR_CLR_TXF_MASK |
|
|
|
|
QSPI_MCR_RESERVED_MASK | QSPI_MCR_END_CFD_LE);
|
|
|
|
qspi_write32(priv->flags, ®s->rbct, QSPI_RBCT_RXBRD_USEIPS);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->sfar, priv->cur_amba_base);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
|
|
|
(SEQID_RDSR << QSPI_IPCR_SEQID_SHIFT) | 0);
|
|
|
|
while (qspi_read32(priv->flags, ®s->sr) & QSPI_SR_BUSY_MASK)
|
2014-05-06 01:13:01 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
while (1) {
|
2015-04-01 03:10:40 +00:00
|
|
|
reg = qspi_read32(priv->flags, ®s->rbsr);
|
2014-05-06 01:13:01 +00:00
|
|
|
if (reg & QSPI_RBSR_RDBFL_MASK) {
|
2015-04-01 03:10:40 +00:00
|
|
|
data = qspi_read32(priv->flags, ®s->rbdr[0]);
|
2014-05-06 01:13:01 +00:00
|
|
|
data = qspi_endian_xchg(data);
|
|
|
|
memcpy(rxbuf, &data, 4);
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
qspi_read32(priv->flags, ®s->mcr) |
|
|
|
|
QSPI_MCR_CLR_RXF_MASK);
|
2014-05-06 01:13:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, mcr_reg);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
static void qspi_op_erase(struct fsl_qspi_priv *priv)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2015-04-01 03:10:40 +00:00
|
|
|
struct fsl_qspi_regs *regs = priv->regs;
|
2014-05-06 01:13:01 +00:00
|
|
|
u32 mcr_reg;
|
|
|
|
u32 to_or_from = 0;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
mcr_reg = qspi_read32(priv->flags, ®s->mcr);
|
|
|
|
qspi_write32(priv->flags, ®s->mcr,
|
|
|
|
QSPI_MCR_CLR_RXF_MASK | QSPI_MCR_CLR_TXF_MASK |
|
|
|
|
QSPI_MCR_RESERVED_MASK | QSPI_MCR_END_CFD_LE);
|
|
|
|
qspi_write32(priv->flags, ®s->rbct, QSPI_RBCT_RXBRD_USEIPS);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
to_or_from = priv->sf_addr + priv->cur_amba_base;
|
|
|
|
qspi_write32(priv->flags, ®s->sfar, to_or_from);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
|
|
|
(SEQID_WREN << QSPI_IPCR_SEQID_SHIFT) | 0);
|
|
|
|
while (qspi_read32(priv->flags, ®s->sr) & QSPI_SR_BUSY_MASK)
|
2014-05-06 01:13:01 +00:00
|
|
|
;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
if (priv->cur_seqid == QSPI_CMD_SE) {
|
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
2014-12-31 03:01:39 +00:00
|
|
|
(SEQID_SE << QSPI_IPCR_SEQID_SHIFT) | 0);
|
2015-04-01 03:10:40 +00:00
|
|
|
} else if (priv->cur_seqid == QSPI_CMD_BE_4K) {
|
|
|
|
qspi_write32(priv->flags, ®s->ipcr,
|
2014-12-31 03:01:39 +00:00
|
|
|
(SEQID_BE_4K << QSPI_IPCR_SEQID_SHIFT) | 0);
|
|
|
|
}
|
2015-04-01 03:10:40 +00:00
|
|
|
while (qspi_read32(priv->flags, ®s->sr) & QSPI_SR_BUSY_MASK)
|
2014-05-06 01:13:01 +00:00
|
|
|
;
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_write32(priv->flags, ®s->mcr, mcr_reg);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
int qspi_xfer(struct fsl_qspi_priv *priv, unsigned int bitlen,
|
2014-05-06 01:13:01 +00:00
|
|
|
const void *dout, void *din, unsigned long flags)
|
|
|
|
{
|
|
|
|
u32 bytes = DIV_ROUND_UP(bitlen, 8);
|
2015-01-04 09:07:14 +00:00
|
|
|
static u32 wr_sfaddr;
|
2014-05-06 01:13:01 +00:00
|
|
|
u32 txbuf;
|
|
|
|
|
|
|
|
if (dout) {
|
2015-01-04 09:07:14 +00:00
|
|
|
if (flags & SPI_XFER_BEGIN) {
|
2015-04-01 03:10:40 +00:00
|
|
|
priv->cur_seqid = *(u8 *)dout;
|
2015-01-04 09:07:14 +00:00
|
|
|
memcpy(&txbuf, dout, 4);
|
|
|
|
}
|
2014-05-06 01:13:01 +00:00
|
|
|
|
|
|
|
if (flags == SPI_XFER_END) {
|
2015-04-01 03:10:40 +00:00
|
|
|
priv->sf_addr = wr_sfaddr;
|
|
|
|
qspi_op_write(priv, (u8 *)dout, bytes);
|
2014-05-06 01:13:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
if (priv->cur_seqid == QSPI_CMD_FAST_READ) {
|
|
|
|
priv->sf_addr = swab32(txbuf) & OFFSET_BITS_MASK;
|
|
|
|
} else if ((priv->cur_seqid == QSPI_CMD_SE) ||
|
|
|
|
(priv->cur_seqid == QSPI_CMD_BE_4K)) {
|
|
|
|
priv->sf_addr = swab32(txbuf) & OFFSET_BITS_MASK;
|
|
|
|
qspi_op_erase(priv);
|
|
|
|
} else if (priv->cur_seqid == QSPI_CMD_PP) {
|
2015-01-04 09:07:14 +00:00
|
|
|
wr_sfaddr = swab32(txbuf) & OFFSET_BITS_MASK;
|
2015-04-01 03:10:40 +00:00
|
|
|
} else if ((priv->cur_seqid == QSPI_CMD_BRWR) ||
|
|
|
|
(priv->cur_seqid == QSPI_CMD_WREAR)) {
|
2015-01-04 09:07:14 +00:00
|
|
|
#ifdef CONFIG_SPI_FLASH_BAR
|
|
|
|
wr_sfaddr = 0;
|
|
|
|
#endif
|
2015-04-01 03:10:40 +00:00
|
|
|
}
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (din) {
|
2015-04-01 03:10:40 +00:00
|
|
|
if (priv->cur_seqid == QSPI_CMD_FAST_READ) {
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_QSPI_AHB
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_ahb_read(priv, din, bytes);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
#else
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_op_read(priv, din, bytes);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
#endif
|
2015-04-01 03:10:40 +00:00
|
|
|
} else if (priv->cur_seqid == QSPI_CMD_RDID)
|
|
|
|
qspi_op_rdid(priv, din, bytes);
|
|
|
|
else if (priv->cur_seqid == QSPI_CMD_RDSR)
|
|
|
|
qspi_op_rdsr(priv, din);
|
2015-01-04 09:07:14 +00:00
|
|
|
#ifdef CONFIG_SPI_FLASH_BAR
|
2015-04-01 03:10:40 +00:00
|
|
|
else if ((priv->cur_seqid == QSPI_CMD_BRRD) ||
|
|
|
|
(priv->cur_seqid == QSPI_CMD_RDEAR)) {
|
|
|
|
priv->sf_addr = 0;
|
|
|
|
qspi_op_rdbank(priv, din, bytes);
|
2015-01-04 09:07:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_QSPI_AHB
|
2015-04-01 03:10:40 +00:00
|
|
|
if ((priv->cur_seqid == QSPI_CMD_SE) ||
|
|
|
|
(priv->cur_seqid == QSPI_CMD_PP) ||
|
|
|
|
(priv->cur_seqid == QSPI_CMD_BE_4K) ||
|
|
|
|
(priv->cur_seqid == QSPI_CMD_WREAR) ||
|
|
|
|
(priv->cur_seqid == QSPI_CMD_BRWR))
|
|
|
|
qspi_ahb_invalid(priv);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qspi_module_disable(struct fsl_qspi_priv *priv, u8 disable)
|
|
|
|
{
|
|
|
|
u32 mcr_val;
|
|
|
|
|
|
|
|
mcr_val = qspi_read32(priv->flags, &priv->regs->mcr);
|
|
|
|
if (disable)
|
|
|
|
mcr_val |= QSPI_MCR_MDIS_MASK;
|
|
|
|
else
|
|
|
|
mcr_val &= ~QSPI_MCR_MDIS_MASK;
|
|
|
|
qspi_write32(priv->flags, &priv->regs->mcr, mcr_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void qspi_cfg_smpr(struct fsl_qspi_priv *priv, u32 clear_bits, u32 set_bits)
|
|
|
|
{
|
|
|
|
u32 smpr_val;
|
|
|
|
|
|
|
|
smpr_val = qspi_read32(priv->flags, &priv->regs->smpr);
|
|
|
|
smpr_val &= ~clear_bits;
|
|
|
|
smpr_val |= set_bits;
|
|
|
|
qspi_write32(priv->flags, &priv->regs->smpr, smpr_val);
|
|
|
|
}
|
|
|
|
#ifndef CONFIG_DM_SPI
|
|
|
|
static unsigned long spi_bases[] = {
|
|
|
|
QSPI0_BASE_ADDR,
|
|
|
|
#ifdef CONFIG_MX6SX
|
|
|
|
QSPI1_BASE_ADDR,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned long amba_bases[] = {
|
|
|
|
QSPI0_AMBA_BASE,
|
|
|
|
#ifdef CONFIG_MX6SX
|
|
|
|
QSPI1_AMBA_BASE,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct fsl_qspi *to_qspi_spi(struct spi_slave *slave)
|
|
|
|
{
|
|
|
|
return container_of(slave, struct fsl_qspi, slave);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
|
|
|
|
unsigned int max_hz, unsigned int mode)
|
|
|
|
{
|
|
|
|
struct fsl_qspi *qspi;
|
|
|
|
struct fsl_qspi_regs *regs;
|
|
|
|
u32 total_size;
|
|
|
|
|
|
|
|
if (bus >= ARRAY_SIZE(spi_bases))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (cs >= FSL_QSPI_FLASH_NUM)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
qspi = spi_alloc_slave(struct fsl_qspi, bus, cs);
|
|
|
|
if (!qspi)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_FSL_QSPI_BE
|
|
|
|
qspi->priv.flags |= QSPI_FLAG_REGMAP_ENDIAN_BIG;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
regs = (struct fsl_qspi_regs *)spi_bases[bus];
|
|
|
|
qspi->priv.regs = regs;
|
|
|
|
/*
|
|
|
|
* According cs, use different amba_base to choose the
|
|
|
|
* corresponding flash devices.
|
|
|
|
*
|
|
|
|
* If not, only one flash device is used even if passing
|
|
|
|
* different cs using `sf probe`
|
|
|
|
*/
|
|
|
|
qspi->priv.cur_amba_base = amba_bases[bus] + cs * FSL_QSPI_FLASH_SIZE;
|
|
|
|
|
|
|
|
qspi->slave.max_write_size = TX_BUFFER_SIZE;
|
|
|
|
|
|
|
|
qspi_write32(qspi->priv.flags, ®s->mcr,
|
|
|
|
QSPI_MCR_RESERVED_MASK | QSPI_MCR_MDIS_MASK);
|
|
|
|
|
|
|
|
qspi_cfg_smpr(&qspi->priv,
|
|
|
|
~(QSPI_SMPR_FSDLY_MASK | QSPI_SMPR_DDRSMP_MASK |
|
|
|
|
QSPI_SMPR_FSPHS_MASK | QSPI_SMPR_HSENA_MASK), 0);
|
|
|
|
|
|
|
|
total_size = FSL_QSPI_FLASH_SIZE * FSL_QSPI_FLASH_NUM;
|
|
|
|
/*
|
|
|
|
* Any read access to non-implemented addresses will provide
|
|
|
|
* undefined results.
|
|
|
|
*
|
|
|
|
* In case single die flash devices, TOP_ADDR_MEMA2 and
|
|
|
|
* TOP_ADDR_MEMB2 should be initialized/programmed to
|
|
|
|
* TOP_ADDR_MEMA1 and TOP_ADDR_MEMB1 respectively - in effect,
|
|
|
|
* setting the size of these devices to 0. This would ensure
|
|
|
|
* that the complete memory map is assigned to only one flash device.
|
|
|
|
*/
|
|
|
|
qspi_write32(qspi->priv.flags, ®s->sfa1ad,
|
|
|
|
FSL_QSPI_FLASH_SIZE | amba_bases[bus]);
|
|
|
|
qspi_write32(qspi->priv.flags, ®s->sfa2ad,
|
|
|
|
FSL_QSPI_FLASH_SIZE | amba_bases[bus]);
|
|
|
|
qspi_write32(qspi->priv.flags, ®s->sfb1ad,
|
|
|
|
total_size | amba_bases[bus]);
|
|
|
|
qspi_write32(qspi->priv.flags, ®s->sfb2ad,
|
|
|
|
total_size | amba_bases[bus]);
|
|
|
|
|
|
|
|
qspi_set_lut(&qspi->priv);
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_FSL_QSPI_AHB
|
|
|
|
qspi_init_ahb_read(&qspi->priv);
|
qspi:fsl implement AHB read
The QSPI controller in i.MX 6SoloX and Vybrid supports reading data using
IP register and AHB bus.
The original driver only supports reading data from IP interface. The IC
team suggests to use AHB read which is faster then IP read. Using AHB read,
we can directly memcpy, a "missed" access to the buffer will cause the
controller to clear the buffer and use the SEQID stored in bfgencr register
to initiate a read from flash device.
Since AHB bus is 64 bit width, we can not set MCR register using 32bit. In
order to minimize code change, redefine QSPI_MCR_END_CFD_LE to 64bit Little
endian but not 32bit Little endia.
Introduce a new configuration option CONFIG_SYS_FSL_QSPI_AHB. If want to
use AHB read, just define CONFIG_SYS_FSL_QSPI_AHB. If not, just ignore it.
Actually if Vybrid is migrated to use AHB read, this option can be removed and
IP read function can be discared. The reason to introduce this option
is that only i.MX SOC is tested in my side, no Vybrid platform for me.
In spi_setup_slave, the original piece code to set AHB is deleted, since
Vybrid platform does not use this to intiate AHB read. Instead, add
qspi_init_ahb_read function if defined CONFIG_SYS_FSL_QSPI_AHB.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
2015-01-08 02:40:20 +00:00
|
|
|
#endif
|
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
qspi_module_disable(&qspi->priv, 0);
|
|
|
|
|
|
|
|
return &qspi->slave;
|
|
|
|
}
|
|
|
|
|
|
|
|
void spi_free_slave(struct spi_slave *slave)
|
|
|
|
{
|
|
|
|
struct fsl_qspi *qspi = to_qspi_spi(slave);
|
|
|
|
|
|
|
|
free(qspi);
|
|
|
|
}
|
|
|
|
|
|
|
|
int spi_claim_bus(struct spi_slave *slave)
|
|
|
|
{
|
2014-05-06 01:13:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void spi_release_bus(struct spi_slave *slave)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
}
|
2015-04-01 03:10:40 +00:00
|
|
|
|
|
|
|
int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
|
|
|
|
const void *dout, void *din, unsigned long flags)
|
|
|
|
{
|
|
|
|
struct fsl_qspi *qspi = to_qspi_spi(slave);
|
|
|
|
|
|
|
|
return qspi_xfer(&qspi->priv, bitlen, dout, din, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void spi_init(void)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static int fsl_qspi_child_pre_probe(struct udevice *dev)
|
|
|
|
{
|
2015-09-29 05:32:01 +00:00
|
|
|
struct spi_slave *slave = dev_get_parent_priv(dev);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
|
|
|
slave->max_write_size = TX_BUFFER_SIZE;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_probe(struct udevice *bus)
|
|
|
|
{
|
|
|
|
u32 total_size;
|
|
|
|
struct fsl_qspi_platdata *plat = dev_get_platdata(bus);
|
|
|
|
struct fsl_qspi_priv *priv = dev_get_priv(bus);
|
|
|
|
struct dm_spi_bus *dm_spi_bus;
|
|
|
|
|
|
|
|
dm_spi_bus = bus->uclass_priv;
|
|
|
|
|
|
|
|
dm_spi_bus->max_hz = plat->speed_hz;
|
|
|
|
|
|
|
|
priv->regs = (struct fsl_qspi_regs *)plat->reg_base;
|
|
|
|
priv->flags = plat->flags;
|
|
|
|
|
|
|
|
priv->speed_hz = plat->speed_hz;
|
|
|
|
priv->amba_base[0] = plat->amba_base;
|
|
|
|
priv->amba_total_size = plat->amba_total_size;
|
|
|
|
priv->flash_num = plat->flash_num;
|
|
|
|
priv->num_chipselect = plat->num_chipselect;
|
|
|
|
|
|
|
|
qspi_write32(priv->flags, &priv->regs->mcr,
|
|
|
|
QSPI_MCR_RESERVED_MASK | QSPI_MCR_MDIS_MASK);
|
|
|
|
|
|
|
|
qspi_cfg_smpr(priv, ~(QSPI_SMPR_FSDLY_MASK | QSPI_SMPR_DDRSMP_MASK |
|
|
|
|
QSPI_SMPR_FSPHS_MASK | QSPI_SMPR_HSENA_MASK), 0);
|
|
|
|
|
|
|
|
total_size = FSL_QSPI_FLASH_SIZE * FSL_QSPI_FLASH_NUM;
|
|
|
|
/*
|
|
|
|
* Any read access to non-implemented addresses will provide
|
|
|
|
* undefined results.
|
|
|
|
*
|
|
|
|
* In case single die flash devices, TOP_ADDR_MEMA2 and
|
|
|
|
* TOP_ADDR_MEMB2 should be initialized/programmed to
|
|
|
|
* TOP_ADDR_MEMA1 and TOP_ADDR_MEMB1 respectively - in effect,
|
|
|
|
* setting the size of these devices to 0. This would ensure
|
|
|
|
* that the complete memory map is assigned to only one flash device.
|
|
|
|
*/
|
|
|
|
qspi_write32(priv->flags, &priv->regs->sfa1ad,
|
|
|
|
FSL_QSPI_FLASH_SIZE | priv->amba_base[0]);
|
|
|
|
qspi_write32(priv->flags, &priv->regs->sfa2ad,
|
|
|
|
FSL_QSPI_FLASH_SIZE | priv->amba_base[0]);
|
|
|
|
qspi_write32(priv->flags, &priv->regs->sfb1ad,
|
|
|
|
total_size | priv->amba_base[0]);
|
|
|
|
qspi_write32(priv->flags, &priv->regs->sfb2ad,
|
|
|
|
total_size | priv->amba_base[0]);
|
|
|
|
|
|
|
|
qspi_set_lut(priv);
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_FSL_QSPI_AHB
|
|
|
|
qspi_init_ahb_read(priv);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
qspi_module_disable(priv, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_ofdata_to_platdata(struct udevice *bus)
|
|
|
|
{
|
|
|
|
struct reg_data {
|
|
|
|
u32 addr;
|
|
|
|
u32 size;
|
|
|
|
} regs_data[2];
|
|
|
|
struct fsl_qspi_platdata *plat = bus->platdata;
|
|
|
|
const void *blob = gd->fdt_blob;
|
|
|
|
int node = bus->of_offset;
|
|
|
|
int ret, flash_num = 0, subnode;
|
|
|
|
|
|
|
|
if (fdtdec_get_bool(blob, node, "big-endian"))
|
|
|
|
plat->flags |= QSPI_FLAG_REGMAP_ENDIAN_BIG;
|
|
|
|
|
|
|
|
ret = fdtdec_get_int_array(blob, node, "reg", (u32 *)regs_data,
|
|
|
|
sizeof(regs_data)/sizeof(u32));
|
|
|
|
if (ret) {
|
|
|
|
debug("Error: can't get base addresses (ret = %d)!\n", ret);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Count flash numbers */
|
|
|
|
fdt_for_each_subnode(blob, subnode, node)
|
|
|
|
++flash_num;
|
|
|
|
|
|
|
|
if (flash_num == 0) {
|
|
|
|
debug("Error: Missing flashes!\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
plat->speed_hz = fdtdec_get_int(blob, node, "spi-max-frequency",
|
|
|
|
FSL_QSPI_DEFAULT_SCK_FREQ);
|
|
|
|
plat->num_chipselect = fdtdec_get_int(blob, node, "num-cs",
|
|
|
|
FSL_QSPI_MAX_CHIPSELECT_NUM);
|
|
|
|
|
|
|
|
plat->reg_base = regs_data[0].addr;
|
|
|
|
plat->amba_base = regs_data[1].addr;
|
|
|
|
plat->amba_total_size = regs_data[1].size;
|
|
|
|
plat->flash_num = flash_num;
|
|
|
|
|
|
|
|
debug("%s: regs=<0x%x> <0x%x, 0x%x>, max-frequency=%d, endianess=%s\n",
|
|
|
|
__func__,
|
|
|
|
plat->reg_base,
|
|
|
|
plat->amba_base,
|
|
|
|
plat->amba_total_size,
|
|
|
|
plat->speed_hz,
|
|
|
|
plat->flags & QSPI_FLAG_REGMAP_ENDIAN_BIG ? "be" : "le"
|
|
|
|
);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_xfer(struct udevice *dev, unsigned int bitlen,
|
|
|
|
const void *dout, void *din, unsigned long flags)
|
|
|
|
{
|
|
|
|
struct fsl_qspi_priv *priv;
|
|
|
|
struct udevice *bus;
|
|
|
|
|
|
|
|
bus = dev->parent;
|
|
|
|
priv = dev_get_priv(bus);
|
|
|
|
|
|
|
|
return qspi_xfer(priv, bitlen, dout, din, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_claim_bus(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct fsl_qspi_priv *priv;
|
|
|
|
struct udevice *bus;
|
|
|
|
struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
|
|
|
|
|
|
|
|
bus = dev->parent;
|
|
|
|
priv = dev_get_priv(bus);
|
|
|
|
|
|
|
|
priv->cur_amba_base =
|
|
|
|
priv->amba_base[0] + FSL_QSPI_FLASH_SIZE * slave_plat->cs;
|
|
|
|
|
|
|
|
qspi_module_disable(priv, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_release_bus(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct fsl_qspi_priv *priv;
|
|
|
|
struct udevice *bus;
|
|
|
|
|
|
|
|
bus = dev->parent;
|
|
|
|
priv = dev_get_priv(bus);
|
|
|
|
|
|
|
|
qspi_module_disable(priv, 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_set_speed(struct udevice *bus, uint speed)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_set_mode(struct udevice *bus, uint mode)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct dm_spi_ops fsl_qspi_ops = {
|
|
|
|
.claim_bus = fsl_qspi_claim_bus,
|
|
|
|
.release_bus = fsl_qspi_release_bus,
|
|
|
|
.xfer = fsl_qspi_xfer,
|
|
|
|
.set_speed = fsl_qspi_set_speed,
|
|
|
|
.set_mode = fsl_qspi_set_mode,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct udevice_id fsl_qspi_ids[] = {
|
|
|
|
{ .compatible = "fsl,vf610-qspi" },
|
|
|
|
{ .compatible = "fsl,imx6sx-qspi" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(fsl_qspi) = {
|
|
|
|
.name = "fsl_qspi",
|
|
|
|
.id = UCLASS_SPI,
|
|
|
|
.of_match = fsl_qspi_ids,
|
|
|
|
.ops = &fsl_qspi_ops,
|
|
|
|
.ofdata_to_platdata = fsl_qspi_ofdata_to_platdata,
|
|
|
|
.platdata_auto_alloc_size = sizeof(struct fsl_qspi_platdata),
|
|
|
|
.priv_auto_alloc_size = sizeof(struct fsl_qspi_priv),
|
|
|
|
.probe = fsl_qspi_probe,
|
|
|
|
.child_pre_probe = fsl_qspi_child_pre_probe,
|
|
|
|
};
|
|
|
|
#endif
|