diff mbox series

[U-Boot,v3,04/12] net: macb: Fix clk API usage for RISC-V systems

Message ID 20190123042442.106038-5-anup.patel@wdc.com
State Superseded
Delegated to: Andes
Headers show
Series SiFive FU540 Support | expand

Commit Message

Anup Patel Jan. 23, 2019, 4:25 a.m. UTC
This patch does following fixes in MACB ethernet driver
for using it on RISC-V systems (particularly QEMU sifive_u
machine):
1. asm/arch/clk.h is not available on RISC-V port so include
   it only for non-RISC-V systems.
2. Don't fail in macb_enable_clk() if clk_enable() returns
   -ENOSYS because we get -ENOSYS for fixed-rate clocks.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
 drivers/net/macb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Joe Hershberger Jan. 23, 2019, 1:57 p.m. UTC | #1
On Tue, Jan 22, 2019 at 10:31 PM Anup Patel <Anup.Patel@wdc.com> wrote:
>
> This patch does following fixes in MACB ethernet driver
> for using it on RISC-V systems (particularly QEMU sifive_u
> machine):
> 1. asm/arch/clk.h is not available on RISC-V port so include
>    it only for non-RISC-V systems.
> 2. Don't fail in macb_enable_clk() if clk_enable() returns
>    -ENOSYS because we get -ENOSYS for fixed-rate clocks.
>
> Signed-off-by: Anup Patel <anup.patel@wdc.com>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>  drivers/net/macb.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index 94c89c762b..9a06b523cc 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -38,7 +38,9 @@
>  #include <linux/mii.h>
>  #include <asm/io.h>
>  #include <asm/dma-mapping.h>
> +#ifndef CONFIG_RISCV
>  #include <asm/arch/clk.h>

It seems much better to include an empty header than to ifdef here.

> +#endif
>  #include <linux/errno.h>
>
>  #include "macb.h"
> @@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice *dev)
>          */
>  #ifndef CONFIG_MACB_ZYNQ
>         ret = clk_enable(&clk);
> -       if (ret)
> +       if (ret && ret != -ENOSYS)
>                 return ret;
>  #endif
>
> --
> 2.17.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Anup Patel Jan. 23, 2019, 3:40 p.m. UTC | #2
> -----Original Message-----
> From: Joe Hershberger [mailto:joe.hershberger@ni.com]
> Sent: Wednesday, January 23, 2019 7:30 PM
> To: Anup Patel <Anup.Patel@wdc.com>
> Cc: Rick Chen <rick@andestech.com>; Bin Meng <bmeng.cn@gmail.com>;
> Joseph Hershberger <joseph.hershberger@ni.com>; Michal Simek
> <monstr@monstr.eu>; Michal Simek <michal.simek@xilinx.com>; Lukas Auer
> <lukas.auer@aisec.fraunhofer.de>; Masahiro Yamada
> <yamada.masahiro@socionext.com>; Simon Glass <sjg@chromium.org>;
> Palmer Dabbelt <palmer@sifive.com>; U-Boot Mailing List <u-
> boot@lists.denx.de>; Alexander Graf <agraf@suse.de>; Christoph Hellwig
> <hch@infradead.org>; Paul Walmsley <paul.walmsley@sifive.com>
> Subject: Re: [U-Boot] [PATCH v3 04/12] net: macb: Fix clk API usage for RISC-
> V systems
> 
> On Tue, Jan 22, 2019 at 10:31 PM Anup Patel <Anup.Patel@wdc.com> wrote:
> >
> > This patch does following fixes in MACB ethernet driver for using it
> > on RISC-V systems (particularly QEMU sifive_u
> > machine):
> > 1. asm/arch/clk.h is not available on RISC-V port so include
> >    it only for non-RISC-V systems.
> > 2. Don't fail in macb_enable_clk() if clk_enable() returns
> >    -ENOSYS because we get -ENOSYS for fixed-rate clocks.
> >
> > Signed-off-by: Anup Patel <anup.patel@wdc.com>
> > Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >  drivers/net/macb.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/macb.c b/drivers/net/macb.c index
> > 94c89c762b..9a06b523cc 100644
> > --- a/drivers/net/macb.c
> > +++ b/drivers/net/macb.c
> > @@ -38,7 +38,9 @@
> >  #include <linux/mii.h>
> >  #include <asm/io.h>
> >  #include <asm/dma-mapping.h>
> > +#ifndef CONFIG_RISCV
> >  #include <asm/arch/clk.h>
> 
> It seems much better to include an empty header than to ifdef here.

Yes, I had tried this but "make mrproper" was failing for me due to
the "rm" command used in "mrproper" make target.

A place-holder asm/arch/clk.h is possible only if we improve the
"mrproper" make target in top-level Makefile.

I will add two more patches:
1. Improve "mrproper" make target
2. Add place-holder asm/arch/clk.h for RISC-V port

Regards,
Anup
diff mbox series

Patch

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 94c89c762b..9a06b523cc 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -38,7 +38,9 @@ 
 #include <linux/mii.h>
 #include <asm/io.h>
 #include <asm/dma-mapping.h>
+#ifndef CONFIG_RISCV
 #include <asm/arch/clk.h>
+#endif
 #include <linux/errno.h>
 
 #include "macb.h"
@@ -1066,7 +1068,7 @@  static int macb_enable_clk(struct udevice *dev)
 	 */
 #ifndef CONFIG_MACB_ZYNQ
 	ret = clk_enable(&clk);
-	if (ret)
+	if (ret && ret != -ENOSYS)
 		return ret;
 #endif