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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CADENCE_QSPI_H__
|
|
|
|
#define __CADENCE_QSPI_H__
|
|
|
|
|
2019-03-01 19:12:35 +00:00
|
|
|
#include <reset.h>
|
|
|
|
|
2014-11-07 11:37:49 +00:00
|
|
|
#define CQSPI_IS_ADDR(cmd_len) (cmd_len > 1 ? 1 : 0)
|
|
|
|
|
|
|
|
#define CQSPI_NO_DECODER_MAX_CS 4
|
|
|
|
#define CQSPI_DECODER_MAX_CS 16
|
|
|
|
#define CQSPI_READ_CAPTURE_MAX_DELAY 16
|
|
|
|
|
2020-12-03 23:55:23 +00:00
|
|
|
struct cadence_spi_plat {
|
2019-11-20 21:27:31 +00:00
|
|
|
unsigned int ref_clk_hz;
|
2014-11-07 11:37:49 +00:00
|
|
|
unsigned int max_hz;
|
|
|
|
void *regbase;
|
|
|
|
void *ahbbase;
|
2018-01-23 23:13:09 +00:00
|
|
|
bool is_decoded_cs;
|
|
|
|
u32 fifo_depth;
|
|
|
|
u32 fifo_width;
|
|
|
|
u32 trigger_address;
|
2020-01-27 05:06:40 +00:00
|
|
|
fdt_addr_t ahbsize;
|
|
|
|
bool use_dac_mode;
|
2021-06-25 19:17:07 +00:00
|
|
|
int read_delay;
|
2021-06-25 19:17:08 +00:00
|
|
|
u32 wr_delay;
|
2014-11-07 11:37:49 +00:00
|
|
|
|
2018-01-23 23:13:09 +00:00
|
|
|
/* Flash parameters */
|
2014-11-07 11:37:49 +00:00
|
|
|
u32 page_size;
|
|
|
|
u32 block_size;
|
|
|
|
u32 tshsl_ns;
|
|
|
|
u32 tsd2d_ns;
|
|
|
|
u32 tchsh_ns;
|
|
|
|
u32 tslch_ns;
|
2021-06-25 19:17:09 +00:00
|
|
|
|
|
|
|
/* Transaction protocol parameters. */
|
|
|
|
u8 inst_width;
|
|
|
|
u8 addr_width;
|
|
|
|
u8 data_width;
|
|
|
|
bool dtr;
|
2014-11-07 11:37:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct cadence_spi_priv {
|
|
|
|
void *regbase;
|
|
|
|
void *ahbbase;
|
|
|
|
size_t cmd_len;
|
|
|
|
u8 cmd_buf[32];
|
|
|
|
size_t data_len;
|
|
|
|
|
|
|
|
int qspi_is_init;
|
|
|
|
unsigned int qspi_calibrated_hz;
|
|
|
|
unsigned int qspi_calibrated_cs;
|
2015-10-17 13:31:55 +00:00
|
|
|
unsigned int previous_hz;
|
2019-03-01 19:12:35 +00:00
|
|
|
|
2022-02-22 16:23:25 +00:00
|
|
|
struct reset_ctl_bulk *resets;
|
2014-11-07 11:37:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Functions call declaration */
|
2020-12-03 23:55:23 +00:00
|
|
|
void cadence_qspi_apb_controller_init(struct cadence_spi_plat *plat);
|
2014-11-07 11:37:49 +00:00
|
|
|
void cadence_qspi_apb_controller_enable(void *reg_base_addr);
|
|
|
|
void cadence_qspi_apb_controller_disable(void *reg_base_addr);
|
2020-01-27 05:06:40 +00:00
|
|
|
void cadence_qspi_apb_dac_mode_enable(void *reg_base);
|
2014-11-07 11:37:49 +00:00
|
|
|
|
2021-06-25 19:17:09 +00:00
|
|
|
int cadence_qspi_apb_command_read_setup(struct cadence_spi_plat *plat,
|
|
|
|
const struct spi_mem_op *op);
|
|
|
|
int cadence_qspi_apb_command_read(struct cadence_spi_plat *plat,
|
2020-01-27 05:06:39 +00:00
|
|
|
const struct spi_mem_op *op);
|
2021-06-25 19:17:09 +00:00
|
|
|
int cadence_qspi_apb_command_write_setup(struct cadence_spi_plat *plat,
|
|
|
|
const struct spi_mem_op *op);
|
|
|
|
int cadence_qspi_apb_command_write(struct cadence_spi_plat *plat,
|
2020-01-27 05:06:39 +00:00
|
|
|
const struct spi_mem_op *op);
|
2014-11-07 11:37:49 +00:00
|
|
|
|
2020-12-03 23:55:23 +00:00
|
|
|
int cadence_qspi_apb_read_setup(struct cadence_spi_plat *plat,
|
2020-01-27 05:06:40 +00:00
|
|
|
const struct spi_mem_op *op);
|
2020-12-03 23:55:23 +00:00
|
|
|
int cadence_qspi_apb_read_execute(struct cadence_spi_plat *plat,
|
2020-01-27 05:06:40 +00:00
|
|
|
const struct spi_mem_op *op);
|
2020-12-03 23:55:23 +00:00
|
|
|
int cadence_qspi_apb_write_setup(struct cadence_spi_plat *plat,
|
2020-01-27 05:06:40 +00:00
|
|
|
const struct spi_mem_op *op);
|
2020-12-03 23:55:23 +00:00
|
|
|
int cadence_qspi_apb_write_execute(struct cadence_spi_plat *plat,
|
2020-01-27 05:06:40 +00:00
|
|
|
const struct spi_mem_op *op);
|
2014-11-07 11:37:49 +00:00
|
|
|
|
|
|
|
void cadence_qspi_apb_chipselect(void *reg_base,
|
|
|
|
unsigned int chip_select, unsigned int decoder_enable);
|
2016-11-29 12:58:31 +00:00
|
|
|
void cadence_qspi_apb_set_clk_mode(void *reg_base, uint mode);
|
2014-11-07 11:37:49 +00:00
|
|
|
void cadence_qspi_apb_config_baudrate_div(void *reg_base,
|
|
|
|
unsigned int ref_clk_hz, unsigned int sclk_hz);
|
|
|
|
void cadence_qspi_apb_delay(void *reg_base,
|
|
|
|
unsigned int ref_clk, unsigned int sclk_hz,
|
|
|
|
unsigned int tshsl_ns, unsigned int tsd2d_ns,
|
|
|
|
unsigned int tchsh_ns, unsigned int tslch_ns);
|
|
|
|
void cadence_qspi_apb_enter_xip(void *reg_base, char xip_dummy);
|
|
|
|
void cadence_qspi_apb_readdata_capture(void *reg_base,
|
|
|
|
unsigned int bypass, unsigned int delay);
|
2022-03-30 22:07:23 +00:00
|
|
|
unsigned int cm_get_qspi_controller_clk_hz(void);
|
2014-11-07 11:37:49 +00:00
|
|
|
|
|
|
|
#endif /* __CADENCE_QSPI_H__ */
|