1 /* 2 * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel 3 * 4 * Portions of this code are copyright (c) 2021 Cypress Semiconductor Corporation 5 * 6 * Copyright (C) 1999-2017, 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 32 #ifndef __BCMSDH_SDMMC_H__ 33 #define __BCMSDH_SDMMC_H__ 34 35 #define sd_err(x) do { if (sd_msglevel & SDH_ERROR_VAL) printf x; } while (0) 36 #define sd_trace(x) do { if (sd_msglevel & SDH_TRACE_VAL) printf x; } while (0) 37 #define sd_info(x) do { if (sd_msglevel & SDH_INFO_VAL) printf x; } while (0) 38 #define sd_debug(x) do { if (sd_msglevel & SDH_DEBUG_VAL) printf x; } while (0) 39 #define sd_data(x) do { if (sd_msglevel & SDH_DATA_VAL) printf x; } while (0) 40 #define sd_ctrl(x) do { if (sd_msglevel & SDH_CTRL_VAL) printf x; } while (0) 41 42 #define sd_sync_dma(sd, read, nbytes) 43 #define sd_init_dma(sd) 44 #define sd_ack_intr(sd) 45 #define sd_wakeup(sd); 46 47 #define sd_log(x) 48 49 #define SDIOH_ASSERT(exp) \ 50 do { if (!(exp)) \ 51 printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \ 52 } while (0) 53 54 #define BLOCK_SIZE_4318 64 55 #define BLOCK_SIZE_4328 512 56 57 /* internal return code */ 58 #define SUCCESS 0 59 #define ERROR 1 60 61 /* private bus modes */ 62 #define SDIOH_MODE_SD4 2 63 #define CLIENT_INTR 0x100 /* Get rid of this! */ 64 #define SDIOH_SDMMC_MAX_SG_ENTRIES 64 65 66 struct sdioh_info { 67 osl_t *osh; /* osh handler */ 68 void *bcmsdh; /* upper layer handle */ 69 bool client_intr_enabled; /* interrupt connnected flag */ 70 bool intr_handler_valid; /* client driver interrupt handler valid */ 71 sdioh_cb_fn_t intr_handler; /* registered interrupt handler */ 72 void *intr_handler_arg; /* argument to call interrupt handler */ 73 uint16 intmask; /* Current active interrupts */ 74 75 int intrcount; /* Client interrupts */ 76 bool sd_use_dma; /* DMA on CMD53 */ 77 bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */ 78 /* Must be on for sd_multiblock to be effective */ 79 bool use_client_ints; /* If this is false, make sure to restore */ 80 int sd_mode; /* SD1/SD4/SPI */ 81 int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */ 82 uint8 num_funcs; /* Supported funcs on client */ 83 uint32 com_cis_ptr; 84 uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; 85 bool use_rxchain; 86 struct scatterlist sg_list[SDIOH_SDMMC_MAX_SG_ENTRIES]; 87 struct sdio_func fake_func0; 88 struct sdio_func *func[SDIOD_MAX_IOFUNCS]; 89 uint sd_clk_rate; 90 }; 91 92 /************************************************************ 93 * Internal interfaces: per-port references into bcmsdh_sdmmc.c 94 */ 95 96 /* Global message bits */ 97 extern uint sd_msglevel; 98 99 /* OS-independent interrupt handler */ 100 extern bool check_client_intr(sdioh_info_t *sd); 101 102 /* Core interrupt enable/disable of device interrupts */ 103 extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd); 104 extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd); 105 106 /************************************************************** 107 * Internal interfaces: bcmsdh_sdmmc.c references to per-port code 108 */ 109 110 /* Register mapping routines */ 111 extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size); 112 extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size); 113 114 /* Interrupt (de)registration routines */ 115 extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq); 116 extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd); 117 118 extern sdioh_info_t *sdioh_attach(osl_t *osh, struct sdio_func *func); 119 extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *sd); 120 #endif /* __BCMSDH_SDMMC_H__ */ 121