Re: [PATCH] usb: dwc3: adapt to use dr_mode device tree helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 07/12/2013 12:50 PM, Felipe Balbi wrote:
> From: Ruchika Kharwar <ruchika@xxxxxx>
> 
> This patch adapts the dwc3 to use the device tree helper
> "of_usb_get_dr_mode" for the mode of operation of the dwc3 instance
> being probed.
> 
> [ balbi@xxxxxx : make of_usb_get_dr_mode() conditional on
> 	dev->of_node and let pdata pass dr_mode too ]
> 
> Signed-off-by: Ruchika Kharwar <ruchika@xxxxxx>
> Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> ---
>  drivers/usb/dwc3/core.c          | 73 +++++++++++++++++++++-------------------
>  drivers/usb/dwc3/core.h          | 11 +++---
>  drivers/usb/dwc3/platform_data.h |  2 ++
>  3 files changed, 44 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index a4dab1c..dcb744c 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -37,6 +37,7 @@
>  #include <linux/usb/ch9.h>
>  #include <linux/usb/gadget.h>
>  #include <linux/usb/of.h>
> +#include <linux/usb/otg.h>
>  
>  #include "platform_data.h"
>  #include "core.h"
> @@ -359,8 +360,6 @@ static int dwc3_probe(struct platform_device *pdev)
>  	void __iomem		*regs;
>  	void			*mem;
>  
> -	u8			mode;
> -
>  	mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
>  	if (!mem) {
>  		dev_err(dev, "not enough memory\n");
> @@ -424,6 +423,7 @@ static int dwc3_probe(struct platform_device *pdev)
>  		}
>  
>  		dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
> +		dwc->dr_mode = of_usb_get_dr_mode(node);
>  	} else {
>  		dwc->maximum_speed = pdata->maximum_speed;
>  
> @@ -440,6 +440,7 @@ static int dwc3_probe(struct platform_device *pdev)
>  		}
>  
>  		dwc->needs_fifo_resize = pdata->tx_fifo_resize;
> +		dwc->dr_mode = pdata->dr_mode;
>  	}
>  
>  	/* default to superspeed if no maximum_speed passed */
> @@ -518,14 +519,17 @@ static int dwc3_probe(struct platform_device *pdev)
>  	}
>  
>  	if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
> -		mode = DWC3_MODE_HOST;
> +		dwc->dr_mode = USB_DR_MODE_HOST;
>  	else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
> -		mode = DWC3_MODE_DEVICE;
> +		dwc->dr_mode = USB_DR_MODE_PERIPHERAL;
>  	else
> -		mode = DWC3_MODE_DRD;
> +		dwc->dr_mode = of_usb_get_dr_mode(node);

Missed to remove this?

> +
> +	if (dwc->dr_mode == USB_DR_MODE_UNKNOWN)
> +		dwc->dr_mode = USB_DR_MODE_OTG;

cheers,
-roger

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux