cadence_qspi.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2012
  3. * Altera Corporation <www.altera.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef __CADENCE_QSPI_H__
  8. #define __CADENCE_QSPI_H__
  9. #define CQSPI_IS_ADDR(cmd_len) (cmd_len > 1 ? 1 : 0)
  10. #define CQSPI_NO_DECODER_MAX_CS 4
  11. #define CQSPI_DECODER_MAX_CS 16
  12. #define CQSPI_READ_CAPTURE_MAX_DELAY 16
  13. struct cadence_spi_platdata {
  14. unsigned int max_hz;
  15. void *regbase;
  16. void *ahbbase;
  17. u32 page_size;
  18. u32 block_size;
  19. u32 tshsl_ns;
  20. u32 tsd2d_ns;
  21. u32 tchsh_ns;
  22. u32 tslch_ns;
  23. };
  24. struct cadence_spi_priv {
  25. void *regbase;
  26. void *ahbbase;
  27. size_t cmd_len;
  28. u8 cmd_buf[32];
  29. size_t data_len;
  30. int qspi_is_init;
  31. unsigned int qspi_calibrated_hz;
  32. unsigned int qspi_calibrated_cs;
  33. };
  34. /* Functions call declaration */
  35. void cadence_qspi_apb_controller_init(struct cadence_spi_platdata *plat);
  36. void cadence_qspi_apb_controller_enable(void *reg_base_addr);
  37. void cadence_qspi_apb_controller_disable(void *reg_base_addr);
  38. int cadence_qspi_apb_command_read(void *reg_base_addr,
  39. unsigned int cmdlen, const u8 *cmdbuf, unsigned int rxlen, u8 *rxbuf);
  40. int cadence_qspi_apb_command_write(void *reg_base_addr,
  41. unsigned int cmdlen, const u8 *cmdbuf,
  42. unsigned int txlen, const u8 *txbuf);
  43. int cadence_qspi_apb_indirect_read_setup(struct cadence_spi_platdata *plat,
  44. unsigned int cmdlen, const u8 *cmdbuf);
  45. int cadence_qspi_apb_indirect_read_execute(struct cadence_spi_platdata *plat,
  46. unsigned int rxlen, u8 *rxbuf);
  47. int cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat,
  48. unsigned int cmdlen, const u8 *cmdbuf);
  49. int cadence_qspi_apb_indirect_write_execute(struct cadence_spi_platdata *plat,
  50. unsigned int txlen, const u8 *txbuf);
  51. void cadence_qspi_apb_chipselect(void *reg_base,
  52. unsigned int chip_select, unsigned int decoder_enable);
  53. void cadence_qspi_apb_set_clk_mode(void *reg_base_addr,
  54. unsigned int clk_pol, unsigned int clk_pha);
  55. void cadence_qspi_apb_config_baudrate_div(void *reg_base,
  56. unsigned int ref_clk_hz, unsigned int sclk_hz);
  57. void cadence_qspi_apb_delay(void *reg_base,
  58. unsigned int ref_clk, unsigned int sclk_hz,
  59. unsigned int tshsl_ns, unsigned int tsd2d_ns,
  60. unsigned int tchsh_ns, unsigned int tslch_ns);
  61. void cadence_qspi_apb_enter_xip(void *reg_base, char xip_dummy);
  62. void cadence_qspi_apb_readdata_capture(void *reg_base,
  63. unsigned int bypass, unsigned int delay);
  64. #endif /* __CADENCE_QSPI_H__ */