* [Qemu-devel] [PATCH 2/3] riscv: sivive_u: Add dummy serial clock and aliases entry for uart
[not found] <1563543645-20804-1-git-send-email-linux@roeck-us.net>
@ 2019-07-19 13:40 ` Guenter Roeck
2019-07-26 20:16 ` Alistair Francis
2019-07-19 13:40 ` [Qemu-devel] [PATCH 3/3] riscv: sifive_u: Fix clock-names property for ethernet node Guenter Roeck
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2019-07-19 13:40 UTC (permalink / raw)
To: Palmer Dabbelt
Cc: qemu-riscv, Sagar Karandikar, Bastian Koppelmann, qemu-devel,
Alistair Francis, Guenter Roeck
The riscv uart needs valid clocks. This requires a refereence
to the clock node. Since the SOC clock is not emulated by qemu,
add a reference to a fixed clock instead. The clock-frequency
entry in the uart node does not seem to be necessary, so drop it.
In addition to a reference to the clock, the driver also needs
an aliases entry for the serial node. Add it as well.
Without this patch, the serial driver fails to instantiate with
the following error message.
sifive-serial 10013000.uart: unable to find controller clock
sifive-serial: probe of 10013000.uart failed with error -2
when trying to boot Linux.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
hw/riscv/sifive_u.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 0657046..5a221c6 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -76,6 +76,7 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
char *nodename;
char ethclk_names[] = "pclk\0hclk\0tx_clk";
uint32_t plic_phandle, ethclk_phandle, phandle = 1;
+ uint32_t uartclk_phandle;
fdt = s->fdt = create_device_tree(&s->fdt_size);
if (!fdt) {
@@ -226,6 +227,17 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0);
g_free(nodename);
+ uartclk_phandle = phandle++;
+ nodename = g_strdup_printf("/soc/uartclk");
+ qemu_fdt_add_subnode(fdt, nodename);
+ qemu_fdt_setprop_string(fdt, nodename, "compatible", "fixed-clock");
+ qemu_fdt_setprop_cell(fdt, nodename, "#clock-cells", 0x0);
+ qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency", 3686400);
+ qemu_fdt_setprop_cell(fdt, nodename, "phandle", uartclk_phandle);
+ qemu_fdt_setprop_cell(fdt, nodename, "linux,phandle", uartclk_phandle);
+ uartclk_phandle = qemu_fdt_get_phandle(fdt, nodename);
+ g_free(nodename);
+
nodename = g_strdup_printf("/soc/uart@%lx",
(long)memmap[SIFIVE_U_UART0].base);
qemu_fdt_add_subnode(fdt, nodename);
@@ -233,8 +245,7 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
qemu_fdt_setprop_cells(fdt, nodename, "reg",
0x0, memmap[SIFIVE_U_UART0].base,
0x0, memmap[SIFIVE_U_UART0].size);
- qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency",
- SIFIVE_U_CLOCK_FREQ / 2);
+ qemu_fdt_setprop_cells(fdt, nodename, "clocks", uartclk_phandle);
qemu_fdt_setprop_cells(fdt, nodename, "interrupt-parent", plic_phandle);
qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_UART0_IRQ);
@@ -243,6 +254,10 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
if (cmdline) {
qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
}
+
+ qemu_fdt_add_subnode(fdt, "/aliases");
+ qemu_fdt_setprop_string(fdt, "/aliases", "serial0", nodename);
+
g_free(nodename);
return fdt;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] riscv: sivive_u: Add dummy serial clock and aliases entry for uart
2019-07-19 13:40 ` [Qemu-devel] [PATCH 2/3] riscv: sivive_u: Add dummy serial clock and aliases entry for uart Guenter Roeck
@ 2019-07-26 20:16 ` Alistair Francis
0 siblings, 0 replies; 6+ messages in thread
From: Alistair Francis @ 2019-07-26 20:16 UTC (permalink / raw)
To: Guenter Roeck
Cc: open list:RISC-V, Sagar Karandikar, Bastian Koppelmann,
Palmer Dabbelt, qemu-devel@nongnu.org Developers,
Alistair Francis
On Fri, Jul 19, 2019 at 6:41 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> The riscv uart needs valid clocks. This requires a refereence
> to the clock node. Since the SOC clock is not emulated by qemu,
> add a reference to a fixed clock instead. The clock-frequency
> entry in the uart node does not seem to be necessary, so drop it.
>
> In addition to a reference to the clock, the driver also needs
> an aliases entry for the serial node. Add it as well.
>
> Without this patch, the serial driver fails to instantiate with
> the following error message.
>
> sifive-serial 10013000.uart: unable to find controller clock
> sifive-serial: probe of 10013000.uart failed with error -2
>
> when trying to boot Linux.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/riscv/sifive_u.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index 0657046..5a221c6 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -76,6 +76,7 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
> char *nodename;
> char ethclk_names[] = "pclk\0hclk\0tx_clk";
> uint32_t plic_phandle, ethclk_phandle, phandle = 1;
> + uint32_t uartclk_phandle;
>
> fdt = s->fdt = create_device_tree(&s->fdt_size);
> if (!fdt) {
> @@ -226,6 +227,17 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
> qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0);
> g_free(nodename);
>
> + uartclk_phandle = phandle++;
> + nodename = g_strdup_printf("/soc/uartclk");
> + qemu_fdt_add_subnode(fdt, nodename);
> + qemu_fdt_setprop_string(fdt, nodename, "compatible", "fixed-clock");
> + qemu_fdt_setprop_cell(fdt, nodename, "#clock-cells", 0x0);
> + qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency", 3686400);
> + qemu_fdt_setprop_cell(fdt, nodename, "phandle", uartclk_phandle);
> + qemu_fdt_setprop_cell(fdt, nodename, "linux,phandle", uartclk_phandle);
> + uartclk_phandle = qemu_fdt_get_phandle(fdt, nodename);
> + g_free(nodename);
> +
> nodename = g_strdup_printf("/soc/uart@%lx",
> (long)memmap[SIFIVE_U_UART0].base);
> qemu_fdt_add_subnode(fdt, nodename);
> @@ -233,8 +245,7 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
> qemu_fdt_setprop_cells(fdt, nodename, "reg",
> 0x0, memmap[SIFIVE_U_UART0].base,
> 0x0, memmap[SIFIVE_U_UART0].size);
> - qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency",
> - SIFIVE_U_CLOCK_FREQ / 2);
> + qemu_fdt_setprop_cells(fdt, nodename, "clocks", uartclk_phandle);
> qemu_fdt_setprop_cells(fdt, nodename, "interrupt-parent", plic_phandle);
> qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_UART0_IRQ);
>
> @@ -243,6 +254,10 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
> if (cmdline) {
> qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
> }
> +
> + qemu_fdt_add_subnode(fdt, "/aliases");
> + qemu_fdt_setprop_string(fdt, "/aliases", "serial0", nodename);
> +
> g_free(nodename);
>
> return fdt;
> --
> 2.7.4
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 3/3] riscv: sifive_u: Fix clock-names property for ethernet node
[not found] <1563543645-20804-1-git-send-email-linux@roeck-us.net>
2019-07-19 13:40 ` [Qemu-devel] [PATCH 2/3] riscv: sivive_u: Add dummy serial clock and aliases entry for uart Guenter Roeck
@ 2019-07-19 13:40 ` Guenter Roeck
2019-07-19 16:19 ` Alistair Francis
2019-07-22 22:28 ` [Qemu-devel] [PATCH 1/3] riscv: sifive_u: Add support for loading initrd Alistair Francis
2019-08-12 22:44 ` Palmer Dabbelt
3 siblings, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2019-07-19 13:40 UTC (permalink / raw)
To: Palmer Dabbelt
Cc: qemu-riscv, Sagar Karandikar, Bastian Koppelmann, qemu-devel,
Alistair Francis, Guenter Roeck
The correct property name is clock-names, not clocks-names.
Without this patch, the Ethernet driver fails to instantiate with
the following error.
macb 100900fc.ethernet: failed to get macb_clk (-2)
macb: probe of 100900fc.ethernet failed with error -2
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
hw/riscv/sifive_u.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 5a221c6..64e233d 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -215,7 +215,7 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_GEM_IRQ);
qemu_fdt_setprop_cells(fdt, nodename, "clocks",
ethclk_phandle, ethclk_phandle, ethclk_phandle);
- qemu_fdt_setprop(fdt, nodename, "clocks-names", ethclk_names,
+ qemu_fdt_setprop(fdt, nodename, "clock-names", ethclk_names,
sizeof(ethclk_names));
qemu_fdt_setprop_cells(fdt, nodename, "#address-cells", 1);
qemu_fdt_setprop_cells(fdt, nodename, "#size-cells", 0);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] riscv: sifive_u: Fix clock-names property for ethernet node
2019-07-19 13:40 ` [Qemu-devel] [PATCH 3/3] riscv: sifive_u: Fix clock-names property for ethernet node Guenter Roeck
@ 2019-07-19 16:19 ` Alistair Francis
0 siblings, 0 replies; 6+ messages in thread
From: Alistair Francis @ 2019-07-19 16:19 UTC (permalink / raw)
To: Guenter Roeck
Cc: open list:RISC-V, Sagar Karandikar, Bastian Koppelmann,
Palmer Dabbelt, qemu-devel@nongnu.org Developers,
Alistair Francis
On Fri, Jul 19, 2019 at 6:41 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> The correct property name is clock-names, not clocks-names.
>
> Without this patch, the Ethernet driver fails to instantiate with
> the following error.
>
> macb 100900fc.ethernet: failed to get macb_clk (-2)
> macb: probe of 100900fc.ethernet failed with error -2
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/riscv/sifive_u.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index 5a221c6..64e233d 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -215,7 +215,7 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
> qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_GEM_IRQ);
> qemu_fdt_setprop_cells(fdt, nodename, "clocks",
> ethclk_phandle, ethclk_phandle, ethclk_phandle);
> - qemu_fdt_setprop(fdt, nodename, "clocks-names", ethclk_names,
> + qemu_fdt_setprop(fdt, nodename, "clock-names", ethclk_names,
> sizeof(ethclk_names));
> qemu_fdt_setprop_cells(fdt, nodename, "#address-cells", 1);
> qemu_fdt_setprop_cells(fdt, nodename, "#size-cells", 0);
> --
> 2.7.4
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] riscv: sifive_u: Add support for loading initrd
[not found] <1563543645-20804-1-git-send-email-linux@roeck-us.net>
2019-07-19 13:40 ` [Qemu-devel] [PATCH 2/3] riscv: sivive_u: Add dummy serial clock and aliases entry for uart Guenter Roeck
2019-07-19 13:40 ` [Qemu-devel] [PATCH 3/3] riscv: sifive_u: Fix clock-names property for ethernet node Guenter Roeck
@ 2019-07-22 22:28 ` Alistair Francis
2019-08-12 22:44 ` Palmer Dabbelt
3 siblings, 0 replies; 6+ messages in thread
From: Alistair Francis @ 2019-07-22 22:28 UTC (permalink / raw)
To: linux, palmer; +Cc: kbastian, qemu-riscv, qemu-devel, sagark
On Fri, 2019-07-19 at 06:40 -0700, Guenter Roeck wrote:
> Add support for loading initrd with "-initrd <filename>"
> to the sifive_u machine. This lets us boot into Linux without
> disk drive.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/riscv/sifive_u.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index 71b8083..0657046 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -67,7 +67,7 @@ static const struct MemmapEntry {
>
> #define GEM_REVISION 0x10070109
>
> -static void create_fdt(SiFiveUState *s, const struct MemmapEntry
> *memmap,
> +static void *create_fdt(SiFiveUState *s, const struct MemmapEntry
> *memmap,
> uint64_t mem_size, const char *cmdline)
> {
> void *fdt;
> @@ -244,11 +244,14 @@ static void create_fdt(SiFiveUState *s, const
> struct MemmapEntry *memmap,
> qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
> cmdline);
> }
> g_free(nodename);
> +
> + return fdt;
> }
>
> static void riscv_sifive_u_init(MachineState *machine)
> {
> const struct MemmapEntry *memmap = sifive_u_memmap;
> + void *fdt;
>
> SiFiveUState *s = g_new0(SiFiveUState, 1);
> MemoryRegion *system_memory = get_system_memory();
> @@ -269,13 +272,24 @@ static void riscv_sifive_u_init(MachineState
> *machine)
> main_mem);
>
> /* create device tree */
> - create_fdt(s, memmap, machine->ram_size, machine-
> >kernel_cmdline);
> + fdt = create_fdt(s, memmap, machine->ram_size, machine-
> >kernel_cmdline);
>
> riscv_find_and_load_firmware(machine, BIOS_FILENAME,
> memmap[SIFIVE_U_DRAM].base);
>
> if (machine->kernel_filename) {
> - riscv_load_kernel(machine->kernel_filename);
> + uint64_t kernel_entry = riscv_load_kernel(machine-
> >kernel_filename);
> +
> + if (machine->initrd_filename) {
> + hwaddr start;
> + hwaddr end = riscv_load_initrd(machine->initrd_filename,
> + machine->ram_size,
> kernel_entry,
> + &start);
> + qemu_fdt_setprop_cell(fdt, "/chosen",
> + "linux,initrd-start", start);
> + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-
> end",
> + end);
> + }
> }
>
> /* reset vector */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] riscv: sifive_u: Add support for loading initrd
[not found] <1563543645-20804-1-git-send-email-linux@roeck-us.net>
` (2 preceding siblings ...)
2019-07-22 22:28 ` [Qemu-devel] [PATCH 1/3] riscv: sifive_u: Add support for loading initrd Alistair Francis
@ 2019-08-12 22:44 ` Palmer Dabbelt
3 siblings, 0 replies; 6+ messages in thread
From: Palmer Dabbelt @ 2019-08-12 22:44 UTC (permalink / raw)
To: linux
Cc: qemu-riscv, sagark, Bastian Koppelmann, qemu-devel,
Alistair Francis, linux
On Fri, 19 Jul 2019 06:40:43 PDT (-0700), linux@roeck-us.net wrote:
> Add support for loading initrd with "-initrd <filename>"
> to the sifive_u machine. This lets us boot into Linux without
> disk drive.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> hw/riscv/sifive_u.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index 71b8083..0657046 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -67,7 +67,7 @@ static const struct MemmapEntry {
>
> #define GEM_REVISION 0x10070109
>
> -static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
> +static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
> uint64_t mem_size, const char *cmdline)
> {
> void *fdt;
> @@ -244,11 +244,14 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
> qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
> }
> g_free(nodename);
> +
> + return fdt;
> }
>
> static void riscv_sifive_u_init(MachineState *machine)
> {
> const struct MemmapEntry *memmap = sifive_u_memmap;
> + void *fdt;
>
> SiFiveUState *s = g_new0(SiFiveUState, 1);
> MemoryRegion *system_memory = get_system_memory();
> @@ -269,13 +272,24 @@ static void riscv_sifive_u_init(MachineState *machine)
> main_mem);
>
> /* create device tree */
> - create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline);
> + fdt = create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline);
>
> riscv_find_and_load_firmware(machine, BIOS_FILENAME,
> memmap[SIFIVE_U_DRAM].base);
>
> if (machine->kernel_filename) {
> - riscv_load_kernel(machine->kernel_filename);
> + uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename);
> +
> + if (machine->initrd_filename) {
> + hwaddr start;
> + hwaddr end = riscv_load_initrd(machine->initrd_filename,
> + machine->ram_size, kernel_entry,
> + &start);
> + qemu_fdt_setprop_cell(fdt, "/chosen",
> + "linux,initrd-start", start);
> + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
> + end);
> + }
> }
>
> /* reset vector */
Thanks. I've queued all three of these.
^ permalink raw reply [flat|nested] 6+ messages in thread