RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
dev_sdio.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2023, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2012-01-15 weety first version
9 */
10
11#ifndef __DEV_SDIO_H__
12#define __DEV_SDIO_H__
13
14#include <rtthread.h>
15#include <drivers/mmcsd_host.h>
16#include <drivers/mmcsd_card.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/*
24 * Card Common Control Registers (CCCR)
25 */
26
27#define SDIO_REG_CCCR_CCCR_REV 0x00
28
29#define SDIO_CCCR_REV_1_00 0 /* CCCR/FBR Version 1.00 */
30#define SDIO_CCCR_REV_1_10 1 /* CCCR/FBR Version 1.10 */
31#define SDIO_CCCR_REV_1_20 2 /* CCCR/FBR Version 1.20 */
32#define SDIO_CCCR_REV_3_00 3 /* CCCR/FBR Version 2.00 */
33
34#define SDIO_SDIO_REV_1_00 0 /* SDIO Spec Version 1.00 */
35#define SDIO_SDIO_REV_1_10 1 /* SDIO Spec Version 1.10 */
36#define SDIO_SDIO_REV_1_20 2 /* SDIO Spec Version 1.20 */
37#define SDIO_SDIO_REV_2_00 3 /* SDIO Spec Version 2.00 */
38
39#define SDIO_REG_CCCR_SD_REV 0x01
40
41#define SDIO_SD_REV_1_01 0 /* SD Physical Spec Version 1.01 */
42#define SDIO_SD_REV_1_10 1 /* SD Physical Spec Version 1.10 */
43#define SDIO_SD_REV_2_00 2 /* SD Physical Spec Version 2.00 */
44
45#define SDIO_REG_CCCR_IO_EN 0x02
46#define SDIO_REG_CCCR_IO_RDY 0x03
47
48#define SDIO_REG_CCCR_INT_EN 0x04 /* Function/Master Interrupt Enable */
49#define SDIO_REG_CCCR_INT_PEND 0x05 /* Function Interrupt Pending */
50
51#define SDIO_REG_CCCR_IO_ABORT 0x06 /* function abort/card reset */
52
53#define SDIO_REG_CCCR_BUS_IF 0x07 /* bus interface controls */
54
55#define SDIO_BUS_WIDTH_1BIT 0x00
56#define SDIO_BUS_WIDTH_4BIT 0x02
57#define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */
58#define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */
59
60#define SDIO_BUS_ASYNC_INT 0x20
61
62#define SDIO_BUS_CD_DISABLE 0x80 /* disable pull-up on DAT3 (pin 1) */
63
64#define SDIO_REG_CCCR_CARD_CAPS 0x08
65
66#define SDIO_CCCR_CAP_SDC 0x01 /* can do CMD52 while data transfer */
67#define SDIO_CCCR_CAP_SMB 0x02 /* can do multi-block xfers (CMD53) */
68#define SDIO_CCCR_CAP_SRW 0x04 /* supports read-wait protocol */
69#define SDIO_CCCR_CAP_SBS 0x08 /* supports suspend/resume */
70#define SDIO_CCCR_CAP_S4MI 0x10 /* interrupt during 4-bit CMD53 */
71#define SDIO_CCCR_CAP_E4MI 0x20 /* enable ints during 4-bit CMD53 */
72#define SDIO_CCCR_CAP_LSC 0x40 /* low speed card */
73#define SDIO_CCCR_CAP_4BLS 0x80 /* 4 bit low speed card */
74
75#define SDIO_REG_CCCR_CIS_PTR 0x09 /* common CIS pointer (3 bytes) */
76
77/* Following 4 regs are valid only if SBS is set */
78#define SDIO_REG_CCCR_BUS_SUSPEND 0x0c
79#define SDIO_REG_CCCR_FUNC_SEL 0x0d
80#define SDIO_REG_CCCR_EXEC_FLAG 0x0e
81#define SDIO_REG_CCCR_READY_FLAG 0x0f
82
83#define SDIO_REG_CCCR_FN0_BLKSIZE 0x10 /* 2bytes, 0x10~0x11 */
84
85#define SDIO_REG_CCCR_POWER_CTRL 0x12
86
87#define SDIO_POWER_SMPC 0x01 /* Supports Master Power Control */
88#define SDIO_POWER_EMPC 0x02 /* Enable Master Power Control */
89
90#define SDIO_REG_CCCR_SPEED 0x13
91
92#define SDIO_SPEED_SHS 0x01 /* Supports High-Speed mode */
93#define SDIO_SPEED_EHS 0x02 /* Enable High-Speed mode */
94
95/*
96 * Function Basic Registers (FBR)
97 */
98
99#define SDIO_REG_FBR_BASE(f) ((f) * 0x100) /* base of function f's FBRs */
100
101#define SDIO_REG_FBR_STD_FUNC_IF 0x00
102
103#define SDIO_FBR_SUPPORTS_CSA 0x40 /* supports Code Storage Area */
104#define SDIO_FBR_ENABLE_CSA 0x80 /* enable Code Storage Area */
105
106#define SDIO_REG_FBR_STD_IF_EXT 0x01
107
108#define SDIO_REG_FBR_POWER 0x02
109
110#define SDIO_FBR_POWER_SPS 0x01 /* Supports Power Selection */
111#define SDIO_FBR_POWER_EPS 0x02 /* Enable (low) Power Selection */
112
113#define SDIO_REG_FBR_CIS 0x09 /* CIS pointer (3 bytes) */
114
115
116#define SDIO_REG_FBR_CSA 0x0C /* CSA pointer (3 bytes) */
117
118#define SDIO_REG_FBR_CSA_DATA 0x0F
119
120#define SDIO_REG_FBR_BLKSIZE 0x10 /* block size (2 bytes) */
121
122/* SDIO CIS Tuple code */
123#define CISTPL_NULL 0x00
124#define CISTPL_CHECKSUM 0x10
125#define CISTPL_VERS_1 0x15
126#define CISTPL_ALTSTR 0x16
127#define CISTPL_MANFID 0x20
128#define CISTPL_FUNCID 0x21
129#define CISTPL_FUNCE 0x22
130#define CISTPL_SDIO_STD 0x91
131#define CISTPL_SDIO_EXT 0x92
132#define CISTPL_END 0xff
133
134/* SDIO device id */
135#define SDIO_ANY_FUNC_ID 0xff
136#define SDIO_ANY_MAN_ID 0xffff
137#define SDIO_ANY_PROD_ID 0xffff
138
145
147{
148 char *name;
152};
153
155 rt_uint32_t ocr,
156 rt_uint32_t *cmd5_resp);
158 rt_int32_t rw,
159 rt_uint32_t fn,
160 rt_uint32_t reg_addr,
161 rt_uint8_t *pdata,
162 rt_uint8_t raw);
164 rt_int32_t rw,
165 rt_uint32_t fn,
166 rt_uint32_t addr,
167 rt_int32_t op_code,
168 rt_uint8_t *buf,
169 rt_uint32_t blocks,
170 rt_uint32_t blksize);
172 rt_int32_t rw,
173 rt_uint32_t addr,
174 rt_int32_t op_code,
175 rt_uint8_t *buf,
176 rt_uint32_t len);
178 rt_uint32_t reg,
179 rt_int32_t *err);
181 rt_uint32_t reg,
182 rt_uint8_t data);
184 rt_uint32_t addr,
185 rt_int32_t *err);
187 rt_uint16_t data,
188 rt_uint32_t addr);
190 rt_uint32_t addr,
191 rt_int32_t *err);
193 rt_uint32_t data,
194 rt_uint32_t addr);
196 rt_uint32_t addr,
197 rt_uint8_t *buf,
198 rt_uint32_t len);
200 rt_uint32_t addr,
201 rt_uint8_t *buf,
202 rt_uint32_t len);
204 rt_uint32_t addr,
205 rt_uint8_t *buf,
206 rt_uint32_t len);
208 rt_uint32_t addr,
209 rt_uint8_t *buf,
210 rt_uint32_t len);
213 rt_sdio_irq_handler_t *handler);
218void sdio_set_drvdata(struct rt_sdio_function *func, void *data);
221 rt_uint32_t blksize);
224void rt_sdio_init(void);
225
226#ifdef __cplusplus
227}
228#endif
229
230#endif
231
void sdio_set_drvdata(struct rt_sdio_function *func, void *data)
rt_int32_t sdio_io_writew(struct rt_sdio_function *func, rt_uint16_t data, rt_uint32_t addr)
rt_uint8_t sdio_io_readb(struct rt_sdio_function *func, rt_uint32_t reg, rt_int32_t *err)
rt_int32_t sdio_io_write_multi_incr_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len)
rt_int32_t sdio_disable_func(struct rt_sdio_function *func)
rt_int32_t sdio_detach_irq(struct rt_sdio_function *func)
rt_int32_t sdio_io_rw_extended(struct rt_mmcsd_card *card, rt_int32_t rw, rt_uint32_t fn, rt_uint32_t addr, rt_int32_t op_code, rt_uint8_t *buf, rt_uint32_t blocks, rt_uint32_t blksize)
rt_int32_t sdio_io_send_op_cond(struct rt_mmcsd_host *host, rt_uint32_t ocr, rt_uint32_t *cmd5_resp)
rt_int32_t sdio_io_rw_extended_block(struct rt_sdio_function *func, rt_int32_t rw, rt_uint32_t addr, rt_int32_t op_code, rt_uint8_t *buf, rt_uint32_t len)
rt_int32_t sdio_io_writel(struct rt_sdio_function *func, rt_uint32_t data, rt_uint32_t addr)
rt_int32_t sdio_unregister_driver(struct rt_sdio_driver *driver)
rt_uint32_t sdio_io_readl(struct rt_sdio_function *func, rt_uint32_t addr, rt_int32_t *err)
rt_int32_t sdio_io_read_multi_fifo_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len)
rt_int32_t sdio_io_rw_direct(struct rt_mmcsd_card *card, rt_int32_t rw, rt_uint32_t fn, rt_uint32_t reg_addr, rt_uint8_t *pdata, rt_uint8_t raw)
rt_int32_t sdio_register_driver(struct rt_sdio_driver *driver)
rt_uint16_t sdio_io_readw(struct rt_sdio_function *func, rt_uint32_t addr, rt_int32_t *err)
rt_int32_t sdio_set_block_size(struct rt_sdio_function *func, rt_uint32_t blksize)
rt_int32_t sdio_io_write_multi_fifo_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len)
void rt_sdio_init(void)
rt_int32_t sdio_attach_irq(struct rt_sdio_function *func, rt_sdio_irq_handler_t *handler)
rt_int32_t sdio_io_read_multi_incr_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len)
rt_int32_t sdio_io_writeb(struct rt_sdio_function *func, rt_uint32_t reg, rt_uint8_t data)
rt_int32_t init_sdio(struct rt_mmcsd_host *host, rt_uint32_t ocr)
rt_int32_t sdio_enable_func(struct rt_sdio_function *func)
void * sdio_get_drvdata(struct rt_sdio_function *func)
void sdio_irq_wakeup(struct rt_mmcsd_host *host)
void rt_sdio_irq_handler_t(struct rt_sdio_function *)
unsigned char rt_uint8_t
unsigned short rt_uint16_t
unsigned int rt_uint32_t
signed int rt_int32_t
rt_uint16_t manufacturer
rt_int32_t(* remove)(struct rt_mmcsd_card *card)
struct rt_sdio_device_id * id
rt_int32_t(* probe)(struct rt_mmcsd_card *card)