1 /* 2 * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel 3 * 4 * Copyright (C) 1999-2019, Broadcom. 5 * 6 * Unless you and Broadcom execute a separate written software license 7 * agreement governing use of this software, this software is licensed to you 8 * under the terms of the GNU General Public License version 2 (the "GPL"), 9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the 10 * following added to such license: 11 * 12 * As a special exception, the copyright holders of this software give you 13 * permission to link this software with independent modules, and to copy and 14 * distribute the resulting executable under terms of your choice, provided that 15 * you also meet, for each linked independent module, the terms and conditions 16 * of the license of that module. An independent module is a module which is 17 * not derived from this software. The special exception does not apply to any 18 * modifications of the software. 19 * 20 * Notwithstanding the above, under no circumstances may you combine this 21 * software in any way with any other Broadcom software provided under a license 22 * other than the GPL, without Broadcom's express prior written consent. 23 * 24 * 25 * <<Broadcom-WL-IPTag/Proprietary,Open:>> 26 * 27 * $Id: bcmsdh_sdmmc.h 753315 2018-03-21 04:10:12Z $ 28 */ 29 30 #ifndef __BCMSDH_SDMMC_H__ 31 #define __BCMSDH_SDMMC_H__ 32 33 #define sd_err(x) \ 34 do { \ 35 if (sd_msglevel & SDH_ERROR_VAL) \ 36 printf x; \ 37 } while (0) 38 #define sd_trace(x) \ 39 do { \ 40 if (sd_msglevel & SDH_TRACE_VAL) \ 41 printf x; \ 42 } while (0) 43 #define sd_info(x) \ 44 do { \ 45 if (sd_msglevel & SDH_INFO_VAL) \ 46 printf x; \ 47 } while (0) 48 #define sd_debug(x) \ 49 do { \ 50 if (sd_msglevel & SDH_DEBUG_VAL) \ 51 printf x; \ 52 } while (0) 53 #define sd_data(x) \ 54 do { \ 55 if (sd_msglevel & SDH_DATA_VAL) \ 56 printf x; \ 57 } while (0) 58 #define sd_ctrl(x) \ 59 do { \ 60 if (sd_msglevel & SDH_CTRL_VAL) \ 61 printf x; \ 62 } while (0) 63 #define sd_cost(x) \ 64 do { \ 65 if (sd_msglevel & SDH_COST_VAL) \ 66 printf x; \ 67 } while (0) 68 69 #define sd_sync_dma(sd, read, nbytes) 70 #define sd_init_dma(sd) 71 #define sd_ack_intr(sd) 72 #define sd_wakeup(sd) ; 73 74 #define sd_log(x) 75 76 #define SDIOH_ASSERT(exp) \ 77 do { \ 78 if (!(exp)) \ 79 printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \ 80 } while (0) 81 82 #define BLOCK_SIZE_4318 64 83 #define BLOCK_SIZE_4328 512 84 85 /* internal return code */ 86 #define SUCCESS 0 87 #define ERROR 1 88 89 /* private bus modes */ 90 #define SDIOH_MODE_SD4 2 91 #define CLIENT_INTR 0x100 /* Get rid of this! */ 92 #define SDIOH_SDMMC_MAX_SG_ENTRIES 64 93 94 struct sdioh_info { 95 osl_t *osh; /* osh handler */ 96 void *bcmsdh; /* upper layer handle */ 97 bool client_intr_enabled; /* interrupt connnected flag */ 98 bool intr_handler_valid; /* client driver interrupt handler valid */ 99 sdioh_cb_fn_t intr_handler; /* registered interrupt handler */ 100 void *intr_handler_arg; /* argument to call interrupt handler */ 101 uint16 intmask; /* Current active interrupts */ 102 103 int intrcount; /* Client interrupts */ 104 bool sd_use_dma; /* DMA on CMD53 */ 105 bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */ 106 /* Must be on for sd_multiblock to be effective */ 107 bool use_client_ints; /* If this is false, make sure to restore */ 108 int sd_mode; /* SD1/SD4/SPI */ 109 int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */ 110 uint8 num_funcs; /* Supported funcs on client */ 111 uint32 com_cis_ptr; 112 uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; 113 bool use_rxchain; 114 struct scatterlist sg_list[SDIOH_SDMMC_MAX_SG_ENTRIES]; 115 struct sdio_func fake_func0; 116 struct sdio_func *func[SDIOD_MAX_IOFUNCS]; 117 uint sd_clk_rate; 118 uint txglom_mode; /* Txglom mode: 0 - copy, 1 - multi-descriptor */ 119 #ifdef PKT_STATICS 120 uint32 sdio_spent_time_us; 121 #endif 122 #if !defined(OOB_INTR_ONLY) 123 struct mutex claim_host_mutex; // terence 20140926: fix for claim host issue 124 #endif 125 }; 126 127 /************************************************************ 128 * Internal interfaces: per-port references into bcmsdh_sdmmc.c 129 */ 130 131 /* Global message bits */ 132 extern uint sd_msglevel; 133 134 /* OS-independent interrupt handler */ 135 extern bool check_client_intr(sdioh_info_t *sd); 136 137 /* Core interrupt enable/disable of device interrupts */ 138 extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd); 139 extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd); 140 141 /************************************************************** 142 * Internal interfaces: bcmsdh_sdmmc.c references to per-port code 143 */ 144 145 /* Register mapping routines */ 146 extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size); 147 extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size); 148 149 /* Interrupt (de)registration routines */ 150 extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq); 151 extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd); 152 153 extern sdioh_info_t *sdioh_attach(osl_t *osh, struct sdio_func *func); 154 extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *sd); 155 156 #ifdef GLOBAL_SDMMC_INSTANCE 157 typedef struct _BCMSDH_SDMMC_INSTANCE { 158 sdioh_info_t *sd; 159 struct sdio_func *func[SDIOD_MAX_IOFUNCS]; 160 } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE; 161 #endif 162 163 #endif /* __BCMSDH_SDMMC_H__ */ 164