net: wifi: rockchip: update broadcom drivers for kernel4.4
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rkwifi / bcmdhd / include / bcmsdh_sdmmc.h
1 /*
2  * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel
3  *
4  * Copyright (C) 1999-2016, 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  *
25  * <<Broadcom-WL-IPTag/Proprietary,Open:>>
26  *
27  * $Id: bcmsdh_sdmmc.h 591160 2015-10-07 06:01:58Z $
28  */
29
30 #ifndef __BCMSDH_SDMMC_H__
31 #define __BCMSDH_SDMMC_H__
32
33 #define sd_err(x)       do { if (sd_msglevel & SDH_ERROR_VAL) printf x; } while (0)
34 #define sd_trace(x)     do { if (sd_msglevel & SDH_TRACE_VAL) printf x; } while (0)
35 #define sd_info(x)      do { if (sd_msglevel & SDH_INFO_VAL) printf x; } while (0)
36 #define sd_debug(x)     do { if (sd_msglevel & SDH_DEBUG_VAL) printf x; } while (0)
37 #define sd_data(x)      do { if (sd_msglevel & SDH_DATA_VAL) printf x; } while (0)
38 #define sd_ctrl(x)      do { if (sd_msglevel & SDH_CTRL_VAL) printf x; } while (0)
39
40 #define sd_sync_dma(sd, read, nbytes)
41 #define sd_init_dma(sd)
42 #define sd_ack_intr(sd)
43 #define sd_wakeup(sd);
44
45 #define sd_log(x)
46
47 #define SDIOH_ASSERT(exp) \
48         do { if (!(exp)) \
49                 printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
50         } while (0)
51
52 #define BLOCK_SIZE_4318 64
53 #define BLOCK_SIZE_4328 512
54
55 /* internal return code */
56 #define SUCCESS 0
57 #define ERROR   1
58
59 /* private bus modes */
60 #define SDIOH_MODE_SD4          2
61 #define CLIENT_INTR                     0x100   /* Get rid of this! */
62 #define SDIOH_SDMMC_MAX_SG_ENTRIES      32
63
64 #if defined(SWTXGLOM)
65 typedef struct glom_buf {
66         void *glom_pkt_head;
67         void *glom_pkt_tail;
68         uint32 count;                           /* Total number of pkts queued */
69 } glom_buf_t;
70 #endif /* SWTXGLOM */
71
72 struct sdioh_info {
73         osl_t           *osh;                   /* osh handler */
74         void            *bcmsdh;                /* upper layer handle */
75         bool            client_intr_enabled;    /* interrupt connnected flag */
76         bool            intr_handler_valid;     /* client driver interrupt handler valid */
77         sdioh_cb_fn_t   intr_handler;           /* registered interrupt handler */
78         void            *intr_handler_arg;      /* argument to call interrupt handler */
79         uint16          intmask;                /* Current active interrupts */
80
81         int             intrcount;              /* Client interrupts */
82         bool            sd_use_dma;             /* DMA on CMD53 */
83         bool            sd_blockmode;           /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
84                                                 /*  Must be on for sd_multiblock to be effective */
85         bool            use_client_ints;        /* If this is false, make sure to restore */
86         int             sd_mode;                /* SD1/SD4/SPI */
87         int             client_block_size[SDIOD_MAX_IOFUNCS];           /* Blocksize */
88         uint8           num_funcs;              /* Supported funcs on client */
89         uint32          com_cis_ptr;
90         uint32          func_cis_ptr[SDIOD_MAX_IOFUNCS];
91         bool            use_rxchain;
92         struct scatterlist      sg_list[SDIOH_SDMMC_MAX_SG_ENTRIES];
93         struct sdio_func        fake_func0;
94         struct sdio_func        *func[SDIOD_MAX_IOFUNCS];
95
96         uint    txglom_mode;            /* Txglom mode: 0 - copy, 1 - multi-descriptor */
97 #if defined(SWTXGLOM)
98         glom_buf_t glom_info;           /* pkt information used for glomming */
99 #endif
100 };
101
102 /************************************************************
103  * Internal interfaces: per-port references into bcmsdh_sdmmc.c
104  */
105
106 /* Global message bits */
107 extern uint sd_msglevel;
108
109 /* OS-independent interrupt handler */
110 extern bool check_client_intr(sdioh_info_t *sd);
111
112 /* Core interrupt enable/disable of device interrupts */
113 extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd);
114 extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd);
115
116
117 /**************************************************************
118  * Internal interfaces: bcmsdh_sdmmc.c references to per-port code
119  */
120
121 /* Register mapping routines */
122 extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size);
123 extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size);
124
125 /* Interrupt (de)registration routines */
126 extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq);
127 extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd);
128
129 extern sdioh_info_t *sdioh_attach(osl_t *osh, struct sdio_func *func);
130 extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *sd);
131
132 #ifdef GLOBAL_SDMMC_INSTANCE
133 typedef struct _BCMSDH_SDMMC_INSTANCE {
134         sdioh_info_t    *sd;
135         struct sdio_func *func[SDIOD_MAX_IOFUNCS];
136 } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE;
137 #endif
138
139 #endif /* __BCMSDH_SDMMC_H__ */