From patchwork Thu Aug 12 17:36:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remy Bohmer X-Patchwork-Id: 71813 X-Patchwork-Delegate: info@emk-elektronik.de Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 403511536EF for ; Thu, 12 Aug 2010 19:37:54 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 2BD8130E1861 for ; Thu, 12 Aug 2010 19:37:54 +0200 (CEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Thu, 12 Aug 2010 19:37:54 +0200 (CEST) Received: from murder ([192.168.8.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Thu, 12 Aug 2010 19:37:26 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend1.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Thu, 12 Aug 2010 19:37:26 +0200 Received: from scanner-3.m-online.net (unknown [192.168.6.168]) by mail.m-online.net (Postfix) with ESMTP id 676311C0018C; Thu, 12 Aug 2010 19:37:26 +0200 (CEST) Received: from mxin-3.m-online.net ([192.168.6.165]) by scanner-3.m-online.net (scanner-3.m-online.net [192.168.6.168]) (amavisd-new, port 10026) with ESMTP id 14840-02; Thu, 12 Aug 2010 19:37:25 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-3.m-online.net (Postfix) with ESMTP id 05B0446F3F4; Thu, 12 Aug 2010 19:37:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2FBD3280D0; Thu, 12 Aug 2010 19:37:20 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dD+4hL8-ugiG; Thu, 12 Aug 2010 19:37:19 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AD0BC280BC; Thu, 12 Aug 2010 19:37:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1601E280CE for ; Thu, 12 Aug 2010 19:37:12 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MMM-q6vahHwO for ; Thu, 12 Aug 2010 19:37:10 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ew0-f44.google.com (mail-ew0-f44.google.com [209.85.215.44]) by theia.denx.de (Postfix) with ESMTP id 0BBBB280CD for ; Thu, 12 Aug 2010 19:37:08 +0200 (CEST) Received: by ewy22 with SMTP id 22so801973ewy.3 for ; Thu, 12 Aug 2010 10:37:08 -0700 (PDT) Received: by 10.213.112.130 with SMTP id w2mr7378737ebp.43.1281634628196; Thu, 12 Aug 2010 10:37:08 -0700 (PDT) Received: from localhost (cp297193-c.venra1.lb.home.nl [84.30.221.127]) by mx.google.com with ESMTPS id u9sm2534421eeh.17.2010.08.12.10.37.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 12 Aug 2010 10:37:07 -0700 (PDT) From: Remy Bohmer To: Sergei Shtylyov , Vitaly Kuzmichev , Stefano Babic , u-boot@lists.denx.de Date: Thu, 12 Aug 2010 19:36:53 +0200 Message-Id: <1281634613-2707-3-git-send-email-linux@bohmer.net> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1281634613-2707-1-git-send-email-linux@bohmer.net> References: <1281634613-2707-1-git-send-email-linux@bohmer.net> Subject: [U-Boot] [PATCH 3/3] Enable the use of Ethernet over USB (CDC) for the AT91SAM9261EK board. X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net Signed-off-by: Thomas Smits Signed-off-by: Remy Bohmer --- 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 #include #include +#include #include #if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_DRIVER_DM9000) #include #include #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