diff mbox

[1/3] ohci-at91: add vbus_pin_inverted platform attribute

Message ID 1309856728-8265-1-git-send-email-thomas.petazzoni@free-electrons.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Petazzoni July 5, 2011, 9:05 a.m. UTC
The existing OHCI AT91 driver made the assumption that the enable
input of the USB power switch was active low. However, some USB power
switches such as the Micrel MIC2026-1 [1] have an active high input to
enable the power. A new vbus_pin_inverted attribute is added to the
at91_usbh_data structure so that board files can tell the OHCI driver
if the vbus pin logic is active low or active high.

[1] http://www.micrel.com/page.do?page=product-info/products/mic2026.shtml

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Andrew Victor <linux@maxim.org.za>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
---
 arch/arm/mach-at91/include/mach/board.h |    1 +
 drivers/usb/host/ohci-at91.c            |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Sergei Shtylyov July 5, 2011, 11:39 a.m. UTC | #1
Hello.

On 05-07-2011 13:05, Thomas Petazzoni wrote:

> The existing OHCI AT91 driver made the assumption that the enable
> input of the USB power switch was active low. However, some USB power
> switches such as the Micrel MIC2026-1 [1] have an active high input to
> enable the power. A new vbus_pin_inverted attribute is added to the
> at91_usbh_data structure so that board files can tell the OHCI driver
> if the vbus pin logic is active low or active high.

> [1] http://www.micrel.com/page.do?page=product-info/products/mic2026.shtml

> Signed-off-by: Thomas Petazzoni<thomas.petazzoni@free-electrons.com>
> Cc: Andrew Victor<linux@maxim.org.za>
> Cc: Nicolas Ferre<nicolas.ferre@atmel.com>
> Cc: Jean-Christophe Plagniol-Villard<plagnioj@jcrosoft.com>
[...]

> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index 944291e..52e50ba 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -284,7 +284,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
>   			if (pdata->vbus_pin[i]<= 0)
>   				continue;
>   			gpio_request(pdata->vbus_pin[i], "ohci_vbus");
> -			gpio_direction_output(pdata->vbus_pin[i], 0);
> +			gpio_direction_output(pdata->vbus_pin[i], 0 ^ pdata->vbus_pin_inverted);

    Why not simply 'pdata->vbus_pin_inverted'?

>   		}
>   	}
>
> @@ -301,7 +301,7 @@ static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
>   		for (i = 0; i<  ARRAY_SIZE(pdata->vbus_pin); i++) {
>   			if (pdata->vbus_pin[i]<= 0)
>   				continue;
> -			gpio_direction_output(pdata->vbus_pin[i], 1);
> +			gpio_direction_output(pdata->vbus_pin[i], 1 ^ pdata->vbus_pin_inverted);

    Why not simply '!pdata->vbus_pin_inverted'?

WBR, Sergei
Thomas Petazzoni July 5, 2011, 11:54 a.m. UTC | #2
Le Tue, 05 Jul 2011 15:39:18 +0400,
Sergei Shtylyov <sshtylyov@mvista.com> a écrit :

> > -			gpio_direction_output(pdata->vbus_pin[i], 0);
> > +			gpio_direction_output(pdata->vbus_pin[i], 0 ^ pdata->vbus_pin_inverted);
> 
>     Why not simply 'pdata->vbus_pin_inverted'?

> > -			gpio_direction_output(pdata->vbus_pin[i], 1);
> > +			gpio_direction_output(pdata->vbus_pin[i], 1 ^ pdata->vbus_pin_inverted);
> 
>     Why not simply '!pdata->vbus_pin_inverted'?

Ah, correct. The 0 and 1 were present before, and I just wanted to xor
them with vbus_pin_inverted, but obviously, there's a simpler way of
writing things, as you suggest.

I'll update my patch and send a new version after gathering comments
from other reviewers.

Thanks!

Thomas
diff mbox

Patch

diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index ed544a0..61d52dc 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -98,6 +98,7 @@  extern void __init at91_add_device_eth(struct at91_eth_data *data);
 struct at91_usbh_data {
 	u8		ports;		/* number of ports on root hub */
 	u8		vbus_pin[2];	/* port power-control pin */
+	u8              vbus_pin_inverted;
 };
 extern void __init at91_add_device_usbh(struct at91_usbh_data *data);
 extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data);
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 944291e..52e50ba 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -284,7 +284,7 @@  static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
 			if (pdata->vbus_pin[i] <= 0)
 				continue;
 			gpio_request(pdata->vbus_pin[i], "ohci_vbus");
-			gpio_direction_output(pdata->vbus_pin[i], 0);
+			gpio_direction_output(pdata->vbus_pin[i], 0 ^ pdata->vbus_pin_inverted);
 		}
 	}
 
@@ -301,7 +301,7 @@  static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
 		for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
 			if (pdata->vbus_pin[i] <= 0)
 				continue;
-			gpio_direction_output(pdata->vbus_pin[i], 1);
+			gpio_direction_output(pdata->vbus_pin[i], 1 ^ pdata->vbus_pin_inverted);
 			gpio_free(pdata->vbus_pin[i]);
 		}
 	}