All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4] sam460ex: Fix sam460ex device tree when booting the Linux kernel
@ 2018-06-23 21:18 Guenter Roeck
  2018-06-23 21:22 ` BALATON Zoltan
  2018-06-24 10:12 ` David Gibson
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2018-06-23 21:18 UTC (permalink / raw)
  To: David Gibson
  Cc: Alexander Graf, qemu-ppc, qemu-devel, BALATON Zoltan, Guenter Roeck

sam460ex (or at least this emulation) does not support the "ibm,cpm" power
management. As a result, Linux crashes when trying to access it. Remove
its device tree node. Also, if/when we boot the Linux kernel directly,
serial port clock frequencies in the device tree file will be unset, and
serial port initialization will fail. Add valid frequency values to
the serial ports to be able to use it. Also set valid values for the other
clock nodes otherwise set by u-boot.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v4: Use correct UART clock.
v3: Fix style problems (ERROR: braces {} are necessary for all arms ...).
    Use defines for clock frequencies.
    Use clock frequencies as reported by u-boot in real system.
    Use more specific prefix in subject.
    Fix typos in description.
v2: Initialize all serial nodes to match u-boot behavior more closely.
    Use direct fdt API functions and ignore errors when clearing out
    /cpm and for setting the serial port clocks.

 hw/ppc/sam460ex.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index bdc53d2..33ea518 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -37,6 +37,8 @@
 #include "hw/i2c/smbus.h"
 #include "hw/usb/hcd-ehci.h"
 
+#include <libfdt.h>
+
 #define BINARY_DEVICE_TREE_FILE "canyonlands.dtb"
 #define UBOOT_FILENAME "u-boot-sam460-20100605.bin"
 /* to extract the official U-Boot bin from the updater: */
@@ -67,6 +69,10 @@
 */
 
 #define CPU_FREQ 1150000000
+#define PLB_FREQ 230000000
+#define OPB_FREQ 115000000
+#define EBC_FREQ 115000000
+#define UART_FREQ 11059200
 #define SDRAM_NR_BANKS 4
 
 /* FIXME: See u-boot.git 8ac41e, also fix in ppc440_uc.c */
@@ -255,6 +261,7 @@ static int sam460ex_load_device_tree(hwaddr addr,
     void *fdt;
     uint32_t tb_freq = CPU_FREQ;
     uint32_t clock_freq = CPU_FREQ;
+    int offset;
 
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
     if (!filename) {
@@ -308,6 +315,27 @@ static int sam460ex_load_device_tree(hwaddr addr,
     qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency",
                               tb_freq);
 
+    /* Remove cpm node if it exists (it is not emulated) */
+    offset = fdt_path_offset(fdt, "/cpm");
+    if (offset >= 0) {
+        fdt_nop_node(fdt, offset);
+    }
+
+    /* set serial port clocks */
+    offset = fdt_node_offset_by_compatible(fdt, -1, "ns16550");
+    while (offset >= 0) {
+        fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ);
+        offset = fdt_node_offset_by_compatible(fdt, offset, "ns16550");
+    }
+
+    /* some more clocks */
+    qemu_fdt_setprop_cell(fdt, "/plb", "clock-frequency",
+                              PLB_FREQ);
+    qemu_fdt_setprop_cell(fdt, "/plb/opb", "clock-frequency",
+                              OPB_FREQ);
+    qemu_fdt_setprop_cell(fdt, "/plb/opb/ebc", "clock-frequency",
+                              EBC_FREQ);
+
     rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
     g_free(fdt);
     ret = fdt_size;
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH v4] sam460ex: Fix sam460ex device tree when booting the Linux kernel
  2018-06-23 21:18 [Qemu-devel] [PATCH v4] sam460ex: Fix sam460ex device tree when booting the Linux kernel Guenter Roeck
@ 2018-06-23 21:22 ` BALATON Zoltan
  2018-06-24 10:12 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: BALATON Zoltan @ 2018-06-23 21:22 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: David Gibson, Alexander Graf, qemu-ppc, qemu-devel

On Sat, 23 Jun 2018, Guenter Roeck wrote:
> sam460ex (or at least this emulation) does not support the "ibm,cpm" power
> management. As a result, Linux crashes when trying to access it. Remove
> its device tree node. Also, if/when we boot the Linux kernel directly,
> serial port clock frequencies in the device tree file will be unset, and
> serial port initialization will fail. Add valid frequency values to
> the serial ports to be able to use it. Also set valid values for the other
> clock nodes otherwise set by u-boot.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>

Thanks again for debugging and fixing it.

> ---
> v4: Use correct UART clock.
> v3: Fix style problems (ERROR: braces {} are necessary for all arms ...).
>    Use defines for clock frequencies.
>    Use clock frequencies as reported by u-boot in real system.
>    Use more specific prefix in subject.
>    Fix typos in description.
> v2: Initialize all serial nodes to match u-boot behavior more closely.
>    Use direct fdt API functions and ignore errors when clearing out
>    /cpm and for setting the serial port clocks.
>
> hw/ppc/sam460ex.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index bdc53d2..33ea518 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -37,6 +37,8 @@
> #include "hw/i2c/smbus.h"
> #include "hw/usb/hcd-ehci.h"
>
> +#include <libfdt.h>
> +
> #define BINARY_DEVICE_TREE_FILE "canyonlands.dtb"
> #define UBOOT_FILENAME "u-boot-sam460-20100605.bin"
> /* to extract the official U-Boot bin from the updater: */
> @@ -67,6 +69,10 @@
> */
>
> #define CPU_FREQ 1150000000
> +#define PLB_FREQ 230000000
> +#define OPB_FREQ 115000000
> +#define EBC_FREQ 115000000
> +#define UART_FREQ 11059200
> #define SDRAM_NR_BANKS 4
>
> /* FIXME: See u-boot.git 8ac41e, also fix in ppc440_uc.c */
> @@ -255,6 +261,7 @@ static int sam460ex_load_device_tree(hwaddr addr,
>     void *fdt;
>     uint32_t tb_freq = CPU_FREQ;
>     uint32_t clock_freq = CPU_FREQ;
> +    int offset;
>
>     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
>     if (!filename) {
> @@ -308,6 +315,27 @@ static int sam460ex_load_device_tree(hwaddr addr,
>     qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency",
>                               tb_freq);
>
> +    /* Remove cpm node if it exists (it is not emulated) */
> +    offset = fdt_path_offset(fdt, "/cpm");
> +    if (offset >= 0) {
> +        fdt_nop_node(fdt, offset);
> +    }
> +
> +    /* set serial port clocks */
> +    offset = fdt_node_offset_by_compatible(fdt, -1, "ns16550");
> +    while (offset >= 0) {
> +        fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ);
> +        offset = fdt_node_offset_by_compatible(fdt, offset, "ns16550");
> +    }
> +
> +    /* some more clocks */
> +    qemu_fdt_setprop_cell(fdt, "/plb", "clock-frequency",
> +                              PLB_FREQ);
> +    qemu_fdt_setprop_cell(fdt, "/plb/opb", "clock-frequency",
> +                              OPB_FREQ);
> +    qemu_fdt_setprop_cell(fdt, "/plb/opb/ebc", "clock-frequency",
> +                              EBC_FREQ);
> +
>     rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
>     g_free(fdt);
>     ret = fdt_size;
>

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

* Re: [Qemu-devel] [PATCH v4] sam460ex: Fix sam460ex device tree when booting the Linux kernel
  2018-06-23 21:18 [Qemu-devel] [PATCH v4] sam460ex: Fix sam460ex device tree when booting the Linux kernel Guenter Roeck
  2018-06-23 21:22 ` BALATON Zoltan
@ 2018-06-24 10:12 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2018-06-24 10:12 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Alexander Graf, qemu-ppc, qemu-devel, BALATON Zoltan

[-- Attachment #1: Type: text/plain, Size: 3640 bytes --]

On Sat, Jun 23, 2018 at 02:18:05PM -0700, Guenter Roeck wrote:
> sam460ex (or at least this emulation) does not support the "ibm,cpm" power
> management. As a result, Linux crashes when trying to access it. Remove
> its device tree node. Also, if/when we boot the Linux kernel directly,
> serial port clock frequencies in the device tree file will be unset, and
> serial port initialization will fail. Add valid frequency values to
> the serial ports to be able to use it. Also set valid values for the other
> clock nodes otherwise set by u-boot.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Applied to ppc-for-3.0, thanks.

> ---
> v4: Use correct UART clock.
> v3: Fix style problems (ERROR: braces {} are necessary for all arms ...).
>     Use defines for clock frequencies.
>     Use clock frequencies as reported by u-boot in real system.
>     Use more specific prefix in subject.
>     Fix typos in description.
> v2: Initialize all serial nodes to match u-boot behavior more closely.
>     Use direct fdt API functions and ignore errors when clearing out
>     /cpm and for setting the serial port clocks.
> 
>  hw/ppc/sam460ex.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index bdc53d2..33ea518 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -37,6 +37,8 @@
>  #include "hw/i2c/smbus.h"
>  #include "hw/usb/hcd-ehci.h"
>  
> +#include <libfdt.h>
> +
>  #define BINARY_DEVICE_TREE_FILE "canyonlands.dtb"
>  #define UBOOT_FILENAME "u-boot-sam460-20100605.bin"
>  /* to extract the official U-Boot bin from the updater: */
> @@ -67,6 +69,10 @@
>  */
>  
>  #define CPU_FREQ 1150000000
> +#define PLB_FREQ 230000000
> +#define OPB_FREQ 115000000
> +#define EBC_FREQ 115000000
> +#define UART_FREQ 11059200
>  #define SDRAM_NR_BANKS 4
>  
>  /* FIXME: See u-boot.git 8ac41e, also fix in ppc440_uc.c */
> @@ -255,6 +261,7 @@ static int sam460ex_load_device_tree(hwaddr addr,
>      void *fdt;
>      uint32_t tb_freq = CPU_FREQ;
>      uint32_t clock_freq = CPU_FREQ;
> +    int offset;
>  
>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
>      if (!filename) {
> @@ -308,6 +315,27 @@ static int sam460ex_load_device_tree(hwaddr addr,
>      qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency",
>                                tb_freq);
>  
> +    /* Remove cpm node if it exists (it is not emulated) */
> +    offset = fdt_path_offset(fdt, "/cpm");
> +    if (offset >= 0) {
> +        fdt_nop_node(fdt, offset);
> +    }
> +
> +    /* set serial port clocks */
> +    offset = fdt_node_offset_by_compatible(fdt, -1, "ns16550");
> +    while (offset >= 0) {
> +        fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ);
> +        offset = fdt_node_offset_by_compatible(fdt, offset, "ns16550");
> +    }
> +
> +    /* some more clocks */
> +    qemu_fdt_setprop_cell(fdt, "/plb", "clock-frequency",
> +                              PLB_FREQ);
> +    qemu_fdt_setprop_cell(fdt, "/plb/opb", "clock-frequency",
> +                              OPB_FREQ);
> +    qemu_fdt_setprop_cell(fdt, "/plb/opb/ebc", "clock-frequency",
> +                              EBC_FREQ);
> +
>      rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
>      g_free(fdt);
>      ret = fdt_size;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2018-06-24 10:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-23 21:18 [Qemu-devel] [PATCH v4] sam460ex: Fix sam460ex device tree when booting the Linux kernel Guenter Roeck
2018-06-23 21:22 ` BALATON Zoltan
2018-06-24 10:12 ` David Gibson

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.