public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Leif Lindholm <leif.lindholm@linaro.org>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Daniel Thompson" <daniel.thompson@linaro.org>,
	"Masami Hiramatsu" <masami.hiramatsu@linaro.org>,
	"Pipat/メタワニットポン ピパット" <methavanitpong.pipat@socionext.com>,
	"Masahisa Kojima" <masahisa.kojima@linaro.org>
Subject: Re: [PATCH edk2-platforms v4 34/34] Platform/SynQuacerEvalBoard: add eMMC driver stack
Date: Fri, 17 Nov 2017 17:35:00 +0000	[thread overview]
Message-ID: <CAKv+Gu82-EqSchtiZLQv22H1tMteVj4CT3Agsu1YuDJpsAHxXA@mail.gmail.com> (raw)
In-Reply-To: <20171117173328.ge32ltas5dryoyjy@bivouac.eciton.net>

On 17 November 2017 at 17:33, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Fri, Nov 17, 2017 at 05:25:45PM +0000, Ard Biesheuvel wrote:
>> On 17 November 2017 at 17:18, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>> > On Fri, Nov 10, 2017 at 02:21:27PM +0000, Ard Biesheuvel wrote:
>> >> Add the drivers required to use the onboard eMMC on the SynQuacer
>> >> Evaluation Board.
>> >>
>> >> Contributed-under: TianoCore Contribution Agreement 1.1
>> >> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> >> ---
>> >> NOTE: this depends on an upstream EDK2 change that is currently still under
>> >>       discussion
>> >>
>> >>  Platform/Socionext/DeveloperBox/DeveloperBox.dsc                |   1 +
>> >>  Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc    |   8 +
>> >>  Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf    |   7 +
>> >>  Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c          | 204 ++++++++++++++++++++
>> >>  Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c   |  12 +-
>> >>  Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h   |  37 ++++
>> >>  Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf |   5 +
>> >>  7 files changed, 266 insertions(+), 8 deletions(-)
>> >>
>> >> diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
>> >> index cd4eb79b35bf..1a09f727b31f 100644
>> >> --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
>> >> +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
>> >> @@ -177,6 +177,7 @@ [LibraryClasses.common.DXE_DRIVER]
>> >>    #
>> >>    PciSegmentLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf
>> >>    PciHostBridgeLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf
>> >> +  NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf
>> >>
>> >>  [LibraryClasses.common.UEFI_APPLICATION]
>> >>    PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
>> >> diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc
>> >> index 4034bcfe82c5..20b719794d06 100644
>> >> --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc
>> >> +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc
>> >> @@ -176,6 +176,7 @@ [LibraryClasses.common.DXE_DRIVER]
>> >>    #
>> >>    PciSegmentLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciSegmentLib/SynQuacerPciSegmentLib.inf
>> >>    PciHostBridgeLib|Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf
>> >> +  NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf
>> >>
>> >>  [LibraryClasses.common.UEFI_APPLICATION]
>> >>    PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
>> >> @@ -529,6 +530,13 @@ [Components.common]
>> >>    MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
>> >>
>> >>    #
>> >> +  # eMMC support
>> >> +  #
>> >> +  MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
>> >> +  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf
>> >> +  MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf
>> >> +
>> >> +  #
>> >>    # AHCI Support
>> >>    #
>> >>    MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
>> >> diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf
>> >> index 4577bd316a1f..1599f8953008 100644
>> >> --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf
>> >> +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf
>> >> @@ -149,6 +149,13 @@ [FV.FvMain]
>> >>    INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
>> >>
>> >>    #
>> >> +  # eMMC support
>> >> +  #
>> >> +  INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
>> >> +  INF MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf
>> >> +  INF MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf
>> >> +
>> >> +  #
>> >>    # AHCI Support
>> >>    #
>> >>    INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
>> >> diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c
>> >> new file mode 100644
>> >> index 000000000000..4c7713d78fa3
>> >> --- /dev/null
>> >> +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c
>> >> @@ -0,0 +1,204 @@
>> >> + /** @file
>> >> +  SynQuacer DXE platform driver - eMMC support
>> >> +
>> >> +  Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
>> >> +
>> >> +  This program and the accompanying materials are licensed and made available
>> >> +  under the terms and conditions of the BSD License which accompanies this
>> >> +  distribution.  The full text of the license may be found at
>> >> +  http://opensource.org/licenses/bsd-license.php
>> >> +
>> >> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> >> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>> >> +**/
>> >> +
>> >> +#include "PlatformDxe.h"
>> >> +
>> >> +// F_SDH30 extended Controller registers
>> >> +#define F_SDH30_AHB_CONFIG        0x100
>> >> +#define  F_SDH30_AHB_BIGED        BIT6
>> >> +#define  F_SDH30_BUSLOCK_DMA      BIT5
>> >> +#define  F_SDH30_BUSLOCK_EN       BIT4
>> >> +#define  F_SDH30_SIN              BIT3
>> >> +#define  F_SDH30_AHB_INCR_16      BIT2
>> >> +#define  F_SDH30_AHB_INCR_8       BIT1
>> >> +#define  F_SDH30_AHB_INCR_4       BIT0
>> >> +
>> >> +#define F_SDH30_TUNING_SETTING    0x108
>> >> +#define  F_SDH30_CMD_CHK_DIS      BIT16
>> >> +
>> >> +#define F_SDH30_IO_CONTROL2       0x114
>> >> +#define  F_SDH30_MSEL_O_1_8       BIT18
>> >> +#define  F_SDH30_CRES_O_DN        BIT19
>> >> +
>> >> +#define F_SDH30_ESD_CONTROL       0x124
>> >> +#define  F_SDH30_EMMC_RST         BIT1
>> >> +#define  F_SDH30_EMMC_HS200       BIT24
>> >> +#define  F_SDH30_CMD_DAT_DELAY    BIT9
>> >> +
>> >> +#define F_SDH30_TUNING_SETTING    0x108
>> >> +#define  F_SDH30_CMD_CHK_DIS      BIT16
>> >> +
>> >> +#define F_SDH30_IO_CONTROL2       0x114
>> >> +#define  F_SDH30_MSEL_O_1_8       BIT18
>> >> +#define  F_SDH30_CRES_O_DN        BIT19
>> >> +
>> >> +#define F_SDH30_ESD_CONTROL       0x124
>> >> +#define  F_SDH30_EMMC_RST         BIT1
>> >> +#define  F_SDH30_EMMC_HS200       BIT24
>> >> +#define  F_SDH30_CMD_DAT_DELAY    BIT9
>> >> +
>> >> +#define SD_HC_CLOCK_CTRL          0x2C
>> >> +#define SYNQUACER_CLOCK_CTRL_VAL  0xBC01
>> >> +
>> >> +#define SD_HC_CAP_SDR104          BIT33
>> >> +
>> >> +#define ESD_CONTROL_RESET_DELAY   (20 * 1000)
>> >> +#define IO_CONTROL2_SETTLE_US     3000
>> >> +
>> >> +STATIC EFI_HANDLE mSdMmcControllerHandle;
>> >> +
>> >> +/**
>> >> +
>> >> +  Override function for SDHCI capability bits
>> >> +
>> >> +  @param[in]      ControllerHandle          The EFI_HANDLE of the controller.
>> >> +  @param[in]      Slot                      The 0 based slot index.
>> >> +  @param[in,out]  SdMmcHcSlotCapability     The SDHCI capability structure.
>> >> +
>> >> +  @retval EFI_SUCCESS           The override function completed successfully.
>> >> +  @retval EFI_NOT_FOUND         The specified controller or slot does not exist.
>> >> +  @retval EFI_INVALID_PARAMETER SdMmcHcSlotCapability is NULL
>> >> +
>> >> +**/
>> >> +STATIC
>> >> +EFI_STATUS
>> >> +EFIAPI
>> >> +SynQuacerSdMmcOverrideCapability (
>> >> +  IN      EFI_HANDLE              ControllerHandle,
>> >> +  IN      UINT8                   Slot,
>> >> +  IN  OUT VOID                    *SdMmcHcSlotCapability
>> >> +  )
>> >> +{
>> >> +  UINT64    *Caps;
>> >> +
>> >> +  ASSERT (ControllerHandle == mSdMmcControllerHandle);
>> >> +  ASSERT (Slot == 0);
>> >> +
>> >> +  if (ControllerHandle != mSdMmcControllerHandle || Slot != 0) {
>> >> +    return EFI_NOT_FOUND;
>> >> +  }
>> >> +
>> >> +  //
>> >> +  // Clear the SDR104 capability bit. This avoids the need for a HS200 tuning
>> >> +  // quirk that is difficult to support using the generic driver.
>> >> +  //
>> >> +  Caps = SdMmcHcSlotCapability;
>> >> +  *Caps &= ~(UINT64)SD_HC_CAP_SDR104;
>> >
>> > MmioAnd64 and drop the temporary Caps variable?
>> > (I only suggest it because it initially confused me to think
>> > something more clever was going on.)
>> >
>>
>> This is memory not MMIO. (The SD/MMC driver reads the capability
>> register and passes the value by reference to this function)
>
> Hmm, OK, but in that case - why is it a VOID * rather than a UINT64 *?
> Is the size of the register (and its location in some struct) not
> standardised across implementations?
>

I guess a UINT64* would be more appropriate. Care to add a comment to
that effect to the EDK2 patches that propose the protocol? :-)


      reply	other threads:[~2017-11-17 17:30 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10 14:20 [PATCH edk2-platforms v4 00/34] add support for Socionext SynQuacer Ard Biesheuvel
2017-11-10 14:20 ` [PATCH edk2-platforms v4 01/34] Silicon/SynQuacer: add package with platform headers Ard Biesheuvel
2017-11-10 14:20 ` [PATCH edk2-platforms v4 02/34] Silicon/Socionext: add driver for NETSEC network controller Ard Biesheuvel
2017-11-10 14:20 ` [PATCH edk2-platforms v4 03/34] Silicon/Socionext: add PlatformPeilib implementation for SynQuacer Ard Biesheuvel
2017-11-10 14:20 ` [PATCH edk2-platforms v4 04/34] Silicon/SynQuacer: implement a platform DXE driver Ard Biesheuvel
2017-11-10 14:20 ` [PATCH edk2-platforms v4 05/34] Silicon/SynQuacer: add MemoryInitPeiLib implementation Ard Biesheuvel
2017-11-10 14:20 ` [PATCH edk2-platforms v4 06/34] Platform: add support for Socionext SynQuacer eval board Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 07/34] Silicon/SynQuacer: implement PciSegmentLib to support dual RCs Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 08/34] Silicon/SynQuacer: implement PciHostBridgeLib support Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 09/34] Silicon/SynQuacer: implement EFI_CPU_IO2_PROTOCOL Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 10/34] Platform/SynQuacerEvalBoard: add PCI support Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 11/34] Platform/SynQuacerEvalBoard: add NETSEC driver Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 12/34] Silicon/SynQuacer: add device tree support for eval board Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 13/34] Silicon/SynQuacer: add NorFlashPlatformLib implementation Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 14/34] Silicon/Socionext: add driver for SPI NOR flash Ard Biesheuvel
2017-11-17 15:08   ` Leif Lindholm
2017-11-10 14:21 ` [PATCH edk2-platforms v4 15/34] Platform/SynQuacer: incorporate NOR flash and variable drivers Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 16/34] Silicon/SynQuacer: implement PlatformFlashAccessLib Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 17/34] SynQuacer/SynQuacerMemoryInitPeiLib: add capsule support Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 18/34] Socionext/SynQuacerEvalBoard: wire up basic " Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 19/34] Socionext/SynQuacerEvalBoard: switch to execute in place Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 20/34] Platform/SynQuacerEvalBoard: add signed capsule update support Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 21/34] Silicon/SynQuacerPciHostBridgeLib: add workaround to support 32-bit only cards Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 22/34] Platform/Socionext: add support for Socionext Developer Box rev 0.1 Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 23/34] Platform/DeveloperBox: add ConsolePrefDxe driver Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 24/34] Silicon/SynQuacer: add description of GPIO block to device tree Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 25/34] Silicon/SynQuacer: add description of EXIU to the " Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 26/34] Silicon/SynQuacer: add DT description of the SDHCI controller Ard Biesheuvel
2017-11-17 15:16   ` Leif Lindholm
2017-11-17 15:18     ` Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 27/34] Silicon/SynQuacerMemoryInitPeiLib: ignore capsules when clearing NVRAM Ard Biesheuvel
2017-11-17 15:23   ` Leif Lindholm
2017-11-10 14:21 ` [PATCH edk2-platforms v4 28/34] Silicon/SynQuacer: implement PEIM that exposes GPIO PPI Ard Biesheuvel
2017-11-17 15:46   ` Leif Lindholm
2017-11-10 14:21 ` [PATCH edk2-platforms v4 29/34] Silicon/SynQuacer: implement 'clear NVRAM' feature using a DIP switch Ard Biesheuvel
2017-11-17 15:51   ` Leif Lindholm
2017-11-17 15:53     ` Ard Biesheuvel
2017-11-17 16:10   ` Leif Lindholm
2017-11-17 17:42     ` Ard Biesheuvel
2017-11-23 12:51       ` Leif Lindholm
2017-11-10 14:21 ` [PATCH edk2-platforms v4 30/34] Silicon/NXP: add RTC support library for PCF8563 I2C IP Ard Biesheuvel
2017-11-17 16:39   ` Leif Lindholm
2017-11-17 16:49     ` Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 31/34] Silicon/Socionext: implement I2C master protocol for SynQuacer I2C Ard Biesheuvel
2017-11-17 17:05   ` Leif Lindholm
2017-11-10 14:21 ` [PATCH edk2-platforms v4 32/34] Platform/DeveloperBox: wire up RTC support Ard Biesheuvel
2017-11-10 14:21 ` [PATCH edk2-platforms v4 33/34] Platform/DeveloperBox: add description of power button to DT Ard Biesheuvel
2017-11-17 17:06   ` Leif Lindholm
2017-11-10 14:21 ` [PATCH edk2-platforms v4 34/34] Platform/SynQuacerEvalBoard: add eMMC driver stack Ard Biesheuvel
2017-11-17 17:18   ` Leif Lindholm
2017-11-17 17:25     ` Ard Biesheuvel
2017-11-17 17:33       ` Leif Lindholm
2017-11-17 17:35         ` Ard Biesheuvel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKv+Gu82-EqSchtiZLQv22H1tMteVj4CT3Agsu1YuDJpsAHxXA@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox