From patchwork Sun Oct 27 14:41:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josua Mayer X-Patchwork-Id: 839060 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2099.outbound.protection.outlook.com [40.107.249.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD12113BADF; Sun, 27 Oct 2024 14:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.99 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730040082; cv=fail; b=TD2VgmQjiRA+aHjjl7du83Ymr1WwTTh5VfaM9YTEnib5kegwbfYitPf6Ljo8Bw6sZSKxTrl/udeubZFUmoQb+BbIUgTjNrKL8VKIpXHm+JvaCC8Q4WXSmfJyLfFv976UnGaEdvhUTj4q7U4B0krcoeQN6NTMwBLZJqFUAeY41HM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730040082; c=relaxed/simple; bh=M5Uuow6FS21HCYbB7Yl2VeSRzs3nfkY7zhGpdfFqc50=; h=From:Date:Subject:Content-Type:Message-Id:To:Cc:MIME-Version; b=Y8dN9Od3Ef4XHDpltuw1GCE7NPKUyYdpUJOsb/lwZBue0yLwwdufeGC2/QLmB7uwJDUixZA2AhEDNbL5iaQqu7+blV/VbpbQM0aIK/Ut25inYhjTQg/BpaGKoRnVyPZ/OD60pD4epXd7/untqCQz3OFcjO2FnIlR5tJeB4kXHVQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=solid-run.com; spf=pass smtp.mailfrom=solid-run.com; dkim=pass (1024-bit key) header.d=solidrn.onmicrosoft.com header.i=@solidrn.onmicrosoft.com header.b=XGNLriCY; arc=fail smtp.client-ip=40.107.249.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=solid-run.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=solid-run.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=solidrn.onmicrosoft.com header.i=@solidrn.onmicrosoft.com header.b="XGNLriCY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q2NHdCZy8uTD35kK8TmufmfDWzHt8JGNfwPin2cvQq2XPO88gbPaEW34/REXFDW46lzqBbpTZ4Lm3RKiMldmr7MBsjyNKIO6at6Ny+zulZfIp5pUvt5WYs9FMu0eAdxmoHM3E71QaP2pSwpwZikvCTafYw1zqPcA+UlJWlBBso+vVgfBr4f/4zZOw7J0Hy95hi4tFb9jgY26ujPAQoN0wv/aMhlfMyn9Hhx3v4OEi22QHL/hHQguaZzHYaO+nB5+DIlY8p9hMICMu2ShTIzs+wJk9lX3/jjjvQe1Iz1M9gUGzRZ5CTwFZoDoAcQ7BoofP7+g69ZGtQRJ+Yj0sMQtIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xJvzBad7BdbiPp+Q5rmwluJa3grMemuK7fh1H4tocws=; b=ojs5wEJk8RnghP0s+jDTDZ65EwOpAKC4qXTrUW+a9sYux01O7wxXaDlT3OvRf0qb+6jz0DMxfUYHiwMuafyxGju0lK4AxrzbRgsS3hIG6ACfa0woYDE/iG//+bv6LCeiNaPz8275G75SORhsB/UJ4K91lCe0lIk7Pr1bk5/E8gYjatoea3NM0E4InFYHBzkbTzHh7UGtd5Q5jCUlwmas0WH/7bpgARNZgyQRFu9fzp+1qTelpH3KVGdxP6VPyA07EuJJuFe76JGKwU4s8CZSdwfwMLlhOaRZDEqMUHwe1KarijtKIuOaniQXf5hq16C+V4pZOBtYA0F7Io/uCxjR6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=solid-run.com; dmarc=pass action=none header.from=solid-run.com; dkim=pass header.d=solid-run.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=solidrn.onmicrosoft.com; s=selector1-solidrn-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xJvzBad7BdbiPp+Q5rmwluJa3grMemuK7fh1H4tocws=; b=XGNLriCYupaD11OdiNFvVwHkjCB9wmF9vB0Y/zDjNcCAyZLJrL7MMkYlI/z6Esgh/lxvXesfDuSixpaLs1xH6p0wUPNir2ckHccMwQvp4nYAveLcupdcuOoKvm1m/XVgvqz5FPEGW8uhHa5n5sFsPLCXi6BbkQZZIR8ZD2Zk8Qo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=solid-run.com; Received: from AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) by AS8PR04MB8385.eurprd04.prod.outlook.com (2603:10a6:20b:3f3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Sun, 27 Oct 2024 14:41:16 +0000 Received: from AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529]) by AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529%4]) with mapi id 15.20.8093.024; Sun, 27 Oct 2024 14:41:16 +0000 From: Josua Mayer Date: Sun, 27 Oct 2024 15:41:02 +0100 Subject: [PATCH] mmc: host: sdhci-esdhc-imx: implement emmc hardware reset Message-Id: <20241027-imx-emmc-reset-v1-1-d5d0c672864a@solid-run.com> X-B4-Tracking: v=1; b=H4sIAP1QHmcC/x3MQQqAIBBA0avIrBtwTBC6SrQInWoWWmiEIN09a fkW/zconIULTKpB5keKnKmDBgX+WNPOKKEbjDaWtHEosSLH6DFz4RsdGRdGInLWQ4+uzJvUfzg v7/sBVNauuGAAAAA= X-Change-ID: 20241027-imx-emmc-reset-7127d311174c To: Adrian Hunter , Haibo Chen , Ulf Hansson , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: Yazan Shhady , Rabeeh Khoury , imx@lists.linux.dev, linux-mmc@vger.kernel.org, s32@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Josua Mayer X-Mailer: b4 0.14.2 X-ClientProxiedBy: FR3P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a4::11) To AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB7586:EE_|AS8PR04MB8385:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a991ab4-c15d-4ec3-9005-08dcf695696f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?fiFa/WHa4RKJsBO/FUg5vYTR6J1eASj?= =?utf-8?q?7QP5ZMekoyb/rmhxRPVRVor6Udx51L5j9Ik53NAf3tSpt0eTDsB7B4/A4HhDaCXTL?= =?utf-8?q?WBZfaVlfucIQ3XsFMRNvLN2NwRdzR/IofBPmIjq1llQZueJ0+QhVcAKzYCJ5e1vl2?= =?utf-8?q?6vQIZrKYkvsavL6y3AFc/CW8CrrQhxH9FEMbwFr0AIUFcDKpAglxO+CwipiGyTno3?= =?utf-8?q?TSzef8d8ClVkHFnveVhFclTbiNDSqXSBKUDHd9m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L4QV1QCQd7pr6GisRxA/+Pxg?= =?utf-8?q?DGQ5DJCWbQaMQB993xRs+/JCEtDlNz9/PD8cDRcbh/ypYxS/mCowXDuD73WsLzauE?= =?utf-8?q?Zf7nz9roNWw+RDOzaZJmXLKmzd07mjk6aKyoKVUQcETfq4Ayc9yJJO2ldt/oL1Myu?= =?utf-8?q?LhGFxYrbYy01sK72OzmWWrzw9Ox5rNSulSi5r0MNa2yg3SCzMTDCmkhc=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB7586.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?eEMU8Ja0+XhK7Anl56lH51RY9OUn?= =?utf-8?q?XSjl8Q4d4iOA8tPlFVIwS+LaexqNWh7+j6MwTq6TZWTs7jodtEglRyqSeIQ77IYlu?= =?utf-8?q?tmYuQobj6rco+Re2w4KztmOxc1Jc8shFbb99+GF8nhtqD/u7K3z/7YG/+SJhf65Jj?= =?utf-8?q?jt4GWubI3K/f4ztV2h6jP13G6Vgrrh5vAvJxw0JiVAB3uvHqIbBDVmVIl52BpfoXY?= =?utf-8?q?rvgVjWVX83dFgrnDqWTexmHsskfPF92T3TByHDa4+BUF3p7UB1XwUowDO3Lukj02H?= =?utf-8?q?4XksWmZ7SVpKb3zenHhCLYgyEQWhkireCzdApuoyNmME2kHNZN6Lv4X25C/b07w/k?= =?utf-8?q?7tjiBBrUZVaguGy51iv9oPdJpZ3brsyBHScdBO3D5o1xdz6J0aiidaAvza5Qb1IsS?= =?utf-8?q?DZPVV2wnZbsWeGAHBSMtgAd2xmQiKBYdhsJoGaPyWCkhKzK/mBxPDqFcw6RMvFRZJ?= =?utf-8?q?Z4pWlqRu2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Etno1mmkwu8KU82XmLAyoNAlAt+S0ZxncgmzzaKdeTk?= =?utf-8?q?djk+9t0/VuzvRA+orCMJUssYS5MloPErF2USRhRy+SkeXKCHgDxiuhoNOem97zsHA?= =?utf-8?q?i4xzAoCE/22uyUDjgEVDhP3D89iPau0rNLYfYXf9rFFMAXTGPb6EA0JbPLKA14xov?= =?utf-8?q?EMdhL8gA1aqd?= X-OriginatorOrg: solid-run.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a991ab4-c15d-4ec3-9005-08dcf695696f X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB7586.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2024 14:41:16.0409 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a4a8aaf3-fd27-4e27-add2-604707ce5b82 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /+PowfP02mi1rqObxzkV3zcUp/Zxq+OoJzb8IbFUqdQE+sj070RmvFifEFYY6UkzyObegrXijBdCvsrdUX+hxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8385 NXP ESDHC supports control of native emmc reset signal when pinmux is set accordingly, using uSDHCx_SYS_CTRL register IPP_RST_N bit. Documentation is available in NXP i.MX6Q Reference Manual. Implement the hw_reset function in sdhci_ops asserting reset for at least 10us and waiting an extra 300us after deassertion. These particular delays were inspired by sunxi-mmc hw_reset function. Tested on SolidRun i.MX8DXL SoM with a scope, and confirmed that eMMC is still accessible after boot. eMMC extcsd has RST_N_FUNCTION=0x01, i.e. reset input enabled, Linux v5.15. Signed-off-by: Josua Mayer --- drivers/mmc/host/sdhci-esdhc-imx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc change-id: 20241027-imx-emmc-reset-7127d311174c Best regards, diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 8f0bc6dca2b0402fd2a0695903cf261a5b4e19dc..ebcfa427cca6cc2791a1701a3515ef6515779aa4 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -33,6 +33,8 @@ #define ESDHC_SYS_CTRL_DTOCV_MASK 0x0f #define ESDHC_CTRL_D3CD 0x08 #define ESDHC_BURST_LEN_EN_INCR (1 << 27) +#define ESDHC_SYS_CTRL 0x2c +#define ESDHC_SYS_CTRL_IPP_RST_N BIT(23) /* VENDOR SPEC register */ #define ESDHC_VENDOR_SPEC 0xc0 #define ESDHC_VENDOR_SPEC_SDIO_QUIRK (1 << 1) @@ -1402,6 +1404,15 @@ static u32 esdhc_cqhci_irq(struct sdhci_host *host, u32 intmask) return 0; } +static void esdhc_hw_reset(struct sdhci_host *host) +{ + esdhc_clrset_le(host, ESDHC_SYS_CTRL_IPP_RST_N, 0, ESDHC_SYS_CTRL); + udelay(10); + esdhc_clrset_le(host, ESDHC_SYS_CTRL_IPP_RST_N, + ESDHC_SYS_CTRL_IPP_RST_N, ESDHC_SYS_CTRL); + udelay(300); +} + static struct sdhci_ops sdhci_esdhc_ops = { .read_l = esdhc_readl_le, .read_w = esdhc_readw_le, @@ -1420,6 +1431,7 @@ static struct sdhci_ops sdhci_esdhc_ops = { .reset = esdhc_reset, .irq = esdhc_cqhci_irq, .dump_vendor_regs = esdhc_dump_debug_regs, + .hw_reset = esdhc_hw_reset, }; static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {