drv_sdmmc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* Copyright (C) 2019 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DRV_SDMMC_H_
  13. #define _DRV_SDMMC_H_
  14. #include "osi_compiler.h"
  15. #include "drv_names.h"
  16. OSI_EXTERN_C_BEGIN
  17. #ifdef CONFIG_QUEC_PROJECT_FEATURE
  18. typedef enum
  19. {
  20. SDMMC_EMMC_INIT = 0,
  21. SDMMC_SD_INIT = 1,
  22. } sdmmcCardTypeInit_t;
  23. #endif
  24. /**
  25. * \brief opaque data struct of sdmmc driver
  26. */
  27. typedef struct drvSdmmc drvSdmmc_t;
  28. /**
  29. * \brief create sdmmc driver instance
  30. *
  31. * \param name device name
  32. * \return
  33. * - created driver instance
  34. * - NULL on error, invalid parameter or out of memory
  35. */
  36. drvSdmmc_t *drvSdmmcCreate(uint32_t name);
  37. /**
  38. * \brief delete sdmmc driver instance
  39. *
  40. * \param context of the function call
  41. */
  42. void drvSdmmcDestroy(void *ctx);
  43. /**
  44. * \brief open sdmmc driver instance
  45. *
  46. * Open the sdmmc driver, done it can read/write data via the sdmmc.
  47. *
  48. * \param context of the function call
  49. * \return
  50. * - true success
  51. * - false fail
  52. */
  53. bool drvSdmmcOpen(void *ctx);
  54. /**
  55. * \brief close sdmmc driver
  56. *
  57. * Close the sdmmc driver, stop all data transfer.
  58. * release resource.
  59. *
  60. * \param context of the function call
  61. */
  62. void drvSdmmcClose(void *ctx);
  63. /**
  64. * \brief get sdmmc block number
  65. *
  66. * \param context of the function call
  67. * \return block number
  68. */
  69. uint32_t drvSdmmcGetBlockNum(void *ctx);
  70. /**
  71. * \brief Write blocks of data to sdmmc
  72. *
  73. * This function is used to write blocks of data on the sdmmc.
  74. *
  75. * \p buffer should be 32 bits (4 bytes) aligned. \p size should be sector
  76. * size aligned.
  77. *
  78. * \p buffer should be SRAM or external RAM. Otherwise, it will return
  79. * false. Though hardware may support DMA from other addresses, it is
  80. * unreasonable to rely on this feature.
  81. *
  82. * \param block_number Start address of the SD memory block for writing
  83. * \param buffer Pointer to the block of data to write.
  84. * \param size Number of bytes to write.
  85. * \return
  86. * - true on sucess.
  87. * - false on fail.
  88. */
  89. bool drvSdmmcWrite(void *ctx, uint32_t block_number, const void *buffer, uint32_t size);
  90. /**
  91. * \brief Read blocks of data from sdmmc
  92. *
  93. * This function is used to Read blocks of data on the MMC.
  94. *
  95. * \p buffer should be 32 bits (4 bytes) aligned. \p size should be sector
  96. * size aligned.
  97. *
  98. * \p buffer should be SRAM or external RAM. Otherwise, it will return
  99. * false.
  100. *
  101. * D-cache invalidate will be performed on \p buffer. Caller should take care
  102. * the effects of D-cache invalidate.
  103. *
  104. * \param block_number Start address of the SD memory block for reading
  105. * \param buffer Pointer to the block of data to read
  106. * \param size Number of bytes to read
  107. * \return
  108. * - true on success.
  109. * - false on fail.
  110. */
  111. bool drvSdmmcRead(void *ctx, uint32_t block_number, void *buffer, uint32_t size);
  112. /**
  113. * get hardware type
  114. */
  115. uint32_t drvSdmmcGetType(void *ctx);
  116. OSI_EXTERN_C_END
  117. #endif