From nobody Mon May 6 19:49:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+46298+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+46298+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1566562293; cv=none; d=zoho.com; s=zohoarc; b=dlY9J1ioIUm+aCyH2m/ovUQzvZtKss0f9vAJ3LEfFrBlm+Ze9tPMjCDede6bwCSD7Z6NJBi1TCUI/zgtlY3GueXar1oTFpXGV/H/0GQHJAMruMNhyhfuvWDYzDidPlync/rkqrRvvSnjkv5VgeL+/12aaPWJGnZYQEzj1XgeUpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566562293; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=ArQ18scdj30IbPBprTVOg0Lg0aMI+WFzwsj9uXHpnYM=; b=Y3/SjDzDL9KcstNulutz3BvbtycZquxdYGoXjEA3FkPArX7/dP3Yib4Xh+cXEicxTmXXXrRC965Htc6IjvWWMCJ9auxlo8XUgoNNNc+FpUufkXRu/9pvcKjC5UMtK05XsLIzJSmYHYz70JP6OOzVwFb4tvG/TzPkUgeOjp2ELGw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+46298+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1566562293636875.6769682763966; Fri, 23 Aug 2019 05:11:33 -0700 (PDT) Return-Path: X-Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by groups.io with SMTP; Fri, 23 Aug 2019 05:11:32 -0700 X-Received: by mail-wm1-f67.google.com with SMTP id f72so8698802wmf.5 for ; Fri, 23 Aug 2019 05:11:31 -0700 (PDT) X-Gm-Message-State: APjAAAUtkg7f6uWParX4FlwFes+auSUBrZO/JSBbEeOo+j3bjIM5qnLi VxlxITm9VAKeX6PiUmiUKN/VgothV8A= X-Google-Smtp-Source: APXvYqzirkUoPdwdJW4u+gvRx49i6fxHV+IjkY/W/hP1M7DA4vVKxvMu7VC5uQUHWw1vxZAdsOZHTw== X-Received: by 2002:a1c:a852:: with SMTP id r79mr4717834wme.36.1566562290160; Fri, 23 Aug 2019 05:11:30 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.87.76]) by smtp.gmail.com with ESMTPSA id 16sm3247579wmx.45.2019.08.23.05.11.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2019 05:11:29 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-devel] [edk2-platforms: PATCH 1/1] Platform/Rpi3: Add compatible property to the "usb" Device Tree node Date: Fri, 23 Aug 2019 13:11:17 +0100 Message-Id: <20190823121117.5624-2-pete@akeo.ie> In-Reply-To: <20190823121117.5624-1-pete@akeo.ie> References: <20190823121117.5624-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1566562293; bh=eGvsbrMYpG+Oh8gXnQHz/hHWnxKsPp/mP8orYsKFxk4=; h=Cc:Date:From:Reply-To:Subject:To; b=wbXcC+5+2vin2u+1dcybUCOP5p4fnREiOenunjZbqPjAHEydX04kolj9ysMQoyg//hU 3xL28gWOA43csd9kMG5p8On1L8rxsaGqgB3Ricj1aeJiaEmrkyw9t0gRrmcyL7vX6UhXA Y6mP0bX41yhG3eVsvuFRopxQB8D/EtYTO9U= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Some Linux kernels (e.g. Debian) require "bcm,bcm2835-usb" to be present in the list of compatible properties for the "usb" node, else they are unable to handle some USB devices. This patch ensures that the compatible property is added if not present. Signed-off-by: Pete Batard --- Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c | 74 ++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c b/Platform/R= aspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c index 45ffe2e394a2..399a48430457 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c +++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c @@ -135,6 +135,75 @@ UpdateMacAddress ( return EFI_SUCCESS; } =20 +// +// Add "bcm2835-usb" to the USB compatible property list, if not present. +// Required because some Linux kernels can't handle USB devices otherwise. +// +STATIC +EFI_STATUS +AddUsbCompatibleProperty ( + VOID + ) +{ + CONST CHAR8 Prop[] =3D "brcm,bcm2708-usb"; + CONST CHAR8 NewProp[] =3D "brcm,bcm2835-usb"; + CONST CHAR8 *List; + CHAR8 *NewList; + INT32 ListSize; + INTN Node; + INTN Retval; + + // Locate the node that the 'usb' alias refers to + Node =3D fdt_path_offset (mFdtImage, "usb"); + if (Node < 0) { + DEBUG ((DEBUG_ERROR, "%a: failed to locate 'usb' alias\n", __FUNCTION_= _)); + return EFI_NOT_FOUND; + } + + // Get the property list. This is a list of NUL terminated strings. + List =3D fdt_getprop (mFdtImage, Node, "compatible", &ListSize); + if (List =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: failed to locate properties\n", __FUNCTION__= )); + return EFI_NOT_FOUND; + } + + // Check if the compatible value we plan to add is already present + if (fdt_stringlist_contains (List, ListSize, NewProp)) { + DEBUG ((DEBUG_INFO, "%a: property '%a' is already set.\n", + __FUNCTION__, NewProp)); + return EFI_SUCCESS; + } + + // Make sure the compatible device is what we expect + if (!fdt_stringlist_contains (List, ListSize, Prop)) { + DEBUG ((DEBUG_ERROR, "%a: property '%a' is missing!\n", + __FUNCTION__, Prop)); + return EFI_NOT_FOUND; + } + + // Add the new NUL terminated entry to our list + DEBUG ((DEBUG_INFO, "%a: adding '%a' to the properties\n", + __FUNCTION__, NewProp)); + + NewList =3D AllocatePool (ListSize + sizeof (NewProp)); + if (NewList =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: failed to allocate memory\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES;; + } + CopyMem (NewList, List, ListSize); + CopyMem (&NewList[ListSize], NewProp, sizeof (NewProp)); + + Retval =3D fdt_setprop (mFdtImage, Node, "compatible", NewList, + ListSize + sizeof (NewProp)); + if (Retval !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: failed to update properties (%d)\n", + __FUNCTION__, Retval)); + return EFI_NOT_FOUND; + } + + return EFI_SUCCESS; +} + STATIC EFI_STATUS CleanMemoryNodes ( @@ -486,6 +555,11 @@ FdtDxeInitialize ( Print (L"Failed to update MAC address: %r\n", Status); } =20 + Status =3D AddUsbCompatibleProperty (); + if (EFI_ERROR (Status)) { + Print (L"Failed to update USB compatible properties: %r\n", Status); + } + if (Internal) { /* * A GPU-provided DTB already has the full command line. --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#46298): https://edk2.groups.io/g/devel/message/46298 Mute This Topic: https://groups.io/mt/33000395/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-