From: Kyungmin Park Date: Thu, 18 Feb 2010 07:49:57 +0000 (+0900) Subject: Enable the use of Ethernet over USB (CDC) for the AT91SAM9261EK board. X-Git-Tag: JB12_20100218~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9800b86acae1384e328cc6526cb3f23650e93e26;p=kernel%2Fu-boot.git Enable the use of Ethernet over USB (CDC) for the AT91SAM9261EK board. Signed-off-by: Thomas Smits Signed-off-by: Remy Bohmer Signed-off-by: Kyungmin Park --- diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c index 7ead2b8..be0a56a 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 fbf7389..9fa8b10 100644 --- a/include/configs/at91sam9261ek.h +++ b/include/configs/at91sam9261ek.h @@ -148,6 +148,24 @@ #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