Re: [PATCH 09/16] mfd: omap-usb-host: override number of ports from platform data

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

 



On Thu, Nov 15, 2012 at 04:34:07PM +0200, Roger Quadros wrote:
> For some platforms e.g. OMAP5, we cannot rely on USBHOST revision
> to determine the number of ports available. In such cases we have

you need to make it clear *why* we can't. Imagine someone reading this 5
years from now... he'll be all like: "why can't I find any documentation
about this OMAP5 ? Why was it so special that its revision register
wasn't enough to figure out number of ports ?"

> to rely on platform data (or FDT) to give us the right number of
> ports.
> 
> Signed-off-by: Roger Quadros <rogerq@xxxxxx>
> ---
>  arch/arm/mach-omap2/usb-host.c        |    1 +
>  arch/arm/plat-omap/include/plat/usb.h |    2 +
>  drivers/mfd/omap-usb-host.c           |   46 +++++++++++++++++++++++----------
>  3 files changed, 35 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c
> index 3c43449..eb85528 100644
> --- a/arch/arm/mach-omap2/usb-host.c
> +++ b/arch/arm/mach-omap2/usb-host.c
> @@ -504,6 +504,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
>  	ohci_data.es2_compatibility = pdata->es2_compatibility;
>  	usbhs_data.ehci_data = &ehci_data;
>  	usbhs_data.ohci_data = &ohci_data;
> +	usbhs_data.nports = pdata->nports;
>  
>  	if (cpu_is_omap34xx()) {
>  		setup_ehci_io_mux(pdata->port_mode);
> diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
> index 87ee140..6b618a1 100644
> --- a/arch/arm/plat-omap/include/plat/usb.h
> +++ b/arch/arm/plat-omap/include/plat/usb.h
> @@ -27,6 +27,7 @@ enum usbhs_omap_port_mode {
>  };
>  
>  struct usbhs_omap_board_data {
> +	int				nports;
>  	enum usbhs_omap_port_mode	port_mode[OMAP3_HS_USB_PORTS];
>  
>  	/* have to be valid if phy_reset is true and portx is in phy mode */
> @@ -59,6 +60,7 @@ struct ohci_hcd_omap_platform_data {
>  };
>  
>  struct usbhs_omap_platform_data {
> +	int					nports;
>  	enum usbhs_omap_port_mode		port_mode[OMAP3_HS_USB_PORTS];
>  
>  	struct ehci_hcd_omap_platform_data	*ehci_data;
> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> index ad89939..c20234b 100644
> --- a/drivers/mfd/omap-usb-host.c
> +++ b/drivers/mfd/omap-usb-host.c
> @@ -500,8 +500,8 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev)
>  
>  	omap->pdata = pdata;
>  	platform_set_drvdata(pdev, omap);
> -
>  	pm_runtime_enable(dev);
> +

trailing change, not part of $SUBJECT.

>  	pm_runtime_get_sync(dev);
>  	omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
>  
> @@ -510,19 +510,37 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev)
>  	 */
>  	pm_runtime_put_sync(dev);
>  
> -	switch (omap->usbhs_rev) {
> -	case OMAP_USBHS_REV1:
> -		omap->nports = 3;
> -		break;
> -	case OMAP_USBHS_REV2:
> -		omap->nports = 2;
> -		break;
> -	default:
> -		omap->nports = MAX_HS_USB_PORTS;
> -		dev_info(dev,
> -		  "USB HOST Rev : 0x%d not recognized, assuming %d ports\n",
> -		   omap->usbhs_rev, omap->nports);
> -		break;
> +	/*
> +	 * If platform data contains nports then use that
> +	 * else make out number of ports from USBHS revision
> +	 */
> +	if (pdata->nports) {
> +		if (omap->nports > MAX_HS_USB_PORTS) {
> +			dev_err(dev,
> +			 "Platform data says %d ports but MAX_HS_USB_PORTS is %d\n",
> +			 omap->nports, MAX_HS_USB_PORTS);
> +		} else {
> +			omap->nports = pdata->nports;
> +		}
> +	} else {
> +		switch (omap->usbhs_rev) {
> +		case OMAP_USBHS_REV1:
> +			omap->nports = 3;
> +			break;
> +		case OMAP_USBHS_REV2:
> +		/* Both OMAP4 and 5 show the same revision but they have
> +		 * different number of ports i.e. 2 and 3 respectively.
> +		 * OMAP5 platforms must supply nports via platform data.
> +		 */

comment indentation is wrong.

> +			omap->nports = 2;
> +			break;
> +		default:
> +			omap->nports = MAX_HS_USB_PORTS;
> +			dev_info(dev,
> +			"USB HOST Rev:0x%d not recognized, assuming %d ports\n",
> +				omap->usbhs_rev, omap->nports);

dev_dbg().

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux