Skip to contentSkip to conversation

am35xx-emac: move generic EMAC init to separate file

PATCH Superseded Ilya Yanok 4 participants 9 messages Nov 17, 2011 – Dec 21, 2011

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ilya Yanok

author
#0 lore raw

PATCH 1/1 am35xx-emac: move generic EMAC init to separate file

AM35xx SoCs include DaVinci EMAC IP. Initialization code in board-am3517evm.c is pretty board independent and will work for any AM35xx based board so move this code to it's own file to be reused by other boards.

---
 arch/arm/mach-omap2/Makefile          |    3 +
 arch/arm/mach-omap2/am35xx-emac.c     |  136 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/am35xx-emac.h     |   17 ++++
 arch/arm/mach-omap2/board-am3517evm.c |  114 +---------------------------
 4 files changed, 158 insertions(+), 112 deletions(-)
 create mode 100644 arch/arm/mach-omap2/am35xx-emac.c
 create mode 100644 arch/arm/mach-omap2/am35xx-emac.h
arch/arm/mach-omap2/Makefile +3 -0
index 69ab1c0..3256301 100644
@@ -267,4 +267,7 @@ obj-$(CONFIG_ARCH_OMAP4)		+= hwspinlock.o
 disp-$(CONFIG_OMAP2_DSS)		:= display.o
 obj-y					+= $(disp-m) $(disp-y)
 
+emac-$(CONFIG_TI_DAVINCI_EMAC)		:= am35xx-emac.o
+obj-y					+= $(emac-m) $(emac-y)
+
 obj-y					+= common-board-devices.o twl-common.o
arch/arm/mach-omap2/am35xx-emac.c new file +136 -0

136 lines not on this page · raw message

arch/arm/mach-omap2/am35xx-emac.h new file +17 -0
new file mode 100644
index 0000000..44cb2b3
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
+
+#ifdef CONFIG_TI_DAVINCI_EMAC
+void am35xx_ethernet_init(unsigned long mdio_bus_freq, int rmii_en);
+#else
+static inline void am35xx_ethernet_init(unsigned long mdio_bus_freq,
+		int rmii_en)
+{
+}
+#endif
+
arch/arm/mach-omap2/board-am3517evm.c +2 -112

132 lines not on this page · raw message

Signature · 1 line
1.7.6.4
maintainer
#1 lore raw
Quoted 4 lines · Ilya Yanok

AM35xx SoCs include DaVinci EMAC IP. Initialization code in board-am3517evm.c is pretty board independent and will work for any AM35xx based board so move this code to it's own file to be reused by other boards.

Should this be just called emac-common.c? Or is it so am35xx specific that it won't work with others?

arch/arm/mach-omap2/am35xx-emac.c line 129

Quoted 4 lines
arch/arm/mach-omap2/am35xx-emac.c new file +4 -0
+	clk_add_alias(NULL, dev_name(&am35xx_emac_device.dev),
+		      "emac_clk", &am35xx_emac_device.dev);
+	clk_add_alias(NULL, dev_name(&am35xx_mdio_device.dev),
+		      "phy_clk", &am35xx_emac_device.dev);

Hmm after moving the code and should be a separate patch, don't we already have these clock aliases in cloc3xxx_data.c?

Tony

author
#2 lore raw

Hi Tony,

Quoted 7 lines · Tony Lindgren
Quoted 4 lines

AM35xx SoCs include DaVinci EMAC IP. Initialization code in board-am3517evm.c is pretty board independent and will work for any AM35xx based board so move this code to it's own file to be reused by other boards.

Should this be just called emac-common.c? Or is it so am35xx specific that it won't work with others?

Uh.. I'm not sure but I thought that EMAC is present only on am35xx SoCs...

Quoted 7 lines

arch/arm/mach-omap2/am35xx-emac.c line 129

Quoted 4 lines
arch/arm/mach-omap2/am35xx-emac.c new file +4 -0
+	clk_add_alias(NULL, dev_name(&am35xx_emac_device.dev),
+		      "emac_clk", &am35xx_emac_device.dev);
+	clk_add_alias(NULL, dev_name(&am35xx_mdio_device.dev),
+		      "phy_clk", &am35xx_emac_device.dev);

Hmm after moving the code and should be a separate patch, don't we already have these clock aliases in cloc3xxx_data.c?

No, we have
CLK("davinci_emac", "emac_clk"...) and
CLK("davinci_emac", "phy_clk"...)
while drivers want ("davinci_emac", NULL) and ("davinci_mdio", NULL).

Probably we have to fix the clock definitions instead of adding the aliases.

So, should I post this as a separate patch?

Regards, Ilya.

#3 lore raw

Hi Ilya

Quoted 21 lines · Ilya Yanok

Hi Tony,

Quoted 7 lines · Tony Lindgren
Quoted 4 lines

AM35xx SoCs include DaVinci EMAC IP. Initialization code in board-am3517evm.c is pretty board independent and will work for any AM35xx based board so move this code to it's own file to be reused by other boards.

Should this be just called emac-common.c? Or is it so am35xx specific that it won't work with others?

Uh.. I'm not sure but I thought that EMAC is present only on am35xx SoCs...

Quoted 7 lines

arch/arm/mach-omap2/am35xx-emac.c line 129

Quoted 4 lines
arch/arm/mach-omap2/am35xx-emac.c new file +4 -0
+	clk_add_alias(NULL, dev_name(&am35xx_emac_device.dev),
+		      "emac_clk", &am35xx_emac_device.dev);
+	clk_add_alias(NULL, dev_name(&am35xx_mdio_device.dev),
+		      "phy_clk", &am35xx_emac_device.dev);

Hmm after moving the code and should be a separate patch, don't we already have these clock aliases in cloc3xxx_data.c?

Quoted 8 lines

No, we have
CLK("davinci_emac", "emac_clk"...) and
CLK("davinci_emac", "phy_clk"...)
while drivers want ("davinci_emac", NULL) and ("davinci_mdio", NULL).

Probably we have to fix the clock definitions instead of adding the aliases.

So, should I post this as a separate patch?

If it comes to that question, Cc Paul...

Signature · 2 lines
Regards,
Igor.
maintainer
#4 lore raw
Quoted 15 lines · Igor Grinberg

Hi Ilya

Quoted 12 lines · Ilya Yanok

Hi Tony,

Quoted 7 lines · Tony Lindgren
Quoted 4 lines

AM35xx SoCs include DaVinci EMAC IP. Initialization code in board-am3517evm.c is pretty board independent and will work for any AM35xx based board so move this code to it's own file to be reused by other boards.

Should this be just called emac-common.c? Or is it so am35xx specific that it won't work with others?

Uh.. I'm not sure but I thought that EMAC is present only on am35xx SoCs...

OK, maybe just do a quick check on that so we don't end up moving the platform init code around again in few months?

Quoted 13 lines
Quoted 13 lines
Quoted 7 lines

arch/arm/mach-omap2/am35xx-emac.c line 129

Quoted 4 lines
arch/arm/mach-omap2/am35xx-emac.c new file +4 -0
+	clk_add_alias(NULL, dev_name(&am35xx_emac_device.dev),
+		      "emac_clk", &am35xx_emac_device.dev);
+	clk_add_alias(NULL, dev_name(&am35xx_mdio_device.dev),
+		      "phy_clk", &am35xx_emac_device.dev);

Hmm after moving the code and should be a separate patch, don't we already have these clock aliases in cloc3xxx_data.c?

No, we have
CLK("davinci_emac", "emac_clk"...) and
CLK("davinci_emac", "phy_clk"...)
while drivers want ("davinci_emac", NULL) and ("davinci_mdio", NULL).

Quoted 5 lines
Quoted 3 lines

Probably we have to fix the clock definitions instead of adding the aliases.

So, should I post this as a separate patch?

If it comes to that question, Cc Paul...

Yes please do that as a separate patch.

Thanks,

TOny

author
#5 lore raw

Hi Tony,

Quoted 7 lines · Tony Lindgren
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Should this be just called emac-common.c? Or is it so am35xx specific that it won't work with others?

Uh.. I'm not sure but I thought that EMAC is present only on am35xx SoCs...

OK, maybe just do a quick check on that so we don't end up moving the platform init code around again in few months?

Well, according to TI site, EMAC can be also found on AM33x, AM387x and AM389x... I'm not sure if it's completely compatible but probably though.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 7 lines

arch/arm/mach-omap2/am35xx-emac.c line 129

Quoted 4 lines
arch/arm/mach-omap2/am35xx-emac.c new file +4 -0
+	clk_add_alias(NULL, dev_name(&am35xx_emac_device.dev),
+		      "emac_clk", &am35xx_emac_device.dev);
+	clk_add_alias(NULL, dev_name(&am35xx_mdio_device.dev),
+		      "phy_clk", &am35xx_emac_device.dev);

Hmm after moving the code and should be a separate patch, don't we already have these clock aliases in cloc3xxx_data.c?

No, we have
CLK("davinci_emac", "emac_clk"...) and
CLK("davinci_emac", "phy_clk"...)
while drivers want ("davinci_emac", NULL) and ("davinci_mdio", NULL).

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Probably we have to fix the clock definitions instead of adding the aliases.

So, should I post this as a separate patch?

If it comes to that question, Cc Paul...

Yes please do that as a separate patch.

Ok, let's wait for Paul's answer and then I'll prepare a separate patch.

Regards, Ilya.

#6 lore raw

(cc'ing Ranjith)

Hi

Quoted 15 lines · Ilya Yanok
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 7 lines

arch/arm/mach-omap2/am35xx-emac.c line 129

Quoted 4 lines
arch/arm/mach-omap2/am35xx-emac.c new file +4 -0
+	clk_add_alias(NULL, dev_name(&am35xx_emac_device.dev),
+		      "emac_clk", &am35xx_emac_device.dev);
+	clk_add_alias(NULL, dev_name(&am35xx_mdio_device.dev),
+		      "phy_clk", &am35xx_emac_device.dev);

Hmm after moving the code and should be a separate patch, don't we already have these clock aliases in cloc3xxx_data.c?

No, we have
CLK("davinci_emac", "emac_clk"...) and
CLK("davinci_emac", "phy_clk"...)
while drivers want ("davinci_emac", NULL) and ("davinci_mdio", NULL).

Probably we have to fix the clock definitions instead of adding the aliases.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

So, should I post this as a separate patch?

If it comes to that question, Cc Paul...

Yes please do that as a separate patch.

Ok, let's wait for Paul's answer and then I'll prepare a separate patch.

Unfortunately the AM3517 TRM (SPRUGR0) here doesn't really have the same level of clock integration information that the WBU TRMs have, so it's kind of hard to tell what's going on :-(

Looking at Figure 22-1 "EMAC and MDIO Block Diagram", it appears that what we call "emac_fck" is really just an optional functional clock for the MDIO PHY?

And it sounds like the AM35xx clock that we call "emac_ick" is actually a combined interface and functional clock for the EMAC and MDIO IP blocks? I guess a combined interface/functional clock would make sense, since the EMAC seems to contain a DMA controller.

Maybe Ranjith can provide some more information; he's cc'ed.

In any case, your changes sound reasonable to me, so a patch to the clock file sounds good. I'd suggest both changing the clkdev aliases and renaming emac_fck - that's a confusing name and I don't think it's in the TRM as such.

- Paul

author
#7 lore raw

Hi Paul,

Quoted 9 lines · Paul Walmsley
Quoted 1 line

Ok, let's wait for Paul's answer and then I'll prepare a separate patch.

Unfortunately the AM3517 TRM (SPRUGR0) here doesn't really have the same level of clock integration information that the WBU TRMs have, so it's kind of hard to tell what's going on :-(

Looking at Figure 22-1 "EMAC and MDIO Block Diagram", it appears that what we call "emac_fck" is really just an optional functional clock for the MDIO PHY?

Hm. I have to admit I'm completely lost here. CONTROL_IPSS_CLK_CTRL register has bit controlling "Func clock of CPGMAC". But there is no mention of this clock anywhere else in the manual. I can't find neither where it comes from nor how it's used. According to the current sources it comes from external 50MHz RMII clock, do you think this is correct?

EMAC section speaks something about variable frequency peripheral clock which is used to generate MDIO bus clock signal. But I can't find any information on that clock in the other parts of the document. It seems to me the EMAC section was just copied from DaVinci RM without any editing...

Quoted 11 lines

And it sounds like the AM35xx clock that we call "emac_ick" is actually a combined interface and functional clock for the EMAC and MDIO IP blocks? I guess a combined interface/functional clock would make sense, since the EMAC seems to contain a DMA controller.

Maybe Ranjith can provide some more information; he's cc'ed.

In any case, your changes sound reasonable to me, so a patch to the clock file sounds good. I'd suggest both changing the clkdev aliases and renaming emac_fck - that's a confusing name and I don't think it's in the TRM as such.

Actually it's called Func clock in the manual (see CONTROL_IPSS_CLK_CTRL). Do you still think we have to rename it?

I have another concern: changing clkdev aliases make things work for me but now I'm not sure if this change is really correct...

Regards, Ilya.

#8 lore raw
Quoted 7 lines · Ilya Yanok
Quoted 6 lines · Paul Walmsley
Quoted 1 line

Ok, let's wait for Paul's answer and then I'll prepare a separate patch.

Unfortunately the AM3517 TRM (SPRUGR0) here doesn't really have the same level of clock integration information that the WBU TRMs have, so it's kind of hard to tell what's going on :-(

Quoted 7 lines
Quoted 3 lines

Looking at Figure 22-1 "EMAC and MDIO Block Diagram", it appears that what we call "emac_fck" is really just an optional functional clock for the MDIO PHY?

Hm. I have to admit I'm completely lost here. CONTROL_IPSS_CLK_CTRL register has bit controlling "Func clock of CPGMAC".

Yeah, I don't think that's correct. Or rather, it's imprecise. It might be true from a strict integration perspective, but it's misleading.

Quoted 4 lines

But there is no mention of this clock anywhere else in the manual. I can't find neither where it comes from nor how it's used. According to the current sources it comes from external 50MHz RMII clock, do you think this is correct?

I think that part is correct.

Quoted 7 lines
Quoted 7 lines

And it sounds like the AM35xx clock that we call "emac_ick" is actually a combined interface and functional clock for the EMAC and MDIO IP blocks? I guess a combined interface/functional clock would make sense, since the EMAC seems to contain a DMA controller.

Maybe Ranjith can provide some more information; he's cc'ed.

Quoted 7 lines
Quoted 4 lines

In any case, your changes sound reasonable to me, so a patch to the clock file sounds good. I'd suggest both changing the clkdev aliases and renaming emac_fck - that's a confusing name and I don't think it's in the TRM as such.

Actually it's called Func clock in the manual (see CONTROL_IPSS_CLK_CTRL). Do you still think we have to rename it?

I guess we have other optional functional clocks with _fck suffixes, so it's probably not such a big deal.

Quoted 2 lines

I have another concern: changing clkdev aliases make things work for me but now I'm not sure if this change is really correct...

Well, sounds like it's better than what we currently have.

- Paul