From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web11.7464.1574868255851946280 for ; Wed, 27 Nov 2019 07:24:16 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QgLaXs54; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574868254; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0kRKFJZ5L/SHpJubRek2jN4xrVBA1w58hVmdE7xmBaw=; b=QgLaXs54GCRSJlvuQGJZGS4zL7DjcUvx+jgF6jxBojTnAsPd9XzSuJLBjnBTFarlu0/VBZ tQ6V0NoPbPz+Zah0Ta3kBscxFDiJSlyVKTa0r82C1iDiBFfIc1oVOUo5/FNVyDMcoyJwUu lEnNk2EVECQgxi5P92h7hiYQd+53Lh8= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-O_0tKH_3M1-Vnnhxh1Lq0g-1; Wed, 27 Nov 2019 10:24:13 -0500 Received: by mail-wr1-f70.google.com with SMTP id d8so8371913wrq.12 for ; Wed, 27 Nov 2019 07:24:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0kRKFJZ5L/SHpJubRek2jN4xrVBA1w58hVmdE7xmBaw=; b=Yi/WSRXD7iEtgRSYNkA705KBko2AhHl2wXxYtyCfWHHV6gAgGHAETJtXnSWhGa6LPQ N5A5aNlEeLAjYYIKA+d10LA49xEFkteuNbJxgPHUByvw6TZVbVOAEFP4u8+iMqNJ5uTb jN9GUooEPGncN5Xq9xgJ/BAou5/GOchJs5Gk7fkdqQekTElamgAiFWFcQWvKnPazHUQ9 rUkl6COxEtiTTZ5NJvAF3fTzy2MTJCER09eDFWtWr5w8TUHRaiRLzBorHjUnsK3DfmM9 TeXZKYLH700/p7LictoIL2svxy5QfvdkPAdHx8s4YvkXhSWbpCDIvbKDoT15FTSl28sj lPpw== X-Gm-Message-State: APjAAAWihu53qjegFdQd6cYWecc9bV8F/Qe4G19M2REi6NxAkGxVNDK1 P6PgLon8sE1PiQAvXKxsQrAl//GlDE1DIXKPZ70dKFQG2mTHZ69Cb3oRgU22YlNZNPn4Y+xc5YE S5sWmDVrOCx99+w== X-Received: by 2002:a5d:678f:: with SMTP id v15mr41632268wru.242.1574868252260; Wed, 27 Nov 2019 07:24:12 -0800 (PST) X-Google-Smtp-Source: APXvYqx4GShIdyS+b67Ob0gkSDJ2eIS96qdJPZBKB9oz+IqJc4iDVYrDGZdmHlYV1mfnr268kO8XSA== X-Received: by 2002:a5d:678f:: with SMTP id v15mr41632238wru.242.1574868251941; Wed, 27 Nov 2019 07:24:11 -0800 (PST) Return-Path: Received: from [192.168.1.35] (182.red-88-21-103.staticip.rima-tde.net. [88.21.103.182]) by smtp.gmail.com with ESMTPSA id g184sm7752512wma.8.2019.11.27.07.24.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Nov 2019 07:24:11 -0800 (PST) Subject: Re: [edk2-platforms][PATCH 5/5] Platform/RPi: Set SD routing according to model To: Pete Batard , devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, samer.el-haj-mahmoud@arm.com, andrey.warkentin@gmail.com References: <20191127123706.4604-1-pete@akeo.ie> <20191127123706.4604-6-pete@akeo.ie> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: <672a8fd3-f9db-3d60-ea02-188af6e8a6a5@redhat.com> Date: Wed, 27 Nov 2019 16:24:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191127123706.4604-6-pete@akeo.ie> X-MC-Unique: O_0tKH_3M1-Vnnhxh1Lq0g-1 X-Mimecast-Spam-Score: 0 Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 11/27/19 1:37 PM, Pete Batard wrote: > 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. "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 = PcdGet32 (PcdCpuClock); > UINT32 CustomCpuClock = PcdGet32 (PcdCustomCpuClock); > UINT32 Rate = 0; > + UINT32 ModelFamily = 0; > > if (CpuClock != 0) { > if (CpuClock == 2) { > @@ -245,51 +249,102 @@ ApplyVariables ( > DEBUG ((DEBUG_INFO, "Current CPU speed is %uHz\n", Rate)); > } > > - /* > - * 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 = GPIO_FSEL_ALT3; > + Status = mFwProtocol->GetModelFamily (&ModelFamily); > + if (Status != 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", ModelFamily)); > + } > + > + > + if (ModelFamily == 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 = GPIO_FSEL_ALT0; > - } else { > - DEBUG ((DEBUG_INFO, "Routing SD to SdHost\n")); > - Gpio48Group = 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 = GPIO_FSEL_ALT3; > + /* > + * Route SDIO to SdHost. > + */ > + Gpio34Group = GPIO_FSEL_ALT0; > + } else { > + DEBUG ((DEBUG_INFO, "Routing SD to SdHost\n")); > + Gpio48Group = GPIO_FSEL_ALT0; > + /* > + * Route SDIO to Arasan. > + */ > + Gpio34Group = 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 == 4){ Missing space before opening brackets. Patch looks good otherwise. > /* > - * Route SDIO to Arasan. > + * Pi 4: either Arasan or eMMC2 goes to SD card. > */ > - Gpio34Group = 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); > > /* > * JTAG pin JTAG sig GPIO Mode Header pin >