From patchwork Mon Jul 6 21:14:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 34333 Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n66LKwMK017083 for ; Mon, 6 Jul 2009 21:20:59 GMT Received: from dlep36.itg.ti.com ([157.170.170.91]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id n66LJbkl009568; Mon, 6 Jul 2009 16:19:42 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id n66LJbcs018484; Mon, 6 Jul 2009 16:19:37 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 8E48780760; Mon, 6 Jul 2009 16:18:56 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 72BD3808F7 for ; Mon, 6 Jul 2009 16:17:54 -0500 (CDT) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id n66LHs7i020827 for ; Mon, 6 Jul 2009 16:17:54 -0500 (CDT) Received: from mail192-va3-R.bigfish.com (mail-va3.bigfish.com [216.32.180.114]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id n66LHmGt032709 for ; Mon, 6 Jul 2009 16:17:53 -0500 Received: from mail192-va3 (localhost.localdomain [127.0.0.1]) by mail192-va3-R.bigfish.com (Postfix) with ESMTP id AA64314681AF for ; Mon, 6 Jul 2009 21:17:48 +0000 (UTC) X-SpamScore: 0 X-BigFish: vps0(zzzz1202hzzz2dh62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 5, X-MS-Exchange-Organization-Antispam-Report: OrigIP: 209.85.216.201; Service: EHS Received: by mail192-va3 (MessageSwitch) id 1246915055686532_11238; Mon, 6 Jul 2009 21:17:35 +0000 (UCT) Received: from mail-px0-f201.google.com (mail-px0-f201.google.com [209.85.216.201]) by mail192-va3.bigfish.com (Postfix) with ESMTP id 6F50314C004B for ; Mon, 6 Jul 2009 21:17:35 +0000 (UTC) Received: by mail-px0-f201.google.com with SMTP id 39so1158123pxi.4 for ; Mon, 06 Jul 2009 14:17:35 -0700 (PDT) Received: by 10.114.152.6 with SMTP id z6mr8164208wad.138.1246915055074; Mon, 06 Jul 2009 14:17:35 -0700 (PDT) Received: from localhost ([216.254.16.51]) by mx.google.com with ESMTPS id v9sm11950868wah.1.2009.07.06.14.17.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 06 Jul 2009 14:17:34 -0700 (PDT) From: Kevin Hilman To: linux-arm-kernel@lists.arm.linux.org.uk Date: Mon, 6 Jul 2009 14:14:51 -0700 Message-Id: <1246914900-9034-18-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1246914900-9034-17-git-send-email-khilman@deeprootsystems.com> References: <1246914900-9034-1-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-2-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-3-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-4-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-5-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-6-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-7-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-8-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-9-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-10-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-11-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-12-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-13-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-14-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-15-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-16-git-send-email-khilman@deeprootsystems.com> <1246914900-9034-17-git-send-email-khilman@deeprootsystems.com> Cc: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH 17/26] davinci: dm365: EMAC support for SoC and dm365 EVM X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com From: Sandeep Paulraj The patch adds Support for EMAC in the DM365 SOC and the DM365 EVM board. Signed-off-by: Sandeep Paulraj Signed-off-by: Kevin Hilman --- arch/arm/mach-davinci/board-dm365-evm.c | 66 ++++++++++++++++++++++++++++++- arch/arm/mach-davinci/dm365.c | 58 +++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index 08c2f12..9dda399 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c @@ -19,12 +19,12 @@ #include #include #include - +#include #include #include #include #include - +#include #include #include #include @@ -34,14 +34,69 @@ #include #include +#define DM365_EVM_PHY_MASK (0x2) +#define DM365_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */ + +static struct at24_platform_data eeprom_info = { + .byte_len = (256*1024) / 8, + .page_size = 64, + .flags = AT24_FLAG_ADDR16, + .setup = davinci_get_mac_addr, + .context = (void *)0x7f00, +}; + +static struct i2c_board_info i2c_info[] = { + { + I2C_BOARD_INFO("24c256", 0x50), + .platform_data = &eeprom_info, + }, +}; + static struct davinci_i2c_platform_data i2c_pdata = { .bus_freq = 400 /* kHz */, .bus_delay = 0 /* usec */, }; +static void dm365evm_emac_configure(void) +{ + /* + * EMAC pins are multiplexed with GPIO and UART + * Further details are available at the DM365 ARM + * Subsystem Users Guide(sprufg5.pdf) pages 125 - 127 + */ + davinci_cfg_reg(DM365_EMAC_TX_EN); + davinci_cfg_reg(DM365_EMAC_TX_CLK); + davinci_cfg_reg(DM365_EMAC_COL); + davinci_cfg_reg(DM365_EMAC_TXD3); + davinci_cfg_reg(DM365_EMAC_TXD2); + davinci_cfg_reg(DM365_EMAC_TXD1); + davinci_cfg_reg(DM365_EMAC_TXD0); + davinci_cfg_reg(DM365_EMAC_RXD3); + davinci_cfg_reg(DM365_EMAC_RXD2); + davinci_cfg_reg(DM365_EMAC_RXD1); + davinci_cfg_reg(DM365_EMAC_RXD0); + davinci_cfg_reg(DM365_EMAC_RX_CLK); + davinci_cfg_reg(DM365_EMAC_RX_DV); + davinci_cfg_reg(DM365_EMAC_RX_ER); + davinci_cfg_reg(DM365_EMAC_CRS); + davinci_cfg_reg(DM365_EMAC_MDIO); + davinci_cfg_reg(DM365_EMAC_MDCLK); + + /* + * EMAC interrupts are multiplexed with GPIO interrupts + * Details are available at the DM365 ARM + * Subsystem Users Guide(sprufg5.pdf) pages 133 - 134 + */ + davinci_cfg_reg(DM365_INT_EMAC_RXTHRESH); + davinci_cfg_reg(DM365_INT_EMAC_RXPULSE); + davinci_cfg_reg(DM365_INT_EMAC_TXPULSE); + davinci_cfg_reg(DM365_INT_EMAC_MISCPULSE); +} + static void __init evm_init_i2c(void) { davinci_init_i2c(&i2c_pdata); + i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); } static struct davinci_uart_config uart_config __initdata = { @@ -55,8 +110,15 @@ static void __init dm365_evm_map_io(void) static __init void dm365_evm_init(void) { + struct davinci_soc_info *soc_info = &davinci_soc_info; + evm_init_i2c(); davinci_serial_init(&uart_config); + + dm365evm_emac_configure(); + + soc_info->emac_pdata->phy_mask = DM365_EVM_PHY_MASK; + soc_info->emac_pdata->mdio_max_freq = DM365_EVM_MDIO_FREQUENCY; } static __init void dm365_evm_irq_init(void) diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index c9ae97a..9d615db 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -546,6 +546,52 @@ INT_CFG(DM365, INT_EMAC_MISCPULSE, 17, 1, 1, false) #endif }; +static struct emac_platform_data dm365_emac_pdata = { + .ctrl_reg_offset = DM365_EMAC_CNTRL_OFFSET, + .ctrl_mod_reg_offset = DM365_EMAC_CNTRL_MOD_OFFSET, + .ctrl_ram_offset = DM365_EMAC_CNTRL_RAM_OFFSET, + .mdio_reg_offset = DM365_EMAC_MDIO_OFFSET, + .ctrl_ram_size = DM365_EMAC_CNTRL_RAM_SIZE, + .version = EMAC_VERSION_2, +}; + +static struct resource dm365_emac_resources[] = { + { + .start = DM365_EMAC_BASE, + .end = DM365_EMAC_BASE + 0x47ff, + .flags = IORESOURCE_MEM, + }, + { + .start = IRQ_DM365_EMAC_RXTHRESH, + .end = IRQ_DM365_EMAC_RXTHRESH, + .flags = IORESOURCE_IRQ, + }, + { + .start = IRQ_DM365_EMAC_RXPULSE, + .end = IRQ_DM365_EMAC_RXPULSE, + .flags = IORESOURCE_IRQ, + }, + { + .start = IRQ_DM365_EMAC_TXPULSE, + .end = IRQ_DM365_EMAC_TXPULSE, + .flags = IORESOURCE_IRQ, + }, + { + .start = IRQ_DM365_EMAC_MISCPULSE, + .end = IRQ_DM365_EMAC_MISCPULSE, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device dm365_emac_device = { + .name = "davinci_emac", + .id = 1, + .dev = { + .platform_data = &dm365_emac_pdata, + }, + .num_resources = ARRAY_SIZE(dm365_emac_resources), + .resource = dm365_emac_resources, +}; static u8 dm365_default_priorities[DAVINCI_N_AINTC_IRQ] = { [IRQ_VDINT0] = 2, @@ -702,6 +748,7 @@ static struct davinci_soc_info davinci_soc_info_dm365 = { .gpio_num = 104, .gpio_irq = 44, .serial_dev = &dm365_serial_device, + .emac_pdata = &dm365_emac_pdata, .sram_dma = 0x00010000, .sram_len = SZ_32K, }; @@ -710,3 +757,14 @@ void __init dm365_init(void) { davinci_common_init(&davinci_soc_info_dm365); } + +static int __init dm365_init_devices(void) +{ + if (!cpu_is_davinci_dm365()) + return 0; + + platform_device_register(&dm365_emac_device); + + return 0; +} +postcore_initcall(dm365_init_devices);