* [U-Boot] [PATCH] net, davinci_emac: add KSZ8864 switch
@ 2011-09-15 5:36 Heiko Schocher
2011-09-15 15:32 ` Mike Frysinger
2011-09-19 5:49 ` [U-Boot] [PATCH v2] " Heiko Schocher
0 siblings, 2 replies; 5+ messages in thread
From: Heiko Schocher @ 2011-09-15 5:36 UTC (permalink / raw)
To: u-boot
Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Paulraj Sandeep <s-paulraj@ti.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
---
arch/arm/cpu/arm926ejs/davinci/Makefile | 2 +-
arch/arm/cpu/arm926ejs/davinci/ksz8873.c | 74 +++++++++++++++++++++++++
arch/arm/include/asm/arch-davinci/emac_defs.h | 6 ++
drivers/net/davinci_emac.c | 7 ++
4 files changed, 88 insertions(+), 1 deletions(-)
create mode 100644 arch/arm/cpu/arm926ejs/davinci/ksz8873.c
diff --git a/arch/arm/cpu/arm926ejs/davinci/Makefile b/arch/arm/cpu/arm926ejs/davinci/Makefile
index 3183e6a..b38623a 100644
--- a/arch/arm/cpu/arm926ejs/davinci/Makefile
+++ b/arch/arm/cpu/arm926ejs/davinci/Makefile
@@ -32,7 +32,7 @@ COBJS-$(CONFIG_SOC_DM355) += dm355.o
COBJS-$(CONFIG_SOC_DM365) += dm365.o
COBJS-$(CONFIG_SOC_DM644X) += dm644x.o
COBJS-$(CONFIG_SOC_DM646X) += dm646x.o
-COBJS-$(CONFIG_DRIVER_TI_EMAC) += lxt972.o dp83848.o et1011c.o
+COBJS-$(CONFIG_DRIVER_TI_EMAC) += lxt972.o dp83848.o et1011c.o ksz8873.o
SOBJS = reset.o
diff --git a/arch/arm/cpu/arm926ejs/davinci/ksz8873.c b/arch/arm/cpu/arm926ejs/davinci/ksz8873.c
new file mode 100644
index 0000000..88929aa
--- /dev/null
+++ b/arch/arm/cpu/arm926ejs/davinci/ksz8873.c
@@ -0,0 +1,74 @@
+/*
+ * Micrel KSZ8873 PHY Driver for TI DaVinci
+ * (TMS320DM644x) based boards.
+ *
+ * Copyright (C) 2011 Heiko Schocher <hsdenx.de>
+ *
+ * based on:
+ * National Semiconductor DP83848 PHY Driver for TI DaVinci
+ * (TMS320DM644x) based boards.
+ *
+ * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
+ *
+ * --------------------------------------------------------
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <miiphy.h>
+#include <net.h>
+#include <asm/arch/emac_defs.h>
+#include <asm/io.h>
+
+#ifdef CONFIG_DRIVER_TI_EMAC
+
+#ifdef CONFIG_CMD_NET
+
+int ksz8873_is_phy_connected(int phy_addr)
+{
+ u_int16_t dummy;
+
+ return davinci_eth_phy_read(phy_addr, MII_PHYSID1, &dummy);
+}
+
+int ksz8873_get_link_speed(int phy_addr)
+{
+ emac_regs *emac = (emac_regs *)EMAC_BASE_ADDR;
+
+ /* we always have a link to the switch, 100 FD */
+ writel((EMAC_MACCONTROL_MIIEN_ENABLE |
+ EMAC_MACCONTROL_FULLDUPLEX_ENABLE),
+ &emac->MACCONTROL);
+ return 1;
+}
+
+
+int ksz8873_init_phy(int phy_addr)
+{
+ return 1;
+}
+
+
+int ksz8873_auto_negotiate(int phy_addr)
+{
+ return dp83848_get_link_speed(phy_addr);
+}
+#endif /* CONFIG_CMD_NET */
+#endif /* CONFIG_DRIVER_ETHER */
diff --git a/arch/arm/include/asm/arch-davinci/emac_defs.h b/arch/arm/include/asm/arch-davinci/emac_defs.h
index 4a4ee04..294a9a8 100644
--- a/arch/arm/include/asm/arch-davinci/emac_defs.h
+++ b/arch/arm/include/asm/arch-davinci/emac_defs.h
@@ -377,6 +377,12 @@ typedef struct
int (*auto_negotiate)(int phy_addr);
} phy_t;
+#define PHY_KSZ8873 (0x00221450)
+int ksz8873_is_phy_connected(int phy_addr);
+int ksz8873_get_link_speed(int phy_addr);
+int ksz8873_init_phy(int phy_addr);
+int ksz8873_auto_negotiate(int phy_addr);
+
#define PHY_LXT972 (0x001378e2)
int lxt972_is_phy_connected(int phy_addr);
int lxt972_get_link_speed(int phy_addr);
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 5b8ab2d..d58c28b 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -711,6 +711,13 @@ int davinci_emac_initialize(void)
phy_id |= tmp & 0x0000ffff;
switch (phy_id) {
+ case PHY_KSZ8873:
+ sprintf(phy.name, "KSZ8873 @ 0x%02x", active_phy_addr);
+ phy.init = ksz8873_init_phy;
+ phy.is_phy_connected = ksz8873_is_phy_connected;
+ phy.get_link_speed = ksz8873_get_link_speed;
+ phy.auto_negotiate = ksz8873_auto_negotiate;
+ break;
case PHY_LXT972:
sprintf(phy.name, "LXT972 @ 0x%02x", active_phy_addr);
phy.init = lxt972_init_phy;
--
1.7.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] net, davinci_emac: add KSZ8864 switch
2011-09-15 5:36 [U-Boot] [PATCH] net, davinci_emac: add KSZ8864 switch Heiko Schocher
@ 2011-09-15 15:32 ` Mike Frysinger
2011-09-16 5:46 ` Heiko Schocher
2011-09-19 5:49 ` [U-Boot] [PATCH v2] " Heiko Schocher
1 sibling, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2011-09-15 15:32 UTC (permalink / raw)
To: u-boot
On Thursday, September 15, 2011 01:36:09 Heiko Schocher wrote:
> --- /dev/null
> +++ b/arch/arm/cpu/arm926ejs/davinci/ksz8873.c
>
> +#ifdef CONFIG_DRIVER_TI_EMAC
this file is only built when this is defined, so this is useless
> +#ifdef CONFIG_CMD_NET
building net drivers but not enabling CMD_NET is a config error. dont bother
checking this yourself.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110915/16a384f6/attachment.pgp
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] net, davinci_emac: add KSZ8864 switch
2011-09-15 15:32 ` Mike Frysinger
@ 2011-09-16 5:46 ` Heiko Schocher
0 siblings, 0 replies; 5+ messages in thread
From: Heiko Schocher @ 2011-09-16 5:46 UTC (permalink / raw)
To: u-boot
Hello Mike,
Mike Frysinger wrote:
> On Thursday, September 15, 2011 01:36:09 Heiko Schocher wrote:
>> --- /dev/null
>> +++ b/arch/arm/cpu/arm926ejs/davinci/ksz8873.c
>>
>> +#ifdef CONFIG_DRIVER_TI_EMAC
>
> this file is only built when this is defined, so this is useless
>
>> +#ifdef CONFIG_CMD_NET
>
> building net drivers but not enabling CMD_NET is a config error. dont bother
> checking this yourself.
Post this change in a v2, thanks for the review!
bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2] net, davinci_emac: add KSZ8864 switch
2011-09-15 5:36 [U-Boot] [PATCH] net, davinci_emac: add KSZ8864 switch Heiko Schocher
2011-09-15 15:32 ` Mike Frysinger
@ 2011-09-19 5:49 ` Heiko Schocher
2011-09-23 19:35 ` Paulraj, Sandeep
1 sibling, 1 reply; 5+ messages in thread
From: Heiko Schocher @ 2011-09-19 5:49 UTC (permalink / raw)
To: u-boot
Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Paulraj Sandeep <s-paulraj@ti.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Cc: Mike Frysinger <vapier@gentoo.org>
---
- changes for v2:
- add comment from Mike Frysinger
remove check if CONFIG_DRIVER_TI_EMAC and CONFIG_CMD_NET
are defined.
arch/arm/cpu/arm926ejs/davinci/Makefile | 2 +-
arch/arm/cpu/arm926ejs/davinci/ksz8873.c | 68 +++++++++++++++++++++++++
arch/arm/include/asm/arch-davinci/emac_defs.h | 6 ++
drivers/net/davinci_emac.c | 7 +++
4 files changed, 82 insertions(+), 1 deletions(-)
create mode 100644 arch/arm/cpu/arm926ejs/davinci/ksz8873.c
diff --git a/arch/arm/cpu/arm926ejs/davinci/Makefile b/arch/arm/cpu/arm926ejs/davinci/Makefile
index 3183e6a..b38623a 100644
--- a/arch/arm/cpu/arm926ejs/davinci/Makefile
+++ b/arch/arm/cpu/arm926ejs/davinci/Makefile
@@ -32,7 +32,7 @@ COBJS-$(CONFIG_SOC_DM355) += dm355.o
COBJS-$(CONFIG_SOC_DM365) += dm365.o
COBJS-$(CONFIG_SOC_DM644X) += dm644x.o
COBJS-$(CONFIG_SOC_DM646X) += dm646x.o
-COBJS-$(CONFIG_DRIVER_TI_EMAC) += lxt972.o dp83848.o et1011c.o
+COBJS-$(CONFIG_DRIVER_TI_EMAC) += lxt972.o dp83848.o et1011c.o ksz8873.o
SOBJS = reset.o
diff --git a/arch/arm/cpu/arm926ejs/davinci/ksz8873.c b/arch/arm/cpu/arm926ejs/davinci/ksz8873.c
new file mode 100644
index 0000000..634eda0
--- /dev/null
+++ b/arch/arm/cpu/arm926ejs/davinci/ksz8873.c
@@ -0,0 +1,68 @@
+/*
+ * Micrel KSZ8873 PHY Driver for TI DaVinci
+ * (TMS320DM644x) based boards.
+ *
+ * Copyright (C) 2011 Heiko Schocher <hsdenx.de>
+ *
+ * based on:
+ * National Semiconductor DP83848 PHY Driver for TI DaVinci
+ * (TMS320DM644x) based boards.
+ *
+ * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
+ *
+ * --------------------------------------------------------
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <miiphy.h>
+#include <net.h>
+#include <asm/arch/emac_defs.h>
+#include <asm/io.h>
+
+int ksz8873_is_phy_connected(int phy_addr)
+{
+ u_int16_t dummy;
+
+ return davinci_eth_phy_read(phy_addr, MII_PHYSID1, &dummy);
+}
+
+int ksz8873_get_link_speed(int phy_addr)
+{
+ emac_regs *emac = (emac_regs *)EMAC_BASE_ADDR;
+
+ /* we always have a link to the switch, 100 FD */
+ writel((EMAC_MACCONTROL_MIIEN_ENABLE |
+ EMAC_MACCONTROL_FULLDUPLEX_ENABLE),
+ &emac->MACCONTROL);
+ return 1;
+}
+
+
+int ksz8873_init_phy(int phy_addr)
+{
+ return 1;
+}
+
+
+int ksz8873_auto_negotiate(int phy_addr)
+{
+ return dp83848_get_link_speed(phy_addr);
+}
diff --git a/arch/arm/include/asm/arch-davinci/emac_defs.h b/arch/arm/include/asm/arch-davinci/emac_defs.h
index 4a4ee04..294a9a8 100644
--- a/arch/arm/include/asm/arch-davinci/emac_defs.h
+++ b/arch/arm/include/asm/arch-davinci/emac_defs.h
@@ -377,6 +377,12 @@ typedef struct
int (*auto_negotiate)(int phy_addr);
} phy_t;
+#define PHY_KSZ8873 (0x00221450)
+int ksz8873_is_phy_connected(int phy_addr);
+int ksz8873_get_link_speed(int phy_addr);
+int ksz8873_init_phy(int phy_addr);
+int ksz8873_auto_negotiate(int phy_addr);
+
#define PHY_LXT972 (0x001378e2)
int lxt972_is_phy_connected(int phy_addr);
int lxt972_get_link_speed(int phy_addr);
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 5b8ab2d..d58c28b 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -711,6 +711,13 @@ int davinci_emac_initialize(void)
phy_id |= tmp & 0x0000ffff;
switch (phy_id) {
+ case PHY_KSZ8873:
+ sprintf(phy.name, "KSZ8873 @ 0x%02x", active_phy_addr);
+ phy.init = ksz8873_init_phy;
+ phy.is_phy_connected = ksz8873_is_phy_connected;
+ phy.get_link_speed = ksz8873_get_link_speed;
+ phy.auto_negotiate = ksz8873_auto_negotiate;
+ break;
case PHY_LXT972:
sprintf(phy.name, "LXT972 @ 0x%02x", active_phy_addr);
phy.init = lxt972_init_phy;
--
1.7.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2] net, davinci_emac: add KSZ8864 switch
2011-09-19 5:49 ` [U-Boot] [PATCH v2] " Heiko Schocher
@ 2011-09-23 19:35 ` Paulraj, Sandeep
0 siblings, 0 replies; 5+ messages in thread
From: Paulraj, Sandeep @ 2011-09-23 19:35 UTC (permalink / raw)
To: u-boot
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> Cc: Paulraj Sandeep <s-paulraj@ti.com>
> Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
> Cc: Mike Frysinger <vapier@gentoo.org>
> ---
> - changes for v2:
> - add comment from Mike Frysinger
> remove check if CONFIG_DRIVER_TI_EMAC and CONFIG_CMD_NET
> are defined.
>
> arch/arm/cpu/arm926ejs/davinci/Makefile | 2 +-
> arch/arm/cpu/arm926ejs/davinci/ksz8873.c | 68
> +++++++++++++++++++++++++
> arch/arm/include/asm/arch-davinci/emac_defs.h | 6 ++
> drivers/net/davinci_emac.c | 7 +++
> 4 files changed, 82 insertions(+), 1 deletions(-)
> create mode 100644 arch/arm/cpu/arm926ejs/davinci/ksz8873.c
>
> diff --git a/arch/arm/cpu/arm926ejs/davinci/Makefile
> b/arch/arm/cpu/arm926ejs/davinci/Makefile
> index 3183e6a..b38623a 100644
> --- a/arch/arm/cpu/arm926ejs/davinci/Makefile
> +++ b/arch/arm/cpu/arm926ejs/davinci/Makefile
> @@ -32,7 +32,7 @@ COBJS-$(CONFIG_SOC_DM355) += dm355.o
> COBJS-$(CONFIG_SOC_DM365) += dm365.o
> COBJS-$(CONFIG_SOC_DM644X) += dm644x.o
> COBJS-$(CONFIG_SOC_DM646X) += dm646x.o
> -COBJS-$(CONFIG_DRIVER_TI_EMAC) += lxt972.o dp83848.o et1011c.o
> +COBJS-$(CONFIG_DRIVER_TI_EMAC) += lxt972.o dp83848.o et1011c.o
> ksz8873.o
Pushed to u-boot-ti/next
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-09-23 19:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-15 5:36 [U-Boot] [PATCH] net, davinci_emac: add KSZ8864 switch Heiko Schocher
2011-09-15 15:32 ` Mike Frysinger
2011-09-16 5:46 ` Heiko Schocher
2011-09-19 5:49 ` [U-Boot] [PATCH v2] " Heiko Schocher
2011-09-23 19:35 ` Paulraj, Sandeep
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox