public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] drivers:usb:common:fsl-dt-fixup: Fix the dt for all type of usb controllers
Date: Mon, 20 Jun 2016 16:16:30 +0200	[thread overview]
Message-ID: <5767FABE.6070806@denx.de> (raw)
In-Reply-To: <1466396111-16177-1-git-send-email-sriram.dash@nxp.com>

On 06/20/2016 06:15 AM, Sriram Dash wrote:
> Currently, U-boot doesn't allow to compile more than one type of USB protocol
> simultaneously. Hence, EHCI and XHCI controllers cannot co-exist and
> CONFIG_USB_MAX_CONTROLLER_COUNT macro represents count of only one type of
> controller.

This does not make sense, with DM we can support all sorts of controllers.

> For the Socs which have more than one type of controller e.g. EHCI and XHCI,
> and the device tree has to support both of them, the macro
> CONFIG_USB_MAX_CONTROLLER_COUNT will not work for fixing dt from u boot.
> 
> So, instead of taking the hard coded number of controller from U boot,
> count the total number of controller present in dt and then fix the dt
> accordingly.
> 
> Signed-off-by: Sriram Dash <sriram.dash@nxp.com>
> Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
> ---
>  drivers/usb/common/fsl-dt-fixup.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c
> index 9c48852..1edf146 100644
> --- a/drivers/usb/common/fsl-dt-fixup.c
> +++ b/drivers/usb/common/fsl-dt-fixup.c
> @@ -131,10 +131,29 @@ static int fdt_fixup_erratum(int *usb_erratum_off, void *blob,
>  	return 0;
>  }
>  
> +static int fdt_max_controller_count(void *blob)
> +{
> +	int count = 0;
> +	int node_offset = -1;
> +	int i;
> +
> +	for (i = 0; compat_usb_fsl[i]; i++) {
> +		do {
> +			node_offset = fdt_node_offset_by_compatible
> +					(blob, node_offset,
> +					 compat_usb_fsl[i]);
> +			if (node_offset >= 0)
> +				count++;
> +		} while (node_offset != -FDT_ERR_NOTFOUND);
> +	}
> +	return count;
> +}
> +
>  void fdt_fixup_dr_usb(void *blob, bd_t *bd)
>  {
>  	static const char * const modes[] = { "host", "peripheral", "otg" };
>  	static const char * const phys[] = { "ulpi", "utmi", "utmi_dual" };
> +	unsigned int usb_max_controller_count;
>  	int usb_erratum_a006261_off = -1;
>  	int usb_erratum_a007075_off = -1;
>  	int usb_erratum_a007792_off = -1;
> @@ -146,7 +165,13 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd)
>  	int i, j;
>  	int ret;
>  
> -	for (i = 1; i <= CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
> +	usb_max_controller_count = fdt_max_controller_count(blob);

Since you walk the tree below anyway, why do you even need to count the
elements? Just walk the tree until you can find no more nodes.

> +	if (!usb_max_controller_count) {
> +		printf("ERROR: FDT fixup erratum fail.\n");
> +		return;
> +	}
> +
> +	for (i = 1; i <= usb_max_controller_count; i++) {
>  		const char *dr_mode_type = NULL;
>  		const char *dr_phy_type = NULL;
>  		int mode_idx = -1, phy_idx = -1;
> 


-- 
Best regards,
Marek Vasut

  reply	other threads:[~2016-06-20 14:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20  4:15 [U-Boot] [PATCH] drivers:usb:common:fsl-dt-fixup: Fix the dt for all type of usb controllers Sriram Dash
2016-06-20 14:16 ` Marek Vasut [this message]
2016-07-20  3:55   ` Sriram Dash
2016-07-20  5:57     ` Marek Vasut
2016-08-17  8:16 ` [U-Boot] [PATCH v2] drivers: usb: fsl-dt-fixup: Fix the dt for multiple USB nodes in single traversal of device tree Sriram Dash
2016-09-14  5:22   ` Sriram Dash
2016-09-14 21:22     ` Marek Vasut
2016-09-14 22:29       ` york sun
2016-09-15  6:40         ` Sriram Dash
2016-09-15 22:01         ` Marek Vasut
2016-09-16  8:47           ` Sriram Dash
2016-09-16  9:17             ` Marek Vasut
2016-09-16 10:27               ` Sriram Dash

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5767FABE.6070806@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox