1 /* 2 * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel 3 * 4 * Copyright (C) 1999-2009, Broadcom Corporation 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 of 16 * the license of that module. An independent module is a module which is not 17 * 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 * $Id: bcmsdh_sdmmc.h,v 13.1.2.1.8.7 2009/10/27 18:22:52 Exp $ 25 */ 26 27 #ifndef __BCMSDH_SDMMC_H__ 28 #define __BCMSDH_SDMMC_H__ 29 30 #define sd_err(x) 31 #define sd_trace(x) 32 #define sd_info(x) 33 #define sd_debug(x) 34 #define sd_data(x) 35 #define sd_ctrl(x) 36 37 #define sd_sync_dma(sd, read, nbytes) 38 #define sd_init_dma(sd) 39 #define sd_ack_intr(sd) 40 #define sd_wakeup(sd); 41 42 /* Allocate/init/free per-OS private data */ 43 extern int sdioh_sdmmc_osinit(sdioh_info_t *sd); 44 extern void sdioh_sdmmc_osfree(sdioh_info_t *sd); 45 46 #define sd_log(x) 47 48 #define SDIOH_ASSERT(exp) \ 49 do { if (!(exp)) \ 50 printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \ 51 } while (0) 52 53 #define BLOCK_SIZE_4318 64 54 #define BLOCK_SIZE_4328 512 55 56 /* internal return code */ 57 #define SUCCESS 0 58 #define ERROR 1 59 60 /* private bus modes */ 61 #define SDIOH_MODE_SD4 2 62 #define CLIENT_INTR 0x100 /* Get rid of this! */ 63 64 struct sdioh_info { 65 osl_t *osh; /* osh handler */ 66 bool client_intr_enabled; /* interrupt connnected flag */ 67 bool intr_handler_valid; /* client driver interrupt handler valid */ 68 sdioh_cb_fn_t intr_handler; /* registered interrupt handler */ 69 void *intr_handler_arg; /* argument to call interrupt handler */ 70 uint16 intmask; /* Current active interrupts */ 71 void *sdos_info; /* Pointer to per-OS private data */ 72 73 uint irq; /* Client irq */ 74 int intrcount; /* Client interrupts */ 75 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 uint max_dma_len; 86 uint max_dma_descriptors; /* DMA Descriptors supported by this controller. */ 87 // SDDMA_DESCRIPTOR SGList[32]; /* Scatter/Gather DMA List */ 88 }; 89 90 /************************************************************ 91 * Internal interfaces: per-port references into bcmsdh_sdmmc.c 92 */ 93 94 /* Global message bits */ 95 extern uint sd_msglevel; 96 97 /* OS-independent interrupt handler */ 98 extern bool check_client_intr(sdioh_info_t *sd); 99 100 /* Core interrupt enable/disable of device interrupts */ 101 extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd); 102 extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd); 103 104 105 /************************************************************** 106 * Internal interfaces: bcmsdh_sdmmc.c references to per-port code 107 */ 108 109 /* Register mapping routines */ 110 extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size); 111 extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size); 112 113 /* Interrupt (de)registration routines */ 114 extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq); 115 extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd); 116 117 typedef struct _BCMSDH_SDMMC_INSTANCE { 118 sdioh_info_t *sd; 119 struct sdio_func *func[SDIOD_MAX_IOFUNCS]; 120 } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE; 121 122 #endif /* __BCMSDH_SDMMC_H__ */ 123