• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel
4  *
5  * Copyright (C) 1999-2019, Broadcom.
6  *
7  *      Unless you and Broadcom execute a separate written software license
8  * agreement governing use of this software, this software is licensed to you
9  * under the terms of the GNU General Public License version 2 (the "GPL"),
10  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
11  * following added to such license:
12  *
13  *      As a special exception, the copyright holders of this software give you
14  * permission to link this software with independent modules, and to copy and
15  * distribute the resulting executable under terms of your choice, provided that
16  * you also meet, for each linked independent module, the terms and conditions of
17  * the license of that module.  An independent module is a module which is not
18  * derived from this software.  The special exception does not apply to any
19  * modifications of the software.
20  *
21  *      Notwithstanding the above, under no circumstances may you combine this
22  * software in any way with any other Broadcom software provided under a license
23  * other than the GPL, without Broadcom's express prior written consent.
24  *
25  *
26  * <<Broadcom-WL-IPTag/Proprietary,Open:>>
27  *
28  * $Id: bcmsdh_sdmmc.h 753315 2018-03-21 04:10:12Z $
29  */
30 
31 #ifndef __BCMSDH_SDMMC_H__
32 #define __BCMSDH_SDMMC_H__
33 
34 #define sd_err(x)	do { if (sd_msglevel & SDH_ERROR_VAL) printf x; } while (0)
35 #define sd_trace(x)	do { if (sd_msglevel & SDH_TRACE_VAL) printf x; } while (0)
36 #define sd_info(x)	do { if (sd_msglevel & SDH_INFO_VAL) printf x; } while (0)
37 #define sd_debug(x)	do { if (sd_msglevel & SDH_DEBUG_VAL) printf x; } while (0)
38 #define sd_data(x)	do { if (sd_msglevel & SDH_DATA_VAL) printf x; } while (0)
39 #define sd_ctrl(x)	do { if (sd_msglevel & SDH_CTRL_VAL) printf x; } while (0)
40 #define sd_cost(x)	do { if (sd_msglevel & SDH_COST_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 	uint	txglom_mode;		/* Txglom mode: 0 - copy, 1 - multi-descriptor */
91 	uint32	sdio_spent_time_us;
92 };
93 
94 /************************************************************
95  * Internal interfaces: per-port references into bcmsdh_sdmmc.c
96  */
97 
98 /* Global message bits */
99 extern uint sd_msglevel;
100 
101 /* OS-independent interrupt handler */
102 extern bool check_client_intr(sdioh_info_t *sd);
103 
104 /* Core interrupt enable/disable of device interrupts */
105 extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd);
106 extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd);
107 
108 /**************************************************************
109  * Internal interfaces: bcmsdh_sdmmc.c references to per-port code
110  */
111 
112 /* Register mapping routines */
113 extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size);
114 extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size);
115 
116 /* Interrupt (de)registration routines */
117 extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq);
118 extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd);
119 
120 extern sdioh_info_t *sdioh_attach(osl_t *osh, struct sdio_func *func);
121 extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *sd);
122 
123 #ifdef GLOBAL_SDMMC_INSTANCE
124 typedef struct _BCMSDH_SDMMC_INSTANCE {
125 	sdioh_info_t	*sd;
126 	struct sdio_func *func[SDIOD_MAX_IOFUNCS];
127 } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE;
128 #endif
129 
130 #endif /* __BCMSDH_SDMMC_H__ */
131