diff options
author | Mark A. Greer <mgreer@animalcreek.com> | 2012-06-27 16:59:57 -0400 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2012-06-27 16:59:57 -0400 |
commit | 31ba88083fec3b141fc1863a2dc0822c474a89a2 (patch) | |
tree | e5bc9130f285c1b2458f230e33a9873bf9573935 /arch/arm/mach-omap2/am35xx-emac.c | |
parent | 6b16351acbd415e66ba16bf7d473ece1574cf0bc (diff) |
ARM: OMAP AM35x: EMAC/MDIO integration: Add Davinci EMAC/MDIO hwmod support
Add hwmod support for the EMAC (and MDIO)
ethernet controller that's on the am35x
family of SoC's.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
[paul@pwsan.com: updated subject line; updated to apply on v3.5-rc4;
added comments to hwmod data regarding IPSS]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/mach-omap2/am35xx-emac.c')
-rw-r--r-- | arch/arm/mach-omap2/am35xx-emac.c | 90 |
1 files changed, 46 insertions, 44 deletions
diff --git a/arch/arm/mach-omap2/am35xx-emac.c b/arch/arm/mach-omap2/am35xx-emac.c index 447682c4e11c..2c90ac686686 100644 --- a/arch/arm/mach-omap2/am35xx-emac.c +++ b/arch/arm/mach-omap2/am35xx-emac.c | |||
@@ -15,27 +15,13 @@ | |||
15 | * General Public License for more details. | 15 | * General Public License for more details. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/clk.h> | 18 | #include <linux/err.h> |
19 | #include <linux/davinci_emac.h> | 19 | #include <linux/davinci_emac.h> |
20 | #include <linux/platform_device.h> | 20 | #include <asm/system.h> |
21 | #include <plat/irqs.h> | 21 | #include <plat/omap_device.h> |
22 | #include <mach/am35xx.h> | 22 | #include <mach/am35xx.h> |
23 | |||
24 | #include "control.h" | 23 | #include "control.h" |
25 | 24 | #include "am35xx-emac.h" | |
26 | static struct mdio_platform_data am35xx_emac_mdio_pdata; | ||
27 | |||
28 | static struct resource am35xx_emac_mdio_resources[] = { | ||
29 | DEFINE_RES_MEM(AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET, SZ_4K), | ||
30 | }; | ||
31 | |||
32 | static struct platform_device am35xx_emac_mdio_device = { | ||
33 | .name = "davinci_mdio", | ||
34 | .id = 0, | ||
35 | .num_resources = ARRAY_SIZE(am35xx_emac_mdio_resources), | ||
36 | .resource = am35xx_emac_mdio_resources, | ||
37 | .dev.platform_data = &am35xx_emac_mdio_pdata, | ||
38 | }; | ||
39 | 25 | ||
40 | static void am35xx_enable_emac_int(void) | 26 | static void am35xx_enable_emac_int(void) |
41 | { | 27 | { |
@@ -69,41 +55,57 @@ static struct emac_platform_data am35xx_emac_pdata = { | |||
69 | .interrupt_disable = am35xx_disable_emac_int, | 55 | .interrupt_disable = am35xx_disable_emac_int, |
70 | }; | 56 | }; |
71 | 57 | ||
72 | static struct resource am35xx_emac_resources[] = { | 58 | static struct mdio_platform_data am35xx_mdio_pdata; |
73 | DEFINE_RES_MEM(AM35XX_IPSS_EMAC_BASE, 0x30000), | ||
74 | DEFINE_RES_IRQ(INT_35XX_EMAC_C0_RXTHRESH_IRQ), | ||
75 | DEFINE_RES_IRQ(INT_35XX_EMAC_C0_RX_PULSE_IRQ), | ||
76 | DEFINE_RES_IRQ(INT_35XX_EMAC_C0_TX_PULSE_IRQ), | ||
77 | DEFINE_RES_IRQ(INT_35XX_EMAC_C0_MISC_PULSE_IRQ), | ||
78 | }; | ||
79 | 59 | ||
80 | static struct platform_device am35xx_emac_device = { | 60 | static int __init omap_davinci_emac_dev_init(struct omap_hwmod *oh, |
81 | .name = "davinci_emac", | 61 | void *pdata, int pdata_len) |
82 | .id = -1, | 62 | { |
83 | .num_resources = ARRAY_SIZE(am35xx_emac_resources), | 63 | struct platform_device *pdev; |
84 | .resource = am35xx_emac_resources, | 64 | |
85 | .dev = { | 65 | pdev = omap_device_build(oh->class->name, 0, oh, pdata, pdata_len, |
86 | .platform_data = &am35xx_emac_pdata, | 66 | NULL, 0, false); |
87 | }, | 67 | if (IS_ERR(pdev)) { |
88 | }; | 68 | WARN(1, "Can't build omap_device for %s:%s.\n", |
69 | oh->class->name, oh->name); | ||
70 | return PTR_ERR(pdev); | ||
71 | } | ||
72 | |||
73 | return 0; | ||
74 | } | ||
89 | 75 | ||
90 | void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en) | 76 | void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en) |
91 | { | 77 | { |
78 | struct omap_hwmod *oh; | ||
92 | u32 v; | 79 | u32 v; |
93 | int err; | 80 | int ret; |
94 | 81 | ||
95 | am35xx_emac_pdata.rmii_en = rmii_en; | 82 | oh = omap_hwmod_lookup("davinci_mdio"); |
96 | am35xx_emac_mdio_pdata.bus_freq = mdio_bus_freq; | 83 | if (!oh) { |
97 | err = platform_device_register(&am35xx_emac_device); | 84 | pr_err("Could not find davinci_mdio hwmod\n"); |
98 | if (err) { | 85 | return; |
99 | pr_err("AM35x: failed registering EMAC device: %d\n", err); | 86 | } |
87 | |||
88 | am35xx_mdio_pdata.bus_freq = mdio_bus_freq; | ||
89 | |||
90 | ret = omap_davinci_emac_dev_init(oh, &am35xx_mdio_pdata, | ||
91 | sizeof(am35xx_mdio_pdata)); | ||
92 | if (ret) { | ||
93 | pr_err("Could not build davinci_mdio hwmod device\n"); | ||
100 | return; | 94 | return; |
101 | } | 95 | } |
102 | 96 | ||
103 | err = platform_device_register(&am35xx_emac_mdio_device); | 97 | oh = omap_hwmod_lookup("davinci_emac"); |
104 | if (err) { | 98 | if (!oh) { |
105 | pr_err("AM35x: failed registering EMAC MDIO device: %d\n", err); | 99 | pr_err("Could not find davinci_emac hwmod\n"); |
106 | platform_device_unregister(&am35xx_emac_device); | 100 | return; |
101 | } | ||
102 | |||
103 | am35xx_emac_pdata.rmii_en = rmii_en; | ||
104 | |||
105 | ret = omap_davinci_emac_dev_init(oh, &am35xx_emac_pdata, | ||
106 | sizeof(am35xx_emac_pdata)); | ||
107 | if (ret) { | ||
108 | pr_err("Could not build davinci_emac hwmod device\n"); | ||
107 | return; | 109 | return; |
108 | } | 110 | } |
109 | 111 | ||