From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5A5B47803EA for ; Mon, 23 Oct 2023 07:18:28 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=WHVXSWxXqLaLtVkFq9ITahLXdmmlHMpuuqW4T1izRSc=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1698045507; v=1; b=F39wixnzbDzD9wR7Z5Jn313u2+Xs0vnyMfNikeUeQFopddV8heK6ooh8C1wmjiCuSYbRQyQP r0PQHixB2wDRsTOZjFEP0N9mFTO0in3XfVhLstp++IoSn9ZRmYy4iCQgL077STVws1uK7EWgfdR 8mVUrsQXanPlCtIxHRKMVxxY= X-Received: by 127.0.0.2 with SMTP id aDfVYY7687511xOk9FQ6C9st; Mon, 23 Oct 2023 00:18:27 -0700 X-Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by mx.groups.io with SMTP id smtpd.web11.115565.1698045505751789443 for ; Mon, 23 Oct 2023 00:18:26 -0700 X-Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 7E1AA24E1BB; Mon, 23 Oct 2023 15:18:20 +0800 (CST) X-Received: from EXMBX073.cuchost.com (172.16.6.83) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 23 Oct 2023 15:18:20 +0800 X-Received: from localhost.localdomain (202.188.176.82) by EXMBX073.cuchost.com (172.16.6.83) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 23 Oct 2023 15:18:17 +0800 From: "John Chew" To: CC: mindachen1987 , Sunil V L , Leif Lindholm , Michael D Kinney , Li Yong , John Chew Subject: [edk2-devel] [PATCH v2 1/5] DesignWare/DwEmmcDxe: Enabled Internal IDMAC interrupt RX/TX register Date: Mon, 23 Oct 2023 15:17:11 +0800 Message-ID: <20231023071715.777-2-yuinyee.chew@starfivetech.com> In-Reply-To: <20231023071715.777-1-yuinyee.chew@starfivetech.com> References: <20231023071715.777-1-yuinyee.chew@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [202.188.176.82] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX073.cuchost.com (172.16.6.83) X-YovoleRuleAgent: yovoleflag Precedence: Bulk List-Subscribe: List-Help: 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,yuinyee.chew@starfivetech.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Gz9gL3oeGltQ4lps6aDELer1x7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=F39wixnz; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: mindachen1987 Remove DMA enable in CTRL register Added DMA polling handling for RX/TX Cc: Sunil V L Cc: Leif Lindholm Cc: Michael D Kinney Cc: Li Yong Co-authored-by: John Chew Signed-off-by: mindachen1987 --- Silicon/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmc.h | 6 +++ Silicon/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmcDxe.c | 52 +++++++++++= +++++++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmc.h b/Silic= on/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmc.h index 09ad9b8428c4..3347418006c7 100644 --- a/Silicon/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmc.h +++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmc.h @@ -129,4 +129,10 @@ =20 #define DWEMMC_GET_HDATA_WIDTH(x) (((x) >> 7) & 0x7) =20 +/* Internal IDMAC interrupt defines */ +#define DWMCI_IDINTEN_RI (1 << 1) +#define DWMCI_IDINTEN_TI (1 << 0) + +#define DWMCI_IDINTEN_MASK (DWMCI_IDINTEN_RI | DWMCI_= IDINTEN_TI) + #endif // __DWEMMC_H__ diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmcDxe.c b/Si= licon/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmcDxe.c index 39b1ea4346dc..7ac286c5f361 100644 --- a/Silicon/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmcDxe.c +++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmmcDxe/DwEmmcDxe.c @@ -215,6 +215,7 @@ DwEmmcNotifyState ( do { Data =3D MmioRead32 (DWEMMC_BMOD); } while (Data & DWEMMC_IDMAC_SWRESET); + MmioWrite32 (DWEMMC_IDINTEN, 0x3); break; case MmcIdleState: break; @@ -463,6 +464,14 @@ PrepareDmaData ( ) { UINTN Cnt, Blks, Idx, LastIdx; + UINT32 Data; /* flag, cnt */ + + MmioWrite32 (DWEMMC_CTRL, DWEMMC_CTRL_FIFO_RESET); + do { + /* Wait until reset operation finished */ + Data =3D MmioRead32 (DWEMMC_CTRL); + } while (Data & DWEMMC_CTRL_RESET_ALL); + MmioWrite32 (DWEMMC_IDSTS, 0xffffffff); =20 Cnt =3D (Length + DWEMMC_DMA_BUF_SIZE - 1) / DWEMMC_DMA_BUF_SIZE; Blks =3D (Length + DWEMMC_BLOCK_SIZE - 1) / DWEMMC_BLOCK_SIZE; @@ -487,9 +496,7 @@ PrepareDmaData ( (IdmacDesc + LastIdx)->Des1 =3D DWEMMC_IDMAC_DES1_BS1(Length - (LastIdx * DWEMMC_DM= A_BUF_SIZE)); /* Set the Next field of Last Descriptor */ - (IdmacDesc + LastIdx)->Des3 =3D 0; MmioWrite32 (DWEMMC_DBADDR, (UINT32)((UINTN)IdmacDesc)); - return EFI_SUCCESS; } =20 @@ -501,7 +508,7 @@ StartDma ( UINT32 Data; =20 Data =3D MmioRead32 (DWEMMC_CTRL); - Data |=3D DWEMMC_CTRL_INT_EN | DWEMMC_CTRL_DMA_EN | DWEMMC_CTRL_IDMAC_EN= ; + Data |=3D DWEMMC_CTRL_DMA_EN | DWEMMC_CTRL_IDMAC_EN; MmioWrite32 (DWEMMC_CTRL, Data); Data =3D MmioRead32 (DWEMMC_BMOD); Data |=3D DWEMMC_IDMAC_ENABLE | DWEMMC_IDMAC_FB; @@ -511,6 +518,41 @@ StartDma ( MmioWrite32 (DWEMMC_BYTCNT, Length); } =20 +STATIC +EFI_STATUS +DwEmmcWaitDmaComplete ( + IN EFI_MMC_HOST_PROTOCOL *This, + IN UINT32 Read + ) +{ + UINT32 Mask, Ctrl, Timeout =3D 1000000; + EFI_STATUS Status =3D EFI_SUCCESS; + + Mask =3D (Read) ? DWMCI_IDINTEN_RI : DWMCI_IDINTEN_TI; + + do { + Ctrl =3D MmioRead32 (DWEMMC_IDSTS); + if (Ctrl & Mask) { + break; + } + Timeout--; + gBS->Stall(1); + } while (Timeout); + + if (!Timeout) { + DEBUG ((DEBUG_INFO, "%a, DMA waiting timeout...\n", __func__)); + Status =3D EFI_DEVICE_ERROR; + } + MmioWrite32 (DWEMMC_IDSTS, DWMCI_IDINTEN_MASK); + Ctrl =3D MmioRead32(DWEMMC_CTRL); + Ctrl &=3D ~(DWEMMC_CTRL_DMA_EN); + Ctrl =3D MmioWrite32(DWEMMC_CTRL, Ctrl); + + gBS->Stall(100); + + return Status; +} + EFI_STATUS DwEmmcReadBlockData ( IN EFI_MMC_HOST_PROTOCOL *This, @@ -544,6 +586,8 @@ DwEmmcReadBlockData ( DEBUG ((DEBUG_ERROR, "Failed to read data, mDwEmmcCommand:%x, mDwEmmcA= rgument:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, Status)); goto out; } + Status =3D DwEmmcWaitDmaComplete(This, 1); + out: // Restore Tpl gBS->RestoreTPL (Tpl); @@ -583,6 +627,8 @@ DwEmmcWriteBlockData ( DEBUG ((DEBUG_ERROR, "Failed to write data, mDwEmmcCommand:%x, mDwEmmc= Argument:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, Status)); goto out; } + Status =3D DwEmmcWaitDmaComplete(This, 0); + out: // Restore Tpl gBS->RestoreTPL (Tpl); --=20 2.34.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 (#109891): https://edk2.groups.io/g/devel/message/109891 Mute This Topic: https://groups.io/mt/102130686/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-