renesas-rpc-if.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Renesas RPC-IF core driver
  4. *
  5. * Copyright (C) 2018~2019 Renesas Solutions Corp.
  6. * Copyright (C) 2019 Macronix International Co., Ltd.
  7. * Copyright (C) 2019-2020 Cogent Embedded, Inc.
  8. */
  9. #ifndef __RENESAS_RPC_IF_H
  10. #define __RENESAS_RPC_IF_H
  11. #include <linux/types.h>
  12. enum rpcif_data_dir {
  13. RPCIF_NO_DATA,
  14. RPCIF_DATA_IN,
  15. RPCIF_DATA_OUT,
  16. };
  17. struct rpcif_op {
  18. struct {
  19. u8 buswidth;
  20. u8 opcode;
  21. bool ddr;
  22. } cmd, ocmd;
  23. struct {
  24. u8 nbytes;
  25. u8 buswidth;
  26. bool ddr;
  27. u64 val;
  28. } addr;
  29. struct {
  30. u8 ncycles;
  31. u8 buswidth;
  32. } dummy;
  33. struct {
  34. u8 nbytes;
  35. u8 buswidth;
  36. bool ddr;
  37. u32 val;
  38. } option;
  39. struct {
  40. u8 buswidth;
  41. unsigned int nbytes;
  42. enum rpcif_data_dir dir;
  43. bool ddr;
  44. union {
  45. void *in;
  46. const void *out;
  47. } buf;
  48. } data;
  49. };
  50. struct rpcif {
  51. struct device *dev;
  52. void __iomem *base;
  53. void __iomem *dirmap;
  54. struct regmap *regmap;
  55. struct reset_control *rstc;
  56. size_t size;
  57. enum rpcif_data_dir dir;
  58. u8 bus_size;
  59. void *buffer;
  60. u32 xferlen;
  61. u32 smcr;
  62. u32 smadr;
  63. u32 command; /* DRCMR or SMCMR */
  64. u32 option; /* DROPR or SMOPR */
  65. u32 enable; /* DRENR or SMENR */
  66. u32 dummy; /* DRDMCR or SMDMCR */
  67. u32 ddr; /* DRDRENR or SMDRENR */
  68. };
  69. int rpcif_sw_init(struct rpcif *rpc, struct device *dev);
  70. void rpcif_hw_init(struct rpcif *rpc, bool hyperflash);
  71. void rpcif_enable_rpm(struct rpcif *rpc);
  72. void rpcif_disable_rpm(struct rpcif *rpc);
  73. void rpcif_prepare(struct rpcif *rpc, const struct rpcif_op *op, u64 *offs,
  74. size_t *len);
  75. int rpcif_manual_xfer(struct rpcif *rpc);
  76. ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs, size_t len, void *buf);
  77. #endif // __RENESAS_RPC_IF_H