Re: [U-Boot] [PATCH v3 02/13] net: fec_mxc: Convert into driver model

2016-12-09 Thread Jagan Teki
On Dec 9, 2016 7:22 PM, "Joe Hershberger"  wrote:

Hi Jagan,

On Mon, Dec 5, 2016 at 5:00 PM, Jagan Teki  wrote:
> From: Jagan Teki 
>
> This patch add driver model support for fec_mxc driver.
>
> Cc: Simon Glass 
> Cc: Joe Hershberger 
> Cc: Peng Fan 
> Cc: Stefano Babic 
> Cc: Michael Trimarchi 
> Signed-off-by: Jagan Teki 
> ---
> Changes for v3:
> - Removed the stub functions[1] and revert back to previous changes where
#ifdef on
>   each function call. We can't use the stub functions to minimize the
#ifdef's as the
>   driver is organize the code in such a way that it can't modularized the
code. So better
>   to use #ifdef to not to break the non-dm.
>
> [1] http://git.denx.de/?p=u-boot/u-boot-imx.git;a=commitdiff;h=
fa2ce02b73fa59fe91d2d0ad61bf837392e03ab9

So the plan is to drop that from u-boot-imx and use this instead? If so,


Yes.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 02/13] net: fec_mxc: Convert into driver model

2016-12-09 Thread Joe Hershberger
Hi Jagan,

On Mon, Dec 5, 2016 at 5:00 PM, Jagan Teki  wrote:
> From: Jagan Teki 
>
> This patch add driver model support for fec_mxc driver.
>
> Cc: Simon Glass 
> Cc: Joe Hershberger 
> Cc: Peng Fan 
> Cc: Stefano Babic 
> Cc: Michael Trimarchi 
> Signed-off-by: Jagan Teki 
> ---
> Changes for v3:
> - Removed the stub functions[1] and revert back to previous changes where 
> #ifdef on
>   each function call. We can't use the stub functions to minimize the 
> #ifdef's as the
>   driver is organize the code in such a way that it can't modularized the 
> code. So better
>   to use #ifdef to not to break the non-dm.
>
> [1] 
> http://git.denx.de/?p=u-boot/u-boot-imx.git;a=commitdiff;h=fa2ce02b73fa59fe91d2d0ad61bf837392e03ab9

So the plan is to drop that from u-boot-imx and use this instead? If so,

Acked-by: Joe Hershberger 

>  drivers/net/fec_mxc.c | 268 
> +-
>  drivers/net/fec_mxc.h |   4 +
>  2 files changed, 246 insertions(+), 26 deletions(-)
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 02/13] net: fec_mxc: Convert into driver model

2016-12-05 Thread Jagan Teki
From: Jagan Teki 

This patch add driver model support for fec_mxc driver.

Cc: Simon Glass 
Cc: Joe Hershberger 
Cc: Peng Fan 
Cc: Stefano Babic 
Cc: Michael Trimarchi 
Signed-off-by: Jagan Teki 
---
Changes for v3:
- Removed the stub functions[1] and revert back to previous changes where 
#ifdef on
  each function call. We can't use the stub functions to minimize the #ifdef's 
as the
  driver is organize the code in such a way that it can't modularized the code. 
So better
  to use #ifdef to not to break the non-dm.

[1] 
http://git.denx.de/?p=u-boot/u-boot-imx.git;a=commitdiff;h=fa2ce02b73fa59fe91d2d0ad61bf837392e03ab9

 drivers/net/fec_mxc.c | 268 +-
 drivers/net/fec_mxc.h |   4 +
 2 files changed, 246 insertions(+), 26 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index b642770..fd96c43 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -9,6 +9,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -368,10 +369,20 @@ static int fec_get_hwaddr(int dev_id, unsigned char *mac)
return !is_valid_ethaddr(mac);
 }
 
+#ifdef CONFIG_DM_ETH
+static int fecmxc_set_hwaddr(struct udevice *dev)
+#else
 static int fec_set_hwaddr(struct eth_device *dev)
+#endif
 {
+#ifdef CONFIG_DM_ETH
+   struct fec_priv *fec = dev_get_priv(dev);
+   struct eth_pdata *pdata = dev_get_platdata(dev);
+   uchar *mac = pdata->enetaddr;
+#else
uchar *mac = dev->enetaddr;
struct fec_priv *fec = (struct fec_priv *)dev->priv;
+#endif
 
writel(0, >eth->iaddr1);
writel(0, >eth->iaddr2);
@@ -426,9 +437,17 @@ static void fec_reg_setup(struct fec_priv *fec)
  * Start the FEC engine
  * @param[in] dev Our device to handle
  */
+#ifdef CONFIG_DM_ETH
+static int fec_open(struct udevice *dev)
+#else
 static int fec_open(struct eth_device *edev)
+#endif
 {
+#ifdef CONFIG_DM_ETH
+   struct fec_priv *fec = dev_get_priv(dev);
+#else
struct fec_priv *fec = (struct fec_priv *)edev->priv;
+#endif
int speed;
uint32_t addr, size;
int i;
@@ -534,14 +553,26 @@ static int fec_open(struct eth_device *edev)
return 0;
 }
 
+#ifdef CONFIG_DM_ETH
+static int fecmxc_init(struct udevice *dev)
+#else
 static int fec_init(struct eth_device *dev, bd_t* bd)
+#endif
 {
+#ifdef CONFIG_DM_ETH
+   struct fec_priv *fec = dev_get_priv(dev);
+#else
struct fec_priv *fec = (struct fec_priv *)dev->priv;
+#endif
uint32_t mib_ptr = (uint32_t)>eth->rmon_t_drop;
int i;
 
/* Initialize MAC address */
+#ifdef CONFIG_DM_ETH
+   fecmxc_set_hwaddr(dev);
+#else
fec_set_hwaddr(dev);
+#endif
 
/*
 * Setup transmit descriptors, there are two in total.
@@ -595,9 +626,17 @@ static int fec_init(struct eth_device *dev, bd_t* bd)
  * Halt the FEC engine
  * @param[in] dev Our device to handle
  */
+#ifdef CONFIG_DM_ETH
+static void fecmxc_halt(struct udevice *dev)
+#else
 static void fec_halt(struct eth_device *dev)
+#endif
 {
+#ifdef CONFIG_DM_ETH
+   struct fec_priv *fec = dev_get_priv(dev);
+#else
struct fec_priv *fec = (struct fec_priv *)dev->priv;
+#endif
int counter = 0x;
 
/*
@@ -637,7 +676,11 @@ static void fec_halt(struct eth_device *dev)
  * @param[in] length Data count in bytes
  * @return 0 on success
  */
+#ifdef CONFIG_DM_ETH
+static int fecmxc_send(struct udevice *dev, void *packet, int length)
+#else
 static int fec_send(struct eth_device *dev, void *packet, int length)
+#endif
 {
unsigned int status;
uint32_t size, end;
@@ -649,7 +692,11 @@ static int fec_send(struct eth_device *dev, void *packet, 
int length)
 * This routine transmits one frame.  This routine only accepts
 * 6-byte Ethernet addresses.
 */
+#ifdef CONFIG_DM_ETH
+   struct fec_priv *fec = dev_get_priv(dev);
+#else
struct fec_priv *fec = (struct fec_priv *)dev->priv;
+#endif
 
/*
 * Check for valid length of data.
@@ -782,9 +829,17 @@ out:
  * @param[in] dev Our ethernet device to handle
  * @return Length of packet read
  */
+#ifdef CONFIG_DM_ETH
+static int fecmxc_recv(struct udevice *dev, int flags, uchar **packetp)
+#else
 static int fec_recv(struct eth_device *dev)
+#endif
 {
+#ifdef CONFIG_DM_ETH
+   struct fec_priv *fec = dev_get_priv(dev);
+#else
struct fec_priv *fec = (struct fec_priv *)dev->priv;
+#endif
struct fec_bd *rbd = >rbd_base[fec->rbd_index];
unsigned long ievent;
int frame_length, len = 0;
@@ -800,8 +855,13 @@ static int fec_recv(struct eth_device *dev)
writel(ievent, >eth->ievent);
debug("fec_recv: ievent 0x%lx\n", ievent);
if (ievent & FEC_IEVENT_BABR) {
+#ifdef CONFIG_DM_ETH
+   fecmxc_halt(dev);
+