All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine
@ 2018-12-19 12:31 Anup Patel
  2018-12-19 12:31 ` [U-Boot] [PATCH v2 1/3] riscv: Add asm/dma-mapping.h for DMA mappings Anup Patel
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Anup Patel @ 2018-12-19 12:31 UTC (permalink / raw)
  To: u-boot

This patchset enables Cadance MACB ethernet driver for
QEMU sifive_u machine. The Cadance MACB ethernet driver
works fine for QEMU sifive_u machince in both M-mode and
S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id
9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are
applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Changes since v1:
 - Minor nit changes in PATCH1

Anup Patel (3):
  riscv: Add asm/dma-mapping.h for DMA mappings
  net: macb: Fix clk API usage for RISC-V systems
  riscv: qemu: Imply MACB ethernet for emulation

 arch/riscv/include/asm/dma-mapping.h | 38 ++++++++++++++++++++++++++++
 board/emulation/qemu-riscv/Kconfig   |  4 +++
 drivers/net/macb.c                   |  4 ++-
 3 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/include/asm/dma-mapping.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH v2 1/3] riscv: Add asm/dma-mapping.h for DMA mappings
  2018-12-19 12:31 [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine Anup Patel
@ 2018-12-19 12:31 ` Anup Patel
  2018-12-19 12:31 ` [U-Boot] [PATCH v2 2/3] net: macb: Fix clk API usage for RISC-V systems Anup Patel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2018-12-19 12:31 UTC (permalink / raw)
  To: u-boot

From: Anup Patel <anup.patel@wdc.com>

This patch adds asm/dma-mapping.h for Linux-like DMA mappings
APIs required by some of the drivers (such as, Cadance MACB
Ethernet driver).

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
 arch/riscv/include/asm/dma-mapping.h | 38 ++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 arch/riscv/include/asm/dma-mapping.h

diff --git a/arch/riscv/include/asm/dma-mapping.h b/arch/riscv/include/asm/dma-mapping.h
new file mode 100644
index 0000000000..3d930c90ec
--- /dev/null
+++ b/arch/riscv/include/asm/dma-mapping.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2018 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel <anup.patel@wdc.com>
+ */
+
+#ifndef __ASM_RISCV_DMA_MAPPING_H
+#define __ASM_RISCV_DMA_MAPPING_H
+
+#include <linux/dma-direction.h>
+
+#define dma_mapping_error(x, y)	0
+
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+	*handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
+	return (void *)*handle;
+}
+
+static inline void dma_free_coherent(void *addr)
+{
+	free(addr);
+}
+
+static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
+					   enum dma_data_direction dir)
+{
+	return (unsigned long)vaddr;
+}
+
+static inline void dma_unmap_single(volatile void *vaddr, size_t len,
+				    unsigned long paddr)
+{
+}
+
+#endif /* __ASM_RISCV_DMA_MAPPING_H */
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH v2 2/3] net: macb: Fix clk API usage for RISC-V systems
  2018-12-19 12:31 [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine Anup Patel
  2018-12-19 12:31 ` [U-Boot] [PATCH v2 1/3] riscv: Add asm/dma-mapping.h for DMA mappings Anup Patel
@ 2018-12-19 12:31 ` Anup Patel
  2018-12-20  5:26   ` Anup Patel
  2018-12-19 12:31 ` [U-Boot] [PATCH v2 3/3] riscv: qemu: Imply MACB ethernet for emulation Anup Patel
  2018-12-20  5:25 ` [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine Anup Patel
  3 siblings, 1 reply; 7+ messages in thread
From: Anup Patel @ 2018-12-19 12:31 UTC (permalink / raw)
  To: u-boot

From: Anup Patel <anup.patel@wdc.com>

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>
+#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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH v2 3/3] riscv: qemu: Imply MACB ethernet for emulation
  2018-12-19 12:31 [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine Anup Patel
  2018-12-19 12:31 ` [U-Boot] [PATCH v2 1/3] riscv: Add asm/dma-mapping.h for DMA mappings Anup Patel
  2018-12-19 12:31 ` [U-Boot] [PATCH v2 2/3] net: macb: Fix clk API usage for RISC-V systems Anup Patel
@ 2018-12-19 12:31 ` Anup Patel
  2018-12-20  5:27   ` Anup Patel
  2018-12-20  5:25 ` [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine Anup Patel
  3 siblings, 1 reply; 7+ messages in thread
From: Anup Patel @ 2018-12-19 12:31 UTC (permalink / raw)
  To: u-boot

From: Anup Patel <anup.patel@wdc.com>

This patch enables Cadence MACB ethernet driver for QEMU RISC-V
emulation by implying MACB, MII, RGMII and NET_RANDOM_ETHADDR on
BOARD_SPECIFIC_OPTIONS.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
 board/emulation/qemu-riscv/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig
index 0d865acf10..5d9611bdc7 100644
--- a/board/emulation/qemu-riscv/Kconfig
+++ b/board/emulation/qemu-riscv/Kconfig
@@ -34,5 +34,9 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply BOARD_LATE_INIT
 	imply OF_BOARD_SETUP
 	imply SIFIVE_SERIAL
+	imply MACB
+	imply RGMII
+	imply MII
+	imply NET_RANDOM_ETHADDR
 
 endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine
  2018-12-19 12:31 [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine Anup Patel
                   ` (2 preceding siblings ...)
  2018-12-19 12:31 ` [U-Boot] [PATCH v2 3/3] riscv: qemu: Imply MACB ethernet for emulation Anup Patel
@ 2018-12-20  5:25 ` Anup Patel
  3 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2018-12-20  5:25 UTC (permalink / raw)
  To: u-boot

+Michal

On Wed, Dec 19, 2018 at 6:02 PM Anup Patel <anup@brainfault.org> wrote:
>
> This patchset enables Cadance MACB ethernet driver for
> QEMU sifive_u machine. The Cadance MACB ethernet driver
> works fine for QEMU sifive_u machince in both M-mode and
> S-mode with some minor fixes.
>
> The patches are based upon latest RISC-V U-Boot tree
> (git://git.denx.de/u-boot-riscv.git) at commit id
> 9deb8d2fcd13d4a40a4e63c396fe4376af46efac
>
> To try on QEMU, please ensure following patches are
> applied to QEMU sources:
> https://patchwork.kernel.org/patch/10729579/
> https://patchwork.kernel.org/patch/10729581/
>
> Changes since v1:
>  - Minor nit changes in PATCH1
>
> Anup Patel (3):
>   riscv: Add asm/dma-mapping.h for DMA mappings
>   net: macb: Fix clk API usage for RISC-V systems
>   riscv: qemu: Imply MACB ethernet for emulation
>
>  arch/riscv/include/asm/dma-mapping.h | 38 ++++++++++++++++++++++++++++
>  board/emulation/qemu-riscv/Kconfig   |  4 +++
>  drivers/net/macb.c                   |  4 ++-
>  3 files changed, 45 insertions(+), 1 deletion(-)
>  create mode 100644 arch/riscv/include/asm/dma-mapping.h
>
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH v2 2/3] net: macb: Fix clk API usage for RISC-V systems
  2018-12-19 12:31 ` [U-Boot] [PATCH v2 2/3] net: macb: Fix clk API usage for RISC-V systems Anup Patel
@ 2018-12-20  5:26   ` Anup Patel
  0 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2018-12-20  5:26 UTC (permalink / raw)
  To: u-boot

+Michal

On Wed, Dec 19, 2018 at 6:02 PM Anup Patel <anup@brainfault.org> wrote:
>
> From: Anup Patel <anup.patel@wdc.com>
>
> 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>
> +#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
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH v2 3/3] riscv: qemu: Imply MACB ethernet for emulation
  2018-12-19 12:31 ` [U-Boot] [PATCH v2 3/3] riscv: qemu: Imply MACB ethernet for emulation Anup Patel
@ 2018-12-20  5:27   ` Anup Patel
  0 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2018-12-20  5:27 UTC (permalink / raw)
  To: u-boot

+Michal

On Wed, Dec 19, 2018 at 6:02 PM Anup Patel <anup@brainfault.org> wrote:
>
> From: Anup Patel <anup.patel@wdc.com>
>
> This patch enables Cadence MACB ethernet driver for QEMU RISC-V
> emulation by implying MACB, MII, RGMII and NET_RANDOM_ETHADDR on
> BOARD_SPECIFIC_OPTIONS.
>
> Signed-off-by: Anup Patel <anup.patel@wdc.com>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>  board/emulation/qemu-riscv/Kconfig | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig
> index 0d865acf10..5d9611bdc7 100644
> --- a/board/emulation/qemu-riscv/Kconfig
> +++ b/board/emulation/qemu-riscv/Kconfig
> @@ -34,5 +34,9 @@ config BOARD_SPECIFIC_OPTIONS # dummy
>         imply BOARD_LATE_INIT
>         imply OF_BOARD_SETUP
>         imply SIFIVE_SERIAL
> +       imply MACB
> +       imply RGMII
> +       imply MII
> +       imply NET_RANDOM_ETHADDR
>
>  endif
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-12-20  5:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-19 12:31 [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine Anup Patel
2018-12-19 12:31 ` [U-Boot] [PATCH v2 1/3] riscv: Add asm/dma-mapping.h for DMA mappings Anup Patel
2018-12-19 12:31 ` [U-Boot] [PATCH v2 2/3] net: macb: Fix clk API usage for RISC-V systems Anup Patel
2018-12-20  5:26   ` Anup Patel
2018-12-19 12:31 ` [U-Boot] [PATCH v2 3/3] riscv: qemu: Imply MACB ethernet for emulation Anup Patel
2018-12-20  5:27   ` Anup Patel
2018-12-20  5:25 ` [U-Boot] [PATCH v2 0/3] Ethernet support for QEMU sifive_u machine Anup Patel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.