diff options
author | Eirik Aanonsen <EAA@wprmedical.com> | 2010-02-05 03:49:25 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-02 17:54:57 -0500 |
commit | 640e95abdfae9fef5949084c92e80c8f2f8b5ec5 (patch) | |
tree | f8cb60315b5b362b53777c0e11650e681c9c3b65 | |
parent | 90f7976880bbbf9968629500972f8e2f80401217 (diff) |
USB: atmel uaba: Adding invert vbus_pin
Adding vbus_pin_inverted so that the usb detect pin can be active high
or low depending on HW implementation also replaced the
gpio_get_value(udc->vbus_pin); with a call to vbus_is_present(udc); This
allows the driver to be loaded and save about 0,15W on the consumption.
Signed-off-by: Eirik Aanonsen <eaa@wprmedical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap700x.c | 7 | ||||
-rw-r--r-- | drivers/usb/gadget/atmel_usba_udc.c | 5 | ||||
-rw-r--r-- | drivers/usb/gadget/atmel_usba_udc.h | 1 | ||||
-rw-r--r-- | include/linux/usb/atmel_usba_udc.h | 1 |
4 files changed, 10 insertions, 4 deletions
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c index b13d1879e51b..3a4bc1a18433 100644 --- a/arch/avr32/mach-at32ap/at32ap700x.c +++ b/arch/avr32/mach-at32ap/at32ap700x.c | |||
@@ -1770,10 +1770,13 @@ at32_add_device_usba(unsigned int id, struct usba_platform_data *data) | |||
1770 | ARRAY_SIZE(usba0_resource))) | 1770 | ARRAY_SIZE(usba0_resource))) |
1771 | goto out_free_pdev; | 1771 | goto out_free_pdev; |
1772 | 1772 | ||
1773 | if (data) | 1773 | if (data) { |
1774 | usba_data.pdata.vbus_pin = data->vbus_pin; | 1774 | usba_data.pdata.vbus_pin = data->vbus_pin; |
1775 | else | 1775 | usba_data.pdata.vbus_pin_inverted = data->vbus_pin_inverted; |
1776 | } else { | ||
1776 | usba_data.pdata.vbus_pin = -EINVAL; | 1777 | usba_data.pdata.vbus_pin = -EINVAL; |
1778 | usba_data.pdata.vbus_pin_inverted = -EINVAL; | ||
1779 | } | ||
1777 | 1780 | ||
1778 | data = &usba_data.pdata; | 1781 | data = &usba_data.pdata; |
1779 | data->num_ep = ARRAY_SIZE(at32_usba_ep); | 1782 | data->num_ep = ARRAY_SIZE(at32_usba_ep); |
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 976822f50c70..f79bdfe4bed9 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -320,7 +320,7 @@ static inline void usba_cleanup_debugfs(struct usba_udc *udc) | |||
320 | static int vbus_is_present(struct usba_udc *udc) | 320 | static int vbus_is_present(struct usba_udc *udc) |
321 | { | 321 | { |
322 | if (gpio_is_valid(udc->vbus_pin)) | 322 | if (gpio_is_valid(udc->vbus_pin)) |
323 | return gpio_get_value(udc->vbus_pin); | 323 | return gpio_get_value(udc->vbus_pin) ^ udc->vbus_pin_inverted; |
324 | 324 | ||
325 | /* No Vbus detection: Assume always present */ | 325 | /* No Vbus detection: Assume always present */ |
326 | return 1; | 326 | return 1; |
@@ -1763,7 +1763,7 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid) | |||
1763 | if (!udc->driver) | 1763 | if (!udc->driver) |
1764 | goto out; | 1764 | goto out; |
1765 | 1765 | ||
1766 | vbus = gpio_get_value(udc->vbus_pin); | 1766 | vbus = vbus_is_present(udc); |
1767 | if (vbus != udc->vbus_prev) { | 1767 | if (vbus != udc->vbus_prev) { |
1768 | if (vbus) { | 1768 | if (vbus) { |
1769 | toggle_bias(1); | 1769 | toggle_bias(1); |
@@ -2000,6 +2000,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
2000 | if (gpio_is_valid(pdata->vbus_pin)) { | 2000 | if (gpio_is_valid(pdata->vbus_pin)) { |
2001 | if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { | 2001 | if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { |
2002 | udc->vbus_pin = pdata->vbus_pin; | 2002 | udc->vbus_pin = pdata->vbus_pin; |
2003 | udc->vbus_pin_inverted = pdata->vbus_pin_inverted; | ||
2003 | 2004 | ||
2004 | ret = request_irq(gpio_to_irq(udc->vbus_pin), | 2005 | ret = request_irq(gpio_to_irq(udc->vbus_pin), |
2005 | usba_vbus_irq, 0, | 2006 | usba_vbus_irq, 0, |
diff --git a/drivers/usb/gadget/atmel_usba_udc.h b/drivers/usb/gadget/atmel_usba_udc.h index f7baea307f0d..88a2e07a11a8 100644 --- a/drivers/usb/gadget/atmel_usba_udc.h +++ b/drivers/usb/gadget/atmel_usba_udc.h | |||
@@ -323,6 +323,7 @@ struct usba_udc { | |||
323 | struct platform_device *pdev; | 323 | struct platform_device *pdev; |
324 | int irq; | 324 | int irq; |
325 | int vbus_pin; | 325 | int vbus_pin; |
326 | int vbus_pin_inverted; | ||
326 | struct clk *pclk; | 327 | struct clk *pclk; |
327 | struct clk *hclk; | 328 | struct clk *hclk; |
328 | 329 | ||
diff --git a/include/linux/usb/atmel_usba_udc.h b/include/linux/usb/atmel_usba_udc.h index 6311fa2d9f82..baf41c8616e9 100644 --- a/include/linux/usb/atmel_usba_udc.h +++ b/include/linux/usb/atmel_usba_udc.h | |||
@@ -15,6 +15,7 @@ struct usba_ep_data { | |||
15 | 15 | ||
16 | struct usba_platform_data { | 16 | struct usba_platform_data { |
17 | int vbus_pin; | 17 | int vbus_pin; |
18 | int vbus_pin_inverted; | ||
18 | int num_ep; | 19 | int num_ep; |
19 | struct usba_ep_data ep[0]; | 20 | struct usba_ep_data ep[0]; |
20 | }; | 21 | }; |