From patchwork Thu Nov 2 02:48:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13443340 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C5FFC0018A for ; Thu, 2 Nov 2023 02:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id: MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=15qxt39a7tkOqAIXugLAbA5hHZdPona5oJw2C88MBh8=; b=StPjy0kA2BEg4A 2vTwng8433YG7dGe5YzVGQhL92vfy55EUQxzSTC/v2oLGtffHL2HLKsXqtJfcm7QCFeB+shlbjNZ3 ZdNr/3xR389ZUWLp623TIs8Q/Xee7G9DHC/vh6N89K8JFTlnftszbnS0W3fXWosoLsX5p1ScZcUR4 fmpApNHx5I1KVdPTus/LWNYZ+d47hfyTCCVYH5Gccevk7p0c9KzdmO0fmQBAzHqCHGHFniFEMkOsw lT0CCQiZDjuZ5Zr0Mm1nHVZWp91i8wMEImc+//+zHGIA5yqcNzALcu0jOPGecs/LeIh72eO7sCxo0 bZNom6Qs3H1xiBBwrsbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyNli-008a1s-2u; Thu, 02 Nov 2023 02:49:14 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlf-008Zzz-0v for linux-riscv@lists.infradead.org; Thu, 02 Nov 2023 02:49:12 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c9b95943beso3714005ad.1 for ; Wed, 01 Nov 2023 19:49:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1698893349; x=1699498149; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=y6aHgY7dVjq1emLLBr9I0qdToBO/wwiRz9A+uR2RPk0=; b=A0KSWS69QQj2Doy+U/aAYWJFhzEwrjDoZScgWTy8PWoLvh/yaHmO4Wbcm5JrWWlG1T 00IU1ImC6TtHtY0H/GA6QEtwFVEThUD5SL0Y3QeUoRjLURrrDtod5fZz9rojfLfgy6kX XAlkRIjYyNjuVAexOJkhVtUsbL3/K3cftfbhLbK2v3U3aa7r/ep9ZoArVa2UQTKK6xgM V2isLNRuMdXvVp5HU1+j7eAEsLURWBterX6zAGjHnxVV2OL2r2u5Cf0EMeFuZXFXB+wO LCq9vL9c/W8TJUaSegVk7W3/yXxZtrBJCsvVoMjpwMd8iNj1BpO7+/xWtghDXUBz26Fi oeWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698893349; x=1699498149; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y6aHgY7dVjq1emLLBr9I0qdToBO/wwiRz9A+uR2RPk0=; b=WM/oO7VXXimhvQPcuw8IM4HsRI4N7SHPch4KmDIRuWZBXcjIGMbANGe+rHW0wMIbwH 2iKO03uosgEtQrwyn0RbPqWMzVEts2U61vzOJEztOYY6iVMff8/hLNirnJPR2rVZKow+ pEMiyxuSih6so13BoTTUIb2Zo6NPaQRiI3PLDONlujGWNb/8VD8NF2VtQxD9UY+v6F1w R61/KjKm+xx9HIMXlvG+n2pqGJbkKz4kUCNa+NxRKP+jcr4QQmavFjJRFsUDM6HExIC9 fcruDW/rWuwZvwU9EDhVB1mBgmIVR6hjhLffd16DTlcCGtOdX6Kz6JeY3cS9m0yvjC44 hFCg== X-Gm-Message-State: AOJu0Yy/YrPBiEfnWPQ8KqDGLh3E/+ul0y918WDwMaCDVDTZhCxpC01O mwFjgc5zZh7rbOFyIaVW4+10ow== X-Google-Smtp-Source: AGHT+IFJRRc6LBUGsDW9ZAGafzrBM0gNGpEPwmu96hSFHU2mmeWEtKtj688InhZr3neYv/dkS/dxwA== X-Received: by 2002:a17:902:c78c:b0:1b8:954c:1f6 with SMTP id w12-20020a170902c78c00b001b8954c01f6mr16004599pla.36.1698893349593; Wed, 01 Nov 2023 19:49:09 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:7e4c:4d4e:6943:bc0f]) by smtp.gmail.com with ESMTPSA id n4-20020a170902e54400b001b850c9d7b3sm1925787plf.249.2023.11.01.19.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 19:49:09 -0700 (PDT) From: Drew Fustini Date: Wed, 01 Nov 2023 19:48:52 -0700 Subject: [PATCH v4 1/7] dt-bindings: mmc: sdhci-of-dwcmhsc: Add T-Head TH1520 support MIME-Version: 1.0 Message-Id: <20231101-th1520-mmc-v4-1-86e0216b5994@baylibre.com> References: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> In-Reply-To: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Adrian Hunter , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698893345; l=855; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=sdi2GBRazAXQCmzsLeFCtwwLCyPq9k+jdkf3IoMSdfo=; b=H4G0SP7skk6Qkcbi+uapfpuNbAmQTW/dR3ZoBNmECYpgjatiRsb97dClg0sTNqpZ4Jlitliv7 IQ3UFs6gNtTCBp7USBUipzcGlL3y+nqr907S94xunPmACrwIsm57q05 X-Developer-Key: i=dfustini@baylibre.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231101_194911_323252_20DE11F8 X-CRM114-Status: UNSURE ( 8.91 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Drew Fustini , Han Gao , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Nelson , Krzysztof Kozlowski , Jason Kridner , Xi Ruoyao , linux-riscv@lists.infradead.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add compatible value for the T-Head TH1520 dwcmshc controller. Acked-by: Guo Ren Acked-by: Krzysztof Kozlowski Signed-off-by: Drew Fustini --- Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml b/Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml index a43eb837f8da..42804d955293 100644 --- a/Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml +++ b/Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml @@ -19,6 +19,7 @@ properties: - rockchip,rk3568-dwcmshc - rockchip,rk3588-dwcmshc - snps,dwcmshc-sdhci + - thead,th1520-dwcmshc reg: maxItems: 1 From patchwork Thu Nov 2 02:48:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13443335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92BA3C4167D for ; Thu, 2 Nov 2023 02:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id: MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i0/advgDImAUm1TIKn0MHtl3pXE08/RKQtDVAhlwAaQ=; b=BdK+s1apXLHsuT XtVOsY046nSRCo6lY12dwIMmtVABzhTA7QhNg/VEwJvFIrIN+I/eN1e0j9I/eFBoqYoF2zi/XHJdF 9xfH025t0ieiHDMDMqurZzzkH1Zclq146q7CYUjb8GxaBfG4WNU3k98RqgXPwY1JU3i1yxIgnAm1W i1UEIfHvyajm+p19uLCALHlEYJYoa+QaZL65R8t+XzWfH+lzQD31l84m+HxShUVAPzEW0utejfJYo bh46YnMo0bkhQBT10WgG93JZ/zhRdIbT3UKTWstDKB4lK3HIMhqQFOV/ddmPBVis5DLw3edhGYQuF Dcp6sQkjcoSY6pzHIiqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyNll-008a3A-1a; Thu, 02 Nov 2023 02:49:17 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlh-008a0g-0H for linux-riscv@lists.infradead.org; Thu, 02 Nov 2023 02:49:14 +0000 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-5a9d8f4388bso337689a12.3 for ; Wed, 01 Nov 2023 19:49:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1698893352; x=1699498152; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=l++Rbeq1YJ0LFMw4HKx/yirX8siQghzI93qQn3u3z5E=; b=FVtj5W+hDFnHVXt7+44MMx0lj/I1p6cMbdh6L/+Bo+emDysG3FLeKQ81Cs7eu2L90y de1N1ZbBoqCItW9GOKBso3fAncKxyrdKxeOppcVO1W1VJ9iapmsjr+m4ZIH1/06XREbI OLmVaYW0zonfkj9zvpqnQNsuewuFY7155ax3qMAjPqqGUl5M+e+MTXD9vvJA9mttXJO6 13w2QoXRasGWOd7hZ6OOrZFlmAxd+O8lf/7OH3DC6i5Vj+zxu45mPE84TINLmooCoY9I lunr0gaFUT7e25mZnGX6uVSf8UUpUA5sBC8Auvaz6NF//m2DD0fEYu6jKz3kxEd6eyGa 0i/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698893352; x=1699498152; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l++Rbeq1YJ0LFMw4HKx/yirX8siQghzI93qQn3u3z5E=; b=mJNP2hnVXl8xxtswlq/TY4sz3E/FtZ28EZ95nKalV1/SrL2OUzwYavh9svBviCYocW 1x/qN/jnbGm/eXSDwNYMg1Hs6sbfmBx1u0IOQwxcvnnPzMUkQvs9F5Ji47gH9/2l0Zm1 sjFEFl7mSIkelGOHM36Qair6EgJi0WDHaIdC3q0vfxoDLVJWhuu0937M2pb8zdGAgv5K AqRoSg8g+eUuHnXy3oxCj4SpeCed3RQywczTE13H1e9hglR51VQ0Y9ACGis1frqtIU6f 1K+59HLPa0CpNAo+kcWZbM+JMzY75lSfVDtF6aY3+NV8fT+S2EpIkUKWnsTSO2/7Oy8V 1omw== X-Gm-Message-State: AOJu0YybNKajffMGounUeHNoI5RL998qAXD0+rr0sXHtwfDU75G/YHOd mN95p9Ij+AMErMACQJFQhulqbg== X-Google-Smtp-Source: AGHT+IF6H7iALM4kXriivWJWeUhTUNwySvr9ZxIwWfw3Qv3hEFAdQDBio6I+smOxkk0K56iCSkXjuw== X-Received: by 2002:a17:902:e28a:b0:1c6:2ae1:dc28 with SMTP id o10-20020a170902e28a00b001c62ae1dc28mr11966568plc.36.1698893351862; Wed, 01 Nov 2023 19:49:11 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:7e4c:4d4e:6943:bc0f]) by smtp.gmail.com with ESMTPSA id n4-20020a170902e54400b001b850c9d7b3sm1925787plf.249.2023.11.01.19.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 19:49:11 -0700 (PDT) From: Drew Fustini Date: Wed, 01 Nov 2023 19:48:53 -0700 Subject: [PATCH v4 2/7] mmc: sdhci: add __sdhci_execute_tuning() to header MIME-Version: 1.0 Message-Id: <20231101-th1520-mmc-v4-2-86e0216b5994@baylibre.com> References: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> In-Reply-To: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Adrian Hunter , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698893345; l=2057; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=O0pl7kPWnknxTc+1ciCix3vi2PmSyK8UTzQqhv8rZP0=; b=5GZXJKYUX2PFkk79fptSj56AIJweFxSSLNmoeJAhqhhT1nEb/6DFj2Ax/BGJa/TaoghgrIX10 cU1vL2QBWy9BYkEYSEo48YklZTTrxD2hSaGn6Vgf6Is+H9lAI4Fza/e X-Developer-Key: i=dfustini@baylibre.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231101_194913_120854_5EC65E66 X-CRM114-Status: GOOD ( 11.57 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Drew Fustini , Han Gao , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Nelson , Jason Kridner , Xi Ruoyao , linux-riscv@lists.infradead.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Expose __sdhci_execute_tuning() so that it can be called from the mmc host controller drivers. In the sdhci-of-dwcmshc driver, sdhci_dwcmshc_th1520_ops sets platform_execute_tuning to th1520_execute_tuning(). That function has to manipulate phy registers before tuning can be performed. To avoid copying the code verbatim from __sdhci_execute_tuning() into th1520_execute_tuning(), make it possible for __sdhci_execute_tuning() to be called from sdhci-of-dwcmshc. Signed-off-by: Drew Fustini Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 3 ++- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ff41aa56564e..c79f73459915 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2841,7 +2841,7 @@ void sdhci_send_tuning(struct sdhci_host *host, u32 opcode) } EXPORT_SYMBOL_GPL(sdhci_send_tuning); -static int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode) +int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode) { int i; @@ -2879,6 +2879,7 @@ static int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode) sdhci_reset_tuning(host); return -EAGAIN; } +EXPORT_SYMBOL_GPL(__sdhci_execute_tuning); int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) { diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index f219bdea8f28..a20864fc0641 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -793,6 +793,7 @@ void sdhci_set_bus_width(struct sdhci_host *host, int width); void sdhci_reset(struct sdhci_host *host, u8 mask); void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing); int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode); +int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode); void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios); int sdhci_start_signal_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios); From patchwork Thu Nov 2 02:48:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13443337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A42FEC0018A for ; Thu, 2 Nov 2023 02:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id: MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0fi/iGMlzI2IpFa+B83lAjeDJQ4sVTRm4pL2aJBXiyw=; b=ps+mddVHwIjFDK GL20cWXe9ye1/o0vi1cDkQ8pD+gVX2qMofIuBnA2/H0q8swtQHtpAreGaRq38O7TsOG1KZZg3T14W JrvvZLTSLAT4yNaM2v8mUzOuLDKeXYMLvAcOim2/9t6iOLFbwJJmJ0hlKnFTEqj7gCmRDw4qgcn/C 0jkDAp13FECwpqlK3OJCUSt74/K/yx2zalcNRnuID4ePjU4LA4i+lI5y8QIhV5eK1sQ/DOw01KUrb xdlyAumxzv26ATg0ev4xoyqyrEngl/yjUTKSsMI8fpJEM8yNh0Y3gwg74nxo8mdi4qNT/OD6+GEnH VrQ6+OAU6JuogcbWUOVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlo-008a4g-1G; Thu, 02 Nov 2023 02:49:20 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlk-008a1u-0F for linux-riscv@lists.infradead.org; Thu, 02 Nov 2023 02:49:18 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1cc3bb32b5dso3660875ad.3 for ; Wed, 01 Nov 2023 19:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1698893354; x=1699498154; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JHk1CgnLLTewJ8o3tN4/S0YEjB9r+T1MH+waxZAekc4=; b=m4aniJh3enQEmg5yOM/ZMJf3JE26gKk7ggcsDEY6c3vEWU+FkgYw9phhQvfaUN5kzz g+gsS8tLE5oFk/VM8KXWsY2KTCkzjeYw7t7PMRmjYrVel+uvBZup3zSXs4k9kAjVLT3P kYIi8HI5m8pMohI6U6fmwR173RLD1qGlb4+e5LhlCsqzv4CkWWf9S8JeSoChCiKRu0kp 109EHZ6C3bux7fLHfAbHxFgdwXbkwUpktCWECs21T4ChHlfNZFMj30RL7AV2r3OlOo8Z vOCDrzERwYZ0CmcyfkcwvdvXpI4ArohUhR8O7L83yOtWIx4iNxhjhJNpWAE3vS/tEetJ nw2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698893354; x=1699498154; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JHk1CgnLLTewJ8o3tN4/S0YEjB9r+T1MH+waxZAekc4=; b=lpsMy3NcMVYn3wkMd00dXrm3anmEyG/q/5+sxBk5wkh/FkegopqqAzbfn8lcfn+daH +qmUZ6BcBOCJcupq0HnWJrrTohClcV3TzdjBcuqMaN3SIZV/dFInn/6hBxnxhcF9f2rX KOWC3sqoChvLokmX5vivUJlMqEYLZTlo4w8ygMSvdkRs1jBuBW7KL1B2EKsKBLJHAw5I sKpk+qnczgn4Dwi2TP8dB+y9p3AFuoOnkgRAwcnmn2glRuxtqa8wOKP0T0a7ARz+cCt4 jVqwk07pYKpR2P7hqOEmQ7BS4fZgHbSiYcvYM/MtLec694haeyb6/h2pwJMXJU3LaJrO CbFQ== X-Gm-Message-State: AOJu0YxmLYXPJToepvUZRG6FgrOwiyF1HszuyDQnZYhAhZc5vgqjemTC x0810ZSVt5WIWA1W/E03MFGQIQ== X-Google-Smtp-Source: AGHT+IHbojNAXOCyiRJActVRk9HchErJrxNFP+TXzHbg/w9+6PClAXl2lvguQKyoqxRgjjRAoyJl4w== X-Received: by 2002:a17:902:c751:b0:1cc:29ef:df7d with SMTP id q17-20020a170902c75100b001cc29efdf7dmr13966868plq.65.1698893354386; Wed, 01 Nov 2023 19:49:14 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:7e4c:4d4e:6943:bc0f]) by smtp.gmail.com with ESMTPSA id n4-20020a170902e54400b001b850c9d7b3sm1925787plf.249.2023.11.01.19.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 19:49:13 -0700 (PDT) From: Drew Fustini Date: Wed, 01 Nov 2023 19:48:54 -0700 Subject: [PATCH v4 3/7] mmc: sdhci-of-dwcmshc: Add support for T-Head TH1520 MIME-Version: 1.0 Message-Id: <20231101-th1520-mmc-v4-3-86e0216b5994@baylibre.com> References: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> In-Reply-To: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Adrian Hunter , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698893345; l=16879; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=uzJNxAqlHPC1mKPXh8Lt4rwNZSxKbrUUvZ0eAWDPuT8=; b=eBWPJFy1hdLcz/UOc5sQy7r+DZYUkyGzXjW9zZqJ8VGORP9vhUIu/RXZtBMmSyFBFSEtp3J2h GfIiShuL4bJAdTYUmtqgWGLzYXUZGG4MZA7lzRgw4eP1RZnJzoN81Q6 X-Developer-Key: i=dfustini@baylibre.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231101_194916_117657_2CDA599A X-CRM114-Status: GOOD ( 17.21 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Drew Fustini , Han Gao , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Nelson , Jason Kridner , Xi Ruoyao , linux-riscv@lists.infradead.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add support for the mmc controller in the T-Head TH1520 with the new compatible "thead,th1520-dwcmshc". Implement custom sdhci_ops for set_uhs_signaling, reset, voltage_switch, and platform_execute_tuning. Signed-off-by: Drew Fustini Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-of-dwcmshc.c | 348 ++++++++++++++++++++++++++++++++++++ 1 file changed, 348 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c index 3a3bae6948a8..1a1386b742c1 100644 --- a/drivers/mmc/host/sdhci-of-dwcmshc.c +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -35,6 +36,21 @@ #define DWCMSHC_CARD_IS_EMMC BIT(0) #define DWCMSHC_ENHANCED_STROBE BIT(8) #define DWCMSHC_EMMC_ATCTRL 0x40 +/* Tuning and auto-tuning fields in AT_CTRL_R control register */ +#define AT_CTRL_AT_EN BIT(0) /* autotuning is enabled */ +#define AT_CTRL_CI_SEL BIT(1) /* interval to drive center phase select */ +#define AT_CTRL_SWIN_TH_EN BIT(2) /* sampling window threshold enable */ +#define AT_CTRL_RPT_TUNE_ERR BIT(3) /* enable reporting framing errors */ +#define AT_CTRL_SW_TUNE_EN BIT(4) /* enable software managed tuning */ +#define AT_CTRL_WIN_EDGE_SEL_MASK GENMASK(11, 8) /* bits [11:8] */ +#define AT_CTRL_WIN_EDGE_SEL 0xf /* sampling window edge select */ +#define AT_CTRL_TUNE_CLK_STOP_EN BIT(16) /* clocks stopped during phase code change */ +#define AT_CTRL_PRE_CHANGE_DLY_MASK GENMASK(18, 17) /* bits [18:17] */ +#define AT_CTRL_PRE_CHANGE_DLY 0x1 /* 2-cycle latency */ +#define AT_CTRL_POST_CHANGE_DLY_MASK GENMASK(20, 19) /* bits [20:19] */ +#define AT_CTRL_POST_CHANGE_DLY 0x3 /* 4-cycle latency */ +#define AT_CTRL_SWIN_TH_VAL_MASK GENMASK(31, 24) /* bits [31:24] */ +#define AT_CTRL_SWIN_TH_VAL 0x9 /* sampling window threshold */ /* Rockchip specific Registers */ #define DWCMSHC_EMMC_DLL_CTRL 0x800 @@ -72,6 +88,82 @@ (((x) & DWCMSHC_EMMC_DLL_TIMEOUT) == 0)) #define RK35xx_MAX_CLKS 3 +/* PHY register area pointer */ +#define DWC_MSHC_PTR_PHY_R 0x300 + +/* PHY general configuration */ +#define PHY_CNFG_R (DWC_MSHC_PTR_PHY_R + 0x00) +#define PHY_CNFG_RSTN_DEASSERT 0x1 /* Deassert PHY reset */ +#define PHY_CNFG_PAD_SP_MASK GENMASK(19, 16) /* bits [19:16] */ +#define PHY_CNFG_PAD_SP 0x0c /* PMOS TX drive strength */ +#define PHY_CNFG_PAD_SN_MASK GENMASK(23, 20) /* bits [23:20] */ +#define PHY_CNFG_PAD_SN 0x0c /* NMOS TX drive strength */ + +/* PHY command/response pad settings */ +#define PHY_CMDPAD_CNFG_R (DWC_MSHC_PTR_PHY_R + 0x04) + +/* PHY data pad settings */ +#define PHY_DATAPAD_CNFG_R (DWC_MSHC_PTR_PHY_R + 0x06) + +/* PHY clock pad settings */ +#define PHY_CLKPAD_CNFG_R (DWC_MSHC_PTR_PHY_R + 0x08) + +/* PHY strobe pad settings */ +#define PHY_STBPAD_CNFG_R (DWC_MSHC_PTR_PHY_R + 0x0a) + +/* PHY reset pad settings */ +#define PHY_RSTNPAD_CNFG_R (DWC_MSHC_PTR_PHY_R + 0x0c) + +/* Bitfields are common for all pad settings */ +#define PHY_PAD_RXSEL_1V8 0x1 /* Receiver type select for 1.8V */ +#define PHY_PAD_RXSEL_3V3 0x2 /* Receiver type select for 3.3V */ + +#define PHY_PAD_WEAKPULL_MASK GENMASK(4, 3) /* bits [4:3] */ +#define PHY_PAD_WEAKPULL_PULLUP 0x1 /* Weak pull up enabled */ +#define PHY_PAD_WEAKPULL_PULLDOWN 0x2 /* Weak pull down enabled */ + +#define PHY_PAD_TXSLEW_CTRL_P_MASK GENMASK(8, 5) /* bits [8:5] */ +#define PHY_PAD_TXSLEW_CTRL_P 0x3 /* Slew control for P-Type pad TX */ +#define PHY_PAD_TXSLEW_CTRL_N_MASK GENMASK(12, 9) /* bits [12:9] */ +#define PHY_PAD_TXSLEW_CTRL_N 0x3 /* Slew control for N-Type pad TX */ + +/* PHY CLK delay line settings */ +#define PHY_SDCLKDL_CNFG_R (DWC_MSHC_PTR_PHY_R + 0x1d) +#define PHY_SDCLKDL_CNFG_UPDATE BIT(4) /* set before writing to SDCLKDL_DC */ + +/* PHY CLK delay line delay code */ +#define PHY_SDCLKDL_DC_R (DWC_MSHC_PTR_PHY_R + 0x1e) +#define PHY_SDCLKDL_DC_INITIAL 0x40 /* initial delay code */ +#define PHY_SDCLKDL_DC_DEFAULT 0x32 /* default delay code */ +#define PHY_SDCLKDL_DC_HS400 0x18 /* delay code for HS400 mode */ + +/* PHY drift_cclk_rx delay line configuration setting */ +#define PHY_ATDL_CNFG_R (DWC_MSHC_PTR_PHY_R + 0x21) +#define PHY_ATDL_CNFG_INPSEL_MASK GENMASK(3, 2) /* bits [3:2] */ +#define PHY_ATDL_CNFG_INPSEL 0x3 /* delay line input source */ + +/* PHY DLL control settings */ +#define PHY_DLL_CTRL_R (DWC_MSHC_PTR_PHY_R + 0x24) +#define PHY_DLL_CTRL_DISABLE 0x0 /* PHY DLL is enabled */ +#define PHY_DLL_CTRL_ENABLE 0x1 /* PHY DLL is disabled */ + +/* PHY DLL configuration register 1 */ +#define PHY_DLL_CNFG1_R (DWC_MSHC_PTR_PHY_R + 0x25) +#define PHY_DLL_CNFG1_SLVDLY_MASK GENMASK(5, 4) /* bits [5:4] */ +#define PHY_DLL_CNFG1_SLVDLY 0x2 /* DLL slave update delay input */ +#define PHY_DLL_CNFG1_WAITCYCLE 0x5 /* DLL wait cycle input */ + +/* PHY DLL configuration register 2 */ +#define PHY_DLL_CNFG2_R (DWC_MSHC_PTR_PHY_R + 0x26) +#define PHY_DLL_CNFG2_JUMPSTEP 0xa /* DLL jump step input */ + +/* PHY DLL master and slave delay line configuration settings */ +#define PHY_DLLDL_CNFG_R (DWC_MSHC_PTR_PHY_R + 0x28) +#define PHY_DLLDL_CNFG_SLV_INPSEL_MASK GENMASK(6, 5) /* bits [6:5] */ +#define PHY_DLLDL_CNFG_SLV_INPSEL 0x3 /* clock source select for slave DL */ + +#define FLAG_IO_FIXED_1V8 BIT(0) + #define BOUNDARY_OK(addr, len) \ ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1))) @@ -92,6 +184,8 @@ struct dwcmshc_priv { struct clk *bus_clk; int vendor_specific_area1; /* P_VENDOR_SPECIFIC_AREA reg */ void *priv; /* pointer to SoC private stuff */ + u16 delay_line; + u16 flags; }; /* @@ -157,6 +251,126 @@ static void dwcmshc_request(struct mmc_host *mmc, struct mmc_request *mrq) sdhci_request(mmc, mrq); } +static void dwcmshc_phy_1_8v_init(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); + u32 val; + + /* deassert phy reset & set tx drive strength */ + val = PHY_CNFG_RSTN_DEASSERT; + val |= FIELD_PREP(PHY_CNFG_PAD_SP_MASK, PHY_CNFG_PAD_SP); + val |= FIELD_PREP(PHY_CNFG_PAD_SN_MASK, PHY_CNFG_PAD_SN); + sdhci_writel(host, val, PHY_CNFG_R); + + /* disable delay line */ + sdhci_writeb(host, PHY_SDCLKDL_CNFG_UPDATE, PHY_SDCLKDL_CNFG_R); + + /* set delay line */ + sdhci_writeb(host, priv->delay_line, PHY_SDCLKDL_DC_R); + sdhci_writeb(host, PHY_DLL_CNFG2_JUMPSTEP, PHY_DLL_CNFG2_R); + + /* enable delay lane */ + val = sdhci_readb(host, PHY_SDCLKDL_CNFG_R); + val &= ~(PHY_SDCLKDL_CNFG_UPDATE); + sdhci_writeb(host, val, PHY_SDCLKDL_CNFG_R); + + /* configure phy pads */ + val = PHY_PAD_RXSEL_1V8; + val |= FIELD_PREP(PHY_PAD_WEAKPULL_MASK, PHY_PAD_WEAKPULL_PULLUP); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_P_MASK, PHY_PAD_TXSLEW_CTRL_P); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_N_MASK, PHY_PAD_TXSLEW_CTRL_N); + sdhci_writew(host, val, PHY_CMDPAD_CNFG_R); + sdhci_writew(host, val, PHY_DATAPAD_CNFG_R); + sdhci_writew(host, val, PHY_RSTNPAD_CNFG_R); + + val = FIELD_PREP(PHY_PAD_TXSLEW_CTRL_P_MASK, PHY_PAD_TXSLEW_CTRL_P); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_N_MASK, PHY_PAD_TXSLEW_CTRL_N); + sdhci_writew(host, val, PHY_CLKPAD_CNFG_R); + + val = PHY_PAD_RXSEL_1V8; + val |= FIELD_PREP(PHY_PAD_WEAKPULL_MASK, PHY_PAD_WEAKPULL_PULLDOWN); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_P_MASK, PHY_PAD_TXSLEW_CTRL_P); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_N_MASK, PHY_PAD_TXSLEW_CTRL_N); + sdhci_writew(host, val, PHY_STBPAD_CNFG_R); + + /* enable data strobe mode */ + sdhci_writeb(host, FIELD_PREP(PHY_DLLDL_CNFG_SLV_INPSEL_MASK, PHY_DLLDL_CNFG_SLV_INPSEL), + PHY_DLLDL_CNFG_R); + + /* enable phy dll */ + sdhci_writeb(host, PHY_DLL_CTRL_ENABLE, PHY_DLL_CTRL_R); +} + +static void dwcmshc_phy_3_3v_init(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); + u32 val; + + /* deassert phy reset & set tx drive strength */ + val = PHY_CNFG_RSTN_DEASSERT; + val |= FIELD_PREP(PHY_CNFG_PAD_SP_MASK, PHY_CNFG_PAD_SP); + val |= FIELD_PREP(PHY_CNFG_PAD_SN_MASK, PHY_CNFG_PAD_SN); + sdhci_writel(host, val, PHY_CNFG_R); + + /* disable delay line */ + sdhci_writeb(host, PHY_SDCLKDL_CNFG_UPDATE, PHY_SDCLKDL_CNFG_R); + + /* set delay line */ + sdhci_writeb(host, priv->delay_line, PHY_SDCLKDL_DC_R); + sdhci_writeb(host, PHY_DLL_CNFG2_JUMPSTEP, PHY_DLL_CNFG2_R); + + /* enable delay lane */ + val = sdhci_readb(host, PHY_SDCLKDL_CNFG_R); + val &= ~(PHY_SDCLKDL_CNFG_UPDATE); + sdhci_writeb(host, val, PHY_SDCLKDL_CNFG_R); + + /* configure phy pads */ + val = PHY_PAD_RXSEL_3V3; + val |= FIELD_PREP(PHY_PAD_WEAKPULL_MASK, PHY_PAD_WEAKPULL_PULLUP); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_P_MASK, PHY_PAD_TXSLEW_CTRL_P); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_N_MASK, PHY_PAD_TXSLEW_CTRL_N); + sdhci_writew(host, val, PHY_CMDPAD_CNFG_R); + sdhci_writew(host, val, PHY_DATAPAD_CNFG_R); + sdhci_writew(host, val, PHY_RSTNPAD_CNFG_R); + + val = FIELD_PREP(PHY_PAD_TXSLEW_CTRL_P_MASK, PHY_PAD_TXSLEW_CTRL_P); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_N_MASK, PHY_PAD_TXSLEW_CTRL_N); + sdhci_writew(host, val, PHY_CLKPAD_CNFG_R); + + val = PHY_PAD_RXSEL_3V3; + val |= FIELD_PREP(PHY_PAD_WEAKPULL_MASK, PHY_PAD_WEAKPULL_PULLDOWN); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_P_MASK, PHY_PAD_TXSLEW_CTRL_P); + val |= FIELD_PREP(PHY_PAD_TXSLEW_CTRL_N_MASK, PHY_PAD_TXSLEW_CTRL_N); + sdhci_writew(host, val, PHY_STBPAD_CNFG_R); + + /* enable phy dll */ + sdhci_writeb(host, PHY_DLL_CTRL_ENABLE, PHY_DLL_CTRL_R); +} + +static void th1520_sdhci_set_phy(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); + u16 emmc_ctrl; + + /* Before power on, set PHY configs */ + if (priv->flags & FLAG_IO_FIXED_1V8) + dwcmshc_phy_1_8v_init(host); + else + dwcmshc_phy_3_3v_init(host); + + if (host->mmc->caps2 & (MMC_CAP2_NO_SD | MMC_CAP2_NO_SDIO)) { + emmc_ctrl = sdhci_readw(host, priv->vendor_specific_area1 + DWCMSHC_EMMC_CONTROL); + emmc_ctrl |= DWCMSHC_CARD_IS_EMMC; + sdhci_writew(host, emmc_ctrl, priv->vendor_specific_area1 + DWCMSHC_EMMC_CONTROL); + } + + sdhci_writeb(host, FIELD_PREP(PHY_DLL_CNFG1_SLVDLY_MASK, PHY_DLL_CNFG1_SLVDLY) | + PHY_DLL_CNFG1_WAITCYCLE, PHY_DLL_CNFG1_R); +} + static void dwcmshc_set_uhs_signaling(struct sdhci_host *host, unsigned int timing) { @@ -189,9 +403,25 @@ static void dwcmshc_set_uhs_signaling(struct sdhci_host *host, ctrl_2 |= DWCMSHC_CTRL_HS400; } + if (priv->flags & FLAG_IO_FIXED_1V8) + ctrl_2 |= SDHCI_CTRL_VDD_180; sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2); } +static void th1520_set_uhs_signaling(struct sdhci_host *host, + unsigned int timing) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); + + dwcmshc_set_uhs_signaling(host, timing); + if (timing == MMC_TIMING_MMC_HS400) + priv->delay_line = PHY_SDCLKDL_DC_HS400; + else + sdhci_writeb(host, 0, PHY_DLLDL_CNFG_R); + th1520_sdhci_set_phy(host); +} + static void dwcmshc_hs400_enhanced_strobe(struct mmc_host *mmc, struct mmc_ios *ios) { @@ -338,6 +568,79 @@ static void rk35xx_sdhci_reset(struct sdhci_host *host, u8 mask) sdhci_reset(host, mask); } +static int th1520_execute_tuning(struct sdhci_host *host, u32 opcode) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); + u32 val = 0; + + if (host->flags & SDHCI_HS400_TUNING) + return 0; + + sdhci_writeb(host, FIELD_PREP(PHY_ATDL_CNFG_INPSEL_MASK, PHY_ATDL_CNFG_INPSEL), + PHY_ATDL_CNFG_R); + val = sdhci_readl(host, priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL); + + /* + * configure tuning settings: + * - center phase select code driven in block gap interval + * - disable reporting of framing errors + * - disable software managed tuning + * - disable user selection of sampling window edges, + * instead tuning calculated edges are used + */ + val &= ~(AT_CTRL_CI_SEL | AT_CTRL_RPT_TUNE_ERR | AT_CTRL_SW_TUNE_EN | + FIELD_PREP(AT_CTRL_WIN_EDGE_SEL_MASK, AT_CTRL_WIN_EDGE_SEL)); + + /* + * configure tuning settings: + * - enable auto-tuning + * - enable sampling window threshold + * - stop clocks during phase code change + * - set max latency in cycles between tx and rx clocks + * - set max latency in cycles to switch output phase + * - set max sampling window threshold value + */ + val |= AT_CTRL_AT_EN | AT_CTRL_SWIN_TH_EN | AT_CTRL_TUNE_CLK_STOP_EN; + val |= FIELD_PREP(AT_CTRL_PRE_CHANGE_DLY_MASK, AT_CTRL_PRE_CHANGE_DLY); + val |= FIELD_PREP(AT_CTRL_POST_CHANGE_DLY_MASK, AT_CTRL_POST_CHANGE_DLY); + val |= FIELD_PREP(AT_CTRL_SWIN_TH_VAL_MASK, AT_CTRL_SWIN_TH_VAL); + + sdhci_writel(host, val, priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL); + val = sdhci_readl(host, priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL); + + /* perform tuning */ + sdhci_start_tuning(host); + host->tuning_err = __sdhci_execute_tuning(host, opcode); + if (host->tuning_err) { + /* disable auto-tuning upon tuning error */ + val &= ~AT_CTRL_AT_EN; + sdhci_writel(host, val, priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL); + dev_err(mmc_dev(host->mmc), "tuning failed: %d\n", host->tuning_err); + return -EIO; + } + sdhci_end_tuning(host); + + return 0; +} + +static void th1520_sdhci_reset(struct sdhci_host *host, u8 mask) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); + u16 ctrl_2; + + sdhci_reset(host, mask); + + if (priv->flags & FLAG_IO_FIXED_1V8) { + ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); + if (!(ctrl_2 & SDHCI_CTRL_VDD_180)) { + ctrl_2 |= SDHCI_CTRL_VDD_180; + sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2); + } + } +} + static const struct sdhci_ops sdhci_dwcmshc_ops = { .set_clock = sdhci_set_clock, .set_bus_width = sdhci_set_bus_width, @@ -356,6 +659,17 @@ static const struct sdhci_ops sdhci_dwcmshc_rk35xx_ops = { .adma_write_desc = dwcmshc_adma_write_desc, }; +static const struct sdhci_ops sdhci_dwcmshc_th1520_ops = { + .set_clock = sdhci_set_clock, + .set_bus_width = sdhci_set_bus_width, + .set_uhs_signaling = th1520_set_uhs_signaling, + .get_max_clock = dwcmshc_get_max_clock, + .reset = th1520_sdhci_reset, + .adma_write_desc = dwcmshc_adma_write_desc, + .voltage_switch = dwcmshc_phy_1_8v_init, + .platform_execute_tuning = &th1520_execute_tuning, +}; + static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = { .ops = &sdhci_dwcmshc_ops, .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, @@ -379,6 +693,12 @@ static const struct sdhci_pltfm_data sdhci_dwcmshc_rk35xx_pdata = { SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN, }; +static const struct sdhci_pltfm_data sdhci_dwcmshc_th1520_pdata = { + .ops = &sdhci_dwcmshc_th1520_ops, + .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, +}; + static int dwcmshc_rk35xx_init(struct sdhci_host *host, struct dwcmshc_priv *dwc_priv) { int err; @@ -447,6 +767,10 @@ static const struct of_device_id sdhci_dwcmshc_dt_ids[] = { .compatible = "snps,dwcmshc-sdhci", .data = &sdhci_dwcmshc_pdata, }, + { + .compatible = "thead,th1520-dwcmshc", + .data = &sdhci_dwcmshc_th1520_pdata, + }, {}, }; MODULE_DEVICE_TABLE(of, sdhci_dwcmshc_dt_ids); @@ -542,6 +866,30 @@ static int dwcmshc_probe(struct platform_device *pdev) goto err_clk; } + if (pltfm_data == &sdhci_dwcmshc_th1520_pdata) { + priv->delay_line = PHY_SDCLKDL_DC_DEFAULT; + + if ((device_property_read_bool(dev, "mmc-ddr-1_8v")) | + (device_property_read_bool(dev, "mmc-hs200-1_8v")) | + (device_property_read_bool(dev, "mmc-hs400-1_8v"))) + priv->flags |= FLAG_IO_FIXED_1V8; + else + priv->flags &= ~FLAG_IO_FIXED_1V8; + + /* + * start_signal_voltage_switch() will try 3.3V first + * then 1.8V. Use SDHCI_SIGNALING_180 rather than + * SDHCI_SIGNALING_330 to avoid setting voltage to 3.3V + * in sdhci_start_signal_voltage_switch(). + */ + if (priv->flags & FLAG_IO_FIXED_1V8) { + host->flags &= ~SDHCI_SIGNALING_330; + host->flags |= SDHCI_SIGNALING_180; + } + + sdhci_enable_v4_mode(host); + } + #ifdef CONFIG_ACPI if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) sdhci_enable_v4_mode(host); From patchwork Thu Nov 2 02:48:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13443338 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D901FC001B2 for ; Thu, 2 Nov 2023 02:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id: MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1mMv4ofHgIshuICtxw8YXyj2s3VD9uu6c5Ar80uMv8M=; b=S6oJo/24LTRZJd KvlUw0VznAa/AlioYjUuTXOjcaTGPsPMqk4V8EVPtmXyRfgh8aX4sIZSzBKi1u2KhpYmP0pmaJju+ Yy+orwjf9A8nJDiilkV4uxoWahEftcO9DK15zxwDAYIiDSC47Rynz59miWNWMK7AjbBw93ZH37oml +z9uoQ43JN9W7mh3ib8Ddxua8RRm8jq4ggxbeMvIRtF/xYGo/AhMieVsxJDGntjnjWWBPZ2vNkQPv b79lAcpEkXhXs8jD0bVm1/u+7nk5FtkYPIGoYNkADRWsI/M7r9+UfTcSfe8tMi/XS0222QT1lQ2OX ZopIhn5o5Tkv9EhiyFVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlp-008a59-04; Thu, 02 Nov 2023 02:49:21 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyNll-008a35-2j for linux-riscv@lists.infradead.org; Thu, 02 Nov 2023 02:49:19 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5a1d89ff4b9so356996a12.0 for ; Wed, 01 Nov 2023 19:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1698893356; x=1699498156; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xY9e61NSBd34WKgwLiextVdIl1pEHWCBao7kYEHaYbc=; b=ppc8zLkc305UrSDqBV41UHecOFsDHIsoSRr3tolay6fPqp336xZq7NvaXJnonzLa60 Dj+E9FdhScmWG1JejVNOPGaxp46i6TRPKcEV+mAb67OCrKGH/QSnVw6i51bRcAonuyT7 KsDtv/Kktl69/vUkAZ+M1+U5ifwxH2t6LjxWLy+biZQnsJEO6gVpbhDkn6/0yCz6drFH pjMstN0H9C/FFIPbH2b5fD+TDMnwTc9D9J+fVaI+dlVudCudGQcmyilZFNoUb02QiXBY VjISUMsu0fL3GT+GvJNHskgXCXjwbuFx5uJ33tf2yAaEOn9omulQB/v0uP7UGugI1CoC PJBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698893356; x=1699498156; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xY9e61NSBd34WKgwLiextVdIl1pEHWCBao7kYEHaYbc=; b=S4tYhB+Mav7oG6tpcrMH1c/pnIl9ntMNzTQ4B4IQ+/jOfnAofe4+KzIv5fSDwraMcj ba2o1C0MqnK23Tzwpo3zRRLJtLCYHS7hTsI2bBb6RaPI2hRD7KSAgwdgNk3aIbVYemLZ 0QRjeicqE859A24VzafGZpX5k2hoXmTBVlHuRjwsLou2LA/+8dtAU8WCL+nSCHg3QQXZ Ch8rQHjtaidPNocCJ0EZk5x2GyfJpJmomhIahp2t3Z0eB1B68bYjF5iR4hYKiVGVzSGw 5Vbg07gWaOl5KjqkvsYJ3gTVzl9QLF2v2gv49c8VGQ83yz8yROlppH0qI/Oj7s48JAOY v+eg== X-Gm-Message-State: AOJu0YyOcetZHWFgzM7OFuHvE1gtfuCBG0FT91V7Pv3h4AxgQekFb043 D1lLYGHz1sv1TGPoC41xaQELGA== X-Google-Smtp-Source: AGHT+IGIkak0BWPmf96vSjrzvsdLE6FSIqQnE69o81x6bAW2NsVUROi7m+yImFnuEBD3qfEnlgNLMA== X-Received: by 2002:a17:902:904a:b0:1ca:a290:4c0c with SMTP id w10-20020a170902904a00b001caa2904c0cmr14004681plz.16.1698893356673; Wed, 01 Nov 2023 19:49:16 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:7e4c:4d4e:6943:bc0f]) by smtp.gmail.com with ESMTPSA id n4-20020a170902e54400b001b850c9d7b3sm1925787plf.249.2023.11.01.19.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 19:49:16 -0700 (PDT) From: Drew Fustini Date: Wed, 01 Nov 2023 19:48:55 -0700 Subject: [PATCH v4 4/7] riscv: defconfig: Enable mmc and dma drivers for T-Head TH1520 MIME-Version: 1.0 Message-Id: <20231101-th1520-mmc-v4-4-86e0216b5994@baylibre.com> References: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> In-Reply-To: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Adrian Hunter , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698893345; l=915; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=ht5Rt9iMCRM1t5yThjxoCTbuOVz3OXmRTAYLzzfd3/s=; b=FZMIpbOF3eXJOg41M+jpGkm0JMPaPS1i+Fh/DURCDFJ6QTIV6xnD4KSvnKvDKTZm/Q5C4u02O XJ40YVrYjkqDC8JNiTK4WMQXC8RJvH5O3/cEe7X9+tCNDrDxEPQ8ITa X-Developer-Key: i=dfustini@baylibre.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231101_194917_889900_2585210B X-CRM114-Status: UNSURE ( 9.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Drew Fustini , Han Gao , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Nelson , Jason Kridner , Xi Ruoyao , linux-riscv@lists.infradead.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Enable the mmc controller driver and dma controller driver needed for T-Head TH1520 based boards, like the LicheePi 4A and BeagleV-Ahead, to boot from eMMC storage. Reviewed-by: Guo Ren Signed-off-by: Drew Fustini --- arch/riscv/configs/defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index ab86ec3b9eab..c5a8583236d0 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -168,12 +168,14 @@ CONFIG_MMC=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_PLTFM=y CONFIG_MMC_SDHCI_CADENCE=y +CONFIG_MMC_SDHCI_OF_DWCMSHC=y CONFIG_MMC_SPI=y CONFIG_MMC_SUNXI=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_SUN6I=y CONFIG_DMADEVICES=y CONFIG_DMA_SUN6I=m +CONFIG_DW_AXI_DMAC=y CONFIG_VIRTIO_PCI=y CONFIG_VIRTIO_BALLOON=y CONFIG_VIRTIO_INPUT=y From patchwork Thu Nov 2 02:48:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13443339 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC36CC4167D for ; Thu, 2 Nov 2023 02:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id: MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tHFuI6sIlVeZ3eBH1UjkCAg2X++VmYq5BtJx444juhg=; b=d9vaJIW6epVqN0 i9vDuE6ouOpBlr9RwW/PjXUsPpE5ou7zrE6w8yh5Ugk3hGiWFFbfpGb0h5WgFzSMvGaIJft5/uY61 sKM/NarsDZCrfgLk26bWBK5C1C0P5Zpio9l4a6Y6na2qPvNPqoCQaUZ9O09cQn1ZwE4ouaMhJ4cCj hH0zczyqBgZHzRuIMHJN8c1tyqziXpbTyH7ZQ3FaOjP6aCTs3CWHJ4VVGUEjFXgUTiv5/PimPO/vr NbsOZxxatOGqS4lxjYLpzlXTL1HLCM2AIp0+GcicIfIjWM/jzN1aUzpLXZeaCqPuHJyB81ykr05bj i8JlIaQWYy0+gN+vpOHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyNls-008a6g-0T; Thu, 02 Nov 2023 02:49:24 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlo-008a4D-1J for linux-riscv@lists.infradead.org; Thu, 02 Nov 2023 02:49:23 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6c0f14d6875so510898b3a.1 for ; Wed, 01 Nov 2023 19:49:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1698893359; x=1699498159; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=frioRiPhaekRnCE/0ENvI5wkvdspg2jE1Z81EEiVDoc=; b=ZR2JLdBgpIeuYNDPKTT0q7jre5Wnp3eeYXtqczZqdwAIReGvr9lLMe6WW1sySIHMXq QNfRkO7xf3s6m5h+fv9nCc0cVcaPMeqekyDXeoxg6y8oM8SkQumZFkG4LrBA+QNsWs+s l37jDIOJuxEfpsHhJSsOBN1ZUaCtctVkYrvbvrQQPCeAFFTzBJs2OmZfFqNZOQA4QEP7 pNt+9bLtK3Ub+l+m+QAa1we0SOk367o7lNYzyshSUJxISIGEKy4PNHCVNAKcTFTUJOwz Pi72WXNPcbRDabUpeczLM2kSn7e03NbBZkRLU1RhRWjEQSMY3StWZi7GScSJhWa7m7r2 4+Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698893359; x=1699498159; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=frioRiPhaekRnCE/0ENvI5wkvdspg2jE1Z81EEiVDoc=; b=Cr6X/1nz4LiW+BBvAnlxxSLjpmrfLgBbQd6YSvxNXC2HE2FW2Io6oTPdTP/qa53Jq2 jl/slB1TJhJyYGnD7dG9qBE4BLAPNrIIQ2sfktDhtzlj4kKmvAD7qfYEoH0SWMsbqho2 I3Iu9q1HxT74CGd9cKqdD0Q8q8akwtWzKXSSH9h5N+8JaVLpsTBu2CBEa3/RoQoGBw6v n4nCXWfHZyZejeg3TLt1z38rEBsGKblS1bnjseQe+mkz46V0PfOgp1BeDO1vhwyGTDwd nhbedwSlHWSjFLSnEG6mvEbEdB/cplUA9JzEtu02nTQAwTHSYEoVs0o3M50AX+gi7aDP 7/Bw== X-Gm-Message-State: AOJu0Yzzdqs+Z7WgII9/CpOQgPhtskzAR90qohLLFxrxjL/ECUsX67oZ ZyC5jUydH6HX81FP318npe/jSQ== X-Google-Smtp-Source: AGHT+IGmGuJJ1mkzEGk8YjnKaLw6xeRQezkEH7j3sN61xb+Q4mvh0F4TOsQumwdOzPdJ/wKXNGt5mQ== X-Received: by 2002:a05:6a21:3290:b0:17b:129b:1817 with SMTP id yt16-20020a056a21329000b0017b129b1817mr17347005pzb.45.1698893359369; Wed, 01 Nov 2023 19:49:19 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:7e4c:4d4e:6943:bc0f]) by smtp.gmail.com with ESMTPSA id n4-20020a170902e54400b001b850c9d7b3sm1925787plf.249.2023.11.01.19.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 19:49:18 -0700 (PDT) From: Drew Fustini Date: Wed, 01 Nov 2023 19:48:56 -0700 Subject: [PATCH v4 5/7] riscv: dts: thead: Add TH1520 mmc controllers and sdhci clock MIME-Version: 1.0 Message-Id: <20231101-th1520-mmc-v4-5-86e0216b5994@baylibre.com> References: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> In-Reply-To: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Adrian Hunter , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698893345; l=1608; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=118IOeI3EDHQnRGvuv5ewuNsGEAnYvxtIZdzQTMEyXk=; b=eyKHDo5yqtNJ502x7Fih43LJiwPFfx23Zy+xbTqFt5fKit9A49CnrPno3Mm3ut0CzYLTtYrbA /vn+hYssfSJB6Sw6E+5blOk1/IPFdDAfudZiDruEEXAfuKyEA9hPRw1 X-Developer-Key: i=dfustini@baylibre.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231101_194920_483000_F2D2F601 X-CRM114-Status: GOOD ( 10.26 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Drew Fustini , Han Gao , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Nelson , Jason Kridner , Xi Ruoyao , linux-riscv@lists.infradead.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add node for the SDHCI fixed clock. Add mmc0 node for the first mmc controller instance which is typically connected to the eMMC device. Add mmc1 node for the second mmc controller instance which is typically connected to microSD slot. Signed-off-by: Drew Fustini --- arch/riscv/boot/dts/thead/th1520.dtsi | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index ff364709a6df..f5ec9326c4b8 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -134,6 +134,13 @@ uart_sclk: uart-sclk-clock { #clock-cells = <0>; }; + sdhci_clk: sdhci-clock { + compatible = "fixed-clock"; + clock-frequency = <198000000>; + clock-output-names = "sdhci_clk"; + #clock-cells = <0>; + }; + soc { compatible = "simple-bus"; interrupt-parent = <&plic>; @@ -292,6 +299,22 @@ dmac0: dma-controller@ffefc00000 { status = "disabled"; }; + mmc0: mmc@ffe7080000 { + compatible = "thead,th1520-dwcmshc"; + reg = <0xff 0xe7080000 0x0 0x10000>; + interrupts = <62 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&sdhci_clk>; + clock-names = "core"; + }; + + mmc1: mmc@ffe7090000 { + compatible = "thead,th1520-dwcmshc"; + reg = <0xff 0xe7090000 0x0 0x10000>; + interrupts = <64 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&sdhci_clk>; + clock-names = "core"; + }; + timer0: timer@ffefc32000 { compatible = "snps,dw-apb-timer"; reg = <0xff 0xefc32000 0x0 0x14>; From patchwork Thu Nov 2 02:48:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13443341 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 936B5C4167B for ; Thu, 2 Nov 2023 02:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id: MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uCEy7fopG0vLuuN/IuAnIvORB0BjanUlKhCC4o7Lzp4=; b=lvGcE7RQwzj1yh 5yUpAumSvmMXiWhRpp6aHaW24Hb5AGeK4L5TdT+6dB3Wi/6WL+SdJJgH+y16K1MV+UtH58RRMmqed kglYtx3fAXCeKWB9xIwl7ujZFKC8xFDGv/br1Isw/2HyqRRGSs/Ul9uc0s2xAWs6nv2ZLv7yV3BVV NfXVD5uLEpvaKpM9ZD4qvhpfeS4vg5Jw6lmap6aGoPrx7mVLvK5ld+An2bkmFVxuyXooMT3+F7VpJ O0lipai5IyH7mEuyRrgSqXKwCqeuILzSadbYuBDvNiI1TAD3Lr8zfJdKiXArtpETRSxqRsyW/jjyq 7yljqqBMdqdH1t5SGuDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlw-008a99-0e; Thu, 02 Nov 2023 02:49:28 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlt-008a6j-0Y for linux-riscv@lists.infradead.org; Thu, 02 Nov 2023 02:49:26 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cc0e78ec92so3226255ad.3 for ; Wed, 01 Nov 2023 19:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1698893364; x=1699498164; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=uSa6NAVY2VMgd1nmwOwphCO64qKVXCiZUmGbVj1XUeM=; b=oILzIY4b3l0H/mM3LybObrysL36XgEkrgbyX344vnIQwEp9k/b61AA1TIvqn4os4Ep aHaNg3nc8F82eGDc+4S6a0/fEm+i4pSlZWlNTE2I6ofEx7uQTuyZCs6PEadCpGm2gNrO lSjFlOE9EB6449KREsHT0V4WLdHzaW4aY4KajXQe/Ywc6kNybZZtwWcR006k5wAilxWB XCJkvjflJqC1xSeXZ4hzah0sPSVcGGDtKGvsySkz6GoNGYnrm9mVLIxpZQJ8llX9yRtK 8Bxvc0ALN65KGJg/fMnLuYBiy99InPtrg/V7BWRNj53oEpT1zdEavExPe25qZ1WC1eWo F0UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698893364; x=1699498164; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uSa6NAVY2VMgd1nmwOwphCO64qKVXCiZUmGbVj1XUeM=; b=sdVUiMJvU1XdWW4ARCu+qyW8CUi/pOmPt7TnTNtX/06B8wNdivbWAPt/92J78nyfTN cN4P0DyXplT6gDs1FXzcJxd+QYWqam8mRrIA1LrwCQFXoPJ8KIPYX/RGuIv2POeJlxlY 5tv4OYPbiPESM9oHtKDSCyBCJ3Z+nDQp8zJywdYQ/xe2TRRtvMFAL4z2LK3InmauYXns h7sV3CfdDsU5EAlu39I6N2hmt0LPwtTENXL8dkRYA6Ev27oNdMWCvdw7VHgTCzjw7hNX Mk9OVe9dvN3fpsPguctAJS6Bcm6p6d6GCziwO/s7g1IIR/qR0icHAWmJ2vdwVaZFihro iJ3A== X-Gm-Message-State: AOJu0YyfNABjuJ5QJ3DC6tma4P2hMLvkyu6cVr1qGIBrGzzIotLoLoY8 rJQ83E5USFBeiFyADcsTvfpAdg== X-Google-Smtp-Source: AGHT+IHX9AJrAVgWSnYbOXa7mutrw1tVdRN6GcBHN4fbPFOszvbXB4wUQnu7dVhwrk4ZcsOpXB+xQw== X-Received: by 2002:a17:903:cd:b0:1cc:5db8:7e92 with SMTP id x13-20020a17090300cd00b001cc5db87e92mr6755183plc.58.1698893363682; Wed, 01 Nov 2023 19:49:23 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:7e4c:4d4e:6943:bc0f]) by smtp.gmail.com with ESMTPSA id n4-20020a170902e54400b001b850c9d7b3sm1925787plf.249.2023.11.01.19.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 19:49:23 -0700 (PDT) From: Drew Fustini Date: Wed, 01 Nov 2023 19:48:57 -0700 Subject: [PATCH v4 6/7] riscv: dts: thead: Enable BeagleV Ahead eMMC and microSD MIME-Version: 1.0 Message-Id: <20231101-th1520-mmc-v4-6-86e0216b5994@baylibre.com> References: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> In-Reply-To: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Adrian Hunter , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698893345; l=1108; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=4bgo3aK3cuR26cRWBbMVA6MrvhUqOJ8As8gzvmDCzhs=; b=aA13H2waFkFK8rdICEfWcJcPhFaGSH0ZRd4ROe0tmGrxSg7hrWq8+i/vrM2/4uVwYFqUm7YA2 XG5qUI7lWhuBylW5Vf6NOpK9BxdJC/LQDXKQpfLDXXSAcE3QiPgjyL3 X-Developer-Key: i=dfustini@baylibre.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231101_194925_211881_2F914BAD X-CRM114-Status: UNSURE ( 9.88 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Drew Fustini , Han Gao , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Nelson , Jason Kridner , Xi Ruoyao , linux-riscv@lists.infradead.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add mmc0 properties for the eMMC device and add mmc1 properties for the microSD slot. Set the frequency for the sdhci clock. Signed-off-by: Drew Fustini --- arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts index 70e8042c8304..f91d94f95510 100644 --- a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts +++ b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts @@ -48,6 +48,10 @@ &apb_clk { clock-frequency = <62500000>; }; +&sdhci_clk { + clock-frequency = <198000000>; +}; + &uart_sclk { clock-frequency = <100000000>; }; @@ -56,6 +60,22 @@ &dmac0 { status = "okay"; }; +&mmc0 { + bus-width = <8>; + max-frequency = <198000000>; + mmc-hs400-1_8v; + non-removable; + no-sdio; + no-sd; + status = "okay"; +}; + +&mmc1 { + max-frequency = <198000000>; + bus-width = <4>; + status = "okay"; +}; + &uart0 { status = "okay"; }; From patchwork Thu Nov 2 02:48:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13443342 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C442C4332F for ; Thu, 2 Nov 2023 02:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id: MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jZNcypdFNQGdQ8MqmnyaFb3GcT8ghodCK6e1fMwGat0=; b=vuNwAaDZyWeiGX 7CYn6qHIzhGp6JEpz8z5PRIFA8Ac+SNsbRZK7zm6OZuSD8tl7WIakfD4gyF3mkwF0rf3xoc0rOOhb ivsUJBd27VJZIZ5N2uklmmmPHe6xSUDUlMIonDO2HP89oZhqPAVRLQsrqTGEoEKxGa9tjro85yR8U IMVEa9/Bvi+NOGRiPwyP3MoBPbaZNlxxgtNA53XbHdnz+s9CeLlEU4pMgwYACUJ+tMxWFdtWsqRg7 IJ7pDioIwd+bxLAnTi3SjnB0Tp8vihKkJJJojW6XL7upxvQVPSeIt2RYr91Cv49CZZ1ZIssTLWX1L dsIXPsIdALKyoAtFXJEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlx-008a9j-0E; Thu, 02 Nov 2023 02:49:29 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyNlu-008a83-1t for linux-riscv@lists.infradead.org; Thu, 02 Nov 2023 02:49:28 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cc53d0030fso4233125ad.0 for ; Wed, 01 Nov 2023 19:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1698893366; x=1699498166; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DnDZGk512Fn6FcfRLVRqtgZTjSOOBJwTCzWACAW0uhY=; b=G59btgkKceEPW1HM4F9RuTgnowku1TYoZ/Tcor7j2Y/L3cTh0EfBc6uM0szHcQeFud EHtyhJ2qKv5K/iBA0cSk2EsJkEvZPgQ7bVf5YVJw6xBpgXi7Ti+S3jvc6blHXJlp6xGy FVAqe4b2a4CENJ7j3Ho2l9sN/6fCSsYfbjO9gboj68omHR6vIoqk5TjlbDckfeURB5Na +ZL8ObGpmA7sUkt0BpFCYR5xpXOXwzCDg8swq2t4127UQC8Yh6+Sl3v5ZjwKfo3I9Prf OfkMBi27UCoV5jL7mC6BDF+lOlhrpEhUXLPQgMw3ZfYK12hn+vmLMfmNF1mJxBUaogPG Me2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698893366; x=1699498166; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DnDZGk512Fn6FcfRLVRqtgZTjSOOBJwTCzWACAW0uhY=; b=HmGyKJokFKpKXqggFSb8bo1PCh3CqsUStUEi8AiMxSgOgzAb+C2lccdiQVxozN2ee6 VTGaGnxJXtPa53llN0d9kP2k/3eV+mlocBCICPNYzRzYnslA6bxhpT35LjvkIgqwnMth g6V5+/ClCbKRIWiY5EmxWNK2iLkUljYKRJxFOZbUAg8mu9NtZmVNScotspXmI3jzmwnI 5arXsqHFEEYAXMWuQeBls2WBGm5LVnONosmYNnof+bHMXPNDWkV9Nvp253DU5y4FoNqK 9kn8G0v82MjhRxdvFzx/xmXPfyof7AmGnVmJj403AHOWnbRvGiAPFfxjfhoF+1sNR5lp saLA== X-Gm-Message-State: AOJu0YxsDzMdkSFv5ZwfGZw76PAKtcPy09P89WU5/xnm8PP6WCtU3pb+ sOB8mxcM+MMtQfWLMaebSIlJZw== X-Google-Smtp-Source: AGHT+IFotN+N+05ghfeh6n+nIwmS9iXKFbCoDtCFHfdCTkyZqRbHe40loI/Ve+moBfFjdnP9WDRB8A== X-Received: by 2002:a17:902:dac9:b0:1cc:5ce4:f64b with SMTP id q9-20020a170902dac900b001cc5ce4f64bmr11068897plx.8.1698893366171; Wed, 01 Nov 2023 19:49:26 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:7e4c:4d4e:6943:bc0f]) by smtp.gmail.com with ESMTPSA id n4-20020a170902e54400b001b850c9d7b3sm1925787plf.249.2023.11.01.19.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 19:49:25 -0700 (PDT) From: Drew Fustini Date: Wed, 01 Nov 2023 19:48:58 -0700 Subject: [PATCH v4 7/7] riscv: dts: thead: Enable LicheePi 4A eMMC and microSD MIME-Version: 1.0 Message-Id: <20231101-th1520-mmc-v4-7-86e0216b5994@baylibre.com> References: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> In-Reply-To: <20231101-th1520-mmc-v4-0-86e0216b5994@baylibre.com> To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Adrian Hunter , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698893345; l=1102; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=vZkA/Rp2zWEJvsAGA/badfpHmHgx6/3DqqLzYe2IxQc=; b=8GSfHaYjbAvdqR5aNak0qxCYTox6ynEJYklYiqEqs75Ahp961sktUsZMwhbfP69H8eDCKd2iX Qb0BX3cam5JBwzRquUhN8ceX4V+t4liKW0/NNfG/NOH4PRVtvHtorW+ X-Developer-Key: i=dfustini@baylibre.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231101_194926_623437_295FC841 X-CRM114-Status: GOOD ( 10.06 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Drew Fustini , Han Gao , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Nelson , Jason Kridner , Xi Ruoyao , linux-riscv@lists.infradead.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add mmc0 properties for the eMMC device and add mmc1 properties for the microSD slot. Set the frequency for the sdhci clock. Signed-off-by: Drew Fustini --- .../boot/dts/thead/th1520-lichee-module-4a.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-module-4a.dtsi b/arch/riscv/boot/dts/thead/th1520-lichee-module-4a.dtsi index a802ab110429..94f1741435a5 100644 --- a/arch/riscv/boot/dts/thead/th1520-lichee-module-4a.dtsi +++ b/arch/riscv/boot/dts/thead/th1520-lichee-module-4a.dtsi @@ -29,6 +29,10 @@ &apb_clk { clock-frequency = <62500000>; }; +&sdhci_clk { + clock-frequency = <198000000>; +}; + &uart_sclk { clock-frequency = <100000000>; }; @@ -36,3 +40,19 @@ &uart_sclk { &dmac0 { status = "okay"; }; + +&mmc0 { + bus-width = <8>; + max-frequency = <198000000>; + mmc-hs400-1_8v; + non-removable; + no-sdio; + no-sd; + status = "okay"; +}; + +&mmc1 { + max-frequency = <198000000>; + bus-width = <4>; + status = "okay"; +};