[U-Boot] [PATCH 3/3] Enable the use of Ethernet over USB (CDC) for the AT91SAM9261EK board.
Remy Bohmer
linux at bohmer.net
Thu Aug 12 19:36:53 CEST 2010
Signed-off-by: Thomas Smits <ts.smits at gmail.com>
Signed-off-by: Remy Bohmer <linux at bohmer.net>
---
board/atmel/at91sam9261ek/at91sam9261ek.c | 43 +++++++++++++++++++++++++++-
include/configs/at91sam9261ek.h | 17 +++++++++++
2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c
index de5cfae..1a27e53 100644
--- a/board/atmel/at91sam9261ek/at91sam9261ek.c
+++ b/board/atmel/at91sam9261ek/at91sam9261ek.c
@@ -33,14 +33,29 @@
#include <asm/arch/gpio.h>
#include <asm/arch/io.h>
#include <lcd.h>
+#include <usb/at91_udc.h>
#include <atmel_lcdc.h>
#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_DRIVER_DM9000)
#include <net.h>
#include <netdev.h>
#endif
+#if defined(CONFIG_USB_GADGET_AT91) && !defined(CONFIG_USB_GADGET)
+#error "Need CONFIG_USB_GADGET when CONFIG_USB_GADGET_AT91 enabled"
+#endif
+
DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_USB_GADGET_AT91
+struct platform_data brd = {
+ .board = {
+ .vbus_pin = AT91_PIN_PB29,
+ .pullup_pin = 0,
+ },
+ .udc_clk = AT91SAM9261_ID_UDP,
+};
+#endif
+
/* ------------------------------------------------------------------------- */
/*
* Miscelaneous platform dependent initialisations
@@ -141,6 +156,16 @@ static void at91sam9261ek_dm9000_hw_init(void)
}
#endif
+#ifdef CONFIG_USB_GADGET_AT91
+static void at91sam9261ek_usbd_hw_init(void)
+{
+ /* PLLB is already enabled by the bootstrap loader... */
+ at91_sys_write(AT91_PMC_SCER, AT91SAM926x_PMC_UDP);
+ at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9261_ID_PIOB);
+ at91_set_gpio_input(brd.board.vbus_pin, 0);
+}
+#endif
+
#ifdef CONFIG_LCD
vidinfo_t panel_info = {
vl_col: 240,
@@ -255,6 +280,9 @@ int board_init(void)
#ifdef CONFIG_HAS_DATAFLASH
at91_spi0_hw_init(1 << 0);
#endif
+#ifdef CONFIG_USB_GADGET_AT91
+ at91sam9261ek_usbd_hw_init();
+#endif
#ifdef CONFIG_DRIVER_DM9000
at91sam9261ek_dm9000_hw_init();
#endif
@@ -264,10 +292,21 @@ int board_init(void)
return 0;
}
-#ifdef CONFIG_DRIVER_DM9000
+#if defined(CONFIG_DRIVER_DM9000) || defined(CONFIG_USB_GADGET_AT91)
int board_eth_init(bd_t *bis)
{
- return dm9000_initialize(bis);
+ int res = -1;
+
+#if defined(CONFIG_DRIVER_DM9000)
+ res = dm9000_initialize(bis);
+#endif
+#if defined(CONFIG_USB_GADGET_AT91)
+ at91udc_probe(&brd);
+
+ if (usb_eth_initialize(bis) >= 0)
+ res = 0;
+#endif
+ return res;
}
#endif
diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h
index df8181b..8749b51 100644
--- a/include/configs/at91sam9261ek.h
+++ b/include/configs/at91sam9261ek.h
@@ -151,6 +151,23 @@
#define CONFIG_DM9000_NO_SROM 1
#define CONFIG_NET_RETRY_COUNT 20
#define CONFIG_RESET_PHY_R 1
+#define CONFIG_NET_DO_NOT_TRY_ANOTHER 1
+
+/* Configure Ethernet over USB */
+#define CONFIG_USB_GADGET 1
+#define CONFIG_USB_GADGET_AT91 1
+#define CONFIG_USB_ETHER 1
+#ifdef CONFIG_USB_GADGET
+#define CFG_USBD_REGS_BASE AT91SAM9261_BASE_UDP
+#endif
+#define CONFIG_USBNET_MANUFACTURER "Atmel AT91SAM9261-EK"
+/* ethaddr settings can be overruled via environment settings */
+#define CONFIG_USBNET_DEV_ADDR "8e:28:0f:fa:3c:39"
+#define CONFIG_USBNET_HOST_ADDR "0a:fa:63:8b:e8:0a"
+#define CONFIG_USB_CDC_VENDOR_ID 0x0525
+#define CONFIG_USB_CDC_PRODUCT_ID 0xa4a1
+#define CONFIG_USB_RNDIS_VENDOR_ID 0x0525
+#define CONFIG_USB_RNDIS_PRODUCT_ID 0xa4a2
/* USB */
#define CONFIG_USB_ATMEL
--
1.7.0.4
More information about the U-Boot
mailing list