summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Kirby <osk@exegin.com>2014-04-16 17:51:11 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2014-04-23 09:24:06 +0200
commit7311cc9bd2719e19bac9b4981d7e34b18b2bc9a9 (patch)
treebd712479742c209f2df34f97f04057ba96a6866f
parentb7f627bb34a16ceb0e3f6cb3fbbac661e5a6c190 (diff)
downloadbarebox-7311cc9bd2719e19bac9b4981d7e34b18b2bc9a9.tar.gz
Fix AT91 UDC driver on boards without vbus.
From 4ea2bd2e1ca18136d7cfd61643bc8d8187b1495f Mon Sep 17 00:00:00 2001 From: Owen Kirby <osk@exegin.com> Date: Wed, 16 Apr 2014 17:45:18 -0700 Subject: [PATCH] Fix AT91 UDC driver on boards without vbus. While porting Barebox to one of our boards, we found that the AT91 UDC driver will fail to connect to USB hosts, and will spam the console with errors if the VBUS pin isn't connected. Signed-off-by: Owen Kirby <osk@exegin.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/usb/gadget/at91_udc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 8ef1ad0..2768ddd 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1329,13 +1329,15 @@ int usb_gadget_poll(void)
if (!udc->udp_baseaddr)
return -ENODEV;
- value = gpio_get_value(udc->board.vbus_pin);
- value ^= udc->board.vbus_active_low;
+ if (gpio_is_valid(udc->board.vbus_pin)) {
+ value = gpio_get_value(udc->board.vbus_pin);
+ value ^= udc->board.vbus_active_low;
- udc->gpio_vbus_val = value;
+ udc->gpio_vbus_val = value;
- if (!value)
- return 0;
+ if (!value)
+ return 0;
+ }
value = at91_udp_read(udc, AT91_UDP_ISR) & (~(AT91_UDP_SOFINT));
if (value)
@@ -1501,14 +1503,14 @@ static int __init at91udc_probe(struct device_d *dev)
udc->vbus = gpio_get_value(udc->board.vbus_pin);
DBG(udc, "VBUS detection: host:%s \n",
udc->vbus ? "present":"absent");
+
+ dev_add_param_bool(dev, "vbus",
+ at91_udc_vbus_set, NULL, &udc->gpio_vbus_val, udc);
} else {
DBG(udc, "no VBUS detection, assuming always-on\n");
udc->vbus = 1;
}
- dev_add_param_bool(dev, "vbus",
- at91_udc_vbus_set, NULL, &udc->gpio_vbus_val, udc);
-
poller_register(&poller);
INFO(udc, "%s version %s\n", driver_name, DRIVER_VERSION);