Enable the use of Ethernet over USB (CDC) for the AT91SAM9261EK board.
authorKyungmin Park <kyungmin.park@samsung.com>
Thu, 18 Feb 2010 07:49:57 +0000 (16:49 +0900)
committerKyungmin Park <kyungmin.park@samsung.com>
Thu, 18 Feb 2010 07:49:57 +0000 (16:49 +0900)
Signed-off-by: Thomas Smits <ts.smits@gmail.com>
Signed-off-by: Remy Bohmer <linux@bohmer.net>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
board/atmel/at91sam9261ek/at91sam9261ek.c
include/configs/at91sam9261ek.h

index 7ead2b8..be0a56a 100644 (file)
 #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
 
index fbf7389..9fa8b10 100644 (file)
 #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_ETH_RNDIS         1*/
+#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