From patchwork Mon Dec 5 08:53:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomer Maimon X-Patchwork-Id: 29608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2139725wrr; Mon, 5 Dec 2022 01:03:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf5oPkWePJ4oLyNQMd2RE9W107aEeBpOjs1ce4kEzzugQMHGk7LGvcxCgjmGq9GLSOCb/5jx X-Received: by 2002:a62:8446:0:b0:574:8c08:6c15 with SMTP id k67-20020a628446000000b005748c086c15mr53022990pfd.82.1670231029451; Mon, 05 Dec 2022 01:03:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670231029; cv=none; d=google.com; s=arc-20160816; b=iQ8E46YCwtbqfu23cZcXJpGJSlDXBWQVlJ1enghZwYwT2phXTxXVT/1aSFn07iX+5d oud5IqNDJuJziGIzClDDkckKSg9WyjtSr1d4M1Ce8KTiPd/nLBF5DwkKBnXkawnL19OV p9yoAU994Tb6S6T4/+0kWbSJk1Pn6uEP3Tuv8/O2Eg4oOARuB8H9doNKnlNbm+VAM+Xj 3cL4/So4dOJAAQB/jKtzgXxID5065HaESwVh55ZIHKVG7pyPLlyZUwu+o3BVkWvZQRfk sUyxqJ6RorRteq7ByM5gI+xwUQ0LRbx0vNGBVIGttL8k+nntRtb04BW0tGfEvaMC5Yfq x8dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rxrPeBgKlcZij8Pe1ZqHDEhtjd4hr009nB2vC8uQlMM=; b=d4KL6ksYOwUhWyObIAvGZUnbHrH9c9fzD97fH66UAQTQubxyNzE3tZndD1EGXa2kBU DwXCMbFqbfAqbqYVUylILJGYQnlsqvjpwjONtXsGfjmSkQ4SdOd2uQhBHb9g53KqGdBH gRPDjUfektfR5dPF1uU5PfoF6cllvUZqKvGocVdcAKhq2Zx5GhZptefHiaCEYVwrqEUc BzusKgJYc5iJVXbaK2/dFV+mgNxfjEArZYcwAPkUfNiUtLOiTS9TCEVbBrgIzKZgpKkb 2NDF09KCeHnrffZc+vFYeBXD15IOs/On7EXwEme8jMbHEOanvjNygBB4h6EEsIjpWsFf +puw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ng9-20020a17090b1a8900b002190fb26b8csi18099385pjb.51.2022.12.05.01.03.35; Mon, 05 Dec 2022 01:03:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232246AbiLEIzX (ORCPT + 99 others); Mon, 5 Dec 2022 03:55:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232237AbiLEIyn (ORCPT ); Mon, 5 Dec 2022 03:54:43 -0500 Received: from maillog.nuvoton.com (maillog.nuvoton.com [202.39.227.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A0C5D240; Mon, 5 Dec 2022 00:54:01 -0800 (PST) Received: from NTHCCAS04.nuvoton.com (NTHCCAS04.nuvoton.com [10.1.8.29]) by maillog.nuvoton.com (Postfix) with ESMTP id 8EDFB1C81290; Mon, 5 Dec 2022 16:53:59 +0800 (CST) Received: from NTHCCAS02.nuvoton.com (10.1.9.121) by NTHCCAS04.nuvoton.com (10.1.8.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 5 Dec 2022 16:53:59 +0800 Received: from NTHCCAS04.nuvoton.com (10.1.8.29) by NTHCCAS02.nuvoton.com (10.1.9.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 5 Dec 2022 16:53:59 +0800 Received: from taln60.nuvoton.co.il (10.191.1.180) by NTHCCAS04.nuvoton.com (10.1.12.25) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Mon, 5 Dec 2022 16:53:58 +0800 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id 2507563A1E; Mon, 5 Dec 2022 10:53:58 +0200 (IST) From: Tomer Maimon To: , , , , , , , , , , , , , , , CC: , , , , Tomer Maimon Subject: [PATCH v2 1/2] dt-bindings: mmc: npcm,sdhci: Document NPCM SDHCI controller Date: Mon, 5 Dec 2022 10:53:50 +0200 Message-ID: <20221205085351.27566-2-tmaimon77@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20221205085351.27566-1-tmaimon77@gmail.com> References: <20221205085351.27566-1-tmaimon77@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,NML_ADSP_CUSTOM_MED,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751364172017791516?= X-GMAIL-MSGID: =?utf-8?q?1751364172017791516?= Add binding for Nuvoton NPCM SDHCI controller. Signed-off-by: Tomer Maimon Reviewed-by: Rob Herring --- .../devicetree/bindings/mmc/npcm,sdhci.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/npcm,sdhci.yaml diff --git a/Documentation/devicetree/bindings/mmc/npcm,sdhci.yaml b/Documentation/devicetree/bindings/mmc/npcm,sdhci.yaml new file mode 100644 index 000000000000..196fdbfa16ed --- /dev/null +++ b/Documentation/devicetree/bindings/mmc/npcm,sdhci.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mmc/npcm,sdhci.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NPCM SDHCI Controller + +maintainers: + - Tomer Maimon + +allOf: + - $ref: mmc-controller.yaml# + +properties: + compatible: + enum: + - nuvoton,npcm750-sdhci + - nuvoton,npcm845-sdhci + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + +unevaluatedProperties: false + +examples: + - | + mmc@f0840000 { + compatible = "nuvoton,npcm750-sdhci"; + reg = <0xf0840000 0x200>; + interrupts = <0 27 4>; + clocks = <&clk 4>; + }; From patchwork Mon Dec 5 08:53:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomer Maimon X-Patchwork-Id: 29609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2140001wrr; Mon, 5 Dec 2022 01:04:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf4lBcUSCAo3nBuvL3u24YW14EYDq7/RnWm4Cvrd4IUsUBfE6Kmy5xqCSBlKqUK9ACLroRV4 X-Received: by 2002:a17:906:660d:b0:7ba:5085:864 with SMTP id b13-20020a170906660d00b007ba50850864mr45480393ejp.357.1670231068824; Mon, 05 Dec 2022 01:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670231068; cv=none; d=google.com; s=arc-20160816; b=o07yYb/oLtT7CMLwl/iL/Z9M+9FrtwM8V0umxAxPSdH2GM6YUBd0x/a3P4tr3yUiZn NFMpGuRhDF8SqruJok8yE07eVCCoGSV/FijlAfXNxC/rbjLVZfehHCdqI2Jb2VPJx3eg tZZ5Gg8ylyei5bAHf4MI4fbLF9E4TETRNvB5ptvmw/Vuippfy/Jz2dfdVJ+e3TLxTCFR c3Xheb/G5EnbDqal2x+pyVVxWsoiCLs2YRhAjTyvHFmkTfJarINz5Gvr/9JIVpvNutux GhzH6Org71P8IdTKyPkm0ty52esxXDOaCMzNTcC2y1SNXLc/AdNdATQ3v9AsjhCXPpak Wj2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ES8KQ8xrF4wsiCaZbXK1hceH5iqoOcxXGT1MBi8AFYY=; b=EiT9ujp4Eof4Kz/Ukw/J/XHCw7WjsNOZh6IdbqUIjua6CrbKlgy0IJh1rOHItxAySK uf7HZsApMzekZrxowM3DT5NKDVjPfz1keazK/Djy9Zxc9u7UDR8uXDH4UrwD1O5MTulg 7wA+mH3NctJdNqdel5vHAwSbTJmxUvanjRkBBz7Kh/k7uC34FORf5h9yw+0ep7ZEbCpg qNrogFaCgde+I+7jIe35o73e/woHt0GXEZg/8gdPJpGHXtbrRgr0UwhSjKl7pKeUWqJW gKdDEPRuWD9qRfPs+5Yy6t8wAHXsw9B5AN3JidtePCdtFUDvcIC2nT9lIm9vJv4sYdJw YKKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rh16-20020a17090720f000b007ae4ed48293si8949836ejb.281.2022.12.05.01.04.05; Mon, 05 Dec 2022 01:04:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232430AbiLEIz3 (ORCPT + 99 others); Mon, 5 Dec 2022 03:55:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232385AbiLEIyn (ORCPT ); Mon, 5 Dec 2022 03:54:43 -0500 Received: from maillog.nuvoton.com (maillog.nuvoton.com [202.39.227.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C3A92BBF; Mon, 5 Dec 2022 00:54:01 -0800 (PST) Received: from NTHCCAS01.nuvoton.com (NTHCCAS01.nuvoton.com [10.1.8.28]) by maillog.nuvoton.com (Postfix) with ESMTP id 32ECE1C81291; Mon, 5 Dec 2022 16:54:00 +0800 (CST) Received: from NTHCCAS03.nuvoton.com (10.1.20.28) by NTHCCAS01.nuvoton.com (10.1.8.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 5 Dec 2022 16:54:00 +0800 Received: from NTHCCAS01.nuvoton.com (10.1.8.28) by NTHCCAS03.nuvoton.com (10.1.20.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Mon, 5 Dec 2022 16:53:59 +0800 Received: from taln60.nuvoton.co.il (10.191.1.180) by NTHCCAS01.nuvoton.com (10.1.12.25) with Microsoft SMTP Server id 15.1.2375.7 via Frontend Transport; Mon, 5 Dec 2022 16:53:59 +0800 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id 9A08563A6B; Mon, 5 Dec 2022 10:53:58 +0200 (IST) From: Tomer Maimon To: , , , , , , , , , , , , , , , CC: , , , , Tomer Maimon Subject: [PATCH v2 2/2] mmc: sdhci-npcm: Add NPCM SDHCI driver Date: Mon, 5 Dec 2022 10:53:51 +0200 Message-ID: <20221205085351.27566-3-tmaimon77@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20221205085351.27566-1-tmaimon77@gmail.com> References: <20221205085351.27566-1-tmaimon77@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,NML_ADSP_CUSTOM_MED,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751364213288095968?= X-GMAIL-MSGID: =?utf-8?q?1751364213288095968?= Add Nuvoton NPCM BMC sdhci-pltfm controller driver. Signed-off-by: Tomer Maimon Acked-by: Adrian Hunter --- drivers/mmc/host/Kconfig | 8 ++++ drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sdhci-npcm.c | 84 +++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 drivers/mmc/host/sdhci-npcm.c diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index fb1062a6394c..82ab6fc25dca 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -415,6 +415,14 @@ config MMC_SDHCI_MILBEAUT If unsure, say N. +config MMC_SDHCI_NPCM + tristate "Secure Digital Host Controller Interface support for NPCM" + depends on ARCH_NPCM || COMPILE_TEST + depends on MMC_SDHCI_PLTFM + help + This provides support for the SD/eMMC controller found in + NPCM BMC family SoCs. + config MMC_SDHCI_IPROC tristate "SDHCI support for the BCM2835 & iProc SD/MMC Controller" depends on ARCH_BCM2835 || ARCH_BCM_IPROC || ARCH_BRCMSTB || COMPILE_TEST diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index 4e4ceb32c4b4..a101f87a5f19 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile @@ -97,6 +97,7 @@ obj-$(CONFIG_MMC_SDHCI_MICROCHIP_PIC32) += sdhci-pic32.o obj-$(CONFIG_MMC_SDHCI_BRCMSTB) += sdhci-brcmstb.o obj-$(CONFIG_MMC_SDHCI_OMAP) += sdhci-omap.o obj-$(CONFIG_MMC_SDHCI_SPRD) += sdhci-sprd.o +obj-$(CONFIG_MMC_SDHCI_NPCM) += sdhci-npcm.o obj-$(CONFIG_MMC_CQHCI) += cqhci.o cqhci-y += cqhci-core.o cqhci-$(CONFIG_MMC_CRYPTO) += cqhci-crypto.o diff --git a/drivers/mmc/host/sdhci-npcm.c b/drivers/mmc/host/sdhci-npcm.c new file mode 100644 index 000000000000..beace15b6c00 --- /dev/null +++ b/drivers/mmc/host/sdhci-npcm.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * NPCM SDHC MMC host controller driver. + * + * Copyright (c) 2020 Nuvoton Technology corporation. + */ + +#include +#include +#include +#include +#include +#include + +#include "sdhci-pltfm.h" + +static const struct sdhci_pltfm_data npcm_sdhci_pdata = { + .quirks = SDHCI_QUIRK_DELAY_AFTER_POWER, + .quirks2 = SDHCI_QUIRK2_STOP_WITH_TC | + SDHCI_QUIRK2_NO_1_8_V, +}; + +static int npcm_sdhci_probe(struct platform_device *pdev) +{ + struct sdhci_pltfm_host *pltfm_host; + struct sdhci_host *host; + u32 caps; + int ret; + + host = sdhci_pltfm_init(pdev, &npcm_sdhci_pdata, 0); + if (IS_ERR(host)) + return PTR_ERR(host); + + pltfm_host = sdhci_priv(host); + + pltfm_host->clk = devm_clk_get_optional(&pdev->dev, NULL); + if (IS_ERR(pltfm_host->clk)) + return PTR_ERR(pltfm_host->clk); + + ret = clk_prepare_enable(pltfm_host->clk); + if (ret) + return ret; + + caps = sdhci_readl(host, SDHCI_CAPABILITIES); + if (caps & SDHCI_CAN_DO_8BIT) + host->mmc->caps |= MMC_CAP_8_BIT_DATA; + + ret = mmc_of_parse(host->mmc); + if (ret) + goto err_sdhci_add; + + ret = sdhci_add_host(host); + if (ret) + goto err_sdhci_add; + + return 0; + +err_sdhci_add: + clk_disable_unprepare(pltfm_host->clk); + sdhci_pltfm_free(pdev); + return ret; +} + +static const struct of_device_id npcm_sdhci_of_match[] = { + { .compatible = "nuvoton,npcm750-sdhci" }, + { .compatible = "nuvoton,npcm845-sdhci" }, + { } +}; +MODULE_DEVICE_TABLE(of, npcm_sdhci_of_match); + +static struct platform_driver npcm_sdhci_driver = { + .driver = { + .name = "npcm-sdhci", + .of_match_table = npcm_sdhci_of_match, + .pm = &sdhci_pltfm_pmops, + }, + .probe = npcm_sdhci_probe, + .remove = sdhci_pltfm_unregister, +}; +module_platform_driver(npcm_sdhci_driver); + +MODULE_DESCRIPTION("NPCM Secure Digital Host Controller Interface driver"); +MODULE_AUTHOR("Tomer Maimon "); +MODULE_LICENSE("GPL");