From: Angelo Dureghello <angelo.dureghello@timesys.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 9/9] drivers: mcfmii: add dm support
Date: Fri, 15 Nov 2019 23:54:20 +0100 [thread overview]
Message-ID: <20191115225420.1445889-9-angelo.dureghello@timesys.com> (raw)
In-Reply-To: <20191115225420.1445889-1-angelo.dureghello@timesys.com>
From: Angelo Durgehello <angelo.dureghello@timesys.com>
Add specific dm code, but maintaining this driver as is, so more in the
shape of a mii library. Can be moved to dm in a further step.
Signed-off-by: Angelo Durgehello <angelo.dureghello@timesys.com>
---
drivers/net/mcfmii.c | 48 +++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/drivers/net/mcfmii.c b/drivers/net/mcfmii.c
index 961618b410..27b7c5149f 100644
--- a/drivers/net/mcfmii.c
+++ b/drivers/net/mcfmii.c
@@ -40,14 +40,6 @@ DECLARE_GLOBAL_DATA_PTR;
# define CONFIG_SYS_UNSPEC_STRID 0
#endif
-#ifdef CONFIG_MCF547x_8x
-typedef struct fec_info_dma FEC_INFO_T;
-#define FEC_T fecdma_t
-#else
-typedef struct fec_info_s FEC_INFO_T;
-#define FEC_T fec_t
-#endif
-
typedef struct phy_info_struct {
u32 phyid;
char *strid;
@@ -77,7 +69,7 @@ phy_info_t phyinfo[] = {
* mii_init -- Initialize the MII for MII command without ethernet
* This function is a subset of eth_init
*/
-void mii_reset(FEC_INFO_T *info)
+void mii_reset(fec_info_t *info)
{
volatile FEC_T *fecp = (FEC_T *) (info->miibase);
int i;
@@ -94,9 +86,13 @@ void mii_reset(FEC_INFO_T *info)
/* send command to phy using mii, wait for result */
uint mii_send(uint mii_cmd)
{
- FEC_INFO_T *info;
- volatile FEC_T *ep;
+#ifdef CONFIG_DM_ETH
+ struct udevice *dev;
+#else
struct eth_device *dev;
+#endif
+ fec_info_t *info;
+ volatile FEC_T *ep;
uint mii_reply;
int j = 0;
@@ -109,11 +105,11 @@ uint mii_send(uint mii_cmd)
ep->mmfr = mii_cmd; /* command to phy */
/* wait for mii complete */
- while (!(ep->eir & FEC_EIR_MII) && (j < MCFFEC_TOUT_LOOP)) {
+ while (!(ep->eir & FEC_EIR_MII) && (j < info->to_loop)) {
udelay(1);
j++;
}
- if (j >= MCFFEC_TOUT_LOOP) {
+ if (j >= info->to_loop) {
printf("MII not complete\n");
return -1;
}
@@ -130,10 +126,9 @@ uint mii_send(uint mii_cmd)
#endif /* CONFIG_SYS_DISCOVER_PHY || (CONFIG_MII) */
#if defined(CONFIG_SYS_DISCOVER_PHY)
-int mii_discover_phy(struct eth_device *dev)
+int mii_discover_phy(fec_info_t *info)
{
#define MAX_PHY_PASSES 11
- FEC_INFO_T *info = dev->priv;
int phyaddr, pass;
uint phyno, phytype;
int i, found = 0;
@@ -156,7 +151,7 @@ int mii_discover_phy(struct eth_device *dev)
phytype = mii_send(mk_mii_read(phyno, MII_PHYSID1));
#ifdef ET_DEBUG
- printf("PHY type 0x%x pass %d type\n", phytype, pass);
+ printf("PHY type 0x%x pass %d\n", phytype, pass);
#endif
if (phytype == 0xffff)
continue;
@@ -206,9 +201,13 @@ void mii_init(void) __attribute__((weak,alias("__mii_init")));
void __mii_init(void)
{
- FEC_INFO_T *info;
- volatile FEC_T *fecp;
+#ifdef CONFIG_DM_ETH
+ struct udevice *dev;
+#else
struct eth_device *dev;
+#endif
+ fec_info_t *info;
+ volatile FEC_T *fecp;
int miispd = 0, i = 0;
u16 status = 0;
u16 linkgood = 0;
@@ -219,7 +218,7 @@ void __mii_init(void)
fecp = (FEC_T *) info->miibase;
- fecpin_setclear(dev, 1);
+ fecpin_setclear(info, 1);
mii_reset(info);
@@ -233,9 +232,13 @@ void __mii_init(void)
miispd = (gd->bus_clk / 1000000) / 5;
fecp->mscr = miispd << 1;
- info->phy_addr = mii_discover_phy(dev);
+#ifdef CONFIG_SYS_DISCOVER_PHY
+ info->phy_addr = mii_discover_phy(info);
+#endif
+ if (info->phy_addr == -1)
+ return;
- while (i < MCFFEC_TOUT_LOOP) {
+ while (i < info->to_loop) {
status = 0;
i++;
/* Read PHY control register */
@@ -256,9 +259,8 @@ void __mii_init(void)
udelay(1);
}
- if (i >= MCFFEC_TOUT_LOOP) {
+ if (i >= info->to_loop)
printf("Link UP timeout\n");
- }
/* adapt to the duplex and speed settings of the phy */
info->dup_spd = miiphy_duplex(dev->name, info->phy_addr) << 16;
--
2.24.0
next prev parent reply other threads:[~2019-11-15 22:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-15 22:54 [U-Boot] [PATCH 1/9] m68k: add fec base node to devicetrees Angelo Dureghello
2019-11-15 22:54 ` [U-Boot] [PATCH 2/9] m68k: add fec fdt overrides to all boards Angelo Dureghello
2020-01-10 21:48 ` Tom Rini
2019-11-15 22:54 ` [U-Boot] [PATCH 3/9] configs: add eth dm support for all ColdFire boards Angelo Dureghello
2020-01-10 21:49 ` Tom Rini
2019-11-15 22:54 ` [U-Boot] [PATCH 4/9] configs: purge unneeded fec defines Angelo Dureghello
2020-01-10 21:49 ` Tom Rini
2019-11-15 22:54 ` [U-Boot] [PATCH 5/9] m68k: add dm fec support Angelo Dureghello
2020-01-10 21:49 ` Tom Rini
2019-11-15 22:54 ` [U-Boot] [PATCH 6/9] drivers: net: add mcf fec dm Kconfig support Angelo Dureghello
2020-01-10 21:49 ` Tom Rini
2019-11-15 22:54 ` [U-Boot] [PATCH 7/9] drivers: mcffec: conversion to dm Angelo Dureghello
2020-01-10 21:49 ` Tom Rini
2019-11-15 22:54 ` [U-Boot] [PATCH 8/9] drivers: fsl_mcdmafec: " Angelo Dureghello
2020-01-10 21:49 ` Tom Rini
2019-11-15 22:54 ` Angelo Dureghello [this message]
2020-01-10 21:49 ` [U-Boot] [PATCH 9/9] drivers: mcfmii: add dm support Tom Rini
2020-01-10 21:48 ` [U-Boot] [PATCH 1/9] m68k: add fec base node to devicetrees Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191115225420.1445889-9-angelo.dureghello@timesys.com \
--to=angelo.dureghello@timesys.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox