Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
u010088926
rt-thread
提交
8c2448a4
R
rt-thread
项目概览
u010088926
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8c2448a4
编写于
9月 11, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
9月 11, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1774 from EvalZero/sdio_dev
[DeviceDriver][SDIO] Update sdio debug log.
上级
1d6fad9d
2c011891
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
101 addition
and
48 deletion
+101
-48
components/drivers/Kconfig
components/drivers/Kconfig
+4
-0
components/drivers/sdio/block_dev.c
components/drivers/sdio/block_dev.c
+19
-9
components/drivers/sdio/mmc.c
components/drivers/sdio/mmc.c
+18
-8
components/drivers/sdio/mmcsd_core.c
components/drivers/sdio/mmcsd_core.c
+16
-6
components/drivers/sdio/sd.c
components/drivers/sdio/sd.c
+18
-8
components/drivers/sdio/sdio.c
components/drivers/sdio/sdio.c
+26
-17
未找到文件。
components/drivers/Kconfig
浏览文件 @
8c2448a4
...
...
@@ -138,6 +138,10 @@ config RT_USING_SDIO
config RT_MMCSD_MAX_PARTITION
int "mmcsd max partition"
default 16
config RT_SDIO_DEBUG
bool "Enable SDIO debug log output"
default n
endif
config RT_USING_SPI
...
...
components/drivers/sdio/block_dev.c
浏览文件 @
8c2448a4
...
...
@@ -27,6 +27,16 @@
#include <drivers/mmcsd_core.h>
#define DBG_ENABLE
#define DBG_SECTION_NAME "[SDIO]"
#ifdef RT_SDIO_DEBUG
#define DBG_LEVEL DBG_LOG
#else
#define DBG_LEVEL DBG_INFO
#endif
/* RT_SDIO_DEBUG */
#define DBG_COLOR
#include <rtdbg.h>
static
rt_list_t
blk_devices
=
RT_LIST_OBJECT_INIT
(
blk_devices
);
#define BLK_MIN(a, b) ((a) < (b) ? (a) : (b))
...
...
@@ -182,7 +192,7 @@ static rt_err_t rt_mmcsd_req_blk(struct rt_mmcsd_card *card,
err
=
mmcsd_send_cmd
(
card
->
host
,
&
cmd
,
5
);
if
(
err
)
{
rt_kprintf
(
"error %d requesting status
\n
"
,
err
);
LOG_E
(
"error %d requesting status
"
,
err
);
break
;
}
/*
...
...
@@ -198,8 +208,8 @@ static rt_err_t rt_mmcsd_req_blk(struct rt_mmcsd_card *card,
if
(
cmd
.
err
||
data
.
err
||
stop
.
err
)
{
rt_kprintf
(
"mmcsd request blocks error
\n
"
);
rt_kprintf
(
"%d,%d,%d, 0x%08x,0x%08x
\n
"
,
LOG_E
(
"mmcsd request blocks error
"
);
LOG_E
(
"%d,%d,%d, 0x%08x,0x%08x
"
,
cmd
.
err
,
data
.
err
,
stop
.
err
,
data
.
flags
,
sector
);
return
-
RT_ERROR
;
...
...
@@ -338,7 +348,7 @@ static rt_int32_t mmcsd_set_blksize(struct rt_mmcsd_card *card)
if
(
err
)
{
rt_kprintf
(
"MMCSD: unable to set block size to %d: %d
\n
"
,
cmd
.
arg
,
err
);
LOG_E
(
"MMCSD: unable to set block size to %d: %d
"
,
cmd
.
arg
,
err
);
return
-
RT_ERROR
;
}
...
...
@@ -373,13 +383,13 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
return
err
;
}
rt_kprintf
(
"probe mmcsd block device!
\n
"
);
LOG_I
(
"probe mmcsd block device!
"
);
/* get the first sector to read partition table */
sector
=
(
rt_uint8_t
*
)
rt_malloc
(
SECTOR_SIZE
);
if
(
sector
==
RT_NULL
)
{
rt_kprintf
(
"allocate partition sector buffer failed
\n
"
);
LOG_E
(
"allocate partition sector buffer failed!
"
);
return
-
RT_ENOMEM
;
}
...
...
@@ -392,7 +402,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
blk_dev
=
rt_calloc
(
1
,
sizeof
(
struct
mmcsd_blk_device
));
if
(
!
blk_dev
)
{
rt_kprintf
(
"mmcsd:malloc memory failed!
\n
"
);
LOG_E
(
"mmcsd:malloc memory failed!
"
);
break
;
}
...
...
@@ -480,7 +490,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
#ifdef RT_USING_DFS_MNTTABLE
if
(
0
)
// if (blk_dev)
{
rt_kprintf
(
"try to mount file system!
\n
"
);
LOG_I
(
"try to mount file system!
"
);
/* try to mount file system on this block device */
dfs_mount_device
(
&
(
blk_dev
->
dev
));
}
...
...
@@ -489,7 +499,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
}
else
{
rt_kprintf
(
"read mmcsd first sector failed
\n
"
);
LOG_E
(
"read mmcsd first sector failed
"
);
err
=
-
RT_ERROR
;
}
...
...
components/drivers/sdio/mmc.c
浏览文件 @
8c2448a4
...
...
@@ -25,6 +25,16 @@
#include <drivers/mmcsd_core.h>
#include <drivers/mmc.h>
#define DBG_ENABLE
#define DBG_SECTION_NAME "[SDIO]"
#ifdef RT_SDIO_DEBUG
#define DBG_LEVEL DBG_LOG
#else
#define DBG_LEVEL DBG_INFO
#endif
/* RT_SDIO_DEBUG */
#define DBG_COLOR
#include <rtdbg.h>
static
const
rt_uint32_t
tran_unit
[]
=
{
10000
,
100000
,
1000000
,
10000000
,
...
...
@@ -81,7 +91,7 @@ static rt_int32_t mmcsd_parse_csd(struct rt_mmcsd_card *card)
*/
csd
->
csd_structure
=
GET_BITS
(
resp
,
126
,
2
);
if
(
csd
->
csd_structure
==
0
)
{
rt_kprintf
(
"unrecognised CSD structure version %d
\n
"
,
csd
->
csd_structure
);
LOG_E
(
"unrecognised CSD structure version %d!
"
,
csd
->
csd_structure
);
return
-
RT_ERROR
;
}
...
...
@@ -137,7 +147,7 @@ static int mmc_get_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t **new_ext_csd)
*/
ext_csd
=
rt_malloc
(
512
);
if
(
!
ext_csd
)
{
rt_kprintf
(
"alloc memory failed when get ext csd
\n
"
);
LOG_E
(
"alloc memory failed when get ext csd!
"
);
return
-
RT_ENOMEM
;
}
...
...
@@ -194,7 +204,7 @@ static int mmc_parse_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd)
card
->
card_capacity
=
*
((
rt_uint32_t
*
)
&
ext_csd
[
EXT_CSD_SEC_CNT
]);
card
->
card_capacity
*=
card
->
card_blksize
;
card
->
card_capacity
>>=
10
;
/* unit:KB */
rt_kprintf
(
"emmc card capacity %d KB
\n
"
,
card
->
card_capacity
);
LOG_I
(
"emmc card capacity %d KB.
"
,
card
->
card_capacity
);
return
0
;
}
...
...
@@ -333,13 +343,13 @@ static int mmc_select_bus_width(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd)
}
else
{
switch
(
ext_csd_bits
[
idx
]){
case
0
:
rt_kprintf
(
"switch to bus width 1 bit failed
\n
"
);
LOG_E
(
"switch to bus width 1 bit failed!
"
);
break
;
case
1
:
rt_kprintf
(
"switch to bus width 4 bit failed
\n
"
);
LOG_E
(
"switch to bus width 4 bit failed!
"
);
break
;
case
2
:
rt_kprintf
(
"switch to bus width 8 bit failed
\n
"
);
LOG_E
(
"switch to bus width 8 bit failed!
"
);
break
;
default:
break
;
...
...
@@ -443,7 +453,7 @@ static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host,
card
=
rt_malloc
(
sizeof
(
struct
rt_mmcsd_card
));
if
(
!
card
)
{
rt_kprintf
(
"malloc card failed
\n
"
);
LOG_E
(
"malloc card failed!
"
);
err
=
-
RT_ENOMEM
;
goto
err
;
}
...
...
@@ -580,7 +590,7 @@ remove_card:
host
->
card
=
RT_NULL
;
err:
rt_kprintf
(
"init MMC card failed
\n
"
);
LOG_E
(
"init MMC card failed!
"
);
return
err
;
}
components/drivers/sdio/mmcsd_core.c
浏览文件 @
8c2448a4
...
...
@@ -28,6 +28,16 @@
#include <drivers/mmc.h>
#include <drivers/sdio.h>
#define DBG_ENABLE
#define DBG_SECTION_NAME "[SDIO]"
#ifdef RT_SDIO_DEBUG
#define DBG_LEVEL DBG_LOG
#else
#define DBG_LEVEL DBG_INFO
#endif
/* RT_SDIO_DEBUG */
#define DBG_COLOR
#include <rtdbg.h>
#ifndef RT_MMCSD_STACK_SIZE
#define RT_MMCSD_STACK_SIZE 1024
#endif
...
...
@@ -206,7 +216,7 @@ rt_int32_t mmcsd_get_cid(struct rt_mmcsd_host *host, rt_uint32_t *cid)
buf
=
(
rt_uint32_t
*
)
rt_malloc
(
16
);
if
(
!
buf
)
{
rt_kprintf
(
"allocate memory failed
\n
"
);
LOG_E
(
"allocate memory failed!
"
);
return
-
RT_ENOMEM
;
}
...
...
@@ -282,7 +292,7 @@ rt_int32_t mmcsd_get_csd(struct rt_mmcsd_card *card, rt_uint32_t *csd)
buf
=
(
rt_uint32_t
*
)
rt_malloc
(
16
);
if
(
!
buf
)
{
rt_kprintf
(
"allocate memory failed
\n
"
);
LOG_E
(
"allocate memory failed!
"
);
return
-
RT_ENOMEM
;
}
...
...
@@ -418,7 +428,7 @@ void mmcsd_set_clock(struct rt_mmcsd_host *host, rt_uint32_t clk)
{
if
(
clk
<
host
->
freq_min
)
{
rt_kprintf
(
"clock too low
\n
"
);
LOG_W
(
"clock too low!
"
);
}
host
->
io_cfg
.
clock
=
clk
;
...
...
@@ -539,7 +549,7 @@ rt_uint32_t mmcsd_select_voltage(struct rt_mmcsd_host *host, rt_uint32_t ocr)
}
else
{
rt_kprintf
(
"host doesn't support card's voltages
\n
"
);
LOG_W
(
"host doesn't support card's voltages!
"
);
ocr
=
0
;
}
...
...
@@ -679,7 +689,7 @@ void mmcsd_detect(void *param)
mmcsd_host_lock
(
host
);
if
(
host
->
card
->
sdio_function_num
!=
0
)
{
rt_kprintf
(
"unsupport sdio card plug out!
\n
"
);
LOG_W
(
"unsupport sdio card plug out!
"
);
}
else
{
...
...
@@ -702,7 +712,7 @@ struct rt_mmcsd_host *mmcsd_alloc_host(void)
host
=
rt_malloc
(
sizeof
(
struct
rt_mmcsd_host
));
if
(
!
host
)
{
rt_kprintf
(
"alloc host failed
\n
"
);
LOG_E
(
"alloc host failed
"
);
return
RT_NULL
;
}
...
...
components/drivers/sdio/sd.c
浏览文件 @
8c2448a4
...
...
@@ -25,6 +25,16 @@
#include <drivers/mmcsd_core.h>
#include <drivers/sd.h>
#define DBG_ENABLE
#define DBG_SECTION_NAME "[SDIO]"
#ifdef RT_SDIO_DEBUG
#define DBG_LEVEL DBG_LOG
#else
#define DBG_LEVEL DBG_INFO
#endif
/* RT_SDIO_DEBUG */
#define DBG_COLOR
#include <rtdbg.h>
static
const
rt_uint32_t
tran_unit
[]
=
{
10000
,
100000
,
1000000
,
10000000
,
...
...
@@ -167,11 +177,11 @@ static rt_int32_t mmcsd_parse_csd(struct rt_mmcsd_card *card)
#endif
break
;
default:
rt_kprintf
(
"unrecognised CSD structure version %d
\n
"
,
csd
->
csd_structure
);
LOG_E
(
"unrecognised CSD structure version %d!
"
,
csd
->
csd_structure
);
return
-
RT_ERROR
;
}
rt_kprintf
(
"SD card capacity %d KB
\n
"
,
card
->
card_capacity
);
LOG_I
(
"SD card capacity %d KB.
"
,
card
->
card_capacity
);
return
0
;
}
...
...
@@ -201,7 +211,7 @@ static rt_int32_t mmcsd_switch(struct rt_mmcsd_card *card)
buf
=
(
rt_uint8_t
*
)
rt_malloc
(
64
);
if
(
!
buf
)
{
rt_kprintf
(
"alloc memory failed
\n
"
);
LOG_E
(
"alloc memory failed!
"
);
return
-
RT_ENOMEM
;
}
...
...
@@ -270,7 +280,7 @@ static rt_int32_t mmcsd_switch(struct rt_mmcsd_card *card)
if
((
buf
[
16
]
&
0xF
)
!=
1
)
{
rt_kprintf
(
"switching card to high speed failed
\n
"
);
LOG_E
(
"switching card to high speed failed!
"
);
goto
err
;
}
...
...
@@ -588,7 +598,7 @@ static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host,
card
=
rt_malloc
(
sizeof
(
struct
rt_mmcsd_card
));
if
(
!
card
)
{
rt_kprintf
(
"malloc card failed
\n
"
);
LOG_E
(
"malloc card failed!
"
);
err
=
-
RT_ENOMEM
;
goto
err
;
}
...
...
@@ -703,9 +713,9 @@ rt_int32_t init_sd(struct rt_mmcsd_host *host, rt_uint32_t ocr)
if
(
ocr
&
VDD_165_195
)
{
rt_kprintf
(
" SD card claims to support the "
LOG_I
(
" SD card claims to support the "
"incompletely defined 'low voltage range'. This "
"will be ignored.
\n
"
);
"will be ignored."
);
ocr
&=
~
VDD_165_195
;
}
...
...
@@ -743,7 +753,7 @@ remove_card:
host
->
card
=
RT_NULL
;
err:
rt_kprintf
(
"init SD card failed
\n
"
);
LOG_D
(
"init SD card failed!
"
);
return
err
;
}
components/drivers/sdio/sdio.c
浏览文件 @
8c2448a4
...
...
@@ -26,6 +26,16 @@
#include <drivers/sdio.h>
#include <drivers/sd.h>
#define DBG_ENABLE
#define DBG_SECTION_NAME "[SDIO]"
#ifdef RT_SDIO_DEBUG
#define DBG_LEVEL DBG_LOG
#else
#define DBG_LEVEL DBG_INFO
#endif
/* RT_SDIO_DEBUG */
#define DBG_COLOR
#include <rtdbg.h>
#ifndef RT_SDIO_STACK_SIZE
#define RT_SDIO_STACK_SIZE 512
#endif
...
...
@@ -432,7 +442,7 @@ static rt_int32_t sdio_read_cccr(struct rt_mmcsd_card *card)
if
(
cccr_version
>
SDIO_CCCR_REV_3_00
)
{
rt_kprintf
(
"unrecognised CCCR structure version %d
\n
"
,
cccr_version
);
LOG_E
(
"unrecognised CCCR structure version %d
"
,
cccr_version
);
return
-
RT_ERROR
;
}
...
...
@@ -579,7 +589,7 @@ static rt_int32_t sdio_read_cis(struct rt_sdio_function *func)
case
CISTPL_MANFID
:
if
(
tpl_link
<
4
)
{
rt_kprintf
(
"bad CISTPL_MANFID length
\n
"
);
LOG_D
(
"bad CISTPL_MANFID length
"
);
break
;
}
if
(
func
->
num
!=
0
)
...
...
@@ -605,15 +615,15 @@ static rt_int32_t sdio_read_cis(struct rt_sdio_function *func)
if
(
ret
)
{
rt_kprintf
(
"bad CISTPL_FUNCE size %u "
"type %u
\n
"
,
tpl_link
,
curr
->
data
[
0
]);
LOG_D
(
"bad CISTPL_FUNCE size %u "
"type %u"
,
tpl_link
,
curr
->
data
[
0
]);
}
break
;
case
CISTPL_VERS_1
:
if
(
tpl_link
<
2
)
{
rt_kprintf
(
"CISTPL_VERS_1 too short
\n
"
);
LOG_D
(
"CISTPL_VERS_1 too short
"
);
}
break
;
default:
...
...
@@ -623,7 +633,7 @@ static rt_int32_t sdio_read_cis(struct rt_sdio_function *func)
curr
->
size
=
tpl_link
;
*
prev
=
curr
;
prev
=
&
curr
->
next
;
rt_kprintf
(
"function %d, CIS tuple code %#x, length %d
\n
"
,
LOG_D
(
"function %d, CIS tuple code %#x, length %d
"
,
func
->
num
,
tpl_code
,
tpl_link
);
break
;
}
...
...
@@ -686,7 +696,6 @@ err:
return
ret
;
}
static
rt_int32_t
sdio_initialize_function
(
struct
rt_mmcsd_card
*
card
,
rt_uint32_t
func_num
)
{
...
...
@@ -698,7 +707,7 @@ static rt_int32_t sdio_initialize_function(struct rt_mmcsd_card *card,
func
=
rt_malloc
(
sizeof
(
struct
rt_sdio_function
));
if
(
!
func
)
{
rt_kprintf
(
"malloc rt_sdio_function failed
\n
"
);
LOG_E
(
"malloc rt_sdio_function failed
"
);
ret
=
-
RT_ENOMEM
;
goto
err
;
}
...
...
@@ -788,7 +797,7 @@ static rt_int32_t sdio_register_card(struct rt_mmcsd_card *card)
sc
=
rt_malloc
(
sizeof
(
struct
sdio_card
));
if
(
sc
==
RT_NULL
)
{
rt_kprintf
(
"malloc sdio card failed
\n
"
);
LOG_E
(
"malloc sdio card failed
"
);
return
-
RT_ENOMEM
;
}
...
...
@@ -836,7 +845,7 @@ static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr)
card
=
rt_malloc
(
sizeof
(
struct
rt_mmcsd_card
));
if
(
!
card
)
{
rt_kprintf
(
"malloc card failed
\n
"
);
LOG_E
(
"malloc card failed
"
);
err
=
-
RT_ENOMEM
;
goto
err
;
}
...
...
@@ -850,7 +859,7 @@ static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr)
card
->
sdio_function
[
0
]
=
rt_malloc
(
sizeof
(
struct
rt_sdio_function
));
if
(
!
card
->
sdio_function
[
0
])
{
rt_kprintf
(
"malloc sdio_func0 failed
\n
"
);
LOG_E
(
"malloc sdio_func0 failed
"
);
err
=
-
RT_ENOMEM
;
goto
err1
;
}
...
...
@@ -944,7 +953,7 @@ err1:
rt_free
(
host
->
card
);
}
err:
rt_kprintf
(
"error %d while initialising SDIO card
\n
"
,
err
);
LOG_E
(
"error %d while initialising SDIO card
"
,
err
);
return
err
;
}
...
...
@@ -958,13 +967,13 @@ rt_int32_t init_sdio(struct rt_mmcsd_host *host, rt_uint32_t ocr)
if
(
ocr
&
0x7F
)
{
rt_kprintf
(
"Card ocr below the defined voltage rang.
\n
"
);
LOG_W
(
"Card ocr below the defined voltage rang.
"
);
ocr
&=
~
0x7F
;
}
if
(
ocr
&
VDD_165_195
)
{
rt_kprintf
(
"Can't support the low voltage SDIO card.
\n
"
);
LOG_W
(
"Can't support the low voltage SDIO card.
"
);
ocr
&=
~
VDD_165_195
;
}
...
...
@@ -987,7 +996,7 @@ remove_card:
host
->
card
=
RT_NULL
;
err:
rt_kprintf
(
"init SDIO card failed
\n
"
);
LOG_E
(
"init SDIO card failed
"
);
return
err
;
}
...
...
@@ -1341,7 +1350,7 @@ rt_int32_t sdio_register_driver(struct rt_sdio_driver *driver)
sd
=
rt_malloc
(
sizeof
(
struct
sdio_driver
));
if
(
sd
==
RT_NULL
)
{
rt_kprintf
(
"malloc sdio driver failed
\n
"
);
LOG_E
(
"malloc sdio driver failed
"
);
return
-
RT_ENOMEM
;
}
...
...
@@ -1378,7 +1387,7 @@ rt_int32_t sdio_unregister_driver(struct rt_sdio_driver *driver)
if
(
sd
==
RT_NULL
)
{
rt_kprintf
(
"SDIO driver %s not register
\n
"
,
driver
->
name
);
LOG_E
(
"SDIO driver %s not register
"
,
driver
->
name
);
return
-
RT_ERROR
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录