diff mbox

davinci: Add EMAC support for da850/omap-l138

Message ID 1247820430-24995-1-git-send-email-sudhakar.raj@ti.com (mailing list archive)
State Accepted
Headers show

Commit Message

Rajashekhara, Sudhakar July 17, 2009, 8:47 a.m. UTC
Ethernet Media Access Controller (EMAC) on da850/omap-l138
supports 10/100 Mbps operation. It also supports Media
Independent Interface (MII) and Reduced Media Independent
Interface (RMII) to physical layer (PHY).

Phy which supports MII is present on the DA850/OMAP-L138
base board and Phy supporting RMII is present on the
UI card. This patch adds support only for the MII Phy.
Support for RMII Phy will be added later.

Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
---
 This patch depends on the following two patches which I
 have submitted earlier:
 [PATCH v3 1/2] davinci: Add base DA850/OMAP-L138 SoC support
 [PATCH v3 2/2] davinci: Add support for DA850/OMAP-L138 EVM board

 This patch has been tested for NFS boot on DA850/OMAP-L138 EVM.

 arch/arm/mach-davinci/board-da850-evm.c    |   18 ++++++++++++++++
 arch/arm/mach-davinci/da850.c              |   31 ++++++++++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/da8xx.h |    1 +
 arch/arm/mach-davinci/include/mach/mux.h   |   17 +++++++++++++++
 4 files changed, 67 insertions(+), 0 deletions(-)

Comments

Kevin Hilman July 17, 2009, 2:53 p.m. UTC | #1
Sudhakar Rajashekhara <sudhakar.raj@ti.com> writes:

> Ethernet Media Access Controller (EMAC) on da850/omap-l138
> supports 10/100 Mbps operation. It also supports Media
> Independent Interface (MII) and Reduced Media Independent
> Interface (RMII) to physical layer (PHY).
>
> Phy which supports MII is present on the DA850/OMAP-L138
> base board and Phy supporting RMII is present on the
> UI card. This patch adds support only for the MII Phy.
> Support for RMII Phy will be added later.
>
> Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>

Thanks, pushing today.

I assume this board has a MAC in EEPROM someplace right?   Currently
this gets a random MAC from the EMAC driver.

Kevin
Rajashekhara, Sudhakar July 20, 2009, 1:56 p.m. UTC | #2
On Fri, Jul 17, 2009 at 20:23:36, Kevin Hilman wrote:
> Sudhakar Rajashekhara <sudhakar.raj@ti.com> writes:
> 
> > Ethernet Media Access Controller (EMAC) on da850/omap-l138
> > supports 10/100 Mbps operation. It also supports Media
> > Independent Interface (MII) and Reduced Media Independent
> > Interface (RMII) to physical layer (PHY).
> >
> > Phy which supports MII is present on the DA850/OMAP-L138
> > base board and Phy supporting RMII is present on the
> > UI card. This patch adds support only for the MII Phy.
> > Support for RMII Phy will be added later.
> >
> > Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
> 
> Thanks, pushing today.
> 
> I assume this board has a MAC in EEPROM someplace right?   Currently
> this gets a random MAC from the EMAC driver.
> 

On da850/omap-l138 EVM MAC address is stored on SPI flash. As of
now there is no memory accessor implementation to read the MAC
address from SPI flash. I can submit a patch to get the MAC
address in Linux through kernel command line.

Regards, Sudhakar
Kevin Hilman July 20, 2009, 2:17 p.m. UTC | #3
"Sudhakar Rajashekhara" <sudhakar.raj@ti.com> writes:

> On Fri, Jul 17, 2009 at 20:23:36, Kevin Hilman wrote:
>> Sudhakar Rajashekhara <sudhakar.raj@ti.com> writes:
>> 
>> > Ethernet Media Access Controller (EMAC) on da850/omap-l138
>> > supports 10/100 Mbps operation. It also supports Media
>> > Independent Interface (MII) and Reduced Media Independent
>> > Interface (RMII) to physical layer (PHY).
>> >
>> > Phy which supports MII is present on the DA850/OMAP-L138
>> > base board and Phy supporting RMII is present on the
>> > UI card. This patch adds support only for the MII Phy.
>> > Support for RMII Phy will be added later.
>> >
>> > Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
>> 
>> Thanks, pushing today.
>> 
>> I assume this board has a MAC in EEPROM someplace right?   Currently
>> this gets a random MAC from the EMAC driver.
>> 
>
> On da850/omap-l138 EVM MAC address is stored on SPI flash. As of
> now there is no memory accessor implementation to read the MAC
> address from SPI flash. I can submit a patch to get the MAC
> address in Linux through kernel command line.

Lets not bother with cmdline since it's not a standard cmdline option.
The SPI driver is almost ready, so we can wait for that instead IMO.

Kevin
Rajashekhara, Sudhakar July 21, 2009, 5:24 a.m. UTC | #4
On Mon, Jul 20, 2009 at 19:47:25, Kevin Hilman wrote:
> "Sudhakar Rajashekhara" <sudhakar.raj@ti.com> writes:
> 
> > On Fri, Jul 17, 2009 at 20:23:36, Kevin Hilman wrote:
> >> Sudhakar Rajashekhara <sudhakar.raj@ti.com> writes:
> >> 
> >> > Ethernet Media Access Controller (EMAC) on da850/omap-l138 supports 
> >> > 10/100 Mbps operation. It also supports Media Independent Interface 
> >> > (MII) and Reduced Media Independent Interface (RMII) to physical 
> >> > layer (PHY).
> >> >
> >> > Phy which supports MII is present on the DA850/OMAP-L138 base board 
> >> > and Phy supporting RMII is present on the UI card. This patch adds 
> >> > support only for the MII Phy.
> >> > Support for RMII Phy will be added later.
> >> >
> >> > Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
> >> 
> >> Thanks, pushing today.
> >> 
> >> I assume this board has a MAC in EEPROM someplace right?   Currently
> >> this gets a random MAC from the EMAC driver.
> >> 
> >
> > On da850/omap-l138 EVM MAC address is stored on SPI flash. As of now 
> > there is no memory accessor implementation to read the MAC address 
> > from SPI flash. I can submit a patch to get the MAC address in Linux 
> > through kernel command line.
> 
> Lets not bother with cmdline since it's not a standard cmdline option.
> The SPI driver is almost ready, so we can wait for that instead IMO.
> 

Even if the SPI controller driver is present, the MTD driver to support
the SPI flash (drivers/mtd/devices/m25p80.c) does not support memory
accessor interface. We may have to implement this to support reading
the MAC address from SPI flash.

After implementing the memory accessor interface for the MTD driver,
the initialization order of MTD and net drivers has to be modified.
Currently MTD drivers are getting initialized after network drivers.

Any thoughts on the above points?

Regards, Sudhakar
Kevin Hilman July 21, 2009, 4:13 p.m. UTC | #5
"Sudhakar Rajashekhara" <sudhakar.raj@ti.com> writes:

> On Mon, Jul 20, 2009 at 19:47:25, Kevin Hilman wrote:
>> "Sudhakar Rajashekhara" <sudhakar.raj@ti.com> writes:
>> 
>> > On Fri, Jul 17, 2009 at 20:23:36, Kevin Hilman wrote:
>> >> Sudhakar Rajashekhara <sudhakar.raj@ti.com> writes:
>> >> 
>> >> > Ethernet Media Access Controller (EMAC) on da850/omap-l138 supports 
>> >> > 10/100 Mbps operation. It also supports Media Independent Interface 
>> >> > (MII) and Reduced Media Independent Interface (RMII) to physical 
>> >> > layer (PHY).
>> >> >
>> >> > Phy which supports MII is present on the DA850/OMAP-L138 base board 
>> >> > and Phy supporting RMII is present on the UI card. This patch adds 
>> >> > support only for the MII Phy.
>> >> > Support for RMII Phy will be added later.
>> >> >
>> >> > Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
>> >> 
>> >> Thanks, pushing today.
>> >> 
>> >> I assume this board has a MAC in EEPROM someplace right?   Currently
>> >> this gets a random MAC from the EMAC driver.
>> >> 
>> >
>> > On da850/omap-l138 EVM MAC address is stored on SPI flash. As of now 
>> > there is no memory accessor implementation to read the MAC address 
>> > from SPI flash. I can submit a patch to get the MAC address in Linux 
>> > through kernel command line.
>> 
>> Lets not bother with cmdline since it's not a standard cmdline option.
>> The SPI driver is almost ready, so we can wait for that instead IMO.
>> 
>
> Even if the SPI controller driver is present, the MTD driver to support
> the SPI flash (drivers/mtd/devices/m25p80.c) does not support memory
> accessor interface. We may have to implement this to support reading
> the MAC address from SPI flash.

Sounds right.  The memory_accessor additions should be quick to
go upstream.

> After implementing the memory accessor interface for the MTD driver,
> the initialization order of MTD and net drivers has to be modified.
> Currently MTD drivers are getting initialized after network drivers.

Sounds like a good discussion topic for linux-mtd.

Kevin
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index eaa1fc1..d989346 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -26,6 +26,9 @@ 
 #include <mach/cp_intc.h>
 #include <mach/da8xx.h>
 
+#define DA850_EVM_PHY_MASK		0x1
+#define DA850_EVM_MDIO_FREQUENCY	2200000 /* PHY bus frequency */
+
 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
 	.bus_freq	= 100,	/* kHz */
 	.bus_delay	= 0,	/* usec */
@@ -37,6 +40,7 @@  static struct davinci_uart_config da850_evm_uart_config __initdata = {
 
 static __init void da850_evm_init(void)
 {
+	struct davinci_soc_info *soc_info = &davinci_soc_info;
 	int ret;
 
 	ret = da8xx_register_edma();
@@ -54,6 +58,20 @@  static __init void da850_evm_init(void)
 		pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
 				ret);
 
+	soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
+	soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
+	soc_info->emac_pdata->rmii_en = 0;
+
+	ret = da8xx_pinmux_setup(da850_cpgmac_pins);
+	if (ret)
+		pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
+				ret);
+
+	ret = da8xx_register_emac();
+	if (ret)
+		pr_warning("da850_evm_init: emac registration failed: %d\n",
+				ret);
+
 	ret = da8xx_register_watchdog();
 	if (ret)
 		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 332cf7f..4a43ae2 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -283,6 +283,12 @@  static struct clk rmii_clk = {
 	.parent		= &pll0_sysclk7,
 };
 
+static struct clk emac_clk = {
+	.name		= "emac",
+	.parent		= &pll0_sysclk4,
+	.lpsc		= DA8XX_LPSC1_CPGMAC,
+};
+
 static struct davinci_clk da850_clks[] = {
 	CLK(NULL,		"ref",		&ref_clk),
 	CLK(NULL,		"pll0",		&pll0_clk),
@@ -319,6 +325,7 @@  static struct davinci_clk da850_clks[] = {
 	CLK(NULL,		"emif3",	&emif3_clk),
 	CLK(NULL,		"arm",		&arm_clk),
 	CLK(NULL,		"rmii",		&rmii_clk),
+	CLK("davinci_emac.1",	NULL,		&emac_clk),
 	CLK(NULL,		NULL,		NULL),
 };
 
@@ -347,6 +354,22 @@  static const struct mux_config da850_pins[] = {
 	/* I2C0 function */
 	MUX_CFG(DA850, I2C0_SDA,	4,	12,	15,	2,	false)
 	MUX_CFG(DA850, I2C0_SCL,	4,	8,	15,	2,	false)
+	/* EMAC function */
+	MUX_CFG(DA850, MII_TXEN,	2,	4,	15,	8,	false)
+	MUX_CFG(DA850, MII_TXCLK,	2,	8,	15,	8,	false)
+	MUX_CFG(DA850, MII_COL,		2,	12,	15,	8,	false)
+	MUX_CFG(DA850, MII_TXD_3,	2,	16,	15,	8,	false)
+	MUX_CFG(DA850, MII_TXD_2,	2,	20,	15,	8,	false)
+	MUX_CFG(DA850, MII_TXD_1,	2,	24,	15,	8,	false)
+	MUX_CFG(DA850, MII_TXD_0,	2,	28,	15,	8,	false)
+	MUX_CFG(DA850, MII_RXCLK,	3,	0,	15,	8,	false)
+	MUX_CFG(DA850, MII_RXDV,	3,	4,	15,	8,	false)
+	MUX_CFG(DA850, MII_RXER,	3,	8,	15,	8,	false)
+	MUX_CFG(DA850, MII_CRS,		3,	12,	15,	8,	false)
+	MUX_CFG(DA850, MII_RXD_3,	3,	16,	15,	8,	false)
+	MUX_CFG(DA850, MII_RXD_2,	3,	20,	15,	8,	false)
+	MUX_CFG(DA850, MII_RXD_1,	3,	24,	15,	8,	false)
+	MUX_CFG(DA850, MII_RXD_0,	3,	28,	15,	8,	false)
 #endif
 };
 
@@ -375,6 +398,14 @@  const short da850_i2c1_pins[] __initdata = {
 	-1
 };
 
+const short da850_cpgmac_pins[] __initdata = {
+	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
+	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
+	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
+	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0,
+	-1
+};
+
 /* FIQ are pri 0-1; otherwise 2-7, with 7 lowest priority */
 static u8 da850_default_priorities[DA850_N_CP_INTC_IRQ] = {
 	[IRQ_DA8XX_COMMTX]		= 7,
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h
index 594f988..a8cb570 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -99,6 +99,7 @@  extern const short da850_uart1_pins[];
 extern const short da850_uart2_pins[];
 extern const short da850_i2c0_pins[];
 extern const short da850_i2c1_pins[];
+extern const short da850_cpgmac_pins[];
 
 int da8xx_pinmux_setup(const short pins[]);
 
diff --git a/arch/arm/mach-davinci/include/mach/mux.h b/arch/arm/mach-davinci/include/mach/mux.h
index 3349fa5..368fca6 100644
--- a/arch/arm/mach-davinci/include/mach/mux.h
+++ b/arch/arm/mach-davinci/include/mach/mux.h
@@ -730,6 +730,23 @@  enum davinci_da850_index {
 	/* I2C0 function */
 	DA850_I2C0_SDA,
 	DA850_I2C0_SCL,
+
+	/* EMAC function */
+	DA850_MII_TXEN,
+	DA850_MII_TXCLK,
+	DA850_MII_COL,
+	DA850_MII_TXD_3,
+	DA850_MII_TXD_2,
+	DA850_MII_TXD_1,
+	DA850_MII_TXD_0,
+	DA850_MII_RXER,
+	DA850_MII_CRS,
+	DA850_MII_RXCLK,
+	DA850_MII_RXDV,
+	DA850_MII_RXD_3,
+	DA850_MII_RXD_2,
+	DA850_MII_RXD_1,
+	DA850_MII_RXD_0,
 };
 
 #ifdef CONFIG_DAVINCI_MUX