2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2020-02-20 17:27:52 +00:00
|
|
|
|
2014-05-06 01:13:01 +00:00
|
|
|
/*
|
2020-02-20 17:27:52 +00:00
|
|
|
* Freescale QuadSPI driver.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Freescale Semiconductor, Inc.
|
|
|
|
* Copyright (C) 2018 Bootlin
|
|
|
|
* Copyright (C) 2018 exceet electronics GmbH
|
|
|
|
* Copyright (C) 2018 Kontron Electronics GmbH
|
|
|
|
* Copyright 2019-2020 NXP
|
|
|
|
*
|
|
|
|
* This driver is a ported version of Linux Freescale QSPI driver taken from
|
|
|
|
* v5.5-rc1 tag having following information.
|
2014-05-06 01:13:01 +00:00
|
|
|
*
|
2020-02-20 17:27:52 +00:00
|
|
|
* Transition to SPI MEM interface:
|
|
|
|
* Authors:
|
|
|
|
* Boris Brezillon <bbrezillon@kernel.org>
|
|
|
|
* Frieder Schrempf <frieder.schrempf@kontron.de>
|
|
|
|
* Yogesh Gaur <yogeshnarayan.gaur@nxp.com>
|
|
|
|
* Suresh Gupta <suresh.gupta@nxp.com>
|
|
|
|
*
|
|
|
|
* Based on the original fsl-quadspi.c spi-nor driver.
|
|
|
|
* Transition to spi-mem in spi-fsl-qspi.c
|
2014-05-06 01:13:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2014-05-06 01:13:01 +00:00
|
|
|
#include <asm/io.h>
|
2020-05-10 17:40:13 +00:00
|
|
|
#include <linux/bitops.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2020-05-10 17:40:01 +00:00
|
|
|
#include <linux/libfdt.h>
|
|
|
|
#include <linux/sizes.h>
|
|
|
|
#include <linux/iopoll.h>
|
2015-04-01 03:10:40 +00:00
|
|
|
#include <dm.h>
|
2020-02-20 17:27:52 +00:00
|
|
|
#include <linux/iopoll.h>
|
|
|
|
#include <linux/sizes.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <spi.h>
|
|
|
|
#include <spi-mem.h>
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/*
|
|
|
|
* The driver only uses one single LUT entry, that is updated on
|
|
|
|
* each call of exec_op(). Index 0 is preset at boot with a basic
|
|
|
|
* read operation, so let's use the last entry (15).
|
|
|
|
*/
|
|
|
|
#define SEQID_LUT 15
|
|
|
|
|
|
|
|
/* Registers used by the driver */
|
|
|
|
#define QUADSPI_MCR 0x00
|
|
|
|
#define QUADSPI_MCR_RESERVED_MASK GENMASK(19, 16)
|
|
|
|
#define QUADSPI_MCR_MDIS_MASK BIT(14)
|
|
|
|
#define QUADSPI_MCR_CLR_TXF_MASK BIT(11)
|
|
|
|
#define QUADSPI_MCR_CLR_RXF_MASK BIT(10)
|
|
|
|
#define QUADSPI_MCR_DDR_EN_MASK BIT(7)
|
|
|
|
#define QUADSPI_MCR_END_CFG_MASK GENMASK(3, 2)
|
|
|
|
#define QUADSPI_MCR_SWRSTHD_MASK BIT(1)
|
|
|
|
#define QUADSPI_MCR_SWRSTSD_MASK BIT(0)
|
|
|
|
|
|
|
|
#define QUADSPI_IPCR 0x08
|
|
|
|
#define QUADSPI_IPCR_SEQID(x) ((x) << 24)
|
|
|
|
#define QUADSPI_FLSHCR 0x0c
|
|
|
|
#define QUADSPI_FLSHCR_TCSS_MASK GENMASK(3, 0)
|
|
|
|
#define QUADSPI_FLSHCR_TCSH_MASK GENMASK(11, 8)
|
|
|
|
#define QUADSPI_FLSHCR_TDH_MASK GENMASK(17, 16)
|
|
|
|
|
|
|
|
#define QUADSPI_BUF3CR 0x1c
|
|
|
|
#define QUADSPI_BUF3CR_ALLMST_MASK BIT(31)
|
|
|
|
#define QUADSPI_BUF3CR_ADATSZ(x) ((x) << 8)
|
|
|
|
#define QUADSPI_BUF3CR_ADATSZ_MASK GENMASK(15, 8)
|
|
|
|
|
|
|
|
#define QUADSPI_BFGENCR 0x20
|
|
|
|
#define QUADSPI_BFGENCR_SEQID(x) ((x) << 12)
|
|
|
|
|
|
|
|
#define QUADSPI_BUF0IND 0x30
|
|
|
|
#define QUADSPI_BUF1IND 0x34
|
|
|
|
#define QUADSPI_BUF2IND 0x38
|
|
|
|
#define QUADSPI_SFAR 0x100
|
|
|
|
|
|
|
|
#define QUADSPI_SMPR 0x108
|
|
|
|
#define QUADSPI_SMPR_DDRSMP_MASK GENMASK(18, 16)
|
|
|
|
#define QUADSPI_SMPR_FSDLY_MASK BIT(6)
|
|
|
|
#define QUADSPI_SMPR_FSPHS_MASK BIT(5)
|
|
|
|
#define QUADSPI_SMPR_HSENA_MASK BIT(0)
|
|
|
|
|
|
|
|
#define QUADSPI_RBCT 0x110
|
|
|
|
#define QUADSPI_RBCT_WMRK_MASK GENMASK(4, 0)
|
|
|
|
#define QUADSPI_RBCT_RXBRD_USEIPS BIT(8)
|
|
|
|
|
|
|
|
#define QUADSPI_TBDR 0x154
|
|
|
|
|
|
|
|
#define QUADSPI_SR 0x15c
|
|
|
|
#define QUADSPI_SR_IP_ACC_MASK BIT(1)
|
|
|
|
#define QUADSPI_SR_AHB_ACC_MASK BIT(2)
|
|
|
|
|
|
|
|
#define QUADSPI_FR 0x160
|
|
|
|
#define QUADSPI_FR_TFF_MASK BIT(0)
|
|
|
|
|
|
|
|
#define QUADSPI_RSER 0x164
|
|
|
|
#define QUADSPI_RSER_TFIE BIT(0)
|
|
|
|
|
|
|
|
#define QUADSPI_SPTRCLR 0x16c
|
|
|
|
#define QUADSPI_SPTRCLR_IPPTRC BIT(8)
|
|
|
|
#define QUADSPI_SPTRCLR_BFPTRC BIT(0)
|
|
|
|
|
|
|
|
#define QUADSPI_SFA1AD 0x180
|
|
|
|
#define QUADSPI_SFA2AD 0x184
|
|
|
|
#define QUADSPI_SFB1AD 0x188
|
|
|
|
#define QUADSPI_SFB2AD 0x18c
|
|
|
|
#define QUADSPI_RBDR(x) (0x200 + ((x) * 4))
|
|
|
|
|
|
|
|
#define QUADSPI_LUTKEY 0x300
|
|
|
|
#define QUADSPI_LUTKEY_VALUE 0x5AF05AF0
|
|
|
|
|
|
|
|
#define QUADSPI_LCKCR 0x304
|
|
|
|
#define QUADSPI_LCKER_LOCK BIT(0)
|
|
|
|
#define QUADSPI_LCKER_UNLOCK BIT(1)
|
|
|
|
|
|
|
|
#define QUADSPI_LUT_BASE 0x310
|
|
|
|
#define QUADSPI_LUT_OFFSET (SEQID_LUT * 4 * 4)
|
|
|
|
#define QUADSPI_LUT_REG(idx) \
|
|
|
|
(QUADSPI_LUT_BASE + QUADSPI_LUT_OFFSET + (idx) * 4)
|
|
|
|
|
|
|
|
/* Instruction set for the LUT register */
|
|
|
|
#define LUT_STOP 0
|
|
|
|
#define LUT_CMD 1
|
|
|
|
#define LUT_ADDR 2
|
|
|
|
#define LUT_DUMMY 3
|
|
|
|
#define LUT_MODE 4
|
|
|
|
#define LUT_MODE2 5
|
|
|
|
#define LUT_MODE4 6
|
|
|
|
#define LUT_FSL_READ 7
|
|
|
|
#define LUT_FSL_WRITE 8
|
|
|
|
#define LUT_JMP_ON_CS 9
|
|
|
|
#define LUT_ADDR_DDR 10
|
|
|
|
#define LUT_MODE_DDR 11
|
|
|
|
#define LUT_MODE2_DDR 12
|
|
|
|
#define LUT_MODE4_DDR 13
|
|
|
|
#define LUT_FSL_READ_DDR 14
|
|
|
|
#define LUT_FSL_WRITE_DDR 15
|
|
|
|
#define LUT_DATA_LEARN 16
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The PAD definitions for LUT register.
|
|
|
|
*
|
|
|
|
* The pad stands for the number of IO lines [0:3].
|
|
|
|
* For example, the quad read needs four IO lines,
|
|
|
|
* so you should use LUT_PAD(4).
|
|
|
|
*/
|
|
|
|
#define LUT_PAD(x) (fls(x) - 1)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macro for constructing the LUT entries with the following
|
|
|
|
* register layout:
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
* | INSTR1 | PAD1 | OPRND1 | INSTR0 | PAD0 | OPRND0 |
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
#define LUT_DEF(idx, ins, pad, opr) \
|
|
|
|
((((ins) << 10) | ((pad) << 8) | (opr)) << (((idx) % 2) * 16))
|
|
|
|
|
|
|
|
/* Controller needs driver to swap endianness */
|
2019-08-14 11:31:36 +00:00
|
|
|
#define QUADSPI_QUIRK_SWAP_ENDIAN BIT(0)
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* Controller needs 4x internal clock */
|
|
|
|
#define QUADSPI_QUIRK_4X_INT_CLK BIT(1)
|
2019-08-14 11:31:36 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/*
|
|
|
|
* TKT253890, the controller needs the driver to fill the txfifo with
|
|
|
|
* 16 bytes at least to trigger a data transfer, even though the extra
|
|
|
|
* data won't be transferred.
|
|
|
|
*/
|
|
|
|
#define QUADSPI_QUIRK_TKT253890 BIT(2)
|
2019-08-14 11:31:36 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* TKT245618, the controller cannot wake up from wait mode */
|
|
|
|
#define QUADSPI_QUIRK_TKT245618 BIT(3)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Controller adds QSPI_AMBA_BASE (base address of the mapped memory)
|
|
|
|
* internally. No need to add it when setting SFXXAD and SFAR registers
|
2015-04-01 03:10:40 +00:00
|
|
|
*/
|
2020-02-20 17:27:52 +00:00
|
|
|
#define QUADSPI_QUIRK_BASE_INTERNAL BIT(4)
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/*
|
|
|
|
* Controller uses TDH bits in register QUADSPI_FLSHCR.
|
|
|
|
* They need to be set in accordance with the DDR/SDR mode.
|
2015-04-01 03:10:40 +00:00
|
|
|
*/
|
2020-02-20 17:27:52 +00:00
|
|
|
#define QUADSPI_QUIRK_USE_TDH_SETTING BIT(5)
|
|
|
|
|
|
|
|
struct fsl_qspi_devtype_data {
|
|
|
|
unsigned int rxfifo;
|
|
|
|
unsigned int txfifo;
|
|
|
|
unsigned int ahb_buf_size;
|
|
|
|
unsigned int quirks;
|
|
|
|
bool little_endian;
|
2014-05-06 01:13:01 +00:00
|
|
|
};
|
|
|
|
|
2019-08-14 11:31:36 +00:00
|
|
|
static const struct fsl_qspi_devtype_data vybrid_data = {
|
2020-02-20 17:27:52 +00:00
|
|
|
.rxfifo = SZ_128,
|
|
|
|
.txfifo = SZ_64,
|
|
|
|
.ahb_buf_size = SZ_1K,
|
|
|
|
.quirks = QUADSPI_QUIRK_SWAP_ENDIAN,
|
|
|
|
.little_endian = true,
|
2019-08-14 11:31:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct fsl_qspi_devtype_data imx6sx_data = {
|
2020-02-20 17:27:52 +00:00
|
|
|
.rxfifo = SZ_128,
|
|
|
|
.txfifo = SZ_512,
|
|
|
|
.ahb_buf_size = SZ_1K,
|
|
|
|
.quirks = QUADSPI_QUIRK_4X_INT_CLK | QUADSPI_QUIRK_TKT245618,
|
|
|
|
.little_endian = true,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct fsl_qspi_devtype_data imx7d_data = {
|
|
|
|
.rxfifo = SZ_128,
|
|
|
|
.txfifo = SZ_512,
|
|
|
|
.ahb_buf_size = SZ_1K,
|
|
|
|
.quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_4X_INT_CLK |
|
|
|
|
QUADSPI_QUIRK_USE_TDH_SETTING,
|
|
|
|
.little_endian = true,
|
2019-08-14 11:31:36 +00:00
|
|
|
};
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static const struct fsl_qspi_devtype_data imx6ul_data = {
|
|
|
|
.rxfifo = SZ_128,
|
|
|
|
.txfifo = SZ_512,
|
|
|
|
.ahb_buf_size = SZ_1K,
|
|
|
|
.quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_4X_INT_CLK |
|
|
|
|
QUADSPI_QUIRK_USE_TDH_SETTING,
|
|
|
|
.little_endian = true,
|
2019-08-14 11:31:36 +00:00
|
|
|
};
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static const struct fsl_qspi_devtype_data ls1021a_data = {
|
|
|
|
.rxfifo = SZ_128,
|
|
|
|
.txfifo = SZ_64,
|
|
|
|
.ahb_buf_size = SZ_1K,
|
|
|
|
.quirks = 0,
|
|
|
|
.little_endian = false,
|
2019-08-14 11:31:40 +00:00
|
|
|
};
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static const struct fsl_qspi_devtype_data ls1088a_data = {
|
|
|
|
.rxfifo = SZ_128,
|
|
|
|
.txfifo = SZ_128,
|
|
|
|
.ahb_buf_size = SZ_1K,
|
|
|
|
.quirks = QUADSPI_QUIRK_TKT253890,
|
|
|
|
.little_endian = true,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct fsl_qspi_devtype_data ls2080a_data = {
|
|
|
|
.rxfifo = SZ_128,
|
|
|
|
.txfifo = SZ_64,
|
|
|
|
.ahb_buf_size = SZ_1K,
|
|
|
|
.quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_BASE_INTERNAL,
|
|
|
|
.little_endian = true,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fsl_qspi {
|
|
|
|
struct udevice *dev;
|
|
|
|
void __iomem *iobase;
|
|
|
|
void __iomem *ahb_addr;
|
|
|
|
u32 memmap_phy;
|
|
|
|
const struct fsl_qspi_devtype_data *devtype_data;
|
|
|
|
int selected;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline int needs_swap_endian(struct fsl_qspi *q)
|
2015-04-01 03:10:40 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
return q->devtype_data->quirks & QUADSPI_QUIRK_SWAP_ENDIAN;
|
2015-04-01 03:10:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static inline int needs_4x_clock(struct fsl_qspi *q)
|
2015-04-01 03:10:40 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
return q->devtype_data->quirks & QUADSPI_QUIRK_4X_INT_CLK;
|
2015-04-01 03:10:40 +00:00
|
|
|
}
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static inline int needs_fill_txfifo(struct fsl_qspi *q)
|
2018-03-22 08:00:55 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
return q->devtype_data->quirks & QUADSPI_QUIRK_TKT253890;
|
2018-03-22 08:00:55 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static inline int needs_wakeup_wait_mode(struct fsl_qspi *q)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
return q->devtype_data->quirks & QUADSPI_QUIRK_TKT245618;
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static inline int needs_amba_base_offset(struct fsl_qspi *q)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
return !(q->devtype_data->quirks & QUADSPI_QUIRK_BASE_INTERNAL);
|
|
|
|
}
|
2016-03-15 06:36:42 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static inline int needs_tdh_setting(struct fsl_qspi *q)
|
|
|
|
{
|
|
|
|
return q->devtype_data->quirks & QUADSPI_QUIRK_USE_TDH_SETTING;
|
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
|
|
|
/*
|
2020-02-20 17:27:52 +00:00
|
|
|
* An IC bug makes it necessary to rearrange the 32-bit data.
|
|
|
|
* Later chips, such as IMX6SLX, have fixed this bug.
|
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
|
|
|
*/
|
2020-02-20 17:27:52 +00:00
|
|
|
static inline u32 fsl_qspi_endian_xchg(struct fsl_qspi *q, u32 a)
|
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
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
return needs_swap_endian(q) ? __swab32(a) : a;
|
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
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/*
|
|
|
|
* R/W functions for big- or little-endian registers:
|
|
|
|
* The QSPI controller's endianness is independent of
|
|
|
|
* the CPU core's endianness. So far, although the CPU
|
|
|
|
* core is little-endian the QSPI controller can use
|
|
|
|
* big-endian or little-endian.
|
|
|
|
*/
|
|
|
|
static void qspi_writel(struct fsl_qspi *q, u32 val, void __iomem *addr)
|
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
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
if (q->devtype_data->little_endian)
|
|
|
|
out_le32(addr, val);
|
|
|
|
else
|
|
|
|
out_be32(addr, val);
|
|
|
|
}
|
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
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static u32 qspi_readl(struct fsl_qspi *q, void __iomem *addr)
|
|
|
|
{
|
|
|
|
if (q->devtype_data->little_endian)
|
|
|
|
return in_le32(addr);
|
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
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
return in_be32(addr);
|
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
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static int fsl_qspi_check_buswidth(struct fsl_qspi *q, u8 width)
|
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
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
switch (width) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
return 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
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
return -ENOTSUPP;
|
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
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static bool fsl_qspi_supports_op(struct spi_slave *slave,
|
|
|
|
const struct spi_mem_op *op)
|
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
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
struct fsl_qspi *q = dev_get_priv(slave->dev->parent);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = fsl_qspi_check_buswidth(q, op->cmd.buswidth);
|
|
|
|
|
|
|
|
if (op->addr.nbytes)
|
|
|
|
ret |= fsl_qspi_check_buswidth(q, op->addr.buswidth);
|
|
|
|
|
|
|
|
if (op->dummy.nbytes)
|
|
|
|
ret |= fsl_qspi_check_buswidth(q, op->dummy.buswidth);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
if (op->data.nbytes)
|
|
|
|
ret |= fsl_qspi_check_buswidth(q, op->data.buswidth);
|
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
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
if (ret)
|
|
|
|
return false;
|
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
|
|
|
|
|
|
|
/*
|
2020-02-20 17:27:52 +00:00
|
|
|
* The number of instructions needed for the op, needs
|
|
|
|
* to fit into a single LUT entry.
|
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
|
|
|
*/
|
2020-02-20 17:27:52 +00:00
|
|
|
if (op->addr.nbytes +
|
|
|
|
(op->dummy.nbytes ? 1 : 0) +
|
|
|
|
(op->data.nbytes ? 1 : 0) > 6)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Max 64 dummy clock cycles supported */
|
|
|
|
if (op->dummy.nbytes &&
|
|
|
|
(op->dummy.nbytes * 8 / op->dummy.buswidth > 64))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Max data length, check controller limits and alignment */
|
|
|
|
if (op->data.dir == SPI_MEM_DATA_IN &&
|
|
|
|
(op->data.nbytes > q->devtype_data->ahb_buf_size ||
|
|
|
|
(op->data.nbytes > q->devtype_data->rxfifo - 4 &&
|
|
|
|
!IS_ALIGNED(op->data.nbytes, 8))))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (op->data.dir == SPI_MEM_DATA_OUT &&
|
|
|
|
op->data.nbytes > q->devtype_data->txfifo)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
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
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static void fsl_qspi_prepare_lut(struct fsl_qspi *q,
|
|
|
|
const struct spi_mem_op *op)
|
2015-01-04 09:07:14 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
void __iomem *base = q->iobase;
|
|
|
|
u32 lutval[4] = {};
|
|
|
|
int lutidx = 1, i;
|
2015-01-04 09:07:14 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
lutval[0] |= LUT_DEF(0, LUT_CMD, LUT_PAD(op->cmd.buswidth),
|
|
|
|
op->cmd.opcode);
|
2015-01-04 09:07:14 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/*
|
|
|
|
* For some unknown reason, using LUT_ADDR doesn't work in some
|
|
|
|
* cases (at least with only one byte long addresses), so
|
|
|
|
* let's use LUT_MODE to write the address bytes one by one
|
|
|
|
*/
|
|
|
|
for (i = 0; i < op->addr.nbytes; i++) {
|
|
|
|
u8 addrbyte = op->addr.val >> (8 * (op->addr.nbytes - i - 1));
|
2015-01-04 09:07:14 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_MODE,
|
|
|
|
LUT_PAD(op->addr.buswidth),
|
|
|
|
addrbyte);
|
|
|
|
lutidx++;
|
2015-01-04 09:07:14 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
if (op->dummy.nbytes) {
|
|
|
|
lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_DUMMY,
|
|
|
|
LUT_PAD(op->dummy.buswidth),
|
|
|
|
op->dummy.nbytes * 8 /
|
|
|
|
op->dummy.buswidth);
|
|
|
|
lutidx++;
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
if (op->data.nbytes) {
|
|
|
|
lutval[lutidx / 2] |= LUT_DEF(lutidx,
|
|
|
|
op->data.dir == SPI_MEM_DATA_IN ?
|
|
|
|
LUT_FSL_READ : LUT_FSL_WRITE,
|
|
|
|
LUT_PAD(op->data.buswidth),
|
|
|
|
0);
|
|
|
|
lutidx++;
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_STOP, 0, 0);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* unlock LUT */
|
|
|
|
qspi_writel(q, QUADSPI_LUTKEY_VALUE, q->iobase + QUADSPI_LUTKEY);
|
|
|
|
qspi_writel(q, QUADSPI_LCKER_UNLOCK, q->iobase + QUADSPI_LCKCR);
|
|
|
|
|
|
|
|
dev_dbg(q->dev, "CMD[%x] lutval[0:%x \t 1:%x \t 2:%x \t 3:%x]\n",
|
|
|
|
op->cmd.opcode, lutval[0], lutval[1], lutval[2], lutval[3]);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* fill LUT */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(lutval); i++)
|
|
|
|
qspi_writel(q, lutval[i], base + QUADSPI_LUT_REG(i));
|
2015-01-04 09:07:14 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* lock LUT */
|
|
|
|
qspi_writel(q, QUADSPI_LUTKEY_VALUE, q->iobase + QUADSPI_LUTKEY);
|
|
|
|
qspi_writel(q, QUADSPI_LCKER_LOCK, q->iobase + QUADSPI_LCKCR);
|
|
|
|
}
|
2015-01-04 09:07:14 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/*
|
|
|
|
* If we have changed the content of the flash by writing or erasing, or if we
|
|
|
|
* read from flash with a different offset into the page buffer, 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.
|
|
|
|
*/
|
|
|
|
static void fsl_qspi_invalidate(struct fsl_qspi *q)
|
|
|
|
{
|
|
|
|
u32 reg;
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
reg = qspi_readl(q, q->iobase + QUADSPI_MCR);
|
|
|
|
reg |= QUADSPI_MCR_SWRSTHD_MASK | QUADSPI_MCR_SWRSTSD_MASK;
|
|
|
|
qspi_writel(q, reg, q->iobase + QUADSPI_MCR);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2017-06-05 09:07:20 +00:00
|
|
|
/*
|
2020-02-20 17:27:52 +00:00
|
|
|
* The minimum delay : 1 AHB + 2 SFCK clocks.
|
|
|
|
* Delay 1 us is enough.
|
2017-06-05 09:07:20 +00:00
|
|
|
*/
|
2020-02-20 17:27:52 +00:00
|
|
|
udelay(1);
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
reg &= ~(QUADSPI_MCR_SWRSTHD_MASK | QUADSPI_MCR_SWRSTSD_MASK);
|
|
|
|
qspi_writel(q, reg, q->iobase + QUADSPI_MCR);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_slave *slave)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
struct dm_spi_slave_platdata *plat =
|
|
|
|
dev_get_parent_platdata(slave->dev);
|
|
|
|
|
|
|
|
if (q->selected == plat->cs)
|
|
|
|
return;
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
q->selected = plat->cs;
|
|
|
|
fsl_qspi_invalidate(q);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static void fsl_qspi_read_ahb(struct fsl_qspi *q, const struct spi_mem_op *op)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
memcpy_fromio(op->data.buf.in,
|
|
|
|
q->ahb_addr + q->selected * q->devtype_data->ahb_buf_size,
|
|
|
|
op->data.nbytes);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static void fsl_qspi_fill_txfifo(struct fsl_qspi *q,
|
|
|
|
const struct spi_mem_op *op)
|
2014-05-06 01:13:01 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
void __iomem *base = q->iobase;
|
|
|
|
int i;
|
|
|
|
u32 val;
|
2014-05-06 01:13:01 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
for (i = 0; i < ALIGN_DOWN(op->data.nbytes, 4); i += 4) {
|
|
|
|
memcpy(&val, op->data.buf.out + i, 4);
|
|
|
|
val = fsl_qspi_endian_xchg(q, val);
|
|
|
|
qspi_writel(q, val, base + QUADSPI_TBDR);
|
2014-05-06 01:13:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
if (i < op->data.nbytes) {
|
|
|
|
memcpy(&val, op->data.buf.out + i, op->data.nbytes - i);
|
|
|
|
val = fsl_qspi_endian_xchg(q, val);
|
|
|
|
qspi_writel(q, val, base + QUADSPI_TBDR);
|
|
|
|
}
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
if (needs_fill_txfifo(q)) {
|
|
|
|
for (i = op->data.nbytes; i < 16; i += 4)
|
|
|
|
qspi_writel(q, 0, base + QUADSPI_TBDR);
|
|
|
|
}
|
2015-04-01 03:10:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static void fsl_qspi_read_rxfifo(struct fsl_qspi *q,
|
|
|
|
const struct spi_mem_op *op)
|
2015-04-01 03:10:40 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
void __iomem *base = q->iobase;
|
|
|
|
int i;
|
|
|
|
u8 *buf = op->data.buf.in;
|
|
|
|
u32 val;
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
for (i = 0; i < ALIGN_DOWN(op->data.nbytes, 4); i += 4) {
|
|
|
|
val = qspi_readl(q, base + QUADSPI_RBDR(i / 4));
|
|
|
|
val = fsl_qspi_endian_xchg(q, val);
|
|
|
|
memcpy(buf + i, &val, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < op->data.nbytes) {
|
|
|
|
val = qspi_readl(q, base + QUADSPI_RBDR(i / 4));
|
|
|
|
val = fsl_qspi_endian_xchg(q, val);
|
|
|
|
memcpy(buf + i, &val, op->data.nbytes - i);
|
|
|
|
}
|
2015-04-01 03:10:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static int fsl_qspi_readl_poll_tout(struct fsl_qspi *q, void __iomem *base,
|
|
|
|
u32 mask, u32 delay_us, u32 timeout_us)
|
2015-04-01 03:10:40 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
u32 reg;
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
if (!q->devtype_data->little_endian)
|
|
|
|
mask = (u32)cpu_to_be32(mask);
|
|
|
|
|
|
|
|
return readl_poll_timeout(base, reg, !(reg & mask), timeout_us);
|
2015-04-01 03:10:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static int fsl_qspi_do_op(struct fsl_qspi *q, const struct spi_mem_op *op)
|
2015-04-01 03:10:40 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
void __iomem *base = q->iobase;
|
|
|
|
int err = 0;
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/*
|
|
|
|
* Always start the sequence at the same index since we update
|
|
|
|
* the LUT at each exec_op() call. And also specify the DATA
|
|
|
|
* length, since it's has not been specified in the LUT.
|
|
|
|
*/
|
|
|
|
qspi_writel(q, op->data.nbytes | QUADSPI_IPCR_SEQID(SEQID_LUT),
|
|
|
|
base + QUADSPI_IPCR);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* wait for the controller being ready */
|
|
|
|
err = fsl_qspi_readl_poll_tout(q, base + QUADSPI_SR,
|
|
|
|
(QUADSPI_SR_IP_ACC_MASK |
|
|
|
|
QUADSPI_SR_AHB_ACC_MASK),
|
|
|
|
10, 1000);
|
|
|
|
|
|
|
|
if (!err && op->data.nbytes && op->data.dir == SPI_MEM_DATA_IN)
|
|
|
|
fsl_qspi_read_rxfifo(q, op);
|
|
|
|
|
|
|
|
return err;
|
2015-04-01 03:10:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static int fsl_qspi_exec_op(struct spi_slave *slave,
|
|
|
|
const struct spi_mem_op *op)
|
2015-04-01 03:10:40 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
struct fsl_qspi *q = dev_get_priv(slave->dev->parent);
|
|
|
|
void __iomem *base = q->iobase;
|
|
|
|
u32 addr_offset = 0;
|
|
|
|
int err = 0;
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* wait for the controller being ready */
|
|
|
|
fsl_qspi_readl_poll_tout(q, base + QUADSPI_SR, (QUADSPI_SR_IP_ACC_MASK |
|
|
|
|
QUADSPI_SR_AHB_ACC_MASK), 10, 1000);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
fsl_qspi_select_mem(q, slave);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
if (needs_amba_base_offset(q))
|
|
|
|
addr_offset = q->memmap_phy;
|
|
|
|
|
|
|
|
qspi_writel(q,
|
|
|
|
q->selected * q->devtype_data->ahb_buf_size + addr_offset,
|
|
|
|
base + QUADSPI_SFAR);
|
|
|
|
|
|
|
|
qspi_writel(q, qspi_readl(q, base + QUADSPI_MCR) |
|
|
|
|
QUADSPI_MCR_CLR_RXF_MASK | QUADSPI_MCR_CLR_TXF_MASK,
|
|
|
|
base + QUADSPI_MCR);
|
|
|
|
|
|
|
|
qspi_writel(q, QUADSPI_SPTRCLR_BFPTRC | QUADSPI_SPTRCLR_IPPTRC,
|
|
|
|
base + QUADSPI_SPTRCLR);
|
|
|
|
|
|
|
|
fsl_qspi_prepare_lut(q, op);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2016-03-15 06:36:40 +00:00
|
|
|
/*
|
2020-02-20 17:27:52 +00:00
|
|
|
* If we have large chunks of data, we read them through the AHB bus
|
|
|
|
* by accessing the mapped memory. In all other cases we use
|
|
|
|
* IP commands to access the flash.
|
2016-03-15 06:36:40 +00:00
|
|
|
*/
|
2020-02-20 17:27:52 +00:00
|
|
|
if (op->data.nbytes > (q->devtype_data->rxfifo - 4) &&
|
|
|
|
op->data.dir == SPI_MEM_DATA_IN) {
|
|
|
|
fsl_qspi_read_ahb(q, op);
|
|
|
|
} else {
|
|
|
|
qspi_writel(q, QUADSPI_RBCT_WMRK_MASK |
|
|
|
|
QUADSPI_RBCT_RXBRD_USEIPS, base + QUADSPI_RBCT);
|
|
|
|
|
|
|
|
if (op->data.nbytes && op->data.dir == SPI_MEM_DATA_OUT)
|
|
|
|
fsl_qspi_fill_txfifo(q, op);
|
|
|
|
|
|
|
|
err = fsl_qspi_do_op(q, op);
|
2019-08-14 11:31:36 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* Invalidate the data in the AHB buffer. */
|
|
|
|
fsl_qspi_invalidate(q);
|
2019-08-14 11:31:36 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
return err;
|
|
|
|
}
|
2017-08-30 14:36:33 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static int fsl_qspi_adjust_op_size(struct spi_slave *slave,
|
|
|
|
struct spi_mem_op *op)
|
|
|
|
{
|
|
|
|
struct fsl_qspi *q = dev_get_priv(slave->dev->parent);
|
|
|
|
|
|
|
|
if (op->data.dir == SPI_MEM_DATA_OUT) {
|
|
|
|
if (op->data.nbytes > q->devtype_data->txfifo)
|
|
|
|
op->data.nbytes = q->devtype_data->txfifo;
|
|
|
|
} else {
|
|
|
|
if (op->data.nbytes > q->devtype_data->ahb_buf_size)
|
|
|
|
op->data.nbytes = q->devtype_data->ahb_buf_size;
|
|
|
|
else if (op->data.nbytes > (q->devtype_data->rxfifo - 4))
|
|
|
|
op->data.nbytes = ALIGN_DOWN(op->data.nbytes, 8);
|
2017-08-30 14:36:33 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_default_setup(struct fsl_qspi *q)
|
|
|
|
{
|
|
|
|
void __iomem *base = q->iobase;
|
|
|
|
u32 reg, addr_offset = 0;
|
|
|
|
|
|
|
|
/* Reset the module */
|
|
|
|
qspi_writel(q, QUADSPI_MCR_SWRSTSD_MASK | QUADSPI_MCR_SWRSTHD_MASK,
|
|
|
|
base + QUADSPI_MCR);
|
|
|
|
udelay(1);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* Disable the module */
|
|
|
|
qspi_writel(q, QUADSPI_MCR_MDIS_MASK | QUADSPI_MCR_RESERVED_MASK,
|
|
|
|
base + QUADSPI_MCR);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2016-03-15 06:36:41 +00:00
|
|
|
/*
|
2020-02-20 17:27:52 +00:00
|
|
|
* Previous boot stages (BootROM, bootloader) might have used DDR
|
|
|
|
* mode and did not clear the TDH bits. As we currently use SDR mode
|
|
|
|
* only, clear the TDH bits if necessary.
|
2016-03-15 06:36:41 +00:00
|
|
|
*/
|
2020-02-20 17:27:52 +00:00
|
|
|
if (needs_tdh_setting(q))
|
|
|
|
qspi_writel(q, qspi_readl(q, base + QUADSPI_FLSHCR) &
|
|
|
|
~QUADSPI_FLSHCR_TDH_MASK,
|
|
|
|
base + QUADSPI_FLSHCR);
|
|
|
|
|
|
|
|
reg = qspi_readl(q, base + QUADSPI_SMPR);
|
|
|
|
qspi_writel(q, reg & ~(QUADSPI_SMPR_FSDLY_MASK
|
|
|
|
| QUADSPI_SMPR_FSPHS_MASK
|
|
|
|
| QUADSPI_SMPR_HSENA_MASK
|
|
|
|
| QUADSPI_SMPR_DDRSMP_MASK), base + QUADSPI_SMPR);
|
|
|
|
|
|
|
|
/* We only use the buffer3 for AHB read */
|
|
|
|
qspi_writel(q, 0, base + QUADSPI_BUF0IND);
|
|
|
|
qspi_writel(q, 0, base + QUADSPI_BUF1IND);
|
|
|
|
qspi_writel(q, 0, base + QUADSPI_BUF2IND);
|
|
|
|
|
|
|
|
qspi_writel(q, QUADSPI_BFGENCR_SEQID(SEQID_LUT),
|
|
|
|
q->iobase + QUADSPI_BFGENCR);
|
|
|
|
qspi_writel(q, QUADSPI_RBCT_WMRK_MASK, base + QUADSPI_RBCT);
|
|
|
|
qspi_writel(q, QUADSPI_BUF3CR_ALLMST_MASK |
|
|
|
|
QUADSPI_BUF3CR_ADATSZ(q->devtype_data->ahb_buf_size / 8),
|
|
|
|
base + QUADSPI_BUF3CR);
|
|
|
|
|
|
|
|
if (needs_amba_base_offset(q))
|
|
|
|
addr_offset = q->memmap_phy;
|
2016-03-15 06:36:41 +00:00
|
|
|
|
2015-04-01 03:10:40 +00:00
|
|
|
/*
|
2020-02-20 17:27:52 +00:00
|
|
|
* In HW there can be a maximum of four chips on two buses with
|
|
|
|
* two chip selects on each bus. We use four chip selects in SW
|
|
|
|
* to differentiate between the four chips.
|
|
|
|
* We use ahb_buf_size for each chip and set SFA1AD, SFA2AD, SFB1AD,
|
|
|
|
* SFB2AD accordingly.
|
2015-04-01 03:10:40 +00:00
|
|
|
*/
|
2020-02-20 17:27:52 +00:00
|
|
|
qspi_writel(q, q->devtype_data->ahb_buf_size + addr_offset,
|
|
|
|
base + QUADSPI_SFA1AD);
|
|
|
|
qspi_writel(q, q->devtype_data->ahb_buf_size * 2 + addr_offset,
|
|
|
|
base + QUADSPI_SFA2AD);
|
|
|
|
qspi_writel(q, q->devtype_data->ahb_buf_size * 3 + addr_offset,
|
|
|
|
base + QUADSPI_SFB1AD);
|
|
|
|
qspi_writel(q, q->devtype_data->ahb_buf_size * 4 + addr_offset,
|
|
|
|
base + QUADSPI_SFB2AD);
|
|
|
|
|
|
|
|
q->selected = -1;
|
|
|
|
|
|
|
|
/* Enable the module */
|
|
|
|
qspi_writel(q, QUADSPI_MCR_RESERVED_MASK | QUADSPI_MCR_END_CFG_MASK,
|
|
|
|
base + QUADSPI_MCR);
|
2015-04-01 03:10:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
static const struct spi_controller_mem_ops fsl_qspi_mem_ops = {
|
|
|
|
.adjust_op_size = fsl_qspi_adjust_op_size,
|
|
|
|
.supports_op = fsl_qspi_supports_op,
|
|
|
|
.exec_op = fsl_qspi_exec_op,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int fsl_qspi_probe(struct udevice *bus)
|
2015-04-01 03:10:40 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
struct dm_spi_bus *dm_bus = bus->uclass_priv;
|
|
|
|
struct fsl_qspi *q = dev_get_priv(bus);
|
2015-04-01 03:10:40 +00:00
|
|
|
const void *blob = gd->fdt_blob;
|
2017-01-17 23:52:55 +00:00
|
|
|
int node = dev_of_offset(bus);
|
2020-02-20 17:27:52 +00:00
|
|
|
struct fdt_resource res;
|
|
|
|
int ret;
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
q->dev = bus;
|
|
|
|
q->devtype_data = (struct fsl_qspi_devtype_data *)
|
|
|
|
dev_get_driver_data(bus);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
/* find the resources */
|
|
|
|
ret = fdt_get_named_resource(blob, node, "reg", "reg-names", "QuadSPI",
|
|
|
|
&res);
|
2016-03-15 06:36:40 +00:00
|
|
|
if (ret) {
|
2020-02-20 17:27:52 +00:00
|
|
|
dev_err(bus, "Can't get regs base addresses(ret = %d)!\n", ret);
|
2016-03-15 06:36:40 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2020-02-20 17:27:52 +00:00
|
|
|
|
|
|
|
q->iobase = map_physmem(res.start, res.end - res.start, MAP_NOCACHE);
|
|
|
|
|
2016-03-15 06:36:40 +00:00
|
|
|
ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
|
2020-02-20 17:27:52 +00:00
|
|
|
"QuadSPI-memory", &res);
|
2015-04-01 03:10:40 +00:00
|
|
|
if (ret) {
|
2020-02-20 17:27:52 +00:00
|
|
|
dev_err(bus, "Can't get AMBA base addresses(ret = %d)!\n", ret);
|
2015-04-01 03:10:40 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
q->ahb_addr = map_physmem(res.start, res.end - res.start, MAP_NOCACHE);
|
|
|
|
q->memmap_phy = res.start;
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
dm_bus->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency",
|
|
|
|
66000000);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
2020-02-20 17:27:52 +00:00
|
|
|
fsl_qspi_default_setup(q);
|
2015-04-01 03:10:40 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_xfer(struct udevice *dev, unsigned int bitlen,
|
2020-02-20 17:27:52 +00:00
|
|
|
const void *dout, void *din, unsigned long flags)
|
2015-04-01 03:10:40 +00:00
|
|
|
{
|
2020-02-20 17:27:52 +00:00
|
|
|
return 0;
|
2015-04-01 03:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_claim_bus(struct udevice *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_release_bus(struct udevice *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_set_speed(struct udevice *bus, uint speed)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_qspi_set_mode(struct udevice *bus, uint mode)
|
|
|
|
{
|
|
|
|
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,
|
2020-02-20 17:27:52 +00:00
|
|
|
.mem_ops = &fsl_qspi_mem_ops,
|
2015-04-01 03:10:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct udevice_id fsl_qspi_ids[] = {
|
2020-02-20 17:27:52 +00:00
|
|
|
{ .compatible = "fsl,vf610-qspi", .data = (ulong)&vybrid_data, },
|
|
|
|
{ .compatible = "fsl,imx6sx-qspi", .data = (ulong)&imx6sx_data, },
|
|
|
|
{ .compatible = "fsl,imx6ul-qspi", .data = (ulong)&imx6ul_data, },
|
|
|
|
{ .compatible = "fsl,imx7d-qspi", .data = (ulong)&imx7d_data, },
|
|
|
|
{ .compatible = "fsl,ls1021a-qspi", .data = (ulong)&ls1021a_data, },
|
|
|
|
{ .compatible = "fsl,ls1088a-qspi", .data = (ulong)&ls1088a_data, },
|
|
|
|
{ .compatible = "fsl,ls2080a-qspi", .data = (ulong)&ls2080a_data, },
|
2015-04-01 03:10:40 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(fsl_qspi) = {
|
|
|
|
.name = "fsl_qspi",
|
|
|
|
.id = UCLASS_SPI,
|
|
|
|
.of_match = fsl_qspi_ids,
|
|
|
|
.ops = &fsl_qspi_ops,
|
2020-02-20 17:27:52 +00:00
|
|
|
.priv_auto_alloc_size = sizeof(struct fsl_qspi),
|
2015-04-01 03:10:40 +00:00
|
|
|
.probe = fsl_qspi_probe,
|
|
|
|
};
|