Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
7b0a5f84
Unverified
Commit
7b0a5f84
authored
6 years ago
by
Dimitris Papastamos
Committed by
GitHub
6 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #1596 from Yann-lms/mmc_defines
mmc: Update framework to use standard response type
parents
1e8d3af9
97d5db8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
drivers/mmc/mmc.c
+18
-18
drivers/mmc/mmc.c
drivers/synopsys/emmc/dw_mmc.c
+0
-3
drivers/synopsys/emmc/dw_mmc.c
include/drivers/mmc.h
+4
-4
include/drivers/mmc.h
with
22 additions
and
25 deletions
+22
-25
drivers/mmc/mmc.c
View file @
7b0a5f84
...
...
@@ -87,7 +87,7 @@ static int mmc_device_state(void)
}
ret
=
mmc_send_cmd
(
MMC_CMD
(
13
),
rca
<<
RCA_SHIFT_OFFSET
,
MMC_RESPONSE_R
(
1
)
,
&
resp_data
[
0
]);
MMC_RESPONSE_R
1
,
&
resp_data
[
0
]);
if
(
ret
!=
0
)
{
return
ret
;
}
...
...
@@ -138,14 +138,14 @@ static int mmc_sd_switch(unsigned int bus_width)
/* CMD55: Application Specific Command */
ret
=
mmc_send_cmd
(
MMC_CMD
(
55
),
rca
<<
RCA_SHIFT_OFFSET
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
MMC_RESPONSE_R
5
,
NULL
);
if
(
ret
!=
0
)
{
return
ret
;
}
/* ACMD51: SEND_SCR */
do
{
ret
=
mmc_send_cmd
(
MMC_ACMD
(
51
),
0
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
ret
=
mmc_send_cmd
(
MMC_ACMD
(
51
),
0
,
MMC_RESPONSE_R
1
,
NULL
);
if
((
ret
!=
0
)
&&
(
retries
==
0
))
{
ERROR
(
"ACMD51 failed after %d retries (ret=%d)
\n
"
,
MMC_DEFAULT_MAX_RETRIES
,
ret
);
...
...
@@ -167,13 +167,13 @@ static int mmc_sd_switch(unsigned int bus_width)
/* CMD55: Application Specific Command */
ret
=
mmc_send_cmd
(
MMC_CMD
(
55
),
rca
<<
RCA_SHIFT_OFFSET
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
MMC_RESPONSE_R
5
,
NULL
);
if
(
ret
!=
0
)
{
return
ret
;
}
/* ACMD6: SET_BUS_WIDTH */
ret
=
mmc_send_cmd
(
MMC_ACMD
(
6
),
bus_width_arg
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
ret
=
mmc_send_cmd
(
MMC_ACMD
(
6
),
bus_width_arg
,
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
ret
;
}
...
...
@@ -235,7 +235,7 @@ static int mmc_fill_device_info(void)
}
/* MMC CMD8: SEND_EXT_CSD */
ret
=
mmc_send_cmd
(
MMC_CMD
(
8
),
0
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
ret
=
mmc_send_cmd
(
MMC_CMD
(
8
),
0
,
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
ret
;
}
...
...
@@ -327,7 +327,7 @@ static int sd_send_op_cond(void)
int
ret
;
/* CMD55: Application Specific Command */
ret
=
mmc_send_cmd
(
MMC_CMD
(
55
),
0
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
ret
=
mmc_send_cmd
(
MMC_CMD
(
55
),
0
,
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
ret
;
}
...
...
@@ -416,7 +416,7 @@ static int mmc_enumerate(unsigned int clk, unsigned int bus_width)
}
else
{
/* CMD8: Send Interface Condition Command */
ret
=
mmc_send_cmd
(
MMC_CMD
(
8
),
VHS_2_7_3_6_V
|
CMD8_CHECK_PATTERN
,
MMC_RESPONSE_R
(
7
)
,
&
resp_data
[
0
]);
MMC_RESPONSE_R
5
,
&
resp_data
[
0
]);
if
((
ret
==
0
)
&&
((
resp_data
[
0
]
&
0xffU
)
==
CMD8_CHECK_PATTERN
))
{
ret
=
sd_send_op_cond
();
...
...
@@ -436,13 +436,13 @@ static int mmc_enumerate(unsigned int clk, unsigned int bus_width)
if
(
mmc_dev_info
->
mmc_dev_type
==
MMC_IS_EMMC
)
{
rca
=
MMC_FIX_RCA
;
ret
=
mmc_send_cmd
(
MMC_CMD
(
3
),
rca
<<
RCA_SHIFT_OFFSET
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
ret
;
}
}
else
{
ret
=
mmc_send_cmd
(
MMC_CMD
(
3
),
0
,
MMC_RESPONSE_R
(
6
)
,
&
resp_data
[
0
]);
MMC_RESPONSE_R
6
,
&
resp_data
[
0
]);
if
(
ret
!=
0
)
{
return
ret
;
}
...
...
@@ -461,7 +461,7 @@ static int mmc_enumerate(unsigned int clk, unsigned int bus_width)
/* CMD7: Select Card */
ret
=
mmc_send_cmd
(
MMC_CMD
(
7
),
rca
<<
RCA_SHIFT_OFFSET
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
ret
;
}
...
...
@@ -499,7 +499,7 @@ size_t mmc_read_blocks(int lba, uintptr_t buf, size_t size)
if
(
is_cmd23_enabled
())
{
/* Set block count */
ret
=
mmc_send_cmd
(
MMC_CMD
(
23
),
size
/
MMC_BLOCK_SIZE
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
0
;
}
...
...
@@ -520,7 +520,7 @@ size_t mmc_read_blocks(int lba, uintptr_t buf, size_t size)
cmd_arg
=
lba
;
}
ret
=
mmc_send_cmd
(
cmd_idx
,
cmd_arg
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
ret
=
mmc_send_cmd
(
cmd_idx
,
cmd_arg
,
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
0
;
}
...
...
@@ -567,7 +567,7 @@ size_t mmc_write_blocks(int lba, const uintptr_t buf, size_t size)
if
(
is_cmd23_enabled
())
{
/* Set block count */
ret
=
mmc_send_cmd
(
MMC_CMD
(
23
),
size
/
MMC_BLOCK_SIZE
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
0
;
}
...
...
@@ -587,7 +587,7 @@ size_t mmc_write_blocks(int lba, const uintptr_t buf, size_t size)
cmd_arg
=
lba
;
}
ret
=
mmc_send_cmd
(
cmd_idx
,
cmd_arg
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
ret
=
mmc_send_cmd
(
cmd_idx
,
cmd_arg
,
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
0
;
}
...
...
@@ -622,18 +622,18 @@ size_t mmc_erase_blocks(int lba, size_t size)
assert
(
ops
!=
NULL
);
assert
((
size
!=
0U
)
&&
((
size
&
MMC_BLOCK_MASK
)
==
0U
));
ret
=
mmc_send_cmd
(
MMC_CMD
(
35
),
lba
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
ret
=
mmc_send_cmd
(
MMC_CMD
(
35
),
lba
,
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
0
;
}
ret
=
mmc_send_cmd
(
MMC_CMD
(
36
),
lba
+
(
size
/
MMC_BLOCK_SIZE
)
-
1U
,
MMC_RESPONSE_R
(
1
)
,
NULL
);
MMC_RESPONSE_R
1
,
NULL
);
if
(
ret
!=
0
)
{
return
0
;
}
ret
=
mmc_send_cmd
(
MMC_CMD
(
38
),
lba
,
MMC_RESPONSE_R
(
0x
1B
)
,
NULL
);
ret
=
mmc_send_cmd
(
MMC_CMD
(
38
),
lba
,
MMC_RESPONSE_R1B
,
NULL
);
if
(
ret
!=
0
)
{
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
drivers/synopsys/emmc/dw_mmc.c
View file @
7b0a5f84
...
...
@@ -263,10 +263,7 @@ static int dw_send_cmd(struct mmc_cmd *cmd)
op
|=
CMD_RESP_EXPECT
|
CMD_CHECK_RESP_CRC
|
CMD_RESP_LEN
;
break
;
case
MMC_RESPONSE_R1
:
case
MMC_RESPONSE_R1B
:
case
MMC_RESPONSE_R3
:
case
MMC_RESPONSE_R5
:
op
|=
CMD_RESP_EXPECT
;
break
;
default:
...
...
This diff is collapsed.
Click to expand it.
include/drivers/mmc.h
View file @
7b0a5f84
...
...
@@ -45,12 +45,12 @@
/* JEDEC 4.51 chapter 6.12 */
#define MMC_RESPONSE_R1 (MMC_RSP_48 | MMC_RSP_CMD_IDX | MMC_RSP_CRC)
#define MMC_RESPONSE_R1B (MMC_RESPONSE_R1 | MMC_RSP_BUSY)
#define MMC_RESPONSE_R2 (MMC_RSP_136 | MMC_RSP_CRC)
#define MMC_RESPONSE_R2 (
MMC_RSP_48 |
MMC_RSP_136 | MMC_RSP_CRC)
#define MMC_RESPONSE_R3 (MMC_RSP_48)
#define MMC_RESPONSE_R4 (MMC_RSP_48)
#define MMC_RESPONSE_R5 (MMC_RSP_48 | MMC_RSP_CRC)
#define MMC_RESPONSE_R
(_x) U(_x
)
#define MMC_RESPONSE_R5 (MMC_RSP_48 | MMC_RSP_CRC
| MMC_RSP_CMD_IDX
)
#define MMC_RESPONSE_R6 (MMC_RSP_48 | MMC_RSP_CRC | MMC_RSP_CMD_IDX)
#define MMC_RESPONSE_R
7 (MMC_RSP_48 | MMC_RSP_CRC | MMC_RSP_CMD_IDX
)
/* Value randomly chosen for eMMC RCA, it should be > 1 */
#define MMC_FIX_RCA 6
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help