SdioDrv.h revision 2a41c9bcfdb878f169a6794b7d7e55ec821ffa9c
1/*
2 * SdioDrv.h
3 *
4 * Copyright (C) 2009 Texas Instruments, Inc. - http://www.ti.com/
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __OMAP3430_SDIODRV_API_H
17#define __OMAP3430_SDIODRV_API_H
18
19#include <asm/types.h>
20#include <linux/mmc/mmc.h>
21
22/* Card Common Control Registers (CCCR) */
23
24#define CCCR_SDIO_REVISION                  0x00
25#define CCCR_SD_SPECIFICATION_REVISION      0x01
26#define CCCR_IO_ENABLE                      0x02
27#define CCCR_IO_READY                       0x03
28#define CCCR_INT_ENABLE                     0x04
29#define CCCR_INT_PENDING                    0x05
30#define CCCR_IO_ABORT                       0x06
31#define CCCR_BUS_INTERFACE_CONTOROL         0x07
32#define CCCR_CARD_CAPABILITY	            0x08
33#define CCCR_COMMON_CIS_POINTER             0x09 /*0x09-0x0B*/
34#define CCCR_FNO_BLOCK_SIZE		0x10 /*0x10-0x11*/
35#define FN0_CCCR_REG_32			0x64
36
37/* Pprotocol defined constants */
38
39#define SD_IO_GO_IDLE_STATE		  		    0
40#define SD_IO_SEND_RELATIVE_ADDR	  	    3
41#define SDIO_CMD5			  			    5
42#define SD_IO_SELECT_CARD		  		    7
43#define SDIO_CMD52		 	 			    52
44#define SDIO_CMD53		 	 			    53
45#define SD_IO_SEND_OP_COND		            SDIO_CMD5
46#define SD_IO_RW_DIRECT			            SDIO_CMD52
47#define SD_IO_RW_EXTENDED		            SDIO_CMD53
48#define SDIO_SHIFT(v,n)                     (v<<n)
49#define SDIO_RWFLAG(v)                      (SDIO_SHIFT(v,31))
50#define SDIO_FUNCN(v)                       (SDIO_SHIFT(v,28))
51#define SDIO_RAWFLAG(v)                     (SDIO_SHIFT(v,27))
52#define SDIO_BLKM(v)                        (SDIO_SHIFT(v,27))
53#define SDIO_OPCODE(v)                      (SDIO_SHIFT(v,26))
54#define SDIO_ADDRREG(v)                     (SDIO_SHIFT(v,9))
55
56
57#define VDD_VOLTAGE_WINDOW                  0xffffc0
58#define FN2_OBI_INV                         0x0002
59
60#define MMC_RSP_NONE	                    (0 << 0)
61#define MMC_RSP_SHORT	                    (1 << 0)
62#define MMC_RSP_LONG	                    (2 << 0)
63#define MMC_RSP_MASK	                    (3 << 0)
64#define MMC_RSP_CRC	                        (1 << 3)
65#define MMC_RSP_BUSY	                    (1 << 4)
66
67#define MMC_RSP_R1	                        (MMC_RSP_SHORT|MMC_RSP_CRC)
68#define MMC_RSP_R1B	                        (MMC_RSP_SHORT|MMC_RSP_CRC|MMC_RSP_BUSY)
69#define MMC_RSP_R2	                        (MMC_RSP_LONG|MMC_RSP_CRC)
70#define MMC_RSP_R3	                        (MMC_RSP_SHORT)
71
72/* HSMMC controller bit definitions
73 * */
74#define OMAP_HSMMC_CMD_NO_RESPONSE          0 << 0
75#define OMAP_HSMMC_CMD_LONG_RESPONSE        1 << 0
76#define OMAP_HSMMC_CMD_SHORT_RESPONSE       2 << 0
77
78#define MMC_ERR_NONE	                    0
79#define MMC_ERR_TIMEOUT	                    1
80#define MMC_ERR_BADCRC	                    2
81#define MMC_ERR_FIFO	                    3
82#define MMC_ERR_FAILED	                    4
83#define MMC_ERR_INVALID	                    5
84
85#undef  MMC_RSP_R4
86#define MMC_RSP_R4 OMAP_HSMMC_CMD_SHORT_RESPONSE
87#undef  MMC_RSP_R5
88#define MMC_RSP_R5 OMAP_HSMMC_CMD_SHORT_RESPONSE
89#undef  MMC_RSP_R6
90#define MMC_RSP_R6 OMAP_HSMMC_CMD_SHORT_RESPONSE
91
92/********************************************************************/
93/*	SDIO driver functions prototypes                                */
94/********************************************************************/
95int sdioDrv_ConnectBus     (void *       fCbFunc,
96                            void *       hCbArg,
97                            unsigned int uBlkSizeShift,
98                            unsigned int uSdioThreadPriority);
99
100int sdioDrv_DisconnectBus  (void);
101
102int sdioDrv_ExecuteCmd     (unsigned int uCmd,
103                            unsigned int uArg,
104                            unsigned int uRespType,
105                            void *       pResponse,
106                            unsigned int uLen);
107
108int sdioDrv_ReadSync       (unsigned int uFunc,
109                            unsigned int uHwAddr,
110                            void *       pData,
111                            unsigned int uLen,
112                            unsigned int bIncAddr,
113                            unsigned int bMore);
114
115int sdioDrv_ReadAsync      (unsigned int uFunc,
116                            unsigned int uHwAddr,
117                            void *       pData,
118                            unsigned int uLen,
119                            unsigned int bBlkMode,
120                            unsigned int bIncAddr,
121                            unsigned int bMore);
122
123int sdioDrv_WriteSync      (unsigned int uFunc,
124                            unsigned int uHwAddr,
125                            void *       pData,
126                            unsigned int uLen,
127                            unsigned int bIncAddr,
128                            unsigned int bMore);
129
130int sdioDrv_WriteAsync     (unsigned int uFunc,
131                            unsigned int uHwAddr,
132                            void *       pData,
133                            unsigned int uLen,
134                            unsigned int bBlkMode,
135                            unsigned int bIncAddr,
136                            unsigned int bMore);
137
138int sdioDrv_ReadSyncBytes  (unsigned int  uFunc,
139                            unsigned int  uHwAddr,
140                            unsigned char *pData,
141                            unsigned int  uLen,
142                            unsigned int  bMore);
143
144int sdioDrv_WriteSyncBytes (unsigned int  uFunc,
145                            unsigned int  uHwAddr,
146                            unsigned char *pData,
147                            unsigned int  uLen,
148                            unsigned int  bMore);
149
150void sdioDrv_register_pm(int (*wlanDrvIf_Start)(void),
151						int (*wlanDrvIf_Stop)(void));
152
153
154#endif/* _OMAP3430_SDIODRV_H */
155