mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 13:11:31 +00:00
Merge branch 'master' of git://git.denx.de/u-boot-usb
- Assorted gadget fixes
This commit is contained in:
commit
c3e8aa1a9e
8 changed files with 101 additions and 35 deletions
|
@ -13,7 +13,7 @@
|
|||
|
||||
static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
{
|
||||
int ret = CMD_RET_FAILURE;
|
||||
int ret;
|
||||
|
||||
if (argc < 2)
|
||||
return CMD_RET_USAGE;
|
||||
|
@ -23,7 +23,11 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
usb_gadget_initialize(controller_index);
|
||||
|
||||
g_dnl_clear_detach();
|
||||
g_dnl_register("usb_dnl_sdp");
|
||||
ret = g_dnl_register("usb_dnl_sdp");
|
||||
if (ret) {
|
||||
pr_err("SDP dnl register failed: %d\n", ret);
|
||||
goto exit_register;
|
||||
}
|
||||
|
||||
ret = sdp_init(controller_index);
|
||||
if (ret) {
|
||||
|
@ -37,9 +41,10 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
|
||||
exit:
|
||||
g_dnl_unregister();
|
||||
exit_register:
|
||||
usb_gadget_release(controller_index);
|
||||
|
||||
return ret;
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(sdp, 2, 1, do_sdp,
|
||||
|
|
|
@ -41,7 +41,7 @@ int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr)
|
|||
set_default_env(NULL, 0);
|
||||
str_env = env_get(dfu_alt_info);
|
||||
if (!str_env) {
|
||||
pr_err("\"dfu_alt_info\" env variable not defined!\n");
|
||||
pr_err("\"%s\" env variable not defined!\n", dfu_alt_info);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,11 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
|
|||
const int controller_index = 0;
|
||||
|
||||
g_dnl_clear_detach();
|
||||
g_dnl_register("usb_dnl_sdp");
|
||||
ret = g_dnl_register("usb_dnl_sdp");
|
||||
if (ret) {
|
||||
pr_err("SDP dnl register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = sdp_init(controller_index);
|
||||
if (ret) {
|
||||
|
|
|
@ -20,7 +20,9 @@ static void getvar_product(char *var_parameter, char *response);
|
|||
static void getvar_platform(char *var_parameter, char *response);
|
||||
static void getvar_current_slot(char *var_parameter, char *response);
|
||||
static void getvar_slot_suffixes(char *var_parameter, char *response);
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
|
||||
static void getvar_has_slot(char *var_parameter, char *response);
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
static void getvar_partition_type(char *part_name, char *response);
|
||||
#endif
|
||||
|
@ -65,9 +67,11 @@ static const struct {
|
|||
}, {
|
||||
.variable = "slot-suffixes",
|
||||
.dispatch = getvar_slot_suffixes
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
|
||||
}, {
|
||||
.variable = "has-slot",
|
||||
.dispatch = getvar_has_slot
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
}, {
|
||||
.variable = "partition-type",
|
||||
|
@ -81,6 +85,47 @@ static const struct {
|
|||
}
|
||||
};
|
||||
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
|
||||
/**
|
||||
* Get partition number and size for any storage type.
|
||||
*
|
||||
* Can be used to check if partition with specified name exists.
|
||||
*
|
||||
* If error occurs, this function guarantees to fill @p response with fail
|
||||
* string. @p response can be rewritten in caller, if needed.
|
||||
*
|
||||
* @param[in] part_name Info for which partition name to look for
|
||||
* @param[in,out] response Pointer to fastboot response buffer
|
||||
* @param[out] size If not NULL, will contain partition size (in blocks)
|
||||
* @return Partition number or negative value on error
|
||||
*/
|
||||
static int getvar_get_part_info(const char *part_name, char *response,
|
||||
size_t *size)
|
||||
{
|
||||
int r;
|
||||
# if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
struct blk_desc *dev_desc;
|
||||
disk_partition_t part_info;
|
||||
|
||||
r = fastboot_mmc_get_part_info(part_name, &dev_desc, &part_info,
|
||||
response);
|
||||
if (r >= 0 && size)
|
||||
*size = part_info.size;
|
||||
# elif CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
|
||||
struct part_info *part_info;
|
||||
|
||||
r = fastboot_nand_get_part_info(part_name, &part_info, response);
|
||||
if (r >= 0 && size)
|
||||
*size = part_info->size;
|
||||
# else
|
||||
fastboot_fail("this storage is not supported in bootloader", response);
|
||||
r = -ENODEV;
|
||||
# endif
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void getvar_version(char *var_parameter, char *response)
|
||||
{
|
||||
fastboot_okay(FASTBOOT_VERSION, response);
|
||||
|
@ -133,23 +178,48 @@ static void getvar_platform(char *var_parameter, char *response)
|
|||
|
||||
static void getvar_current_slot(char *var_parameter, char *response)
|
||||
{
|
||||
/* A/B not implemented, for now always return _a */
|
||||
fastboot_okay("_a", response);
|
||||
/* A/B not implemented, for now always return "a" */
|
||||
fastboot_okay("a", response);
|
||||
}
|
||||
|
||||
static void getvar_slot_suffixes(char *var_parameter, char *response)
|
||||
{
|
||||
fastboot_okay("_a,_b", response);
|
||||
fastboot_okay("a,b", response);
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
|
||||
static void getvar_has_slot(char *part_name, char *response)
|
||||
{
|
||||
if (part_name && (!strcmp(part_name, "boot") ||
|
||||
!strcmp(part_name, "system")))
|
||||
fastboot_okay("yes", response);
|
||||
else
|
||||
fastboot_okay("no", response);
|
||||
char part_name_wslot[PART_NAME_LEN];
|
||||
size_t len;
|
||||
int r;
|
||||
|
||||
if (!part_name || part_name[0] == '\0')
|
||||
goto fail;
|
||||
|
||||
/* part_name_wslot = part_name + "_a" */
|
||||
len = strlcpy(part_name_wslot, part_name, PART_NAME_LEN - 3);
|
||||
if (len > PART_NAME_LEN - 3)
|
||||
goto fail;
|
||||
strcat(part_name_wslot, "_a");
|
||||
|
||||
r = getvar_get_part_info(part_name_wslot, response, NULL);
|
||||
if (r >= 0) {
|
||||
fastboot_okay("yes", response); /* part exists and slotted */
|
||||
return;
|
||||
}
|
||||
|
||||
r = getvar_get_part_info(part_name, response, NULL);
|
||||
if (r >= 0)
|
||||
fastboot_okay("no", response); /* part exists but not slotted */
|
||||
|
||||
/* At this point response is filled with okay or fail string */
|
||||
return;
|
||||
|
||||
fail:
|
||||
fastboot_fail("invalid partition name", response);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
static void getvar_partition_type(char *part_name, char *response)
|
||||
|
@ -176,22 +246,7 @@ static void getvar_partition_size(char *part_name, char *response)
|
|||
int r;
|
||||
size_t size;
|
||||
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
struct blk_desc *dev_desc;
|
||||
disk_partition_t part_info;
|
||||
|
||||
r = fastboot_mmc_get_part_info(part_name, &dev_desc, &part_info,
|
||||
response);
|
||||
if (r >= 0)
|
||||
size = part_info.size;
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
|
||||
struct part_info *part_info;
|
||||
|
||||
r = fastboot_nand_get_part_info(part_name, &part_info, response);
|
||||
if (r >= 0)
|
||||
size = part_info->size;
|
||||
#endif
|
||||
r = getvar_get_part_info(part_name, response, &size);
|
||||
if (r >= 0)
|
||||
fastboot_response("OKAY", response, "0x%016zx", size);
|
||||
}
|
||||
|
|
|
@ -298,7 +298,8 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
|
|||
* @part_info: Pointer to returned disk_partition_t
|
||||
* @response: Pointer to fastboot response buffer
|
||||
*/
|
||||
int fastboot_mmc_get_part_info(char *part_name, struct blk_desc **dev_desc,
|
||||
int fastboot_mmc_get_part_info(const char *part_name,
|
||||
struct blk_desc **dev_desc,
|
||||
disk_partition_t *part_info, char *response)
|
||||
{
|
||||
int r;
|
||||
|
|
|
@ -152,8 +152,8 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,
|
|||
* @part_info: Pointer to returned part_info pointer
|
||||
* @response: Pointer to fastboot response buffer
|
||||
*/
|
||||
int fastboot_nand_get_part_info(char *part_name, struct part_info **part_info,
|
||||
char *response)
|
||||
int fastboot_nand_get_part_info(const char *part_name,
|
||||
struct part_info **part_info, char *response)
|
||||
{
|
||||
struct mtd_info *mtd = NULL;
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
* @part_info: Pointer to returned disk_partition_t
|
||||
* @response: Pointer to fastboot response buffer
|
||||
*/
|
||||
int fastboot_mmc_get_part_info(char *part_name, struct blk_desc **dev_desc,
|
||||
int fastboot_mmc_get_part_info(const char *part_name,
|
||||
struct blk_desc **dev_desc,
|
||||
disk_partition_t *part_info, char *response);
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* @part_info: Pointer to returned part_info pointer
|
||||
* @response: Pointer to fastboot response buffer
|
||||
*/
|
||||
int fastboot_nand_get_part_info(char *part_name, struct part_info **part_info,
|
||||
char *response);
|
||||
int fastboot_nand_get_part_info(const char *part_name,
|
||||
struct part_info **part_info, char *response);
|
||||
|
||||
/**
|
||||
* fastboot_nand_flash_write() - Write image to NAND for fastboot
|
||||
|
|
Loading…
Add table
Reference in a new issue