bcmsdh_sdmmc.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel
  3. *
  4. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  5. *
  6. * Copyright (C) 1999-2020, Broadcom Corporation
  7. *
  8. * Unless you and Broadcom execute a separate written software license
  9. * agreement governing use of this software, this software is licensed to you
  10. * under the terms of the GNU General Public License version 2 (the "GPL"),
  11. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  12. * following added to such license:
  13. *
  14. * As a special exception, the copyright holders of this software give you
  15. * permission to link this software with independent modules, and to copy and
  16. * distribute the resulting executable under terms of your choice, provided that
  17. * you also meet, for each linked independent module, the terms and conditions of
  18. * the license of that module. An independent module is a module which is not
  19. * derived from this software. The special exception does not apply to any
  20. * modifications of the software.
  21. *
  22. * Notwithstanding the above, under no circumstances may you combine this
  23. * software in any way with any other Broadcom software provided under a license
  24. * other than the GPL, without Broadcom's express prior written consent.
  25. *
  26. *
  27. * <<Broadcom-WL-IPTag/Proprietary,Open:>>
  28. *
  29. * $Id: bcmsdh_sdmmc.h 690294 2017-03-15 12:33:14Z $
  30. */
  31. #ifndef __BCMSDH_SDMMC_H__
  32. #define __BCMSDH_SDMMC_H__
  33. #define sd_err(x) do { if (sd_msglevel & SDH_ERROR_VAL) printf x; } while (0)
  34. #define sd_trace(x)
  35. #define sd_info(x)
  36. #define sd_debug(x)
  37. #define sd_data(x)
  38. #define sd_ctrl(x)
  39. #define sd_sync_dma(sd, read, nbytes)
  40. #define sd_init_dma(sd)
  41. #define sd_ack_intr(sd)
  42. #define sd_wakeup(sd);
  43. #define sd_log(x)
  44. #define SDIOH_ASSERT(exp) \
  45. do { if (!(exp)) \
  46. printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
  47. } while (0)
  48. #define BLOCK_SIZE_4318 64
  49. #define BLOCK_SIZE_4328 512
  50. /* internal return code */
  51. #define SUCCESS 0
  52. #define ERROR 1
  53. /* private bus modes */
  54. #define SDIOH_MODE_SD4 2
  55. #define CLIENT_INTR 0x100 /* Get rid of this! */
  56. #define SDIOH_SDMMC_MAX_SG_ENTRIES 64
  57. struct sdioh_info {
  58. osl_t *osh; /* osh handler */
  59. void *bcmsdh; /* upper layer handle */
  60. bool client_intr_enabled; /* interrupt connnected flag */
  61. bool intr_handler_valid; /* client driver interrupt handler valid */
  62. sdioh_cb_fn_t intr_handler; /* registered interrupt handler */
  63. void *intr_handler_arg; /* argument to call interrupt handler */
  64. uint16 intmask; /* Current active interrupts */
  65. int intrcount; /* Client interrupts */
  66. bool sd_use_dma; /* DMA on CMD53 */
  67. bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
  68. /* Must be on for sd_multiblock to be effective */
  69. bool use_client_ints; /* If this is false, make sure to restore */
  70. int sd_mode; /* SD1/SD4/SPI */
  71. int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */
  72. uint8 num_funcs; /* Supported funcs on client */
  73. uint32 com_cis_ptr;
  74. uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
  75. bool use_rxchain;
  76. struct scatterlist sg_list[SDIOH_SDMMC_MAX_SG_ENTRIES];
  77. struct sdio_func fake_func0;
  78. struct sdio_func *func[SDIOD_MAX_IOFUNCS];
  79. uint sd_clk_rate;
  80. };
  81. /************************************************************
  82. * Internal interfaces: per-port references into bcmsdh_sdmmc.c
  83. */
  84. /* Global message bits */
  85. extern uint sd_msglevel;
  86. /* OS-independent interrupt handler */
  87. extern bool check_client_intr(sdioh_info_t *sd);
  88. /* Core interrupt enable/disable of device interrupts */
  89. extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd);
  90. extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd);
  91. /**************************************************************
  92. * Internal interfaces: bcmsdh_sdmmc.c references to per-port code
  93. */
  94. /* Register mapping routines */
  95. extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size);
  96. extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size);
  97. /* Interrupt (de)registration routines */
  98. extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq);
  99. extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd);
  100. extern sdioh_info_t *sdioh_attach(osl_t *osh, struct sdio_func *func);
  101. extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *sd);
  102. #endif /* __BCMSDH_SDMMC_H__ */