From nobody Mon Feb 9 19:07:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+51339+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51339+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1574858251; cv=none; d=zohomail.com; s=zohoarc; b=YWunZRlN/i7ixftsChRttSRJlYpEoNcTGEh0NGjQy2/psVIVpdjHssKXq07gZ7kJmeVP/EvfVY4ndozhE7oX47GNfu/O8jfQlbb4lGK5Vc0v4RvNt7PLfG1fXcYRVFw0Bz6oGmDDgsxcxt1crBmYFrzIFqPUSN0FDXgX0W+V4MQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574858251; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=7kND2kx6vB7J/73IX70xkqgRw+5hrhdzlG9NEGZ03vQ=; b=lZAksYfVaTRkuI4/v1ql6eTqIisHCKTZUYxnU+XMOliPUO4piQP/D0KOA0HfXULEBqi/C/eGWQpZt+yVCQyRjeB1Ay6Ci0LvkapkA8Ve0+M6FT+fXX1RsTOBtibSh3znIBhDWMgbctx/CXK9+Ta7DdKR/rIHX6YIveBWXNurRx0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51339+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157485825145760.502968701211216; Wed, 27 Nov 2019 04:37:31 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Wed, 27 Nov 2019 04:37:31 -0800 X-Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web10.5435.1574858250144410117 for ; Wed, 27 Nov 2019 04:37:30 -0800 X-Received: by mail-wr1-f68.google.com with SMTP id z3so26476895wru.3 for ; Wed, 27 Nov 2019 04:37:29 -0800 (PST) X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= X-Google-Smtp-Source: APXvYqzQh1lj1aBmdy6KioOTBBryt+VS/JEvef3wPWWnL9QoayCYqUXyc1nRWuVTv38HPofSFVXPUA== X-Received: by 2002:adf:e3c1:: with SMTP id k1mr1660166wrm.151.1574858248384; Wed, 27 Nov 2019 04:37:28 -0800 (PST) X-Received: from localhost.localdomain ([84.203.37.1]) by smtp.gmail.com with ESMTPSA id p9sm18847833wrs.55.2019.11.27.04.37.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Nov 2019 04:37:27 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com, samer.el-haj-mahmoud@arm.com, andrey.warkentin@gmail.com Subject: [edk2-devel] [edk2-platforms][PATCH 5/5] Platform/RPi: Set SD routing according to model Date: Wed, 27 Nov 2019 12:37:06 +0000 Message-Id: <20191127123706.4604-6-pete@akeo.ie> In-Reply-To: <20191127123706.4604-1-pete@akeo.ie> References: <20191127123706.4604-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=1574858251; bh=H4Lyduu0ch+yyKX46zDl1658ZIudvJU5IV4OjAq1C0E=; h=Cc:Date:From:Reply-To:Subject:To; b=tXCSFgC5SpNQR3LUXeN8vYhv/Ms9M8CFyxhWpwd0EVOq3uaXce4ZRcIIvgBApMwrNm+ gQu9htYXq7CQNBLWHX9XJ5OgeFtLUy4FIo8GWmHqo45DtAD4F0T1i+9qWqBB0gK+3igen TQCD5mks6/GIQ9PfSVGmTKsZg5BpRP6UDTs= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Samer El-Haj-Mahmoud The Raspberry Pi 4 has a new SD controller. As a result we must handle SD routing according to the model, which we perform in the Config driver by using the GetModelFamily () call that was recently introduced. Signed-off-by: Pete Batard --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 137 ++++++++++++++---= --- 1 file changed, 96 insertions(+), 41 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index 98e58a560ed4..26bc92f28185 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -1,6 +1,7 @@ /** @file * - * Copyright (c) 2018, Andrei Warkentin + * Copyright (c) 2019, ARM Limited. All rights reserved. + * Copyright (c) 2018 - 2019, Andrei Warkentin * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -9,10 +10,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -212,6 +215,7 @@ ApplyVariables ( UINT32 CpuClock =3D PcdGet32 (PcdCpuClock); UINT32 CustomCpuClock =3D PcdGet32 (PcdCustomCpuClock); UINT32 Rate =3D 0; + UINT32 ModelFamily =3D 0; =20 if (CpuClock !=3D 0) { if (CpuClock =3D=3D 2) { @@ -245,51 +249,102 @@ ApplyVariables ( DEBUG ((DEBUG_INFO, "Current CPU speed is %uHz\n", Rate)); } =20 - /* - * Switching two groups around, so disable both first. - * - * No, I've not seen a problem, but having a group be - * routed to two sets of pins seems like asking for trouble. - */ - GpioPinFuncSet (34, GPIO_FSEL_INPUT); - GpioPinFuncSet (35, GPIO_FSEL_INPUT); - GpioPinFuncSet (36, GPIO_FSEL_INPUT); - GpioPinFuncSet (37, GPIO_FSEL_INPUT); - GpioPinFuncSet (38, GPIO_FSEL_INPUT); - GpioPinFuncSet (39, GPIO_FSEL_INPUT); - GpioPinFuncSet (48, GPIO_FSEL_INPUT); - GpioPinFuncSet (49, GPIO_FSEL_INPUT); - GpioPinFuncSet (50, GPIO_FSEL_INPUT); - GpioPinFuncSet (51, GPIO_FSEL_INPUT); - GpioPinFuncSet (52, GPIO_FSEL_INPUT); - GpioPinFuncSet (53, GPIO_FSEL_INPUT); - if (PcdGet32 (PcdSdIsArasan)) { - DEBUG ((DEBUG_INFO, "Routing SD to Arasan\n")); - Gpio48Group =3D GPIO_FSEL_ALT3; + Status =3D mFwProtocol->GetModelFamily (&ModelFamily); + if (Status !=3D EFI_SUCCESS) { + DEBUG ((DEBUG_ERROR, "Couldn't get the Raspberry Pi model family: %r\n= ", Status)); + } else { + DEBUG ((DEBUG_INFO, "Current Raspberry Pi model family is 0x%x\n", Mod= elFamily)); + } + + + if (ModelFamily =3D=3D 3) { /* - * Route SDIO to SdHost. + * Pi 3: either Arasan or SdHost goes to SD card. + * + * Switching two groups around, so disable both first. + * + * No, I've not seen a problem, but having a group be + * routed to two sets of pins seems like asking for trouble. */ - Gpio34Group =3D GPIO_FSEL_ALT0; - } else { - DEBUG ((DEBUG_INFO, "Routing SD to SdHost\n")); - Gpio48Group =3D GPIO_FSEL_ALT0; + GpioPinFuncSet (34, GPIO_FSEL_INPUT); + GpioPinFuncSet (35, GPIO_FSEL_INPUT); + GpioPinFuncSet (36, GPIO_FSEL_INPUT); + GpioPinFuncSet (37, GPIO_FSEL_INPUT); + GpioPinFuncSet (38, GPIO_FSEL_INPUT); + GpioPinFuncSet (39, GPIO_FSEL_INPUT); + GpioPinFuncSet (48, GPIO_FSEL_INPUT); + GpioPinFuncSet (49, GPIO_FSEL_INPUT); + GpioPinFuncSet (50, GPIO_FSEL_INPUT); + GpioPinFuncSet (51, GPIO_FSEL_INPUT); + GpioPinFuncSet (52, GPIO_FSEL_INPUT); + GpioPinFuncSet (53, GPIO_FSEL_INPUT); + + if (PcdGet32 (PcdSdIsArasan)) { + DEBUG ((DEBUG_INFO, "Routing SD to Arasan\n")); + Gpio48Group =3D GPIO_FSEL_ALT3; + /* + * Route SDIO to SdHost. + */ + Gpio34Group =3D GPIO_FSEL_ALT0; + } else { + DEBUG ((DEBUG_INFO, "Routing SD to SdHost\n")); + Gpio48Group =3D GPIO_FSEL_ALT0; + /* + * Route SDIO to Arasan. + */ + Gpio34Group =3D GPIO_FSEL_ALT3; + } + GpioPinFuncSet (34, Gpio34Group); + GpioPinFuncSet (35, Gpio34Group); + GpioPinFuncSet (36, Gpio34Group); + GpioPinFuncSet (37, Gpio34Group); + GpioPinFuncSet (38, Gpio34Group); + GpioPinFuncSet (39, Gpio34Group); + GpioPinFuncSet (48, Gpio48Group); + GpioPinFuncSet (49, Gpio48Group); + GpioPinFuncSet (50, Gpio48Group); + GpioPinFuncSet (51, Gpio48Group); + GpioPinFuncSet (52, Gpio48Group); + GpioPinFuncSet (53, Gpio48Group); + + } else if (ModelFamily =3D=3D 4){ /* - * Route SDIO to Arasan. + * Pi 4: either Arasan or eMMC2 goes to SD card. */ - Gpio34Group =3D GPIO_FSEL_ALT3; + if (PcdGet32 (PcdSdIsArasan)) { + /* + * WiFi disabled. + */ + GpioPinFuncSet (34, GPIO_FSEL_INPUT); + GpioPinFuncSet (35, GPIO_FSEL_INPUT); + GpioPinFuncSet (36, GPIO_FSEL_INPUT); + GpioPinFuncSet (37, GPIO_FSEL_INPUT); + GpioPinFuncSet (38, GPIO_FSEL_INPUT); + GpioPinFuncSet (39, GPIO_FSEL_INPUT); + /* + * SD card pins go to Arasan. + */ + MmioWrite32((GPIO_BASE_ADDRESS + 0xD0), + MmioRead32(GPIO_BASE_ADDRESS + 0xD0) | 0x2); + } else { + /* + * SD card pins back to eMMC2. + */ + MmioWrite32((GPIO_BASE_ADDRESS + 0xD0), + MmioRead32(GPIO_BASE_ADDRESS + 0xD0) & ~0x2); + /* + * WiFi back to Arasan. + */ + GpioPinFuncSet (34, GPIO_FSEL_ALT3); + GpioPinFuncSet (35, GPIO_FSEL_ALT3); + GpioPinFuncSet (36, GPIO_FSEL_ALT3); + GpioPinFuncSet (37, GPIO_FSEL_ALT3); + GpioPinFuncSet (38, GPIO_FSEL_ALT3); + GpioPinFuncSet (39, GPIO_FSEL_ALT3); + } + } else { + DEBUG ((DEBUG_ERROR, "Model Family %d not supported...\n", ModelFamily= )); } - GpioPinFuncSet (34, Gpio34Group); - GpioPinFuncSet (35, Gpio34Group); - GpioPinFuncSet (36, Gpio34Group); - GpioPinFuncSet (37, Gpio34Group); - GpioPinFuncSet (38, Gpio34Group); - GpioPinFuncSet (39, Gpio34Group); - GpioPinFuncSet (48, Gpio48Group); - GpioPinFuncSet (49, Gpio48Group); - GpioPinFuncSet (50, Gpio48Group); - GpioPinFuncSet (51, Gpio48Group); - GpioPinFuncSet (52, Gpio48Group); - GpioPinFuncSet (53, Gpio48Group); =20 /* * JTAG pin JTAG sig GPIO Mode Header pin --=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 (#51339): https://edk2.groups.io/g/devel/message/51339 Mute This Topic: https://groups.io/mt/62504750/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-