2 * SD-SPI Protocol Conversion - BCMSDH->SPI Translation Layer
4 * Copyright (C) 1999-2011, Broadcom Corporation
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:
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.
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.
24 * $Id: bcmsdspi.h 277737 2011-08-16 17:54:59Z $
29 /* global msglevel for debug messages - bitvals come from sdiovar.h */
40 #define SDIOH_ASSERT(exp) \
42 printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
45 #define BLOCK_SIZE_4318 64
46 #define BLOCK_SIZE_4328 512
48 /* internal return code */
53 /* private bus modes */
54 #define SDIOH_MODE_SPI 0
56 #define USE_BLOCKMODE 0x2 /* Block mode can be single block or multi */
57 #define USE_MULTIBLOCK 0x4
60 uint cfg_bar; /* pci cfg address for bar */
61 uint32 caps; /* cached value of capabilities reg */
62 uint bar0; /* BAR0 for PCI Device */
63 osl_t *osh; /* osh handler */
64 void *controller; /* Pointer to SPI Controller's private data struct */
66 uint lockcount; /* nest count of sdspi_lock() calls */
67 bool client_intr_enabled; /* interrupt connnected flag */
68 bool intr_handler_valid; /* client driver interrupt handler valid */
69 sdioh_cb_fn_t intr_handler; /* registered interrupt handler */
70 void *intr_handler_arg; /* argument to call interrupt handler */
71 bool initialized; /* card initialized */
72 uint32 target_dev; /* Target device ID */
73 uint32 intmask; /* Current active interrupts */
74 void *sdos_info; /* Pointer to per-OS private data */
76 uint32 controller_type; /* Host controller type */
77 uint8 version; /* Host Controller Spec Compliance Version */
78 uint irq; /* Client irq */
79 uint32 intrcount; /* Client interrupts */
80 uint32 local_intrcount; /* Controller interrupts */
81 bool host_init_done; /* Controller initted */
82 bool card_init_done; /* Client SDIO interface initted */
83 bool polled_mode; /* polling for command completion */
85 bool sd_use_dma; /* DMA on CMD53 */
86 bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
87 /* Must be on for sd_multiblock to be effective */
88 bool use_client_ints; /* If this is false, make sure to restore */
89 bool got_hcint; /* Host Controller interrupt. */
90 /* polling hack in wl_linux.c:wl_timer() */
91 int adapter_slot; /* Maybe dealing with multiple slots/controllers */
92 int sd_mode; /* SD1/SD4/SPI */
93 int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */
94 uint32 data_xfer_count; /* Current register transfer size */
95 uint32 cmd53_wr_data; /* Used to pass CMD53 write data */
96 uint32 card_response; /* Used to pass back response status byte */
97 uint32 card_rsp_data; /* Used to pass back response data word */
98 uint16 card_rca; /* Current Address */
99 uint8 num_funcs; /* Supported funcs on client */
101 uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
104 int r_cnt; /* rx count */
105 int t_cnt; /* tx_count */
108 /************************************************************
109 * Internal interfaces: per-port references into bcmsdspi.c
112 /* Global message bits */
113 extern uint sd_msglevel;
115 /**************************************************************
116 * Internal interfaces: bcmsdspi.c references to per-port code
119 /* Register mapping routines */
120 extern uint32 *spi_reg_map(osl_t *osh, uintptr addr, int size);
121 extern void spi_reg_unmap(osl_t *osh, uintptr addr, int size);
123 /* Interrupt (de)registration routines */
124 extern int spi_register_irq(sdioh_info_t *sd, uint irq);
125 extern void spi_free_irq(uint irq, sdioh_info_t *sd);
127 /* OS-specific interrupt wrappers (atomic interrupt enable/disable) */
128 extern void spi_lock(sdioh_info_t *sd);
129 extern void spi_unlock(sdioh_info_t *sd);
131 /* Allocate/init/free per-OS private data */
132 extern int spi_osinit(sdioh_info_t *sd);
133 extern void spi_osfree(sdioh_info_t *sd);
135 #endif /* _BCM_SD_SPI_H */