Source
x
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2009, 2011 Freescale Semiconductor, Inc.
*
* (C) Copyright 2008, Excito Elektronik i Sk=E5ne AB
*
* Author: Tor Krill tor@excito.com
*/
/* USB Controllers */
static const char * const compat_usb_fsl[] = {
FSL_USB2_MPH,
FSL_USB2_DR,
SNPS_DWC3,
NULL
};
static int fdt_usb_get_node_type(void *blob, int start_offset,
int *node_offset, const char **node_type)
{
int i;
int ret = -ENOENT;
for (i = 0; compat_usb_fsl[i]; i++) {
*node_offset = fdt_node_offset_by_compatible
(blob, start_offset,
compat_usb_fsl[i]);
if (*node_offset >= 0) {
*node_type = compat_usb_fsl[i];
ret = 0;
break;
}
}
return ret;
}
static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode,
const char *phy_type, int start_offset)
{
const char *prop_mode = "dr_mode";
const char *prop_type = "phy_type";
const char *node_type = NULL;
int node_offset;
int err;
err = fdt_usb_get_node_type(blob, start_offset,
&node_offset, &node_type);
if (err < 0)
return err;
if (mode) {
err = fdt_setprop(blob, node_offset, prop_mode, mode,
strlen(mode) + 1);
if (err < 0)
printf("WARNING: could not set %s for %s: %s.\n",
prop_mode, node_type, fdt_strerror(err));
}
if (phy_type) {
err = fdt_setprop(blob, node_offset, prop_type, phy_type,
strlen(phy_type) + 1);
if (err < 0)
printf("WARNING: could not set %s for %s: %s.\n",
prop_type, node_type, fdt_strerror(err));
}
return node_offset;
}
static int fsl_fdt_fixup_usb_erratum(void *blob, const char *prop_erratum,
const char *controller_type,
int start_offset)
{
int node_offset, err;