VBUS fix
From AVRFreaks Wiki
[edit] VBUS fix
In order to add VBUS to a GPIO we need to add two resistors to convert from 5v to 3v3. It can be done in the following way:
850
GPIO (+3.3v) --+--\/\/-- VBUS (+5v)
|
\
/
\ 1.65K
/
|
GND
The linux kernel also needs to be patched in order to know which GPIO pin is used for the VBUS signal. Here is a patch for using PB18:
--- linux-2.6.24.3.atmel.3/arch/avr32/boards/atngw100/setup.c.orig 2008-05-07 18:03:10.000000000 +0200
+++ linux-2.6.24.3.atmel.3/arch/avr32/boards/atngw100/setup.c 2008-05-07 18:02:13.000000000 +0200
@@ -16,6 +16,7 @@
#include <linux/types.h>
#include <linux/leds.h>
#include <linux/spi/spi.h>
+#include <linux/usb/atmel_usba_udc.h>
#include <asm/io.h>
#include <asm/setup.h>
@@ -147,6 +148,10 @@ static struct platform_device i2c_gpio_d
};
#endif
+static struct usba_platform_data usb_pd = {
+ .vbus_pin = GPIO_PIN_PB(18)
+};
+
static int __init atngw100_init(void)
{
unsigned i;
@@ -165,7 +170,7 @@ static int __init atngw100_init(void)
at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
at32_add_device_mci(0, &mci0_data);
- at32_add_device_usba(0, NULL);
+ at32_add_device_usba(0, &usb_pd);
for (i = 0; i < ARRAY_SIZE(ngw_leds); i++) {
at32_select_gpio(ngw_leds[i].gpio,
After the VBUS fix has been applied my board looks like this http://duff.dk/vbus-fix.jpg
