ARM: ipq8074: fdt_fixup: Added support to patch usb mode

This patch enables user to choose usb mode of port 0 in kernel.
By default, usb port 0 will be in host mode.
By setting an environment variable 'usb_mode' to "peripheral",
user can force port 0 to device mode.

Change-Id: Ib18d4db387ace1a0fa4fa1a74cffbc47464160f8
Signed-off-by: Gokul Sriram Palanisamy <gokulsri@codeaurora.org>
This commit is contained in:
Gokul Sriram Palanisamy 2017-06-13 16:24:10 +05:30
parent 025bb86829
commit 6760565641
4 changed files with 41 additions and 0 deletions

View file

@ -271,6 +271,7 @@ int ft_board_setup(void *blob, bd_t *bd)
ipq_fdt_fixup_socinfo(blob);
dcache_disable();
fdt_fixup_ethernet(blob);
ipq_fdt_fixup_usb_device_mode(blob);
#ifdef CONFIG_QCA_MMC
board_mmc_deinit();

View file

@ -315,6 +315,11 @@ int ipq_fdt_fixup_socinfo(void *blob)
return 0;
}
void ipq_fdt_fixup_usb_device_mode(void *blob)
{
return;
}
void set_flash_secondary_type(qca_smem_flash_info_t * smem)
{
return;

View file

@ -326,6 +326,11 @@ int ipq_fdt_fixup_socinfo(void *blob)
return ret;
}
void ipq_fdt_fixup_usb_device_mode(void *blob)
{
return;
}
void board_mmc_deinit(void)
{
emmc_clock_reset();

View file

@ -328,6 +328,36 @@ int ipq_fdt_fixup_socinfo(void *blob)
return 0;
}
void ipq_fdt_fixup_usb_device_mode(void *blob)
{
int nodeoff, ret, node;
const char *usb_dr_mode = "peripheral"; /* Supported mode */
const char *usb_node[] = {"/soc/usb3@8A00000/dwc3@8A00000"};
const char *usb_cfg;
usb_cfg = getenv("usb_mode");
if (!usb_cfg)
return;
if (strcmp(usb_cfg, usb_dr_mode))
printf("fixup_usb: usb_mode can be either 'peripheral' or not set\n");
return;
for (node = 0; node < ARRAY_SIZE(usb_node); node++) {
nodeoff = fdt_path_offset(blob, usb_node[node]);
if (nodeoff < 0) {
printf("fixup_usb: unable to find node '%s'\n",
usb_node[node]);
return;
}
ret = fdt_setprop(blob, nodeoff, "dr_mode",
usb_dr_mode,
(strlen(usb_dr_mode) + 1));
if (ret)
printf("fixup_usb: 'dr_mode' cannot be set");
}
}
void set_flash_secondary_type(qca_smem_flash_info_t *smem)
{
return;