renesas-rpc-if.h 1.5 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/pm_runtime.h>
  12. #include <linux/types.h>
  13. enum rpcif_data_dir {
  14. RPCIF_NO_DATA,
  15. RPCIF_DATA_IN,
  16. RPCIF_DATA_OUT,
  17. };
  18. struct rpcif_op {
  19. struct {
  20. u8 buswidth;
  21. u8 opcode;
  22. bool ddr;
  23. } cmd, ocmd;
  24. struct {
  25. u8 nbytes;
  26. u8 buswidth;
  27. bool ddr;
  28. u64 val;
  29. } addr;
  30. struct {
  31. u8 ncycles;
  32. u8 buswidth;
  33. } dummy;
  34. struct {
  35. u8 nbytes;
  36. u8 buswidth;
  37. bool ddr;
  38. u32 val;
  39. } option;
  40. struct {
  41. u8 buswidth;
  42. unsigned int nbytes;
  43. enum rpcif_data_dir dir;
  44. bool ddr;
  45. union {
  46. void *in;
  47. const void *out;
  48. } buf;
  49. } data;
  50. };
  51. enum rpcif_type {
  52. RPCIF_RCAR_GEN3,
  53. RPCIF_RZ_G2L,
  54. };
  55. struct rpcif {
  56. struct device *dev;
  57. void __iomem *dirmap;
  58. size_t size;
  59. };
  60. int rpcif_sw_init(struct rpcif *rpc, struct device *dev);
  61. int rpcif_hw_init(struct rpcif *rpc, bool hyperflash);
  62. void rpcif_prepare(struct rpcif *rpc, const struct rpcif_op *op, u64 *offs,
  63. size_t *len);
  64. int rpcif_manual_xfer(struct rpcif *rpc);
  65. ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs, size_t len, void *buf);
  66. static inline void rpcif_enable_rpm(struct rpcif *rpc)
  67. {
  68. pm_runtime_enable(rpc->dev);
  69. }
  70. static inline void rpcif_disable_rpm(struct rpcif *rpc)
  71. {
  72. pm_runtime_disable(rpc->dev);
  73. }
  74. #endif // __RENESAS_RPC_IF_H