2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-11-07 11:37:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012
|
|
|
|
* Altera Corporation <www.altera.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-11-20 21:27:31 +00:00
|
|
|
#include <clk.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-12-05 10:16:06 +00:00
|
|
|
#include <asm-generic/io.h>
|
2014-11-07 11:37:49 +00:00
|
|
|
#include <dm.h>
|
|
|
|
#include <fdtdec.h>
|
|
|
|
#include <malloc.h>
|
2019-03-01 19:12:35 +00:00
|
|
|
#include <reset.h>
|
2014-11-07 11:37:49 +00:00
|
|
|
#include <spi.h>
|
2020-01-27 05:06:39 +00:00
|
|
|
#include <spi-mem.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <dm/device_compat.h>
|
2020-02-03 14:36:15 +00:00
|
|
|
#include <linux/err.h>
|
2016-09-21 02:28:55 +00:00
|
|
|
#include <linux/errno.h>
|
2020-01-27 05:06:40 +00:00
|
|
|
#include <linux/sizes.h>
|
2014-11-07 11:37:49 +00:00
|
|
|
#include "cadence_qspi.h"
|
|
|
|
|
2021-06-25 19:17:08 +00:00
|
|
|
#define NSEC_PER_SEC 1000000000L
|
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
#define CQSPI_STIG_READ 0
|
|
|
|
#define CQSPI_STIG_WRITE 1
|
2020-01-27 05:06:40 +00:00
|
|
|
#define CQSPI_READ 2
|
|
|
|
#define CQSPI_WRITE 3
|
2014-11-07 11:37:49 +00:00
|
|
|
|
|
|
|
static int cadence_spi_write_speed(struct udevice *bus, uint hz)
|
|
|
|
{
|
2020-12-23 02:30:28 +00:00
|
|
|
struct cadence_spi_plat *plat = dev_get_plat(bus);
|
2014-11-07 11:37:49 +00:00
|
|
|
struct cadence_spi_priv *priv = dev_get_priv(bus);
|
|
|
|
|
|
|
|
cadence_qspi_apb_config_baudrate_div(priv->regbase,
|
2019-11-20 21:27:31 +00:00
|
|
|
plat->ref_clk_hz, hz);
|
2014-11-07 11:37:49 +00:00
|
|
|
|
|
|
|
/* Reconfigure delay timing if speed is changed. */
|
2019-11-20 21:27:31 +00:00
|
|
|
cadence_qspi_apb_delay(priv->regbase, plat->ref_clk_hz, hz,
|
2014-11-07 11:37:49 +00:00
|
|
|
plat->tshsl_ns, plat->tsd2d_ns,
|
|
|
|
plat->tchsh_ns, plat->tslch_ns);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-25 19:17:09 +00:00
|
|
|
static int cadence_spi_read_id(struct cadence_spi_plat *plat, u8 len,
|
|
|
|
u8 *idcode)
|
2020-01-27 05:06:39 +00:00
|
|
|
{
|
|
|
|
struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(0x9F, 1),
|
|
|
|
SPI_MEM_OP_NO_ADDR,
|
|
|
|
SPI_MEM_OP_NO_DUMMY,
|
|
|
|
SPI_MEM_OP_DATA_IN(len, idcode, 1));
|
|
|
|
|
2021-06-25 19:17:09 +00:00
|
|
|
return cadence_qspi_apb_command_read(plat, &op);
|
2020-01-27 05:06:39 +00:00
|
|
|
}
|
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
/* Calibration sequence to determine the read data capture delay register */
|
2015-10-17 13:31:55 +00:00
|
|
|
static int spi_calibration(struct udevice *bus, uint hz)
|
2014-11-07 11:37:49 +00:00
|
|
|
{
|
|
|
|
struct cadence_spi_priv *priv = dev_get_priv(bus);
|
2021-06-25 19:17:09 +00:00
|
|
|
struct cadence_spi_plat *plat = dev_get_plat(bus);
|
2014-11-07 11:37:49 +00:00
|
|
|
void *base = priv->regbase;
|
|
|
|
unsigned int idcode = 0, temp = 0;
|
|
|
|
int err = 0, i, range_lo = -1, range_hi = -1;
|
|
|
|
|
|
|
|
/* start with slowest clock (1 MHz) */
|
|
|
|
cadence_spi_write_speed(bus, 1000000);
|
|
|
|
|
|
|
|
/* configure the read data capture delay register to 0 */
|
|
|
|
cadence_qspi_apb_readdata_capture(base, 1, 0);
|
|
|
|
|
|
|
|
/* Enable QSPI */
|
|
|
|
cadence_qspi_apb_controller_enable(base);
|
|
|
|
|
|
|
|
/* read the ID which will be our golden value */
|
2021-06-25 19:17:09 +00:00
|
|
|
err = cadence_spi_read_id(plat, 3, (u8 *)&idcode);
|
2014-11-07 11:37:49 +00:00
|
|
|
if (err) {
|
|
|
|
puts("SF: Calibration failed (read)\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* use back the intended clock and find low range */
|
2015-10-17 13:31:55 +00:00
|
|
|
cadence_spi_write_speed(bus, hz);
|
2014-11-07 11:37:49 +00:00
|
|
|
for (i = 0; i < CQSPI_READ_CAPTURE_MAX_DELAY; i++) {
|
|
|
|
/* Disable QSPI */
|
|
|
|
cadence_qspi_apb_controller_disable(base);
|
|
|
|
|
|
|
|
/* reconfigure the read data capture delay register */
|
|
|
|
cadence_qspi_apb_readdata_capture(base, 1, i);
|
|
|
|
|
|
|
|
/* Enable back QSPI */
|
|
|
|
cadence_qspi_apb_controller_enable(base);
|
|
|
|
|
|
|
|
/* issue a RDID to get the ID value */
|
2021-06-25 19:17:09 +00:00
|
|
|
err = cadence_spi_read_id(plat, 3, (u8 *)&temp);
|
2014-11-07 11:37:49 +00:00
|
|
|
if (err) {
|
|
|
|
puts("SF: Calibration failed (read)\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* search for range lo */
|
|
|
|
if (range_lo == -1 && temp == idcode) {
|
|
|
|
range_lo = i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* search for range hi */
|
|
|
|
if (range_lo != -1 && temp != idcode) {
|
|
|
|
range_hi = i - 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
range_hi = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (range_lo == -1) {
|
|
|
|
puts("SF: Calibration failed (low range)\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable QSPI for subsequent initialization */
|
|
|
|
cadence_qspi_apb_controller_disable(base);
|
|
|
|
|
|
|
|
/* configure the final value for read data capture delay register */
|
|
|
|
cadence_qspi_apb_readdata_capture(base, 1, (range_hi + range_lo) / 2);
|
|
|
|
debug("SF: Read data capture delay calibrated to %i (%i - %i)\n",
|
|
|
|
(range_hi + range_lo) / 2, range_lo, range_hi);
|
|
|
|
|
|
|
|
/* just to ensure we do once only when speed or chip select change */
|
2015-10-17 13:31:55 +00:00
|
|
|
priv->qspi_calibrated_hz = hz;
|
2014-11-07 11:37:49 +00:00
|
|
|
priv->qspi_calibrated_cs = spi_chip_select(bus);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cadence_spi_set_speed(struct udevice *bus, uint hz)
|
|
|
|
{
|
2020-12-23 02:30:28 +00:00
|
|
|
struct cadence_spi_plat *plat = dev_get_plat(bus);
|
2014-11-07 11:37:49 +00:00
|
|
|
struct cadence_spi_priv *priv = dev_get_priv(bus);
|
|
|
|
int err;
|
|
|
|
|
2015-10-17 13:32:38 +00:00
|
|
|
if (hz > plat->max_hz)
|
|
|
|
hz = plat->max_hz;
|
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
/* Disable QSPI */
|
|
|
|
cadence_qspi_apb_controller_disable(priv->regbase);
|
|
|
|
|
2015-10-17 13:31:55 +00:00
|
|
|
/*
|
2021-06-25 19:17:07 +00:00
|
|
|
* If the device tree already provides a read delay value, use that
|
|
|
|
* instead of calibrating.
|
2015-10-17 13:31:55 +00:00
|
|
|
*/
|
2021-06-25 19:17:07 +00:00
|
|
|
if (plat->read_delay >= 0) {
|
|
|
|
cadence_spi_write_speed(bus, hz);
|
|
|
|
cadence_qspi_apb_readdata_capture(priv->regbase, 1,
|
|
|
|
plat->read_delay);
|
|
|
|
} else if (priv->previous_hz != hz ||
|
|
|
|
priv->qspi_calibrated_hz != hz ||
|
|
|
|
priv->qspi_calibrated_cs != spi_chip_select(bus)) {
|
|
|
|
/*
|
|
|
|
* Calibration required for different current SCLK speed,
|
|
|
|
* requested SCLK speed or chip select
|
|
|
|
*/
|
2015-10-17 13:31:55 +00:00
|
|
|
err = spi_calibration(bus, hz);
|
2014-11-07 11:37:49 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
2015-10-17 13:31:55 +00:00
|
|
|
|
|
|
|
/* prevent calibration run when same as previous request */
|
|
|
|
priv->previous_hz = hz;
|
2014-11-07 11:37:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable QSPI */
|
|
|
|
cadence_qspi_apb_controller_enable(priv->regbase);
|
|
|
|
|
|
|
|
debug("%s: speed=%d\n", __func__, hz);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cadence_spi_probe(struct udevice *bus)
|
|
|
|
{
|
2020-12-23 02:30:28 +00:00
|
|
|
struct cadence_spi_plat *plat = dev_get_plat(bus);
|
2014-11-07 11:37:49 +00:00
|
|
|
struct cadence_spi_priv *priv = dev_get_priv(bus);
|
2020-02-24 07:10:51 +00:00
|
|
|
struct clk clk;
|
2019-03-01 19:12:35 +00:00
|
|
|
int ret;
|
2014-11-07 11:37:49 +00:00
|
|
|
|
|
|
|
priv->regbase = plat->regbase;
|
|
|
|
priv->ahbbase = plat->ahbbase;
|
|
|
|
|
2020-02-24 07:10:51 +00:00
|
|
|
if (plat->ref_clk_hz == 0) {
|
|
|
|
ret = clk_get_by_index(bus, 0, &clk);
|
|
|
|
if (ret) {
|
2022-03-30 22:07:23 +00:00
|
|
|
#ifdef CONFIG_HAS_CQSPI_REF_CLK
|
2020-02-24 07:10:51 +00:00
|
|
|
plat->ref_clk_hz = CONFIG_CQSPI_REF_CLK;
|
2022-03-30 22:07:23 +00:00
|
|
|
#elif defined(CONFIG_ARCH_SOCFPGA)
|
|
|
|
plat->ref_clk_hz = cm_get_qspi_controller_clk_hz();
|
2020-02-24 07:10:51 +00:00
|
|
|
#else
|
|
|
|
return ret;
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
plat->ref_clk_hz = clk_get_rate(&clk);
|
|
|
|
clk_free(&clk);
|
|
|
|
if (IS_ERR_VALUE(plat->ref_clk_hz))
|
|
|
|
return plat->ref_clk_hz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-22 16:23:25 +00:00
|
|
|
priv->resets = devm_reset_bulk_get_optional(bus);
|
|
|
|
if (priv->resets)
|
|
|
|
reset_deassert_bulk(priv->resets);
|
2019-03-01 19:12:35 +00:00
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
if (!priv->qspi_is_init) {
|
|
|
|
cadence_qspi_apb_controller_init(plat);
|
|
|
|
priv->qspi_is_init = 1;
|
|
|
|
}
|
|
|
|
|
2021-06-25 19:17:08 +00:00
|
|
|
plat->wr_delay = 50 * DIV_ROUND_UP(NSEC_PER_SEC, plat->ref_clk_hz);
|
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-01 19:12:35 +00:00
|
|
|
static int cadence_spi_remove(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct cadence_spi_priv *priv = dev_get_priv(dev);
|
2022-02-22 16:23:25 +00:00
|
|
|
int ret = 0;
|
2019-03-01 19:12:35 +00:00
|
|
|
|
2022-02-22 16:23:25 +00:00
|
|
|
if (priv->resets)
|
|
|
|
ret = reset_release_bulk(priv->resets);
|
|
|
|
|
|
|
|
return ret;
|
2019-03-01 19:12:35 +00:00
|
|
|
}
|
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
static int cadence_spi_set_mode(struct udevice *bus, uint mode)
|
|
|
|
{
|
2020-12-23 02:30:28 +00:00
|
|
|
struct cadence_spi_plat *plat = dev_get_plat(bus);
|
2014-11-07 11:37:49 +00:00
|
|
|
struct cadence_spi_priv *priv = dev_get_priv(bus);
|
|
|
|
|
|
|
|
/* Disable QSPI */
|
|
|
|
cadence_qspi_apb_controller_disable(priv->regbase);
|
|
|
|
|
|
|
|
/* Set SPI mode */
|
2016-11-29 12:58:31 +00:00
|
|
|
cadence_qspi_apb_set_clk_mode(priv->regbase, mode);
|
2014-11-07 11:37:49 +00:00
|
|
|
|
2020-01-27 05:06:40 +00:00
|
|
|
/* Enable Direct Access Controller */
|
|
|
|
if (plat->use_dac_mode)
|
|
|
|
cadence_qspi_apb_dac_mode_enable(priv->regbase);
|
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
/* Enable QSPI */
|
|
|
|
cadence_qspi_apb_controller_enable(priv->regbase);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-01-27 05:06:39 +00:00
|
|
|
static int cadence_spi_mem_exec_op(struct spi_slave *spi,
|
|
|
|
const struct spi_mem_op *op)
|
2014-11-07 11:37:49 +00:00
|
|
|
{
|
2020-01-27 05:06:39 +00:00
|
|
|
struct udevice *bus = spi->dev->parent;
|
2020-12-23 02:30:28 +00:00
|
|
|
struct cadence_spi_plat *plat = dev_get_plat(bus);
|
2014-11-07 11:37:49 +00:00
|
|
|
struct cadence_spi_priv *priv = dev_get_priv(bus);
|
|
|
|
void *base = priv->regbase;
|
|
|
|
int err = 0;
|
2020-01-27 05:06:39 +00:00
|
|
|
u32 mode;
|
2014-11-07 11:37:49 +00:00
|
|
|
|
|
|
|
/* Set Chip select */
|
2020-01-27 05:06:39 +00:00
|
|
|
cadence_qspi_apb_chipselect(base, spi_chip_select(spi->dev),
|
2018-01-23 23:13:09 +00:00
|
|
|
plat->is_decoded_cs);
|
2014-11-07 11:37:49 +00:00
|
|
|
|
2020-01-27 05:06:39 +00:00
|
|
|
if (op->data.dir == SPI_MEM_DATA_IN && op->data.buf.in) {
|
|
|
|
if (!op->addr.nbytes)
|
|
|
|
mode = CQSPI_STIG_READ;
|
|
|
|
else
|
2020-01-27 05:06:40 +00:00
|
|
|
mode = CQSPI_READ;
|
2020-01-27 05:06:39 +00:00
|
|
|
} else {
|
|
|
|
if (!op->addr.nbytes || !op->data.buf.out)
|
|
|
|
mode = CQSPI_STIG_WRITE;
|
|
|
|
else
|
2020-01-27 05:06:40 +00:00
|
|
|
mode = CQSPI_WRITE;
|
2020-01-27 05:06:39 +00:00
|
|
|
}
|
2014-11-07 11:37:49 +00:00
|
|
|
|
2020-01-27 05:06:39 +00:00
|
|
|
switch (mode) {
|
|
|
|
case CQSPI_STIG_READ:
|
2021-06-25 19:17:09 +00:00
|
|
|
err = cadence_qspi_apb_command_read_setup(plat, op);
|
|
|
|
if (!err)
|
|
|
|
err = cadence_qspi_apb_command_read(plat, op);
|
2014-11-07 11:37:49 +00:00
|
|
|
break;
|
2020-01-27 05:06:39 +00:00
|
|
|
case CQSPI_STIG_WRITE:
|
2021-06-25 19:17:09 +00:00
|
|
|
err = cadence_qspi_apb_command_write_setup(plat, op);
|
|
|
|
if (!err)
|
|
|
|
err = cadence_qspi_apb_command_write(plat, op);
|
2014-11-07 11:37:49 +00:00
|
|
|
break;
|
2020-01-27 05:06:40 +00:00
|
|
|
case CQSPI_READ:
|
|
|
|
err = cadence_qspi_apb_read_setup(plat, op);
|
|
|
|
if (!err)
|
|
|
|
err = cadence_qspi_apb_read_execute(plat, op);
|
2020-01-27 05:06:39 +00:00
|
|
|
break;
|
2020-01-27 05:06:40 +00:00
|
|
|
case CQSPI_WRITE:
|
|
|
|
err = cadence_qspi_apb_write_setup(plat, op);
|
|
|
|
if (!err)
|
|
|
|
err = cadence_qspi_apb_write_execute(plat, op);
|
2020-01-27 05:06:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = -1;
|
|
|
|
break;
|
2014-11-07 11:37:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2021-06-25 19:17:09 +00:00
|
|
|
static bool cadence_spi_mem_supports_op(struct spi_slave *slave,
|
|
|
|
const struct spi_mem_op *op)
|
|
|
|
{
|
|
|
|
bool all_true, all_false;
|
|
|
|
|
|
|
|
all_true = op->cmd.dtr && op->addr.dtr && op->dummy.dtr &&
|
|
|
|
op->data.dtr;
|
|
|
|
all_false = !op->cmd.dtr && !op->addr.dtr && !op->dummy.dtr &&
|
|
|
|
!op->data.dtr;
|
|
|
|
|
|
|
|
/* Mixed DTR modes not supported. */
|
|
|
|
if (!(all_true || all_false))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (all_true)
|
|
|
|
return spi_mem_dtr_supports_op(slave, op);
|
|
|
|
else
|
|
|
|
return spi_mem_default_supports_op(slave, op);
|
|
|
|
}
|
|
|
|
|
2020-12-03 23:55:21 +00:00
|
|
|
static int cadence_spi_of_to_plat(struct udevice *bus)
|
2014-11-07 11:37:49 +00:00
|
|
|
{
|
2020-12-23 02:30:28 +00:00
|
|
|
struct cadence_spi_plat *plat = dev_get_plat(bus);
|
2019-05-09 20:11:56 +00:00
|
|
|
ofnode subnode;
|
2014-11-07 11:37:49 +00:00
|
|
|
|
2018-05-07 09:42:55 +00:00
|
|
|
plat->regbase = (void *)devfdt_get_addr_index(bus, 0);
|
2020-01-27 05:06:40 +00:00
|
|
|
plat->ahbbase = (void *)devfdt_get_addr_size_index(bus, 1,
|
|
|
|
&plat->ahbsize);
|
2019-05-09 20:11:56 +00:00
|
|
|
plat->is_decoded_cs = dev_read_bool(bus, "cdns,is-decoded-cs");
|
|
|
|
plat->fifo_depth = dev_read_u32_default(bus, "cdns,fifo-depth", 128);
|
|
|
|
plat->fifo_width = dev_read_u32_default(bus, "cdns,fifo-width", 4);
|
|
|
|
plat->trigger_address = dev_read_u32_default(bus,
|
|
|
|
"cdns,trigger-address",
|
|
|
|
0);
|
2020-01-27 05:06:40 +00:00
|
|
|
/* Use DAC mode only when MMIO window is at least 8M wide */
|
|
|
|
if (plat->ahbsize >= SZ_8M)
|
|
|
|
plat->use_dac_mode = true;
|
2014-11-07 11:37:49 +00:00
|
|
|
|
|
|
|
/* All other paramters are embedded in the child node */
|
2019-05-09 20:11:56 +00:00
|
|
|
subnode = dev_read_first_subnode(bus);
|
|
|
|
if (!ofnode_valid(subnode)) {
|
2014-11-07 11:37:49 +00:00
|
|
|
printf("Error: subnode with SPI flash config missing!\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2015-10-17 13:32:14 +00:00
|
|
|
/* Use 500 KHz as a suitable default */
|
2019-05-09 20:11:56 +00:00
|
|
|
plat->max_hz = ofnode_read_u32_default(subnode, "spi-max-frequency",
|
|
|
|
500000);
|
2015-10-17 13:32:14 +00:00
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
/* Read other parameters from DT */
|
2019-05-09 20:11:56 +00:00
|
|
|
plat->page_size = ofnode_read_u32_default(subnode, "page-size", 256);
|
|
|
|
plat->block_size = ofnode_read_u32_default(subnode, "block-size", 16);
|
|
|
|
plat->tshsl_ns = ofnode_read_u32_default(subnode, "cdns,tshsl-ns",
|
|
|
|
200);
|
|
|
|
plat->tsd2d_ns = ofnode_read_u32_default(subnode, "cdns,tsd2d-ns",
|
|
|
|
255);
|
|
|
|
plat->tchsh_ns = ofnode_read_u32_default(subnode, "cdns,tchsh-ns", 20);
|
|
|
|
plat->tslch_ns = ofnode_read_u32_default(subnode, "cdns,tslch-ns", 20);
|
2021-06-25 19:17:07 +00:00
|
|
|
/*
|
|
|
|
* Read delay should be an unsigned value but we use a signed integer
|
|
|
|
* so that negative values can indicate that the device tree did not
|
|
|
|
* specify any signed values and we need to perform the calibration
|
|
|
|
* sequence to find it out.
|
|
|
|
*/
|
|
|
|
plat->read_delay = ofnode_read_s32_default(subnode, "cdns,read-delay",
|
|
|
|
-1);
|
2014-11-07 11:37:49 +00:00
|
|
|
|
|
|
|
debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
|
|
|
|
__func__, plat->regbase, plat->ahbbase, plat->max_hz,
|
|
|
|
plat->page_size);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-01-27 05:06:39 +00:00
|
|
|
static const struct spi_controller_mem_ops cadence_spi_mem_ops = {
|
|
|
|
.exec_op = cadence_spi_mem_exec_op,
|
2021-06-25 19:17:09 +00:00
|
|
|
.supports_op = cadence_spi_mem_supports_op,
|
2020-01-27 05:06:39 +00:00
|
|
|
};
|
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
static const struct dm_spi_ops cadence_spi_ops = {
|
|
|
|
.set_speed = cadence_spi_set_speed,
|
|
|
|
.set_mode = cadence_spi_set_mode,
|
2020-01-27 05:06:39 +00:00
|
|
|
.mem_ops = &cadence_spi_mem_ops,
|
2014-11-07 11:37:49 +00:00
|
|
|
/*
|
|
|
|
* cs_info is not needed, since we require all chip selects to be
|
|
|
|
* in the device tree explicitly
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct udevice_id cadence_spi_ids[] = {
|
2018-11-02 10:54:51 +00:00
|
|
|
{ .compatible = "cdns,qspi-nor" },
|
2019-12-05 10:16:07 +00:00
|
|
|
{ .compatible = "ti,am654-ospi" },
|
2014-11-07 11:37:49 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(cadence_spi) = {
|
|
|
|
.name = "cadence_spi",
|
|
|
|
.id = UCLASS_SPI,
|
|
|
|
.of_match = cadence_spi_ids,
|
|
|
|
.ops = &cadence_spi_ops,
|
2020-12-03 23:55:21 +00:00
|
|
|
.of_to_plat = cadence_spi_of_to_plat,
|
2020-12-03 23:55:23 +00:00
|
|
|
.plat_auto = sizeof(struct cadence_spi_plat),
|
2020-12-03 23:55:17 +00:00
|
|
|
.priv_auto = sizeof(struct cadence_spi_priv),
|
2014-11-07 11:37:49 +00:00
|
|
|
.probe = cadence_spi_probe,
|
2019-03-01 19:12:35 +00:00
|
|
|
.remove = cadence_spi_remove,
|
|
|
|
.flags = DM_FLAG_OS_PREPARE,
|
2014-11-07 11:37:49 +00:00
|
|
|
};
|