mmc: Support-FFU-for-eMMC-v5.0
Some of Samsung eMMC does not show the argument for ffu in ext_csd. In case of this, eMMC shows 0x0 from ext_csd, Host has to modify the argument.
Add "#define CID_MANFID_SAMSUNG 0x15"
Quoted 23 lines
(quoted diff) +23
-0+int mmc_ffu_download(struct mmc_card *card, struct mmc_command *cmd, + u8 *data, int buf_bytes) +{ + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + int ret; + + /* Read the EXT_CSD */ + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit; + } + + /* Check if FFU is supported by card */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + } +
Review
Quoted 10 lines
(quoted diff) +10
-0+ err = mmc_host_set_ffu(card, ext_csd[EXT_CSD_FW_CONFIG]); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + err = -EINVAL; + goto exit; + } + + /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_MODE_CONFIG,
Review
Quoted 13 lines
(quoted diff) +13
-0+ MMC_FFU_MODE_SET, card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit_normal; + } + + /* set CMD ARG */ + cmd->arg = ext_csd[EXT_CSD_FFU_ARG] | + ext_csd[EXT_CSD_FFU_ARG + 1] << 8 | + ext_csd[EXT_CSD_FFU_ARG + 2] << 16 | + ext_csd[EXT_CSD_FFU_ARG + 3] << 24; +
Add followings
"
/* If arg is zero, should be set to a special value for samsung eMMC
*/
if ( card->cid.manfid == CID_MANFID_SAMSUNG && cmd->arg == 0x0 ) {
cmd->arg = 0xc7810000;
}"
Quoted 5 lines
(quoted diff) +5
-0+ err = mmc_ffu_write(card, data, cmd->arg, buf_bytes); + +exit_normal: + /* host switch back to work in normal MMC Read/Write commands */ + ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
Review
Quoted 10 lines
(quoted diff) +10
-0+ EXT_CSD_MODE_CONFIG, MMC_FFU_MODE_NORMAL, + card->ext_csd.generic_cmd6_time); + if (ret) + err = ret; + +exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_download); +
eMMC 5.0 Spec. says if device does not support MODE_OPERATION_CODES, device doesn't need to use NUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED. So, it's better to move the code for checking this value to FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]
Quoted 11 lines
(quoted diff) +11
-0+int mmc_ffu_install(struct mmc_card *card) { + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + u32 ffu_data_len; + u32 timeout; + + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit;
Review
Quoted 10 lines
(quoted diff) +10
-0+ } + + /* Check if FFU is supported */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE]) || + FFU_CONFIG(ext_csd[EXT_CSD_FW_CONFIG])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + }
Remove followings
"
ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]|
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 |
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 |
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] << 24;
if (!ffu_data_len) {
err = -EPERM;
return err;
}"
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* check mode operation */ + if (!FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES])) { + /* restart the eMMC */ + err = mmc_ffu_restart(card); + if (err) { + pr_err("FFU: %s: error %d FFU install:\n", + mmc_hostname(card->host), err); + } + } else {
Add followings
"
ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]|
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8
|
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] <<
16 |
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] <<24;
if (!ffu_data_len) {
err = -EPERM;
return err;
}"
Review
Quoted 6 lines
(quoted diff) +6
-0+ /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_CONFIG, 0x1, + card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is not
supported\n",
Review
Quoted 3 lines
(quoted diff) +3
-0+ mmc_hostname(card->host), err); + goto exit; + }
Checking ffu status in ext_csd should be done even if device does not support MODE_OPERATION_CODES So, it's better to move the code for checking this value to out of brace for FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]
Review
Quoted 7 lines
(quoted diff) +7
-0+ /* set ext_csd to install mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_OPERATION_CODES, + MMC_FFU_INSTALL_SET, timeout); + + if (err) { + pr_err("FFU: %s: error %d setting install
mode\n",
Review
Quoted 4 lines
(quoted diff) +4
-0+ mmc_hostname(card->host), err); + goto exit; + } +
Remove followings
"
/* read ext_csd */
err = mmc_send_ext_csd(card, ext_csd);
if (err) {
pr_err("FFU: %s: error %d sending ext_csd\n",
mmc_hostname(card->host), err);
goto exit;
}
/* return status */
err = ext_csd[EXT_CSD_FFU_STATUS];
if (err) {
pr_err("FFU: %s: error %d FFU install:\n",
mmc_hostname(card->host), err);
err = -EINVAL;
goto exit;
}"
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +
Add followings
"
/* read ext_csd */
err = mmc_send_ext_csd(card, ext_csd);
if (err) {
pr_err("FFU: %s: error %d sending ext_csd\n",
mmc_hostname(card->host), err);
goto exit;
}
/* return status */
err = ext_csd[EXT_CSD_FFU_STATUS];
if (err) {
pr_err("FFU: %s: error %d FFU install:\n",
mmc_hostname(card->host), err);
err = -EINVAL;
goto exit;
}"
Review
Quoted 5 lines
(quoted diff) +5
-0+exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_install); +
And some device's fw should be transferred with one command. They does not support multiple commands for fw transfer. For these devices, MMC_IOC_MAX_BYTES should be greater.
include/uapi/linux/mmc/ioctl.h +1 -1
@@ -53,5 +53,5 @@ struct mmc_ioc_cmd {* is enforced per ioctl call. For larger data transfers, use the normal * block device operations. */ -#define MMC_IOC_MAX_BYTES (512L * 256) +#define MMC_IOC_MAX_BYTES (512L * 1024)#endif /* LINUX_MMC_IOCTL_H */
Hi, Seunguk.
Quoted 5 lines · Seunguk Shin
Some of Samsung eMMC does not show the argument for ffu in
ext_csd. In case of this, eMMC shows0x0fromext_csd, Host has to modify the argument.Add "#define
CID_MANFID_SAMSUNG0x15"
If you need to add the Samsung eMMC specific code,
it would be better you would send the Samsung eMMC specific patch. (based-on this patch.) This patch isn't patch for samsung eMMC.
I didn't see this patch fully, but i think this patch is general code.
Best Regards,
Jaehoon Chung
Quoted 244 lines
Quoted 24 lines
(quoted diff) +23
-0+int mmc_ffu_download(struct mmc_card *card, struct mmc_command *cmd, + u8 *data, int buf_bytes) +{ + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + int ret; + + /* Read the EXT_CSD */ + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit; + } + + /* Check if FFU is supported by card */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + } +Review
Quoted 10 lines
(quoted diff) +10
-0+ err = mmc_host_set_ffu(card, ext_csd[EXT_CSD_FW_CONFIG]); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + err = -EINVAL; + goto exit; + } + + /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_MODE_CONFIG,Review
Quoted 13 lines
(quoted diff) +13
-0+ MMC_FFU_MODE_SET, card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit_normal; + } + + /* set CMD ARG */ + cmd->arg = ext_csd[EXT_CSD_FFU_ARG] | + ext_csd[EXT_CSD_FFU_ARG + 1] << 8 | + ext_csd[EXT_CSD_FFU_ARG + 2] << 16 | + ext_csd[EXT_CSD_FFU_ARG + 3] << 24; +Add followings
"/* If arg is zero, should be set to a special value for samsung eMMC */ if ( card->cid.manfid == CID_MANFID_SAMSUNG && cmd->arg == 0x0 ) { cmd->arg = 0xc7810000; }"
Quoted 5 lines
(quoted diff) +5
-0+ err = mmc_ffu_write(card, data, cmd->arg, buf_bytes); + +exit_normal: + /* host switch back to work in normal MMC Read/Write commands */ + ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,Review
Quoted 10 lines
(quoted diff) +10
-0+ EXT_CSD_MODE_CONFIG, MMC_FFU_MODE_NORMAL, + card->ext_csd.generic_cmd6_time); + if (ret) + err = ret; + +exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_download); +eMMC 5.0 Spec. says if device does not support
MODE_OPERATION_CODES, device doesn't need to useNUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED. So, it's better to move the code for checking this value to FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Quoted 11 lines
(quoted diff) +11
-0+int mmc_ffu_install(struct mmc_card *card) { + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + u32 ffu_data_len; + u32 timeout; + + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit;Review
Quoted 10 lines
(quoted diff) +10
-0+ } + + /* Check if FFU is supported */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE]) || + FFU_CONFIG(ext_csd[EXT_CSD_FW_CONFIG])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + }Remove followings
"ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]| ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] << 24; if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* check mode operation */ + if (!FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES])) { + /* restart the eMMC */ + err = mmc_ffu_restart(card); + if (err) { + pr_err("FFU: %s: error %d FFU install:\n", + mmc_hostname(card->host), err); + } + } else {Add followings
"ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]| ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] <<24;
if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 6 lines
(quoted diff) +6
-0+ /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_CONFIG, 0x1, + card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is notsupported\n",
Review
Quoted 3 lines
(quoted diff) +3
-0+ mmc_hostname(card->host), err); + goto exit; + }Checking ffu status in
ext_csdshould be done even if device does not supportMODE_OPERATION_CODESSo, it's better to move the code for checking this value to out of brace for FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Review
Quoted 7 lines
(quoted diff) +7
-0+ /* set ext_csd to install mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_OPERATION_CODES, + MMC_FFU_INSTALL_SET, timeout); + + if (err) { + pr_err("FFU: %s: error %d setting installmode\n",
Review
Quoted 4 lines
(quoted diff) +4
-0+ mmc_hostname(card->host), err); + goto exit; + } +Remove followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +Add followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 5 lines
(quoted diff) +5
-0+exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_install); +And some device's fw should be transferred with one command. They does not support multiple commands for fw transfer. For these devices,
MMC_IOC_MAX_BYTESshould be greater.include/uapi/linux/mmc/ioctl.h +1
-2@@ -53,5 +53,5 @@ struct mmc_ioc_cmd {* is enforced per ioctl call. For larger data transfers, use the normal * block device operations. */ -#define MMC_IOC_MAX_BYTES (512L * 256) +#define MMC_IOC_MAX_BYTES (512L * 1024)#endif /* LINUX_MMC_IOCTL_H */ --To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CANEJEGt=5EegY80F3EvsG70poUwVFRjeZT-hUJD8LdULAz=S_w@mail.gmail.com
argh...reposting my response as text only since linux-mmc doesn't like html mail. :(
Quoted 312 lines · Grant Grundler
Quoted 4 lines · Jaehoon Chung
Hi, Seunguk.
On 03/31/2014 07:51 PM, Seunguk Shin wrote:
Quoted 8 lines
Quoted 5 lines
Some of Samsung eMMC does not show the argument for ffu in
ext_csd. In case of this, eMMC shows0x0fromext_csd, Host has to modify the argument.Add "#define
CID_MANFID_SAMSUNG0x15"If you need to add the Samsung eMMC specific code,
it would be better you would send the Samsung eMMC specific patch. (based-on this patch.)I believe Seunguk Shin provided the information so someone else could add this code. I could be that person if no one from Samsung has have time for this. I'm very grateful to Seungguk for posting these details.
I hope we can see the same details for Samsung eMMC 4.5 also (but please use a different email Subject line so we aren't confused.)
Quoted 2 lines
This patch isn't patch for samsung eMMC.
I didn't see this patch fully, but i think this patch is general code.AFAICT, the
MANFID_SAMSUNGis only a "quirk" for Samsung devices which specify theEXT_CSD_FFU_ARGas 0.The original patch from SanDisk is general code and most of Seunguk's comments are general too. SanDisk (ie Avi) should please ACK they've seen those comments since I believe Seunguk is correct.
And Avi, please let us know if/when you plan on posting a V2. Or at least not be offended if I get impatient and hijack this patch series. :)
cheers,
grantQuoted 267 lines
Best Regards,
Jaehoon ChungQuoted 255 lines
Quoted 24 lines
(quoted diff) +23
-0+int mmc_ffu_download(struct mmc_card *card, struct mmc_command *cmd, + u8 *data, int buf_bytes) +{ + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + int ret; + + /* Read the EXT_CSD */ + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit; + } + + /* Check if FFU is supported by card */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + } +Review
Quoted 10 lines
(quoted diff) +10
-0+ err = mmc_host_set_ffu(card, ext_csd[EXT_CSD_FW_CONFIG]); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + err = -EINVAL; + goto exit; + } + + /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_MODE_CONFIG,Review
Quoted 13 lines
(quoted diff) +13
-0+ MMC_FFU_MODE_SET, card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit_normal; + } + + /* set CMD ARG */ + cmd->arg = ext_csd[EXT_CSD_FFU_ARG] | + ext_csd[EXT_CSD_FFU_ARG + 1] << 8 | + ext_csd[EXT_CSD_FFU_ARG + 2] << 16 | + ext_csd[EXT_CSD_FFU_ARG + 3] << 24; +Add followings
"/* If arg is zero, should be set to a special value for samsung eMMC */ if ( card->cid.manfid == CID_MANFID_SAMSUNG && cmd->arg == 0x0 ) { cmd->arg = 0xc7810000; }"
Quoted 6 lines
(quoted diff) +4
-0+ err = mmc_ffu_write(card, data, cmd->arg, buf_bytes); + +exit_normal: + /* host switch back to work in normal MMC Read/Write commands*/
(quoted diff) +1
-0+ ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,Review
Quoted 10 lines
(quoted diff) +10
-0+ EXT_CSD_MODE_CONFIG, MMC_FFU_MODE_NORMAL, + card->ext_csd.generic_cmd6_time); + if (ret) + err = ret; + +exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_download); +eMMC 5.0 Spec. says if device does not support
MODE_OPERATION_CODES, device
doesn't need to useNUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED. So, it's better to move the code for checking this value to FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Quoted 11 lines
(quoted diff) +11
-0+int mmc_ffu_install(struct mmc_card *card) { + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + u32 ffu_data_len; + u32 timeout; + + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit;Review
Quoted 10 lines
(quoted diff) +10
-0+ } + + /* Check if FFU is supported */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE]) || + FFU_CONFIG(ext_csd[EXT_CSD_FW_CONFIG])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + }Remove followings
"ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]| ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] << 24; if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* check mode operation */ + if (!FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES])) { + /* restart the eMMC */ + err = mmc_ffu_restart(card); + if (err) { + pr_err("FFU: %s: error %d FFU install:\n", + mmc_hostname(card->host), err); + } + } else {Add followings
"
ffu_data_len=
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]|ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3]<<
24;if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 6 lines
(quoted diff) +6
-0+ /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_CONFIG, 0x1, + card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is notsupported\n",
Review
Quoted 3 lines
(quoted diff) +3
-0+ mmc_hostname(card->host), err); + goto exit; + }Checking ffu status in
ext_csdshould be done even if device does not supportMODE_OPERATION_CODESSo, it's better to move the code for checking
this value to out of brace for FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Quoted 8 lines
(quoted diff) +7
-0+ /* set ext_csd to install mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_OPERATION_CODES, + MMC_FFU_INSTALL_SET, timeout); + + if (err) { + pr_err("FFU: %s: error %d settinginstall
mode\n",
Review
Quoted 4 lines
(quoted diff) +4
-0+ mmc_hostname(card->host), err); + goto exit; + } +Remove followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +Add followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 5 lines
(quoted diff) +5
-0+exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_install); +And some device's fw should be transferred with one command. They does not support multiple commands for fw transfer. For these devices,
MMC_IOC_MAX_BYTESshould be greater.include/uapi/linux/mmc/ioctl.h +0
-0@@ -53,5 +53,5 @@ struct mmc_ioc_cmd {* is enforced per ioctl call. For larger data transfers, use the normal
* block device operations.
*/include/uapi/linux/mmc/ioctl.h +1
-2-#define MMC_IOC_MAX_BYTES (512L * 256) +#define MMC_IOC_MAX_BYTES (512L * 1024)#endif /* LINUX_MMC_IOCTL_H */ --Quoted 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Dear, Grant.
Quoted 26 lines · Grant Grundler
argh...reposting my response as text only since linux-mmc doesn't like html mail. :(
Quoted 22 lines · Grant Grundler
Quoted 4 lines · Jaehoon Chung
Hi, Seunguk.
On 03/31/2014 07:51 PM, Seunguk Shin wrote:
Quoted 8 lines
Quoted 5 lines
Some of Samsung eMMC does not show the argument for ffu in
ext_csd. In case of this, eMMC shows0x0fromext_csd, Host has to modify the argument.Add "#define
CID_MANFID_SAMSUNG0x15"If you need to add the Samsung eMMC specific code,
it would be better you would send the Samsung eMMC specific patch. (based-on this patch.)I believe Seunguk Shin provided the information so someone else could add this code. I could be that person if no one from Samsung has have time for this. I'm very grateful to Seungguk for posting these details.
Right. his comment is helpful, when samsung eMMC is used. But I think it should be separated with this patch. :)
Quoted 8 lines
Quoted 8 lines
I hope we can see the same details for Samsung eMMC 4.5 also (but please use a different email Subject line so we aren't confused.)
Quoted 2 lines
This patch isn't patch for samsung eMMC.
I didn't see this patch fully, but i think this patch is general code.
Quoted 6 lines
Quoted 6 lines
AFAICT, the
MANFID_SAMSUNGis only a "quirk" for Samsung devices which specify theEXT_CSD_FFU_ARGas 0.The original patch from SanDisk is general code and most of Seunguk's comments are general too. SanDisk (ie Avi) should please ACK they've seen those comments since I believe Seunguk is correct.
Other comment is general, but I think he have also mentioned the samsung specific part.
Best Regards,
Jaehoon Chung
Quoted 281 lines
Quoted 276 lines
And Avi, please let us know if/when you plan on posting a V2. Or at least not be offended if I get impatient and hijack this patch series. :)
cheers,
grantQuoted 267 lines
Best Regards,
Jaehoon ChungQuoted 255 lines
Quoted 24 lines
(quoted diff) +23
-0+int mmc_ffu_download(struct mmc_card *card, struct mmc_command *cmd, + u8 *data, int buf_bytes) +{ + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + int ret; + + /* Read the EXT_CSD */ + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit; + } + + /* Check if FFU is supported by card */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + } +Review
Quoted 10 lines
(quoted diff) +10
-0+ err = mmc_host_set_ffu(card, ext_csd[EXT_CSD_FW_CONFIG]); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + err = -EINVAL; + goto exit; + } + + /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_MODE_CONFIG,Review
Quoted 13 lines
(quoted diff) +13
-0+ MMC_FFU_MODE_SET, card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit_normal; + } + + /* set CMD ARG */ + cmd->arg = ext_csd[EXT_CSD_FFU_ARG] | + ext_csd[EXT_CSD_FFU_ARG + 1] << 8 | + ext_csd[EXT_CSD_FFU_ARG + 2] << 16 | + ext_csd[EXT_CSD_FFU_ARG + 3] << 24; +Add followings
"/* If arg is zero, should be set to a special value for samsung eMMC */ if ( card->cid.manfid == CID_MANFID_SAMSUNG && cmd->arg == 0x0 ) { cmd->arg = 0xc7810000; }"
Quoted 6 lines
(quoted diff) +4
-0+ err = mmc_ffu_write(card, data, cmd->arg, buf_bytes); + +exit_normal: + /* host switch back to work in normal MMC Read/Write commands*/
(quoted diff) +1
-0+ ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,Review
Quoted 10 lines
(quoted diff) +10
-0+ EXT_CSD_MODE_CONFIG, MMC_FFU_MODE_NORMAL, + card->ext_csd.generic_cmd6_time); + if (ret) + err = ret; + +exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_download); +eMMC 5.0 Spec. says if device does not support
MODE_OPERATION_CODES, device
doesn't need to useNUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED. So, it's better to move the code for checking this value to FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Quoted 11 lines
(quoted diff) +11
-0+int mmc_ffu_install(struct mmc_card *card) { + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + u32 ffu_data_len; + u32 timeout; + + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit;Review
Quoted 10 lines
(quoted diff) +10
-0+ } + + /* Check if FFU is supported */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE]) || + FFU_CONFIG(ext_csd[EXT_CSD_FW_CONFIG])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + }Remove followings
"ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]| ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] << 24; if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* check mode operation */ + if (!FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES])) { + /* restart the eMMC */ + err = mmc_ffu_restart(card); + if (err) { + pr_err("FFU: %s: error %d FFU install:\n", + mmc_hostname(card->host), err); + } + } else {Add followings
"
ffu_data_len=
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]|ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3]<<
24;if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 6 lines
(quoted diff) +6
-0+ /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_CONFIG, 0x1, + card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is notsupported\n",
Review
Quoted 3 lines
(quoted diff) +3
-0+ mmc_hostname(card->host), err); + goto exit; + }Checking ffu status in
ext_csdshould be done even if device does not supportMODE_OPERATION_CODESSo, it's better to move the code for checking
this value to out of brace for FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Quoted 8 lines
(quoted diff) +7
-0+ /* set ext_csd to install mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_OPERATION_CODES, + MMC_FFU_INSTALL_SET, timeout); + + if (err) { + pr_err("FFU: %s: error %d settinginstall
mode\n",
Review
Quoted 4 lines
(quoted diff) +4
-0+ mmc_hostname(card->host), err); + goto exit; + } +Remove followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +Add followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 5 lines
(quoted diff) +5
-0+exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_install); +And some device's fw should be transferred with one command. They does not support multiple commands for fw transfer. For these devices,
MMC_IOC_MAX_BYTESshould be greater.include/uapi/linux/mmc/ioctl.h +0
-0@@ -53,5 +53,5 @@ struct mmc_ioc_cmd {* is enforced per ioctl call. For larger data transfers, use the normal
* block device operations.
*/include/uapi/linux/mmc/ioctl.h +1
-2-#define MMC_IOC_MAX_BYTES (512L * 256) +#define MMC_IOC_MAX_BYTES (512L * 1024)#endif /* LINUX_MMC_IOCTL_H */ --Quoted 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Dear. Jaehoon
I mentioned 3 items.
One is for only Samsung emmc (argument for ffu) The others are for general emmc
I'll make a separated patch for first item. But, the others should be applied to this patch.
Thank you.
Best Regards,
Seunguk Shin
Quoted 339 lines
Dear, Grant.
Quoted 4 lines · Grant Grundler
argh...reposting my response as text only since linux-mmc doesn't like html mail. :(
On Tue, Apr 1, 2014 at 1:26 PM, Grant Grundler <[email protected]>
Quoted 15 lines · wrote:
Quoted 15 lines
Quoted 9 lines · Jaehoon Chung
Hi, Seunguk.
Quoted 5 lines · Seunguk Shin
Some of Samsung eMMC does not show the argument for ffu in
ext_csd. In case of this, eMMC shows0x0fromext_csd, Host has to modify the argument.Add "#define
CID_MANFID_SAMSUNG0x15"Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
If you need to add the Samsung eMMC specific code, it would be better you would send the Samsung eMMC specific patch. (based-on this patch.)
I believe Seunguk Shin provided the information so someone else could add this code. I could be that person if no one from Samsung has have time for this. I'm very grateful to Seungguk for posting these details.
Right. his comment is helpful, when samsung eMMC is used. But I think it should be separated with this patch. :)
Quoted 8 lines
Quoted 8 lines
I hope we can see the same details for Samsung eMMC 4.5 also (but please use a different email Subject line so we aren't confused.)
Quoted 2 lines
This patch isn't patch for samsung eMMC.
I didn't see this patch fully, but i think this patch is general code.Quoted 6 lines
Quoted 6 lines
AFAICT, the
MANFID_SAMSUNGis only a "quirk" for Samsung devices which specify theEXT_CSD_FFU_ARGas 0.The original patch from SanDisk is general code and most of Seunguk's comments are general too. SanDisk (ie Avi) should please ACK they've seen those comments since I believe Seunguk is correct.
Other comment is general, but I think he have also mentioned the samsung specific part.
Best Regards,
Jaehoon ChungQuoted 275 lines
Quoted 275 lines
And Avi, please let us know if/when you plan on posting a V2. Or at least not be offended if I get impatient and hijack this patch series. :)
cheers,
grantQuoted 265 lines
Best Regards,
Jaehoon ChungQuoted 253 lines
Quoted 24 lines
(quoted diff) +23
-0+int mmc_ffu_download(struct mmc_card *card, struct mmc_command *cmd, + u8 *data, int buf_bytes) +{ + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + int ret; + + /* Read the EXT_CSD */ + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit; + } + + /* Check if FFU is supported by card */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + } +Review
Quoted 10 lines
(quoted diff) +10
-0+ err = mmc_host_set_ffu(card, ext_csd[EXT_CSD_FW_CONFIG]); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + err = -EINVAL; + goto exit; + } + + /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_MODE_CONFIG,Review
Quoted 13 lines
(quoted diff) +13
-0+ MMC_FFU_MODE_SET, card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit_normal; + } + + /* set CMD ARG */ + cmd->arg = ext_csd[EXT_CSD_FFU_ARG] | + ext_csd[EXT_CSD_FFU_ARG + 1] << 8 | + ext_csd[EXT_CSD_FFU_ARG + 2] << 16 | + ext_csd[EXT_CSD_FFU_ARG + 3] << 24; +Add followings
"/* If arg is zero, should be set to a special value for samsung eMMC */ if ( card->cid.manfid == CID_MANFID_SAMSUNG && cmd->arg == 0x0 ) { cmd->arg = 0xc7810000; }"
Quoted 7 lines
(quoted diff) +5
-0+ err = mmc_ffu_write(card, data, cmd->arg, buf_bytes); + +exit_normal: + /* host switch back to work in normal MMC Read/Write +commands*/
(quoted diff) +1
-0+ ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,Review
Quoted 10 lines
(quoted diff) +10
-0+ EXT_CSD_MODE_CONFIG, MMC_FFU_MODE_NORMAL, + card->ext_csd.generic_cmd6_time); + if (ret) + err = ret; + +exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_download); +eMMC 5.0 Spec. says if device does not support
MODE_OPERATION_CODES, device doesn't need to useNUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED.
So, it's better to move the code for checking this value to FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Quoted 11 lines
(quoted diff) +11
-0+int mmc_ffu_install(struct mmc_card *card) { + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + u32 ffu_data_len; + u32 timeout; + + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit;Review
Quoted 10 lines
(quoted diff) +10
-0+ } + + /* Check if FFU is supported */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE]) || + FFU_CONFIG(ext_csd[EXT_CSD_FW_CONFIG])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + }Remove followings
"ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]| ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] << 24; if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* check mode operation */ + if (!FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES])) { + /* restart the eMMC */ + err = mmc_ffu_restart(card); + if (err) { + pr_err("FFU: %s: error %d FFU install:\n", + mmc_hostname(card->host), err); + } + } else {Add followings
"
ffu_data_len=
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]|
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG
+ 1] << 8
|
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG
+ 2] <<
16 |
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG
+ 3] << 24;if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 7 lines
(quoted diff) +7
-0+ /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_CONFIG, 0x1, + card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is + notsupported\n",
Review
Quoted 3 lines
(quoted diff) +3
-0+ mmc_hostname(card->host), err); + goto exit; + }Checking ffu status in
ext_csdshould be done even if device does not supportMODE_OPERATION_CODESSo, it's better to move the code for checking this value to out of brace for FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Quoted 8 lines
(quoted diff) +7
-0+ /* set ext_csd to install mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_OPERATION_CODES, + MMC_FFU_INSTALL_SET, timeout); + + if (err) { + pr_err("FFU: %s: error %d settinginstall
mode\n",
Review
Quoted 4 lines
(quoted diff) +4
-0+ mmc_hostname(card->host), err); + goto exit; + } +Remove followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +Add followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 5 lines
(quoted diff) +5
-0+exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_install); +And some device's fw should be transferred with one command. They does not support multiple commands for fw transfer. For these devices,
MMC_IOC_MAX_BYTESshould be greater.(quoted diff) +0
-0
b/include/uapi/linux/mmc/ioctl.hindex 1f5e689..af9ea62 100644include/uapi/linux/mmc/ioctl.h +0
-0@@ -53,5 +53,5 @@ struct mmc_ioc_cmd {* is enforced per ioctl call. For larger data transfers, use the normal
* block device operations.
*/include/uapi/linux/mmc/ioctl.h +1
-2-#define MMC_IOC_MAX_BYTES (512L * 256) +#define MMC_IOC_MAX_BYTES (512L * 1024)#endif /* LINUX_MMC_IOCTL_H */ --Quoted 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.htmlQuoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Hi Grant,
We work on V2, and Avi will post it in few coming days.
Thanks,
Alex
Quoted 335 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Grant Grundler
Sent: Tuesday, April 01, 2014 11:30 PM
To: Grant Grundler
Cc: Jaehoon Chung; Seunguk Shin; [email protected]; Avi Shchislowski; Chris Ball; CPGS; Puthikorn Voravootivat; Gwendal Grignou
Subject: Re: [RFC PATCH 1/1 ]mmc: Support-FFU-for-eMMC-v5.0argh...reposting my response as text only since linux-mmc doesn't like html mail. :(
Quoted 24 lines · Grant Grundler
Quoted 4 lines · Jaehoon Chung
Hi, Seunguk.
On 03/31/2014 07:51 PM, Seunguk Shin wrote:
Quoted 8 lines
Quoted 5 lines
Some of Samsung eMMC does not show the argument for ffu in
ext_csd. In case of this, eMMC shows0x0fromext_csd, Host has to modify the argument.Add "#define
CID_MANFID_SAMSUNG0x15"If you need to add the Samsung eMMC specific code, it would be better you would send the Samsung eMMC specific patch.
(based-on this patch.)I believe Seunguk Shin provided the information so someone else could add this code. I could be that person if no one from Samsung has have time for this. I'm very grateful to Seungguk for posting these details.
Quoted 8 lines
I hope we can see the same details for Samsung eMMC 4.5 also (but please use a different email Subject line so we aren't confused.)
Quoted 2 lines
This patch isn't patch for samsung eMMC.
I didn't see this patch fully, but i think this patch is general code.AFAICT, the
MANFID_SAMSUNGis only a "quirk" for Samsung deviceswhich
Quoted 6 lines
specify the
EXT_CSD_FFU_ARGas 0.The original patch from SanDisk is general code and most of Seunguk's comments are general too. SanDisk (ie Avi) should please ACK they've seen those comments since I believe Seunguk is correct.
Quoted 12 lines
And Avi, please let us know if/when you plan on posting a V2. Or at least not be offended if I get impatient and hijack this patch series. :)
cheers,
grantQuoted 5 lines
Best Regards,
Jaehoon ChungQuoted 2 lines
Quoted 2 lines
+int mmc_ffu_download(struct
mmc_card*card, struct
mmc_command*cmd,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +8
-0+ u8 *data, int buf_bytes) +{ + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + int ret; + + /* Read the EXT_CSD */ + err = mmc_send_ext_csd(card, ext_csd);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+ if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit; + } + + /* Check if FFU is supported by card */ + if(!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE])) {
Quoted 67 lines
Quoted 67 lines
Quoted 67 lines
Quoted 6 lines
(quoted diff) +6
-0+ err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + } +Review
Quoted 10 lines
(quoted diff) +10
-0+ err = mmc_host_set_ffu(card, ext_csd[EXT_CSD_FW_CONFIG]); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + err = -EINVAL; + goto exit; + } + + /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_MODE_CONFIG,Review
Quoted 13 lines
(quoted diff) +13
-0+ MMC_FFU_MODE_SET, card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit_normal; + } + + /* set CMD ARG */ + cmd->arg = ext_csd[EXT_CSD_FFU_ARG] | + ext_csd[EXT_CSD_FFU_ARG + 1] << 8 | + ext_csd[EXT_CSD_FFU_ARG + 2] << 16 | + ext_csd[EXT_CSD_FFU_ARG + 3] << 24; +Add followings
"/* If arg is zero, should be set to a special value for samsung eMMC */ if ( card->cid.manfid == CID_MANFID_SAMSUNG && cmd->arg == 0x0 ) { cmd->arg = 0xc7810000; }"
Quoted 7 lines
(quoted diff) +5
-0+ err = mmc_ffu_write(card, data, cmd->arg, buf_bytes); + +exit_normal: + /* host switch back to work in normal MMC Read/Write +commands*/
(quoted diff) +1
-0+ ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,Review
Quoted 10 lines
(quoted diff) +10
-0+ EXT_CSD_MODE_CONFIG, MMC_FFU_MODE_NORMAL, + card->ext_csd.generic_cmd6_time); + if (ret) + err = ret; + +exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_download); +eMMC 5.0 Spec. says if device does not support
MODE_OPERATION_CODES, device doesn't need to useNUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED.
So, it's better to move the code for checking this value to FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +7
-0+int mmc_ffu_install(struct mmc_card *card) { + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + u32 ffu_data_len; + u32 timeout; + + err = mmc_send_ext_csd(card, ext_csd);Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+ if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit; + } + + /* Check if FFU is supported */ + if(!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE]) ||
Quoted 152 lines
Quoted 152 lines
Quoted 152 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ FFU_CONFIG(ext_csd[EXT_CSD_FW_CONFIG])) { + err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + }Remove followings
"ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]| ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] << 24; if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* check mode operation */ + if (!FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES])) { + /* restart the eMMC */ + err = mmc_ffu_restart(card); + if (err) { + pr_err("FFU: %s: error %d FFU install:\n", + mmc_hostname(card->host), err); + } + } else {Add followings
"
ffu_data_len=
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]|
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG
+ 1] << 8
|
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG
+ 2] <<
16 |
ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG
+ 3] << 24;if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 7 lines
(quoted diff) +7
-0+ /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_CONFIG, 0x1, + card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is + notsupported\n",
Review
Quoted 3 lines
(quoted diff) +3
-0+ mmc_hostname(card->host), err); + goto exit; + }Checking ffu status in
ext_csdshould be done even if device does not supportMODE_OPERATION_CODESSo, it's better to move the code for checking this value to out of brace for FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]Quoted 8 lines
(quoted diff) +7
-0+ /* set ext_csd to install mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_OPERATION_CODES, + MMC_FFU_INSTALL_SET, timeout); + + if (err) { + pr_err("FFU: %s: error %d settinginstall
mode\n",
Review
Quoted 4 lines
(quoted diff) +4
-0+ mmc_hostname(card->host), err); + goto exit; + } +Remove followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +Add followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 5 lines
(quoted diff) +5
-0+exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_install); +And some device's fw should be transferred with one command. They does not support multiple commands for fw transfer. For these devices,
MMC_IOC_MAX_BYTESshould be greater.(quoted diff) +0
-0
b/include/uapi/linux/mmc/ioctl.hindex 1f5e689..af9ea62 100644include/uapi/linux/mmc/ioctl.h +0
-0@@ -53,5 +53,5 @@ struct mmc_ioc_cmd {* is enforced per ioctl call. For larger data transfers, use the normal
* block device operations.
*/include/uapi/linux/mmc/ioctl.h +1
-1-#define MMC_IOC_MAX_BYTES (512L * 256) +#define MMC_IOC_MAX_BYTES (512L * 1024)#endif /* LINUX_MMC_IOCTL_H */ Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] Moremajordomo
Quoted 3 lines
Quoted 1 line
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Hi Seunguk,
Quoted 66 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Seunguk Shin
Sent: Monday, March 31, 2014 1:52 PM
To: [email protected]; Avi Shchislowski; [email protected]; [email protected]
Subject: Re: [RFC PATCH 1/1 ]mmc: Support-FFU-for-eMMC-v5.0Some of Samsung eMMC does not show the argument for ffu in
ext_csd. In case of this, eMMC shows0x0fromext_csd, Host has to modify the argument.Add "#define
CID_MANFID_SAMSUNG0x15"Quoted 1 line
+int mmc_ffu_download(struct
mmc_card*card, structmmc_command*cmd,
Quoted 6 lines
(quoted diff) +6
-0+ u8 *data, int buf_bytes) +{ + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + int ret; +Review
Quoted 10 lines
(quoted diff) +10
-0+ /* Read the EXT_CSD */ + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit; + } + + /* Check if FFU is supported by card */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE])){
Quoted 6 lines
(quoted diff) +6
-0+ err = -EINVAL; + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit; + } +Review
Quoted 10 lines
(quoted diff) +10
-0+ err = mmc_host_set_ffu(card, ext_csd[EXT_CSD_FW_CONFIG]); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + err = -EINVAL; + goto exit; + } + + /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_MODE_CONFIG,Review
Quoted 13 lines
(quoted diff) +13
-0+ MMC_FFU_MODE_SET, card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is not supported\n", + mmc_hostname(card->host), err); + goto exit_normal; + } + + /* set CMD ARG */ + cmd->arg = ext_csd[EXT_CSD_FFU_ARG] | + ext_csd[EXT_CSD_FFU_ARG + 1] << 8 | + ext_csd[EXT_CSD_FFU_ARG + 2] << 16 | + ext_csd[EXT_CSD_FFU_ARG + 3] << 24; +Add followings
"
Quoted 5 lines
/* If arg is zero, should be set to a special value for samsung eMMC */ if ( card->cid.manfid == CID_MANFID_SAMSUNG && cmd->arg == 0x0 ) { cmd->arg = 0xc7810000; }"
This code is provides a generic FFU solution.
I think it will be better to implement the Samsung-specific part as a QUIRK in MMC driver, and commit this as a separate patch.
Quoted 19 lines
Quoted 6 lines
(quoted diff) +5
-0+ err = mmc_ffu_write(card, data, cmd->arg, buf_bytes); + +exit_normal: + /* host switch back to work in normal MMC Read/Write commands */ + ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,Review
Quoted 10 lines
(quoted diff) +10
-0+ EXT_CSD_MODE_CONFIG, MMC_FFU_MODE_NORMAL, + card->ext_csd.generic_cmd6_time); + if (ret) + err = ret; + +exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_download); +
Quoted 5 lines
eMMC 5.0 Spec. says if device does not support
MODE_OPERATION_CODES, device doesn't need to useNUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED.
So, it's better to move the code for checking this value to FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]
OK, will be checked only in case of MODE_OPERATION_CODES is NOT supported.
Quoted 76 lines
Quoted 6 lines
(quoted diff) +5
-0+int mmc_ffu_install(struct mmc_card *card) { + u8 ext_csd[CARD_BLOCK_SIZE]; + int err; + u32 ffu_data_len; + u32 timeout;Review
Quoted 10 lines
(quoted diff) +10
-0+ + err = mmc_send_ext_csd(card, ext_csd); + if (err) { + pr_err("FFU: %s: error %d sending ext_csd\n", + mmc_hostname(card->host), err); + goto exit; + } + + /* Check if FFU is supported */ + if (!FFU_SUPPORTED_MODE(ext_csd[EXT_CSD_SUPPORTED_MODE])|| > + FFU_CONFIG(ext_csd[EXT_CSD_FW_CONFIG])) { > + err = -EINVAL; > + pr_err("FFU: %s: error %d FFU is not supported\n", > + mmc_hostname(card->host), err); > + goto exit; > + }Remove followings
"ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]| ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] << 24; if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* check mode operation */ + if (!FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES])) { + /* restart the eMMC */ + err = mmc_ffu_restart(card); + if (err) { + pr_err("FFU: %s: error %d FFU install:\n", + mmc_hostname(card->host), err); + } + } else {Add followings
"ffu_data_len = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG]| ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 1] << 8 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 2] << 16 | ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG + 3] << 24; if (!ffu_data_len) { err = -EPERM; return err; }"
Review
Quoted 6 lines
(quoted diff) +6
-0+ /* set device to FFU mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_CONFIG, 0x1, + card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("FFU: %s: error %d FFU is notsupported\n",
Review
Quoted 3 lines
(quoted diff) +3
-0+ mmc_hostname(card->host), err); + goto exit; + }
Quoted 4 lines
Checking ffu status in
ext_csdshould be done even if device does not supportMODE_OPERATION_CODESSo, it's better to move the code for checking this value to out of brace for FFU_FEATURES(ext_csd[EXT_CSD_FFU_FEATURES]
You are right, we will move ffu status check to be done in both modes.
Quoted 72 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+ /* set ext_csd to install mode */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_MODE_OPERATION_CODES, + MMC_FFU_INSTALL_SET, timeout); + + if (err) { + pr_err("FFU: %s: error %d setting + installmode\n",
Review
Quoted 4 lines
(quoted diff) +4
-0+ mmc_hostname(card->host), err); + goto exit; + } +Remove followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +Add followings
"/* read ext_csd */ err = mmc_send_ext_csd(card, ext_csd); if (err) { pr_err("FFU: %s: error %d sending ext_csd\n", mmc_hostname(card->host), err); goto exit; } /* return status */ err = ext_csd[EXT_CSD_FFU_STATUS]; if (err) { pr_err("FFU: %s: error %d FFU install:\n", mmc_hostname(card->host), err); err = -EINVAL; goto exit; }"
Review
Quoted 5 lines
(quoted diff) +5
-0+exit: + return err; +} +EXPORT_SYMBOL(mmc_ffu_install); +And some device's fw should be transferred with one command. They does not support multiple commands for fw transfer. For these devices,
MMC_IOC_MAX_BYTESshould be greater.include/uapi/linux/mmc/ioctl.h +0
-0
include/uapi/linux/mmc/ioctl.h struct mmc_ioc_cmd { · line 57
Quoted 6 lines
include/uapi/linux/mmc/ioctl.h +1
-1@@ -53,5 +53,5 @@ struct mmc_ioc_cmd {* is enforced per ioctl call. For larger data transfers, use the normal * block device operations. */ -#define MMC_IOC_MAX_BYTES (512L * 256) +#define MMC_IOC_MAX_BYTES (512L * 1024)#endif /* LINUX_MMC_IOCTL_H */
We do not feel confident enough with changing the previously defined IOCTL limitation. Our next patch (V2) should probably resolve FW size limitation - will use "udev" mechanism.
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html