-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 295927 b: refs/heads/master c: a8195ba h: refs/heads/master i: 295925: b9161df 295923: 2dfe7ac 295919: 4fe1cd0 v: v3
- Loading branch information
Ilya Yanok
authored and
Tony Lindgren
committed
Mar 5, 2012
1 parent
2421377
commit 5d1fea7
Showing
5 changed files
with
138 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: d4860ebef4f7e45ebc37013d5008de85cc24a94e | ||
refs/heads/master: a8195ba87cc746bf765bd507d87a2945602c8adc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright (C) 2011 Ilya Yanok, Emcraft Systems | ||
* | ||
* Based on mach-omap2/board-am3517evm.c | ||
* Copyright (C) 2009 Texas Instruments Incorporated | ||
* Author: Ranjith Lohithakshan <ranjithl@ti.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, | ||
* whether express or implied; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
*/ | ||
|
||
#include <linux/clk.h> | ||
#include <linux/davinci_emac.h> | ||
#include <linux/platform_device.h> | ||
#include <plat/irqs.h> | ||
#include <mach/am35xx.h> | ||
|
||
#include "control.h" | ||
|
||
static struct mdio_platform_data am35xx_emac_mdio_pdata; | ||
|
||
static struct resource am35xx_emac_mdio_resources[] = { | ||
DEFINE_RES_MEM(AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET, SZ_4K), | ||
}; | ||
|
||
static struct platform_device am35xx_emac_mdio_device = { | ||
.name = "davinci_mdio", | ||
.id = 0, | ||
.num_resources = ARRAY_SIZE(am35xx_emac_mdio_resources), | ||
.resource = am35xx_emac_mdio_resources, | ||
.dev.platform_data = &am35xx_emac_mdio_pdata, | ||
}; | ||
|
||
static void am35xx_enable_emac_int(void) | ||
{ | ||
u32 regval; | ||
|
||
regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); | ||
regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR | | ||
AM35XX_CPGMAC_C0_TX_PULSE_CLR | | ||
AM35XX_CPGMAC_C0_MISC_PULSE_CLR | | ||
AM35XX_CPGMAC_C0_RX_THRESH_CLR); | ||
omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR); | ||
regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); | ||
} | ||
|
||
static void am35xx_disable_emac_int(void) | ||
{ | ||
u32 regval; | ||
|
||
regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); | ||
regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR | | ||
AM35XX_CPGMAC_C0_TX_PULSE_CLR); | ||
omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR); | ||
regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); | ||
} | ||
|
||
static struct emac_platform_data am35xx_emac_pdata = { | ||
.ctrl_reg_offset = AM35XX_EMAC_CNTRL_OFFSET, | ||
.ctrl_mod_reg_offset = AM35XX_EMAC_CNTRL_MOD_OFFSET, | ||
.ctrl_ram_offset = AM35XX_EMAC_CNTRL_RAM_OFFSET, | ||
.ctrl_ram_size = AM35XX_EMAC_CNTRL_RAM_SIZE, | ||
.hw_ram_addr = AM35XX_EMAC_HW_RAM_ADDR, | ||
.version = EMAC_VERSION_2, | ||
.interrupt_enable = am35xx_enable_emac_int, | ||
.interrupt_disable = am35xx_disable_emac_int, | ||
}; | ||
|
||
static struct resource am35xx_emac_resources[] = { | ||
DEFINE_RES_MEM(AM35XX_IPSS_EMAC_BASE, 0x30000), | ||
DEFINE_RES_IRQ(INT_35XX_EMAC_C0_RXTHRESH_IRQ), | ||
DEFINE_RES_IRQ(INT_35XX_EMAC_C0_RX_PULSE_IRQ), | ||
DEFINE_RES_IRQ(INT_35XX_EMAC_C0_TX_PULSE_IRQ), | ||
DEFINE_RES_IRQ(INT_35XX_EMAC_C0_MISC_PULSE_IRQ), | ||
}; | ||
|
||
static struct platform_device am35xx_emac_device = { | ||
.name = "davinci_emac", | ||
.id = -1, | ||
.num_resources = ARRAY_SIZE(am35xx_emac_resources), | ||
.resource = am35xx_emac_resources, | ||
.dev = { | ||
.platform_data = &am35xx_emac_pdata, | ||
}, | ||
}; | ||
|
||
void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en) | ||
{ | ||
unsigned int regval; | ||
int err; | ||
|
||
am35xx_emac_pdata.rmii_en = rmii_en; | ||
am35xx_emac_mdio_pdata.bus_freq = mdio_bus_freq; | ||
err = platform_device_register(&am35xx_emac_device); | ||
if (err) { | ||
pr_err("AM35x: failed registering EMAC device: %d\n", err); | ||
return; | ||
} | ||
|
||
err = platform_device_register(&am35xx_emac_mdio_device); | ||
if (err) { | ||
pr_err("AM35x: failed registering EMAC MDIO device: %d\n", err); | ||
platform_device_unregister(&am35xx_emac_device); | ||
return; | ||
} | ||
|
||
regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); | ||
regval = regval & (~(AM35XX_CPGMACSS_SW_RST)); | ||
omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET); | ||
regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (C) 2011 Ilya Yanok, Emcraft Systems | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#define AM35XX_DEFAULT_MDIO_FREQUENCY 1000000 | ||
|
||
#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE) | ||
void am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en); | ||
#else | ||
static inline void am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en) {} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters