diff mbox series

[U-Boot,03/19] riscv: qemu: Create a simple-bus driver for the soc node

Message ID 1542097327-6629-4-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Andes
Headers show
Series riscv: Adding RISC-V CPU and timer driver | expand

Commit Message

Bin Meng Nov. 13, 2018, 8:21 a.m. UTC
To enumerate devices on the /soc/ node, create a "simple-bus"
driver to match "riscv-virtio-soc".

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 arch/riscv/cpu/qemu/cpu.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Lukas Auer Nov. 14, 2018, 9:26 p.m. UTC | #1
Hi Bin,

On Tue, 2018-11-13 at 00:21 -0800, Bin Meng wrote:
> To enumerate devices on the /soc/ node, create a "simple-bus"
> driver to match "riscv-virtio-soc".
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
> 
>  arch/riscv/cpu/qemu/cpu.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 

Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>

Would it makes sense to move this to cpu/ to make this driver available
to all RISC-V CPUs? I think most CPUs will need this driver to make
devices under the soc/ node available before relocation.

> diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/qemu/cpu.c
> index 6c7a327..221f3a8 100644
> --- a/arch/riscv/cpu/qemu/cpu.c
> +++ b/arch/riscv/cpu/qemu/cpu.c
> @@ -4,6 +4,7 @@
>   */
>  
>  #include <common.h>
> +#include <dm.h>
>  
>  /*
>   * cleanup_before_linux() is called just before we call linux
> @@ -19,3 +20,15 @@ int cleanup_before_linux(void)
>  
>  	return 0;
>  }
> +
> +/* To enumerate devices on the /soc/ node, create a "simple-bus"
> driver */
> +static const struct udevice_id riscv_virtio_soc_ids[] = {
> +	{ .compatible = "riscv-virtio-soc" },
> +	{ }
> +};
> +
> +U_BOOT_DRIVER(riscv_virtio_soc) = {
> +	.name = "riscv_virtio_soc",
> +	.id = UCLASS_SIMPLE_BUS,
> +	.of_match = riscv_virtio_soc_ids,
> +};

I think the DM_FLAG_PRE_RELOC flag should be set, since it is set for
the syscon driver for the clint0.

Thanks,
Lukas
Bin Meng Nov. 30, 2018, 9:47 a.m. UTC | #2
Hi Lukas,

On Thu, Nov 15, 2018 at 5:26 AM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Tue, 2018-11-13 at 00:21 -0800, Bin Meng wrote:
> > To enumerate devices on the /soc/ node, create a "simple-bus"
> > driver to match "riscv-virtio-soc".
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >
> >  arch/riscv/cpu/qemu/cpu.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> >
>
> Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
>
> Would it makes sense to move this to cpu/ to make this driver available
> to all RISC-V CPUs? I think most CPUs will need this driver to make
> devices under the soc/ node available before relocation.
>

I suspect this can apply to other RISC-V CPUs because it compatible
string says: "riscv-virtio-soc"

> > diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/qemu/cpu.c
> > index 6c7a327..221f3a8 100644
> > --- a/arch/riscv/cpu/qemu/cpu.c
> > +++ b/arch/riscv/cpu/qemu/cpu.c
> > @@ -4,6 +4,7 @@
> >   */
> >
> >  #include <common.h>
> > +#include <dm.h>
> >
> >  /*
> >   * cleanup_before_linux() is called just before we call linux
> > @@ -19,3 +20,15 @@ int cleanup_before_linux(void)
> >
> >       return 0;
> >  }
> > +
> > +/* To enumerate devices on the /soc/ node, create a "simple-bus"
> > driver */
> > +static const struct udevice_id riscv_virtio_soc_ids[] = {
> > +     { .compatible = "riscv-virtio-soc" },
> > +     { }
> > +};
> > +
> > +U_BOOT_DRIVER(riscv_virtio_soc) = {
> > +     .name = "riscv_virtio_soc",
> > +     .id = UCLASS_SIMPLE_BUS,
> > +     .of_match = riscv_virtio_soc_ids,
> > +};
>
> I think the DM_FLAG_PRE_RELOC flag should be set, since it is set for
> the syscon driver for the clint0.
>

Will fix in v2.

Regards,
Bin
diff mbox series

Patch

diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/qemu/cpu.c
index 6c7a327..221f3a8 100644
--- a/arch/riscv/cpu/qemu/cpu.c
+++ b/arch/riscv/cpu/qemu/cpu.c
@@ -4,6 +4,7 @@ 
  */
 
 #include <common.h>
+#include <dm.h>
 
 /*
  * cleanup_before_linux() is called just before we call linux
@@ -19,3 +20,15 @@  int cleanup_before_linux(void)
 
 	return 0;
 }
+
+/* To enumerate devices on the /soc/ node, create a "simple-bus" driver */
+static const struct udevice_id riscv_virtio_soc_ids[] = {
+	{ .compatible = "riscv-virtio-soc" },
+	{ }
+};
+
+U_BOOT_DRIVER(riscv_virtio_soc) = {
+	.name = "riscv_virtio_soc",
+	.id = UCLASS_SIMPLE_BUS,
+	.of_match = riscv_virtio_soc_ids,
+};