From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.383.1610086461864884905 for ; Thu, 07 Jan 2021 22:14:22 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: jeremy.linton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 82F81113E; Thu, 7 Jan 2021 22:14:21 -0800 (PST) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 71C5B3F66E; Thu, 7 Jan 2021 22:14:21 -0800 (PST) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: ard.biesheuvel@arm.com, leif@nuviainc.com, pete@akeo.ie, samer.el-haj-mahmoud@arm.com, awarkentin@vmware.com, Jeremy Linton , Philippe Mathieu-Daude Subject: [PATCH v5 3/7] Platform/RaspberryPi: Split MMC register definitions Date: Fri, 8 Jan 2021 00:14:07 -0600 Message-Id: <20210108061411.1721734-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210108061411.1721734-1-jeremy.linton@arm.com> References: <20210108061411.1721734-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable The current MMC (really SDHCI) definitions are tied to the Arasan controller. As we intend to reuse the definitions lets make the base address configurable when the driver loads. This assumes we won't ever want to run both the eMMC2 and Arasan SDHCI controller at the same time. Signed-off-by: Jeremy Linton Reviewed-by: Andrei Warkentin Reviewed-by: Philippe Mathieu-Daude --- .../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c | 9 ++++- .../Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h | 42 ++++++++++++------= ---- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe= .c b/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c index 88e9126e35..379b271187 100644 --- a/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c +++ b/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c @@ -16,6 +16,7 @@ STATIC CARD_DETECT_STATE mCardDetectState =3D CardDetectR= equired; UINT32 LastExecutedCommand =3D (UINT32) -1;=0D =0D STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;=0D +STATIC UINTN mMmcHsBase;=0D =0D /**=0D These SD commands are optional, according to the SD Spec=0D @@ -763,7 +764,13 @@ MMCInitialize ( =0D DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: MMCInitialize()\n"));=0D =0D - if (!PcdGet32 (PcdSdIsArasan)) {=0D + if (PcdGet32 (PcdSdIsArasan)) {=0D + DEBUG ((DEBUG_INFO, "SD is routed to Arasan\n"));=0D + mMmcHsBase =3D MMCHS1_BASE;=0D + } else if (RPI_MODEL =3D=3D 4) {=0D + DEBUG ((DEBUG_INFO, "SD is routed to emmc2\n"));=0D + mMmcHsBase =3D MMCHS2_BASE;=0D + } else {=0D DEBUG ((DEBUG_INFO, "SD is not routed to Arasan\n"));=0D return EFI_REQUEST_UNLOAD_IMAGE;=0D }=0D diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.= h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h index fd07b47170..1068a63b4b 100644 --- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h +++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h @@ -13,15 +13,18 @@ =0D // MMC/SD/SDIO1 register definitions.=0D #define MMCHS1_OFFSET 0x00300000=0D +#define MMCHS2_OFFSET 0x00340000=0D #define MMCHS1_BASE (BCM2836_SOC_REGISTERS + MMCHS1_OFFSET)=0D +#define MMCHS2_BASE (BCM2836_SOC_REGISTERS + MMCHS2_OFFSET)=0D #define MMCHS1_LENGTH 0x00000100=0D +#define MMCHS2_LENGTH 0x00000100=0D =0D -#define MMCHS_BLK (MMCHS1_BASE + 0x4)=0D +#define MMCHS_BLK (mMmcHsBase + 0x4)=0D #define BLEN_512BYTES (0x200UL << 0)=0D =0D -#define MMCHS_ARG (MMCHS1_BASE + 0x8)=0D +#define MMCHS_ARG (mMmcHsBase + 0x8)=0D =0D -#define MMCHS_CMD (MMCHS1_BASE + 0xC)=0D +#define MMCHS_CMD (mMmcHsBase + 0xC)=0D #define BCE_ENABLE BIT1=0D #define DDIR_READ BIT4=0D #define DDIR_WRITE (0x0UL << 4)=0D @@ -43,13 +46,13 @@ #define INDX(CMD_INDX) (TYPE(CMD_TYPE_NORMAL) | _INDX(CMD_INDX))=0D #define INDX_ABORT(CMD_INDX) (TYPE(CMD_TYPE_ABORT) | _INDX(CMD_INDX))=0D =0D -#define MMCHS_RSP10 (MMCHS1_BASE + 0x10)=0D -#define MMCHS_RSP32 (MMCHS1_BASE + 0x14)=0D -#define MMCHS_RSP54 (MMCHS1_BASE + 0x18)=0D -#define MMCHS_RSP76 (MMCHS1_BASE + 0x1C)=0D -#define MMCHS_DATA (MMCHS1_BASE + 0x20)=0D +#define MMCHS_RSP10 (mMmcHsBase + 0x10)=0D +#define MMCHS_RSP32 (mMmcHsBase + 0x14)=0D +#define MMCHS_RSP54 (mMmcHsBase + 0x18)=0D +#define MMCHS_RSP76 (mMmcHsBase + 0x1C)=0D +#define MMCHS_DATA (mMmcHsBase + 0x20)=0D =0D -#define MMCHS_PRES_STATE (MMCHS1_BASE + 0x24)=0D +#define MMCHS_PRES_STATE (mMmcHsBase + 0x24)=0D #define CMDI_MASK BIT0=0D #define CMDI_ALLOWED (0x0UL << 0)=0D #define CMDI_NOT_ALLOWED BIT0=0D @@ -58,17 +61,19 @@ #define DATI_NOT_ALLOWED BIT1=0D #define WRITE_PROTECT_OFF BIT19=0D =0D -#define MMCHS_HCTL (MMCHS1_BASE + 0x28)=0D +#define MMCHS_HCTL (mMmcHsBase + 0x28)=0D #define DTW_1_BIT (0x0UL << 1)=0D #define DTW_4_BIT BIT1=0D #define SDBP_MASK BIT8=0D #define SDBP_OFF (0x0UL << 8)=0D #define SDBP_ON BIT8=0D +#define SDVS_MASK (0x7UL << 9)=0D #define SDVS_1_8_V (0x5UL << 9)=0D #define SDVS_3_0_V (0x6UL << 9)=0D +#define SDVS_3_3_V (0x7UL << 9)=0D #define IWE BIT24=0D =0D -#define MMCHS_SYSCTL (MMCHS1_BASE + 0x2C)=0D +#define MMCHS_SYSCTL (mMmcHsBase + 0x2C)=0D #define ICE BIT0=0D #define ICS_MASK BIT1=0D #define ICS BIT1=0D @@ -84,7 +89,7 @@ #define SRC BIT25=0D #define SRD BIT26=0D =0D -#define MMCHS_INT_STAT (MMCHS1_BASE + 0x30)=0D +#define MMCHS_INT_STAT (mMmcHsBase + 0x30)=0D #define CC BIT0=0D #define TC BIT1=0D #define BWR BIT4=0D @@ -96,7 +101,7 @@ #define DCRC BIT21=0D #define DEB BIT22=0D =0D -#define MMCHS_IE (MMCHS1_BASE + 0x34)=0D +#define MMCHS_IE (mMmcHsBase + 0x34)=0D #define CC_EN BIT0=0D #define TC_EN BIT1=0D #define BWR_EN BIT4=0D @@ -112,7 +117,7 @@ #define BADA_EN BIT29=0D #define ALL_EN 0xFFFFFFFF=0D =0D -#define MMCHS_ISE (MMCHS1_BASE + 0x38)=0D +#define MMCHS_ISE (mMmcHsBase + 0x38)=0D #define CC_SIGEN BIT0=0D #define TC_SIGEN BIT1=0D #define BWR_SIGEN BIT4=0D @@ -127,14 +132,15 @@ #define CERR_SIGEN BIT28=0D #define BADA_SIGEN BIT29=0D =0D -#define MMCHS_AC12 (MMCHS1_BASE + 0x3C)=0D +#define MMCHS_AC12 (mMmcHsBase + 0x3C)=0D +#define MMCHS_HC2R (mMmcHsBase + 0x3E)=0D =0D -#define MMCHS_CAPA (MMCHS1_BASE + 0x40)=0D +#define MMCHS_CAPA (mMmcHsBase + 0x40)=0D #define VS30 BIT25=0D #define VS18 BIT26=0D =0D -#define MMCHS_CUR_CAPA (MMCHS1_BASE + 0x48)=0D -#define MMCHS_REV (MMCHS1_BASE + 0xFC)=0D +#define MMCHS_CUR_CAPA (mMmcHsBase + 0x48)=0D +#define MMCHS_REV (mMmcHsBase + 0xFC)=0D =0D #define BLOCK_COUNT_SHIFT 16=0D #define RCA_SHIFT 16=0D --=20 2.13.7