From nobody Mon Apr 29 19:03:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529716800055541.8549226034319; Fri, 22 Jun 2018 18:20:00 -0700 (PDT) Received: from localhost ([::1]:36805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWXDS-0007A5-9H for importer@patchew.org; Fri, 22 Jun 2018 21:19:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWXCW-0006j7-9L for qemu-devel@nongnu.org; Fri, 22 Jun 2018 21:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWXCV-0004O4-BQ for qemu-devel@nongnu.org; Fri, 22 Jun 2018 21:18:52 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:60233) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fWXCO-0004MA-R3; Fri, 22 Jun 2018 21:18:45 -0400 Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:45804 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.89) (envelope-from ) id 1fWXCM-002vK8-Vf; Sat, 23 Jun 2018 01:18:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Qcc1a0MJzUCarP9lyDnF9gsd3tg/HnmJ00c5/ea3Zl0=; b=iTx3nX6xAIMfbjs3P7DSV0Ov29 02P5j//ExzF/Xl6YFbJFx4R58PQms0sZx0UHrSd6SUI+g1rvuZboCG6sAuTgm30yQUI8wX+l+CmQZ +HmRsNu739ZRBvCGcnCrDYyz9zTNkk/4HL5GjxZciXZ8eq59iIjFZfVOKV25QucAIvviEF0BroyNx 4RKMTSI+IYJdlVZh+TgAoPGW90dfkGR3r8Ma5G0w1S6IlXV4DrYWzegOFBj7x57eSVxE3m2p3ef02 IlbZfEHfiexRmtFaobGaJX2YSmE+NfvvB0aZfK+htoZ2wkP24Ei+CNEJ3W1eh8ggbI56u3bFqtoUZ qD0CGzdQ==; From: Guenter Roeck To: David Gibson Date: Fri, 22 Jun 2018 18:18:41 -0700 Message-Id: <1529716721-28400-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - nongnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 208.91.199.152 Subject: [Qemu-devel] [PATCH v2] ppc: Fix sam460ex devicetree when booting the Linux kernel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, Alexander Graf , Guenter Roeck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" sam4660ex (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 devicetree node. Also, if/when we boot the Linux kernel directly, serial port clock frequencies in the devicetree file will be unset, and serial port initialization will fail. Add plausible frequency values to the serials port 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 --- 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 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index bdc53d2..a91382c 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" =20 +#include + #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: */ @@ -255,6 +257,7 @@ static int sam460ex_load_device_tree(hwaddr addr, void *fdt; uint32_t tb_freq =3D CPU_FREQ; uint32_t clock_freq =3D CPU_FREQ; + int offset; =20 filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FI= LE); if (!filename) { @@ -308,6 +311,26 @@ static int sam460ex_load_device_tree(hwaddr addr, qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency", tb_freq); =20 + /* Remove cpm node if it exists (it is not emulated) */ + offset =3D fdt_path_offset(fdt, "/cpm"); + if (offset >=3D 0) + fdt_nop_node(fdt, offset); + + /* set serial port clocks */ + offset =3D fdt_node_offset_by_compatible(fdt, -1, "ns16550"); + while (offset >=3D 0) { + fdt_setprop_cell(fdt, offset, "clock-frequency", 50000000); + offset =3D fdt_node_offset_by_compatible(fdt, offset, "ns16550"); + } + + /* some more clocks */ + qemu_fdt_setprop_cell(fdt, "/plb", "clock-frequency", + 50000000); + qemu_fdt_setprop_cell(fdt, "/plb/opb", "clock-frequency", + 50000000); + qemu_fdt_setprop_cell(fdt, "/plb/opb/ebc", "clock-frequency", + 50000000); + rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); g_free(fdt); ret =3D fdt_size; --=20 2.7.4