From patchwork Fri Sep 22 01:49:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13394872 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 E045BE7D0BD for ; Fri, 22 Sep 2023 01:51: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=pDwNSiK9VuIIa9uYOpoNK2FC5BnlqV4AI7q6v516qow=; b=ASHShK+SHVPwUY FejDbdy3ezWFYAcFQ6ZgmalGDikUe/u1B03a2FoyRUWmm0GabJdn3zcN59Z12ylCMGw6aPsduQaxP GSAADxqi6jmBNWOREf7OwbjiZX7P2piebdcckTfY3Wv1SSweuPekUF7w1tTAwi2lqRLeQDGcWsfpv mH0f7B1EJsPyheG7+H0NAPrJsDAisxKuk1VESdoTahmjg9619T/igdJZsP41b3ja6yNieK8F8QLJH F5jmMVXVdh5kv+3m87c91xAKwwknyjz8qsKD+LjkoEJg6d2DEUGGmnYL0ezT+456Lh5dfhSgEF8v6 bQrT3emXa/LUcNtlZBOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjVK5-007aYw-16; Fri, 22 Sep 2023 01:51:13 +0000 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjVK2-007aWi-1L for linux-riscv@lists.infradead.org; Fri, 22 Sep 2023 01:51:12 +0000 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3a88ef953adso1006277b6e.0 for ; Thu, 21 Sep 2023 18:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695347469; x=1695952269; 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=AdU57Jx9PEmIXARyS6MsKYI5yf8mmNXKxZvGJyz9CZ0=; b=s74GbAhWhEoo2Hj+a+7/J8fHEWrdCNwiRUTqkRbZqiF/A3J4IvfI6g3diw+VDkQITw 1/73Gzu51v36g4iNcM25Giw4bkBmjCvZ8LmjPKQtVkq6SbWu+MN6BEOWKOf9QKOy6T1q rBaL9rCTuPYPZlaOvUzxUMut5bo9uVSAdinosHSLU9bJXjgDaHjgYw/Rat6qWugM3rXe NsIoE1N5mBmX+T2YBT4pMyA0WVChsvCXimomDCE97ZYDan7tcih7wFg6ycDZHE2G9TNR iwKppTije+GklH6gWrJ2ildDx5u1qLhYjHFwJSaCQ6I41wWtzMHVjm1aBmX7Lx2OJfAv zbIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695347469; x=1695952269; 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=AdU57Jx9PEmIXARyS6MsKYI5yf8mmNXKxZvGJyz9CZ0=; b=oVd5kZMB1fAw1tF7TymJgeSbDqMlRDPJv/4SfQEXTtN05loSKBu9ysmjPAFDpBfSg0 f5szFtQsERW7To85x80m6UP/kcuHk7/eBn+FjgMPBx77AtbODAFNHUuEPKry89MEEyTM Zo/PzQQBnh3l1dN98byGtt3xU/us4CtQHSAtjQH5QE2qDKWjN41kZ3jEg+HkEJPzR+8h uOBAiAcBAi6xyAh+qydMxPCWyily8t6aMQc5XbnKgPU9/r5IAVkpODMPdjdDvl1226gw y+1TK/fZUHqnQJQ/CphHMK6bMNMDzBykL7Q6Nn6whaPB56e4kk8tWZEKVovQAQxiyr7t I0mw== X-Gm-Message-State: AOJu0YxyTDf5lmT1G7yeZptQFyRMJOlAa2y/E8jGujNcfB8TbfjMuKdo bcJPWyzFpvRLIflAmvzI45juKw== X-Google-Smtp-Source: AGHT+IHBIOCNTfL32DX8sqcPvGCoAvfb0oRHov683BI2vSEw1XFpc+I3dbfeffGIcS9K8qEUO9NE9Q== X-Received: by 2002:a05:6870:3293:b0:1be:ccce:7991 with SMTP id q19-20020a056870329300b001beccce7991mr7369865oac.13.1695347469207; Thu, 21 Sep 2023 18:51:09 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:fa26:6227:be1c:67f0]) by smtp.gmail.com with ESMTPSA id y10-20020a63b50a000000b0057412d84d25sm1973856pge.4.2023.09.21.18.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:51:08 -0700 (PDT) From: Drew Fustini Date: Thu, 21 Sep 2023 18:49:48 -0700 Subject: [PATCH 1/6] dt-bindings: mmc: sdhci-of-dwcmhsc: Add T-Head TH1520 support MIME-Version: 1.0 Message-Id: <20230921-th1520-mmc-v1-1-49f76c274fb3@baylibre.com> References: <20230921-th1520-mmc-v1-0-49f76c274fb3@baylibre.com> In-Reply-To: <20230921-th1520-mmc-v1-0-49f76c274fb3@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=1695347467; l=1067; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=lVStiUHxeHbyNt2+zib4d2cdPudtKK6oNMBUQREoPOc=; b=Q8id6rVsSYwP6E+iXtE8EEJBdpfTwGmm0EDwKwz276FYyD9CgqZLnz0ACffcwGavDc/d0fScS a4r/IUtRvh1A4kShsI9oBwJNbY9Otbdr+VEmtnmc12pL4kS6vyLRKBn 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-20230921_185110_678804_F20ECF52 X-CRM114-Status: UNSURE ( 9.05 ) 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 compatible value for the T-Head TH1520 dwcmshc controller and add thead,phy-pull-up property. Signed-off-by: Drew Fustini --- Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml b/Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml index a43eb837f8da..46b768d46712 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 @@ -60,6 +61,9 @@ properties: description: Specify the number of delay for tx sampling. $ref: /schemas/types.yaml#/definitions/uint8 + thead,phy-pull-up: + description: Enable weak pull-up on PHY pads + type: boolean required: - compatible From patchwork Fri Sep 22 01:49:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13394870 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 F218AE7D0BF for ; Fri, 22 Sep 2023 01:51:19 +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=E09lckMtOcZFDL+rp5IAtOXlLBjIaGKY5LkZbKKFBcI=; b=xZE/b5a1oR7/Fr ZlPqvCRj7yXMpwCw5Q7BeEW0FcJfFYEhyXCpRY8NEwiAG5WUfCizzJX5a9G75O6rAwr20/kL9H2CL 2J7sm2B9vxxd12Ki+Rd2bFIag8lXF01Jjzhkm9vbLeRvX7Wwp7E0kCrorTe/DLifhMkuWdcyvHlTI JhjLk3haxSNMsiNymNFMcwypbpf6UeiALYM5rosNENzXLF++K9xlREMVrDWrtz9VgZ6AKX2Fd7zFo WZ1fzGyQLDDI9MXRv0CMwUQCsOR1WTPiGekHbQkl0z1OQ+NUUta5ioDBLX2S26NZJv/2mhjfPxH6M i/+96eFhnx+csZTZAphQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjVK8-007aay-05; Fri, 22 Sep 2023 01:51:16 +0000 Received: from mail-vs1-f50.google.com ([209.85.217.50]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjVK3-007aXw-35 for linux-riscv@lists.infradead.org; Fri, 22 Sep 2023 01:51:13 +0000 Received: by mail-vs1-f50.google.com with SMTP id ada2fe7eead31-4527d7f7305so818585137.1 for ; Thu, 21 Sep 2023 18:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695347470; x=1695952270; 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=ixTqiGVx8ZXpjpR7y6lRGGFsz7OZ+ET+MZdQ4NUAsFY=; b=yYvZaoxx1/cwio9uoWvbJDNVkdnjH8YuPJm+4k6NpWswn5bx1ccnbbxhwmQRGkGHDC 5c9fCckplG52ep8b5ng6mPMiGhndZXQ74mh0CAi29ZDElaiHj0YvMpeHUgY1i7syul2q MT+Ke8fin7Em6uGNYwD8NsfJgfEj2t5DgFW9TWXqnUNYLGTIu81eYXG6GnVzeMEDk/rU n9zGHaUQVzudhCIBRHh96l6HMfu4vvPrjOjsj5m5wqjhdr+ZIrXhNm5ugQb+Cclw+6iL TLNVK9cTelck0F8HwpfKWuvnNS/2alZiSZy5g3eqXibUZScklJyHOkyyUvm3rlKBhadG pRKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695347470; x=1695952270; 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=ixTqiGVx8ZXpjpR7y6lRGGFsz7OZ+ET+MZdQ4NUAsFY=; b=e1gfc1qVsuei2QJa9u2R6RPA5GOzvMffmNkxufcKWF98angoqGw7JgVVWqR97Tek+Z DjIQ09h2QZvpUMSUuJgrAcer63Y8XgKrjLYJnQf62iIUJCQtXfy/TR7nzSgNTSnnUHQR 1c2AL1Cw9W0LP5L2birLrUlbQmzOI2YUkcYV4FPra04x4Qp54uA6XrOdAEw9wwUWfQU7 O9rloiD9N+DSt6qibeWp9E4XSRkj+/knl9xbmERU/eAT6R+0ImmwCNGQNbLM7bD2G7AK fW/NifiD6WAZtkhRQ1/UYrAeEnanf/NvSs+iUUyjPX+f6LZjfUeKsS1w35PKYQYiMnDQ AHVQ== X-Gm-Message-State: AOJu0YzTEARVUdViSIxV5lAFl58Xoe7oySIsNvfFD6bfdtRY6IDeIHkh aVtzxV7cS5Eca46tNvc92lAWpA== X-Google-Smtp-Source: AGHT+IHj0Lr/Be8FAt3qA85CiKz6e+2ivU8VOj029IZto83YwRL3xxqYZvq42aLws+pyGjAy7HTN1A== X-Received: by 2002:a05:6102:302c:b0:44d:4d5f:79a4 with SMTP id v12-20020a056102302c00b0044d4d5f79a4mr6139892vsa.20.1695347470206; Thu, 21 Sep 2023 18:51:10 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:fa26:6227:be1c:67f0]) by smtp.gmail.com with ESMTPSA id y10-20020a63b50a000000b0057412d84d25sm1973856pge.4.2023.09.21.18.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:51:09 -0700 (PDT) From: Drew Fustini Date: Thu, 21 Sep 2023 18:49:49 -0700 Subject: [PATCH 2/6] mmc: sdhci: add __sdhci_execute_tuning() to header MIME-Version: 1.0 Message-Id: <20230921-th1520-mmc-v1-2-49f76c274fb3@baylibre.com> References: <20230921-th1520-mmc-v1-0-49f76c274fb3@baylibre.com> In-Reply-To: <20230921-th1520-mmc-v1-0-49f76c274fb3@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=1695347467; l=1797; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=jbhsItAspw9Y505sHjMPZkocmfoBMXCEAbwf8HhAE8A=; b=Y7zI2YH3NQD0FaxiSQ4VnQS2RFqoHRb3cydOhAc2I8kHbSV81T3H1sj3MdzwctHhwtJlv39EH CGD7yjz/YJWDePGxpJZ2guSYNA4iKk5mDzTqvA3yDNkTUQHmVRbKFIQ 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-20230921_185112_002745_C954FBA9 X-CRM114-Status: GOOD ( 11.83 ) 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 --- drivers/mmc/host/sdhci.c | 2 +- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ff41aa56564e..fd607058d176 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; 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 Fri Sep 22 01:49:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13394874 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 7CDB1E7D0BB for ; Fri, 22 Sep 2023 01:51:28 +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=oQDg9q9g1FG+u3ik2p2fDujQ5ueRppovD4wxE89Diws=; b=QUH72QpPbJxEIo o2TpF1dePo03NGCSTC4sbDUFrClbPAax8nm1AuZIUCOMfLP8AG6WZ2RyyPQIi422c9cbZFgXAAWwy ka4xhQ2sxptk2RQiefwtDvvNN5fFLC9tG0MstN6y3eI9W62zlFYug8GynRi+Uhc2hTjyfJMNcDbVH YrPdgcmmhkkVF0uJruVAlZi43hnc5trNQ8f9vJk4pNP/7ZN2XRLatspWGzgK6/kgqkwH5MDi/GTsd +wzv9jdRNUfRMNfskrY9RGg2/180kBvpv7rwunBhV9ANnNmj2PrqpoealXuKrPnHks1TW4Ox1n3zO zzpJrAHXGCoc3J8udV4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjVKG-007aib-34; Fri, 22 Sep 2023 01:51:24 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjVKE-007aeo-0c for linux-riscv@bombadil.infradead.org; Fri, 22 Sep 2023 01:51:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=1Qr4tSpb4BNnKQQwWMoToDq5tTNIzWA+Sp0qHl9b8Mo=; b=jPRhAa2RdLtpbYXGO8AkZMlXIr uj/CLG3O1iB3B/qTYDvplbcP+kk2a4ZlWMlpQCTblaZIr4Ccu+Xahov9JpEIi8YLaPmi4w4dm4lCN b58Z1XnnWe1jIIo3e9GcXgG50s0WvuyCKtDMBV9AKI9fwt7F9txxwzIwf/edjQtLP6AmtgI2rw9Z5 WZLcBC1N6Hg/NK0wulyqtiJhrzMc6l1prGxtNt9jH7M+aUkZQ3V5LzEcvmH+iafi9egbJXkCdHQCn tUqNg2+9pZt0Erm57W4w3/JQLUph1iEItaQ3WM4kstZ0wMkBPtaUk6H+s/SFQHkfCC8OCvkR8eVEn Hy3Tj/ww==; Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjVK6-00Fq1V-1a for linux-riscv@lists.infradead.org; Fri, 22 Sep 2023 01:51:20 +0000 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-59c0b5f984aso19799277b3.2 for ; Thu, 21 Sep 2023 18:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695347471; x=1695952271; 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=1Qr4tSpb4BNnKQQwWMoToDq5tTNIzWA+Sp0qHl9b8Mo=; b=XOrg4wXMTPuIl4iFo4IkxxHfXgdh0tUaNTVVPDTm/npluZxOrlAODY22FVMOHdi33B YX+VTHaIdnSqi+6oke7b+tzLQjC8M9pT1923TxMFc24BxRGZp0CEF3800XeIQ8iC8SSi i4bt9M3iYA7lCWfj4qbHSv1a0bwOKJ0wBe+RZ1gcdicKa8D1r2egKLmkrkJpGea689LS 6dKzG1N7heaeLPXIseMR2HzR2mbHiTGanllsPIz08MMkOgPKHIF6NrAaJmeliGgzSnwu mnT89tIKx3AWCTcGVmiuomB8x1GJHBOwM8xTMkKP1XTELdXj7FrPHBrBN4elcS7LEKtm B8nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695347471; x=1695952271; 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=1Qr4tSpb4BNnKQQwWMoToDq5tTNIzWA+Sp0qHl9b8Mo=; b=iZnJ/ejuuM+cbUD8D9n+mZoVXMNrN3/4MZ+UJeKkHPPBhqdeMqAhQzFZqOVT/4Dwvv 1If55Wb1XdmnBQffjO+wt7H+NWZIFu/DB/3FTv/+pyGc95dYG5uT+jbD60LK693ra1pA gN4O/2LQoj4xQJr8Cbv1OSzgzeC1d/mXsISoxLDfDbseiY7QTFbP/jKIAwBpzwSGpRZy hg6rghhbItvzJiF1ybw34tpNrR7/AFSymrjhKHQrwSi8Dxhucx9R3so+DpOuQBnkO9FY se7dfwrqgLNCrXI76ClPAk0yxovEYpeos2awQhgpZ/CgyuZ/ZRlnBevvc3O5mIX/5uU3 5z/g== X-Gm-Message-State: AOJu0YwDhiuJgJVcPfS6mvaNUUISKlatGjviwjJ+NIk925GqSv5vG7bK yX5AQ1jCxmSrLyFlGuBfzoVo5g== X-Google-Smtp-Source: AGHT+IHz4MeKzQNpGS3GuXJru1bhFANMtBidBLfjB0S7BBLwpdV+bF/LMZO4YdD6LDF1rILDlQEt4w== X-Received: by 2002:a81:5c45:0:b0:59b:fda7:9d7f with SMTP id q66-20020a815c45000000b0059bfda79d7fmr7108949ywb.49.1695347471227; Thu, 21 Sep 2023 18:51:11 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:fa26:6227:be1c:67f0]) by smtp.gmail.com with ESMTPSA id y10-20020a63b50a000000b0057412d84d25sm1973856pge.4.2023.09.21.18.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:51:10 -0700 (PDT) From: Drew Fustini Date: Thu, 21 Sep 2023 18:49:50 -0700 Subject: [PATCH 3/6] mmc: sdhci-of-dwcmshc: Add support for T-Head TH1520 MIME-Version: 1.0 Message-Id: <20230921-th1520-mmc-v1-3-49f76c274fb3@baylibre.com> References: <20230921-th1520-mmc-v1-0-49f76c274fb3@baylibre.com> In-Reply-To: <20230921-th1520-mmc-v1-0-49f76c274fb3@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=1695347467; l=20376; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=LDBhzAz693ogyYuKvJM9mF/EbXQOvMewS07B6vi+b3k=; b=yYz3jnd3fEfUzx0/uJpKvvgpPyCv7j4OeZ9Sn2VxAp4GZKuyrjqgk7tJ8bGXYL5sV2RObxTKr pp//Lt66lltA4rUCNzwYqkpUs+FZmCsr1rEqst8FYmfO5JZpmDkH1V1 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-20230922_025116_721154_0F347620 X-CRM114-Status: GOOD ( 16.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 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 --- drivers/mmc/host/sdhci-of-dwcmshc.c | 456 ++++++++++++++++++++++++++++++++++++ 1 file changed, 456 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c index 3a3bae6948a8..7294bf1afb7d 100644 --- a/drivers/mmc/host/sdhci-of-dwcmshc.c +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c @@ -35,6 +35,26 @@ #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 0x1 /* autotuning is enabled */ +#define AT_CTRL_CI_SEL_SHIFT 0x1 /* bit 1 */ +#define AT_CTRL_CI_SEL 0x1 /* interval to drive center phase select */ +#define AT_CTRL_SWIN_TH_EN_SHIFT 0x2 /* bit 2 */ +#define AT_CTRL_SWIN_TH_EN 0x1 /* sampling window threshold enable */ +#define AT_CTRL_RPT_TUNE_ERR_SHIFT 0x3 /* bit 3 */ +#define AT_CTRL_RPT_TUNE_ERR 0x1 /* enable reporting framing errors */ +#define AT_CTRL_SW_TUNE_EN_SHIFT 0x4 /* bit 4 */ +#define AT_CTRL_SW_TUNE_EN 0x1 /* enable software managed tuning */ +#define AT_CTRL_WIN_EDGE_SEL_SHIFT 0x8 /* bits [11:8] */ +#define AT_CTRL_WIN_EDGE_SEL 0xf /* sampling window edge select */ +#define AT_CTRL_TUNE_CLK_STOP_EN_SHIFT 0x10 /* bit 16 */ +#define AT_CTRL_TUNE_CLK_STOP_EN 0x1 /* clocks stopped during phase code change */ +#define AT_CTRL_PRE_CHANGE_DLY_SHIFT 0x11 /* bits [18:17] */ +#define AT_CTRL_PRE_CHANGE_DLY 0x1 /* 2-cycle latency */ +#define AT_CTRL_POST_CHANGE_DLY_SHIFT 0x13 /* bits [20:19] */ +#define AT_CTRL_POST_CHANGE_DLY 0x3 /* 4-cycle latency */ +#define AT_CTRL_SWIN_TH_VAL_SHIFT 0x18 /* bits [31:24] */ +#define AT_CTRL_SWIN_TH_VAL 0x9 /* sampling window threshold */ /* Rockchip specific Registers */ #define DWCMSHC_EMMC_DLL_CTRL 0x800 @@ -72,6 +92,84 @@ (((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_SHIFT 0x10 /* bits [16:9] */ +#define PHY_CNFG_PAD_SP_VALUE 0x0c /* PMOS TX drive strength */ +#define PHY_CNFG_PAD_SN_SHIFT 0x14 /* bits [23:20] */ +#define PHY_CNFG_PAD_SN_VALUE 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_SHIFT 0x3 /* bits [4:3] */ +#define PHY_PAD_WEAKPULL_PULLUP 0x1 /* Weak pull down enabled */ +#define PHY_PAD_WEAKPULL_PULLDOWN 0x2 /* Weak pull down enabled */ + +#define PHY_PAD_TXSLEW_CTRL_P_SHIFT 0x5 /* bits [8:5] */ +#define PHY_PAD_TXSLEW_CTRL_P_VALUE 0x3 /* Slew control for P-Type pad TX */ +#define PHY_PAD_TXSLEW_CTRL_N_SHIFT 0x9 /* bits [12:9] */ +#define PHY_PAD_TXSLEW_CTRL_N_VALUE 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_SHIFT 0x4 /* bit 4 */ +#define PHY_SDCLKDL_CNFG_UPDATE_DC 0x1 /* 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_SHIFT 0x2 /* bits [3:2] */ +#define PHY_ATDL_CNFG_INPSEL_VALUE 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_SHIFT 0x4 /* bits [5:4] */ +#define PHY_DLL_CNFG1_SLVDLY_VALUE 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_SHIFT 0x5 /* bits [6:5] */ +#define PHY_DLLDL_CNFG_SLV_INPSEL_VALUE 0x3 /* clock source select for slave DL */ + +#define FLAG_PULL_UP_EN BIT(0) +#define FLAG_IO_FIXED_1V8 BIT(1) + #define BOUNDARY_OK(addr, len) \ ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1))) @@ -92,6 +190,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 +257,206 @@ static void dwcmshc_request(struct mmc_host *mmc, struct mmc_request *mrq) sdhci_request(mmc, mrq); } +static void th1520_phy_1_8v_init_no_pull(struct sdhci_host *host) +{ + u32 val; + + /* deassert phy reset */ + sdhci_writel(host, PHY_CNFG_RSTN_DEASSERT, PHY_CNFG_R); + + /* disable delay line */ + sdhci_writeb(host, PHY_SDCLKDL_CNFG_UPDATE_DC << PHY_SDCLKDL_CNFG_UPDATE_SHIFT, + PHY_SDCLKDL_CNFG_R); + + /* set delay line */ + sdhci_writeb(host, PHY_SDCLKDL_DC_INITIAL, PHY_SDCLKDL_DC_R); + + /* enable delay lane */ + val = sdhci_readb(host, PHY_SDCLKDL_CNFG_R); + val &= ~(PHY_SDCLKDL_CNFG_UPDATE_DC << PHY_SDCLKDL_CNFG_UPDATE_SHIFT); + sdhci_writeb(host, val, PHY_SDCLKDL_CNFG_R); + + /* configure phy pads */ + val = sdhci_readw(host, PHY_CMDPAD_CNFG_R); + sdhci_writew(host, val | PHY_PAD_RXSEL_1V8, PHY_CMDPAD_CNFG_R); + + val = sdhci_readw(host, PHY_DATAPAD_CNFG_R); + sdhci_writew(host, val | PHY_PAD_RXSEL_1V8, PHY_DATAPAD_CNFG_R); + + val = sdhci_readw(host, PHY_RSTNPAD_CNFG_R); + sdhci_writew(host, val | PHY_PAD_RXSEL_1V8, PHY_RSTNPAD_CNFG_R); + + val = sdhci_readw(host, PHY_STBPAD_CNFG_R); + sdhci_writew(host, val | PHY_PAD_RXSEL_1V8, PHY_STBPAD_CNFG_R); + + /* enable phy dll */ + val = sdhci_readb(host, PHY_DLL_CTRL_R); + sdhci_writeb(host, val | PHY_DLL_CTRL_ENABLE, PHY_DLL_CTRL_R); +} + +static void th1520_phy_3_3v_init_no_pull(struct sdhci_host *host) +{ + u32 val; + + /* deassert phy reset */ + sdhci_writel(host, PHY_CNFG_RSTN_DEASSERT, PHY_CNFG_R); + + /* disable delay line */ + sdhci_writeb(host, PHY_SDCLKDL_CNFG_UPDATE_DC << PHY_SDCLKDL_CNFG_UPDATE_SHIFT, + PHY_SDCLKDL_CNFG_R); + + /* set delay line */ + sdhci_writeb(host, PHY_SDCLKDL_DC_INITIAL, PHY_SDCLKDL_DC_R); + + /* enable delay lane */ + val = sdhci_readb(host, PHY_SDCLKDL_CNFG_R); + val &= ~(PHY_SDCLKDL_CNFG_UPDATE_DC << PHY_SDCLKDL_CNFG_UPDATE_SHIFT); + sdhci_writeb(host, val, PHY_SDCLKDL_CNFG_R); + + /* configure phy pads */ + val = sdhci_readw(host, PHY_CMDPAD_CNFG_R); + sdhci_writew(host, val | PHY_PAD_RXSEL_3V3, PHY_CMDPAD_CNFG_R); + + val = sdhci_readw(host, PHY_DATAPAD_CNFG_R); + sdhci_writew(host, val | PHY_PAD_RXSEL_3V3, PHY_DATAPAD_CNFG_R); + + val = sdhci_readw(host, PHY_RSTNPAD_CNFG_R); + sdhci_writew(host, val | PHY_PAD_RXSEL_3V3, PHY_RSTNPAD_CNFG_R); + + val = sdhci_readw(host, PHY_STBPAD_CNFG_R); + sdhci_writew(host, val | PHY_PAD_RXSEL_3V3, PHY_STBPAD_CNFG_R); + + /* enable phy dll */ + val = sdhci_readb(host, PHY_DLL_CTRL_R); + sdhci_writeb(host, val | PHY_DLL_CTRL_ENABLE, PHY_DLL_CTRL_R); +} + +static void th1520_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; + + if (!priv) + return; + + if (!(priv->flags & FLAG_PULL_UP_EN)) { + th1520_phy_1_8v_init_no_pull(host); + return; + } + + /* deassert phy reset & set tx drive strength */ + sdhci_writel(host, PHY_CNFG_RSTN_DEASSERT | + (PHY_CNFG_PAD_SP_VALUE << PHY_CNFG_PAD_SP_SHIFT) | + (PHY_CNFG_PAD_SN_VALUE << PHY_CNFG_PAD_SN_SHIFT), + PHY_CNFG_R); + + /* disable delay line */ + sdhci_writeb(host, PHY_SDCLKDL_CNFG_UPDATE_DC << PHY_SDCLKDL_CNFG_UPDATE_SHIFT, + 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_DC << PHY_SDCLKDL_CNFG_UPDATE_SHIFT); + sdhci_writeb(host, val, PHY_SDCLKDL_CNFG_R); + + /* configure phy pads */ + val = PHY_PAD_RXSEL_1V8 | (PHY_PAD_WEAKPULL_PULLUP << PHY_PAD_WEAKPULL_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_P_VALUE << PHY_PAD_TXSLEW_CTRL_P_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_N_VALUE << PHY_PAD_TXSLEW_CTRL_N_SHIFT); + 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 = (PHY_PAD_TXSLEW_CTRL_P_VALUE << PHY_PAD_TXSLEW_CTRL_P_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_N_VALUE << PHY_PAD_TXSLEW_CTRL_N_SHIFT); + sdhci_writew(host, val, PHY_CLKPAD_CNFG_R); + + val = PHY_PAD_RXSEL_1V8 | (PHY_PAD_WEAKPULL_PULLDOWN << PHY_PAD_WEAKPULL_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_P_VALUE << PHY_PAD_TXSLEW_CTRL_P_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_N_VALUE << PHY_PAD_TXSLEW_CTRL_N_SHIFT); + sdhci_writew(host, val, PHY_STBPAD_CNFG_R); + + /* enable data strobe mode */ + sdhci_writeb(host, PHY_DLLDL_CNFG_SLV_INPSEL_VALUE << PHY_DLLDL_CNFG_SLV_INPSEL_SHIFT, + PHY_DLLDL_CNFG_R); + + /* enable phy dll */ + sdhci_writeb(host, PHY_DLL_CTRL_ENABLE, PHY_DLL_CTRL_R); +} + +static void th1520_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; + + if (!(priv->flags & FLAG_PULL_UP_EN)) { + th1520_phy_3_3v_init_no_pull(host); + return; + } + + /* deassert phy reset & set tx drive strength */ + sdhci_writel(host, PHY_CNFG_RSTN_DEASSERT | + (PHY_CNFG_PAD_SP_VALUE << PHY_CNFG_PAD_SP_SHIFT) | + (PHY_CNFG_PAD_SN_VALUE << PHY_CNFG_PAD_SN_SHIFT), + PHY_CNFG_R); + + /* disable delay line */ + sdhci_writeb(host, PHY_SDCLKDL_CNFG_UPDATE_DC << PHY_SDCLKDL_CNFG_UPDATE_SHIFT, + 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_DC << PHY_SDCLKDL_CNFG_UPDATE_SHIFT); + sdhci_writeb(host, val, PHY_SDCLKDL_CNFG_R); + + /* configure phy pads */ + val = PHY_PAD_RXSEL_3V3 | (PHY_PAD_WEAKPULL_PULLUP << PHY_PAD_WEAKPULL_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_P_VALUE << PHY_PAD_TXSLEW_CTRL_P_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_N_VALUE << PHY_PAD_TXSLEW_CTRL_N_SHIFT); + 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 = (PHY_PAD_TXSLEW_CTRL_P_VALUE << PHY_PAD_TXSLEW_CTRL_P_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_N_VALUE << PHY_PAD_TXSLEW_CTRL_N_SHIFT); + sdhci_writew(host, val, PHY_CLKPAD_CNFG_R); + + val = PHY_PAD_RXSEL_3V3 | (PHY_PAD_WEAKPULL_PULLDOWN << PHY_PAD_WEAKPULL_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_P_VALUE << PHY_PAD_TXSLEW_CTRL_P_SHIFT) | + (PHY_PAD_TXSLEW_CTRL_N_VALUE << PHY_PAD_TXSLEW_CTRL_N_SHIFT); + sdhci_writew(host, val, PHY_STBPAD_CNFG_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 (host->mmc->caps & MMC_CAP_NONREMOVABLE) { + th1520_phy_1_8v_init(host); + 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); + } else { + th1520_phy_3_3v_init(host); + } + + sdhci_writeb(host, (PHY_DLL_CNFG1_SLVDLY_VALUE << PHY_DLL_CNFG1_SLVDLY_SHIFT) | + PHY_DLL_CNFG1_WAITCYCLE, PHY_DLL_CNFG1_R); +} + static void dwcmshc_set_uhs_signaling(struct sdhci_host *host, unsigned int timing) { @@ -189,9 +489,30 @@ 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); + u32 reg; + + dwcmshc_set_uhs_signaling(host, timing); + if (timing == MMC_TIMING_MMC_HS400) { + reg = sdhci_readl(host, priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL); + reg &= ~AT_CTRL_AT_EN; + sdhci_writel(host, reg, priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL); + priv->delay_line = PHY_SDCLKDL_DC_HS400; + th1520_sdhci_set_phy(host); + } else { + sdhci_writeb(host, 0, PHY_DLLDL_CNFG_R); + } +} + static void dwcmshc_hs400_enhanced_strobe(struct mmc_host *mmc, struct mmc_ios *ios) { @@ -338,6 +659,91 @@ 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, PHY_ATDL_CNFG_INPSEL_VALUE << PHY_ATDL_CNFG_INPSEL_SHIFT, + 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_CI_SEL_SHIFT) | + (AT_CTRL_RPT_TUNE_ERR << AT_CTRL_RPT_TUNE_ERR_SHIFT) | + (AT_CTRL_SW_TUNE_EN << AT_CTRL_SW_TUNE_EN_SHIFT) | + (AT_CTRL_WIN_EDGE_SEL << AT_CTRL_WIN_EDGE_SEL_SHIFT)); + + /* + * 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_SWIN_TH_EN_SHIFT) | + (AT_CTRL_TUNE_CLK_STOP_EN << AT_CTRL_TUNE_CLK_STOP_EN_SHIFT) | + (AT_CTRL_PRE_CHANGE_DLY << AT_CTRL_PRE_CHANGE_DLY_SHIFT) | + (AT_CTRL_POST_CHANGE_DLY << AT_CTRL_POST_CHANGE_DLY_SHIFT) | + (AT_CTRL_SWIN_TH_VAL << AT_CTRL_SWIN_TH_VAL_SHIFT); + + sdhci_writel(host, val, priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL); + val = sdhci_readl(host, priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL); + + /* check if is possible to enable auto-tuning */ + if (!(val & AT_CTRL_AT_EN)) { + dev_err(mmc_dev(host->mmc), "failed to enable auto tuning\n"); + return -EIO; + } + + /* disable auto tuning */ + val &= ~AT_CTRL_AT_EN; + sdhci_writel(host, val, 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) { + 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 +762,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 = th1520_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 +796,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 +870,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 +969,35 @@ 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_present(&pdev->dev, "thead,phy-pull-up")) + priv->flags |= FLAG_PULL_UP_EN; + else + priv->flags &= ~FLAG_PULL_UP_EN; + + 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 ranther 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 Fri Sep 22 01:49:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13394876 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 36FCCE7D0BC for ; Fri, 22 Sep 2023 01:51:34 +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=akzwyEBDd9+qC0JbC1VCPdBgKjdsR+7tUt00sdZvgpo=; b=W5bo0tskSsd+Ag IhRI0SpWHefQDG5Q77W0c4xxy3wGYdBFJBBH39/4iWa8ty/r8YQIn8gGK/27jL5kN8WQijYsJwnlG ZuMfh5GCPHQ0bfhqFFrem4f8whMqLMPfpZB33Ta7bo8x22ZbFaBBR7TkHaQfLHyEJYVU4qhIA6Pme U/zajpicEdfGIRQfKNIOsnNJOLLg7fQ0uxTttpQvQ+Qz3jSbdSSv2hAexUe/YS/geDa3znLzCmkGs BDlhjx5gdvsD19A63Y7m7yLrV14Vsu1JwPgLch9saFp7i1Nxb5Mbc+qKgTjdo0/S3H9n5lJFc2Q9u J6CvIHlD0Qo4qvt2d8AQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjVKG-007aht-11; Fri, 22 Sep 2023 01:51:24 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjVKD-007aeh-1Z for linux-riscv@bombadil.infradead.org; Fri, 22 Sep 2023 01:51:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=FhR9frpmu/yAUsLJSS2gpg1w0JSCDYrDF2EFLnkclH4=; b=b2BpaAX8bKQhhE5luFGpYVbuPy GhFQu5JGiZJAr66JD+K30ZjNn23nBvSlLztSksF87EKEsWWoHxApafo09LOZRhDUfmkq+iJz5gCZm VVwv6Yo9KW6koNudZK2wysEHlScQ5vgYELrT1cfmbdpUHmRDyL659PSFBN8nBphTqYDX7PoeEHz8w 2u8Q5DgU/F2q7gdEJy+W8oJPa4POqLa0EMoGmTi3YuC7i8tONf1y3R190z/LzHi99BWvLIJ/Mvgxa riNp4DKuABozcRYAFtgz/rptCINnH8a5TdXPFNDwjBoeaO2Ybt11zEfyAFb/UvAT4EZvNBAsuH5Wn tiIgISww==; Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjVK6-00Fq1W-1Z for linux-riscv@lists.infradead.org; Fri, 22 Sep 2023 01:51:19 +0000 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1dc863efb61so610714fac.0 for ; Thu, 21 Sep 2023 18:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695347472; x=1695952272; 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=FhR9frpmu/yAUsLJSS2gpg1w0JSCDYrDF2EFLnkclH4=; b=SrZpbQ7HhnOmICYB8vLHEC/Dv8IjEMQKIbopxFwUh9dN8mC8JZ2mjqqNAMSn1ruy+3 wA6LVih/KanrgqTaAoVQnae7KpJZYodSVYXYMuS1RL+3MhZA18fQBm6EL9mfJUq5QQGA NTvAE4fQ48hwkNUY0PQ4ecNzsFnbQOitPVUGMu67AG5ErbE+BrNaKq2lNBrzv2SPyLoE H1xtKBbOQK9fonM4rQDkEWXfkH6YvoyKB/gYMJeO77/C+UygRtQiP39c8xuTfIxMYa86 9F4rlrB1+ve7EGICniki2xCN54jKOPAwT0A2gs/6ArOji/WgJf9/cRT37wIKhXuSjEKv A8IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695347472; x=1695952272; 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=FhR9frpmu/yAUsLJSS2gpg1w0JSCDYrDF2EFLnkclH4=; b=nMU3N2uF0CKGHSVNzJu1Ko0UGZNHj2upLrZKcNtww2arlDXrg9+YP7twc8LrZ58S7n CEm3HPdYZrWCvN7kHGdpqG58TA9aVuc9GaIYBhl91g/Iw9IA+tPvb+ps3LwKXbTox4Ri z+GBe63DWzb+FINi/GNORjPYOYJ0WPVUb/p7atXO8urpsh72bTfsNEUnziexy5tuWHH+ 3CxtPL+0eCp4ksmUZdjsM+uwv7x6wHSVjSFrHscr57jlelSlXL8kyBBv7JlANpjndM2H S6aBbyycidnK/00WS0OXAjP1KA6dX5HibJJeMp8XIDXhcs/Wtd6VxlW1UiuhJJ9G+nwG e/ZA== X-Gm-Message-State: AOJu0Yyquer2z+rmxje+PfwmgWXjnjp9dhz1L+WK3EqkgDOjrwXxu6CJ cTIai68xyuByY/55WqDb0mA2Wg== X-Google-Smtp-Source: AGHT+IG6f1s/2Qluw/AcJPeKmsWPsdAsou8qMp5DVhViZ2oFPjZlrQWRIfAn8jL/kTb28f16DxKnNQ== X-Received: by 2002:a05:6870:418f:b0:1bf:607:e0f2 with SMTP id y15-20020a056870418f00b001bf0607e0f2mr7359618oac.29.1695347472260; Thu, 21 Sep 2023 18:51:12 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:fa26:6227:be1c:67f0]) by smtp.gmail.com with ESMTPSA id y10-20020a63b50a000000b0057412d84d25sm1973856pge.4.2023.09.21.18.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:51:11 -0700 (PDT) From: Drew Fustini Date: Thu, 21 Sep 2023 18:49:51 -0700 Subject: [PATCH 4/6] riscv: dts: thead: Add TH1520 mmc controller and sdhci clock MIME-Version: 1.0 Message-Id: <20230921-th1520-mmc-v1-4-49f76c274fb3@baylibre.com> References: <20230921-th1520-mmc-v1-0-49f76c274fb3@baylibre.com> In-Reply-To: <20230921-th1520-mmc-v1-0-49f76c274fb3@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=1695347467; l=1256; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=BOuTsoiS4wD+cP61c2nYQjChDl2neNVnlaTjhPPnjNo=; b=828BIUxxnWEqAhThpR3UsYUCLsNEjUrqd+nJV6aT2PNkFMKfXThBLTjniRlEi27zEM9N2HE7i 2TD3Ch0KrQ3BZYG48TuKVeR9eYlfwYG7F8m+g8psY+m2UCtMFgl1xpF 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-20230922_025116_716537_A486A62A X-CRM114-Status: UNSURE ( 9.82 ) 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 nodes for the SDHCI fixed clock and the first mmc controller which is typically connected to the eMMC device. Signed-off-by: Drew Fustini --- arch/riscv/boot/dts/thead/th1520.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index ff364709a6df..ee0711352790 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,14 @@ 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"; + }; + timer0: timer@ffefc32000 { compatible = "snps,dw-apb-timer"; reg = <0xff 0xefc32000 0x0 0x14>; From patchwork Fri Sep 22 01:49: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: 13394871 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 366A3E7D0BB for ; Fri, 22 Sep 2023 01:51: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=XgIj0u+H+gJcImBli6LH5tw7QgKKaAXuv56fCaxRMog=; b=n9uxPez2rK/Lhb 92lv6gk6BMtjFX9cKirbZfnbWykOBk14kvioCaH6+clnRlskunLPfgf0QJNYuzr71YkbgV1OPVNXV 4Y9qz6uMOh1dbWYKBKmcc+VCQ0kFxBib5fY1VB7AemXkWWsCH/f2SW7k2AN83sGOU3JPsNXmfUCTr RKkEDe78Tdk+0gsfik4d3af1TJwnHuKndkBqcfJjKh3xzpxhIVgb34PVReuGp+qms0nX6DXU/ldkl 79vADXS/p7AQi0mNqz6wwsTlz6ZBtMWN8x8gnbqlAopgyh+ckpckqItetJLWBpvdqQ8d0jOkXkOGT eHg/fZUAV4vRe9rEU2Iw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjVKB-007ad5-1m; Fri, 22 Sep 2023 01:51:19 +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 1qjVK6-007aZG-27 for linux-riscv@lists.infradead.org; Fri, 22 Sep 2023 01:51:15 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-690d25b1dbdso1449926b3a.2 for ; Thu, 21 Sep 2023 18:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695347473; x=1695952273; 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=iPEbvkuSlI+waNlJffRe2ktpor2JpDqdyWj2rz7p8Wk=; b=d2rl4tXBALoyf4x+5l9FSf1dSq9Oc/dKiOVPnKzj/HYaA7QkthHxd5biSsEF6cfxd1 3JnE0yyzreSDyZVJSnCFfEsedXJOECfDFaOrLQ3WP0qtP4/Q8YSjMkid3nFiRKjLyNIB PwSvm5zZygtpYMUPUB4hsTcGhZuOBh05fqo+Y7PiVgl7T0Gr8bWGPym16xMu44zwted6 KogwYkCmgrFvmJky4S0nbvg8JQ3uTs6LMIV3cB28FNS+0A5ZMr3B5R3Keww7i11H31t7 +o9XCWeS1fvJuwEOo51RPwWnj/0GkMH8RUaNZpZiPHhTsGrQl1xsgFW+rVF87B8PbOfg 1Y4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695347473; x=1695952273; 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=iPEbvkuSlI+waNlJffRe2ktpor2JpDqdyWj2rz7p8Wk=; b=K/cZR2ehOiUevfyFPpooQ/CoAQdaDc7GcL73TCzYpR6b0CuoPANxc7NHar0KKl/7P3 9UcXOVQ/g7UqvzwJSo1z6DhOztOgS8ZOYvX1RPb5WLMg+sEWnfkRclBBb+BKg478u6mc uHrGyuM229YOTM2as0ISxkU5uL/LwKiWOqFs1G1ETQ1HxLmdXzpYgqlmQMrRD2TT1Jjx u9MdLC1eZWtuy9lEQK1no8dlnfREoxkPD3epDEGvEaQPHlPqCQOl4ClOo0fds8DvyfpX lIzA3i7IbH5Qnc5zzAYfu6akdsAq2FJ0udkwCtBuKNZOlx9MxdNAnhLn3RCBAXD/hwr6 1cvg== X-Gm-Message-State: AOJu0YytQQoFflM8/NXsvIceaPlOQeoYqOkGZ591SsNzzNn5oqgRmNUr 0vJjg0CAqH1UlZH7t6LSBahlBw== X-Google-Smtp-Source: AGHT+IE4X42yF1HXpuaoHL3ejmIEJ9fFuH2zgYBey6U1orqlaNK7fEzRXNdULELkEbDzi1O+u9EzjA== X-Received: by 2002:a05:6a00:997:b0:68a:49bc:e0af with SMTP id u23-20020a056a00099700b0068a49bce0afmr8809508pfg.1.1695347473242; Thu, 21 Sep 2023 18:51:13 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:fa26:6227:be1c:67f0]) by smtp.gmail.com with ESMTPSA id y10-20020a63b50a000000b0057412d84d25sm1973856pge.4.2023.09.21.18.51.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:51:12 -0700 (PDT) From: Drew Fustini Date: Thu, 21 Sep 2023 18:49:52 -0700 Subject: [PATCH 5/6] riscv: dts: thead: Enable BeagleV Ahead eMMC controller MIME-Version: 1.0 Message-Id: <20230921-th1520-mmc-v1-5-49f76c274fb3@baylibre.com> References: <20230921-th1520-mmc-v1-0-49f76c274fb3@baylibre.com> In-Reply-To: <20230921-th1520-mmc-v1-0-49f76c274fb3@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=1695347467; l=956; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=e7hYW7QNhal0RaNuGY3AGvE/4Ei4UdLG9Fj7V3U8VKw=; b=IYvBWMTKLnO4eGhXZDaLu7J6cKyV/rnBRhIPRir14soBubLYnpWwdB1YUX5SiQQsnHUuOHFn8 opoUzD3CmAzChvQqTcQdMtI/oVbApUhunFrq/jQQ+eMCvA40mghGlE8 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-20230921_185114_695553_419B1835 X-CRM114-Status: UNSURE ( 8.80 ) 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 properties to the emmc node and enable it and set the frequency for the sdhci clock. Signed-off-by: Drew Fustini --- arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts | 15 +++++++++++++++ 1 file changed, 15 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..dde645789b7e 100644 --- a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts +++ b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts @@ -52,6 +52,10 @@ &uart_sclk { clock-frequency = <100000000>; }; +&sdhci_clk { + clock-frequency = <198000000>; +}; + &dmac0 { status = "okay"; }; @@ -59,3 +63,14 @@ &dmac0 { &uart0 { status = "okay"; }; + +&mmc0 { + bus-width = <8>; + max-frequency = <198000000>; + mmc-hs400-1_8v; + non-removable; + no-sdio; + no-sd; + thead,phy-pull-up; + status = "okay"; +}; From patchwork Fri Sep 22 01:49: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: 13394873 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 57562E7D0BE for ; Fri, 22 Sep 2023 01:51:24 +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=23++ysZuPHR3lyK1+kWAhXngoLg7/pOyePXfYQBAjP4=; b=ySP9oC6T6ZkJhS XzhTZlSf7RN5rwLZniVzRyIEtmYQKSvbvk7tEBgLXwnaAAOD0gAzMdujPekM0mn9DoCVbnOlwNz1P +9IA4Ma6YNxN/bujKz0K33lf1uJpkJ/FhGYZ4DLAa7vghqVSDbIUGdKtmB4N4KgVko4NKYRUqtfmL ifTJykQbsEVfgXNdW2EL+pY2dIozv6NPW7JXJZh1b95LBGYvt3Nuq5FacMWX54UvzsoKdRe7sppkD Rzm0Vh8gOezHzHM+xrE/bX6gKykmp5G5G7XxMJJb7NFt1bPVug24yd+ZVPXg35mGIUiOjlbF2rrMb +38n9rxH8Sk0hYRRDPtw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjVKC-007adr-0W; Fri, 22 Sep 2023 01:51:20 +0000 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjVK7-007aZv-23 for linux-riscv@lists.infradead.org; Fri, 22 Sep 2023 01:51:16 +0000 Received: by mail-vs1-xe30.google.com with SMTP id ada2fe7eead31-45281e0b1cbso847690137.0 for ; Thu, 21 Sep 2023 18:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695347474; x=1695952274; 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=cDyDoj9zqW3tb6f+dTciYYHXjkgtjjsfpMWk3ptqz4Y=; b=exupgGxvRz9CdCHbC/lt6mqVafuInZ8tG1uLLeRaBbhg9tYltiTN6XPsO7k9FDT3Iu MPQV1CYYJ+Bc575+29HAqeCzb0OH/TDX/u8CJsn7H58Lk5xwIcCEAZCqmVlWm0GkrG8m kG244BYSuwFG2RtrfYNLsCg4lxlPMhwMBAFqgVDdGnwagRDhqL7iinK6uE3pnc35mXxR j2XfRpM2Qkm7fYJPho0S2qwAYTFzR17u5FyMQ2IY3DVZk8TFeGGGayCAxcJF7j8G/ege uHbArsAnQAwWwQH/0gJ8JAkDSX2+2WPq6LWr37kuLDLbsXlF93iQDq1MBg/ugNo4Sfsj Saaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695347474; x=1695952274; 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=cDyDoj9zqW3tb6f+dTciYYHXjkgtjjsfpMWk3ptqz4Y=; b=TfHmYAW82THv6hep+7f2C2aiiQEB0U4M1vQL+LDZCPV/i0k8faUDKDQQK2aTfXLkpM AHkPhtpp/R+IsYolQuw/d8sz1wVLXli6U34U0JGlEZ5DfIT6qXI8IClXM46V0s3cJn9S 086BtKiAilKQ+BCj+3Gu5lVSZaH8CPeEC1EeqUlW04nJ9Kd/2++wHW6aBXckDQg+nYNd 5VztdROA0SmMrWT3/FhquAPhSGwseHKv2rUkRLOfOVVLVc+hGPWikhPZIOdz1s6Z0ABU rVnBT71ATJDC/bHEwTQg7MgAU4neAObDrd4YDeCGKltbALc1TJvzZyWa1IQZ4jdKtf6L ew5g== X-Gm-Message-State: AOJu0YyMYobNhXMG1NkXbUIGx1p8t6V/n9mx+KYfFg7rco6icfwyMaPw a4msaEh+ViVSQD0RJa980WnZ6g== X-Google-Smtp-Source: AGHT+IFXdS2JE5SAgxFGpk2JBdV0QiDMGOB+zNKqvG/7UuF33hvfFUA7v/UeS7e5AxcMQ4nkJcmsTQ== X-Received: by 2002:a67:b911:0:b0:452:5798:64b6 with SMTP id q17-20020a67b911000000b00452579864b6mr7136727vsn.29.1695347474300; Thu, 21 Sep 2023 18:51:14 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:fa26:6227:be1c:67f0]) by smtp.gmail.com with ESMTPSA id y10-20020a63b50a000000b0057412d84d25sm1973856pge.4.2023.09.21.18.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:51:14 -0700 (PDT) From: Drew Fustini Date: Thu, 21 Sep 2023 18:49:53 -0700 Subject: [PATCH 6/6] riscv: dts: thead: Enable LicheePi 4A eMMC controller MIME-Version: 1.0 Message-Id: <20230921-th1520-mmc-v1-6-49f76c274fb3@baylibre.com> References: <20230921-th1520-mmc-v1-0-49f76c274fb3@baylibre.com> In-Reply-To: <20230921-th1520-mmc-v1-0-49f76c274fb3@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=1695347467; l=995; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=NVR/jz5zFITHdlX9LFGuP143Lx0/07lnI+f1VmxUhWc=; b=raxv8sdLi3NXEnuRTMoKuMBfYJblfB31JVKLCA7ZyLEQDTMFK0QMg4FBDAS1/RE2PwM8GeM9g 37Bq/mEBjXzC14O3M2KIDYrOlsISgPYO/PybYfDJ47mNjxkGGIw5rgl 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-20230921_185115_674431_C0855C0A X-CRM114-Status: UNSURE ( 8.89 ) 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 properties to the emmc node and enable it and set the frequency for the sdhci clock. Signed-off-by: Drew Fustini --- arch/riscv/boot/dts/thead/th1520-lichee-module-4a.dtsi | 15 +++++++++++++++ 1 file changed, 15 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..3de8ae0a4384 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,14 @@ &uart_sclk { &dmac0 { status = "okay"; }; + +&mmc0 { + bus-width = <8>; + max-frequency = <198000000>; + mmc-hs400-1_8v; + non-removable; + no-sdio; + no-sd; + thead,phy-pull-up; + status = "okay"; +};