Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2537344rwb; Wed, 30 Nov 2022 07:48:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf7zTm2BH5MITEh+KUoilRp4lEIjgEFnIpdoMXw3GStns0j6XN+Ihd85FwuHrPjLJbTsI1eN X-Received: by 2002:a17:906:b108:b0:7b5:dd3e:69c1 with SMTP id u8-20020a170906b10800b007b5dd3e69c1mr36505902ejy.381.1669823328455; Wed, 30 Nov 2022 07:48:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669823328; cv=none; d=google.com; s=arc-20160816; b=Y1hEhUbzRE0/ETtw4wXpMkrR8mhLIrG5I5t4hy5IgFSmANwUyUlVhPCp7jjwjW07C4 hqrAa+/FOgKkl5qOT7wMDkDiGVca+HSKl2tb6KAHLAR/+d9GVyczfgjphzobw+SjC/Am 4BR1TcZ6VNfZp6MLqFb5X5Y5VGqz3kbvJXH7Gm4k3Jj9O1lr1nun8IieW690jdNorHo/ absOJAUFDqsTBKHkk0y9/gejN9O03M2k8ixJhn0X7Tv1UcnkvUMKN6TU3IGuf+TeSz+K nlZ4gydq4S+yvcIiMhSgbYkRDTAGEpUKwuN0ErOfyA1F9mLO6MF8xvokjmbu4Syh3Vek aRTQ== 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=jel2BESA/0cOcWPYB800W/WJC/2q+UbPQ+M19GtcKnM=; b=fk5UB9DSYvwYdT/EHoTiTqt2ifvjG808pwxAbyUHJWKLUYFLG6Ez+F5PuNOGepiWCB OflLTC1IRHw1/5eKyY23rgLqeiiu1FAOEQV5ne3+uORHDy4GPrSJHJgFEtBzIGjy/UZz oL1/BrpLuaJ7tNN3cLnC1jm+NzVlZeHRxpRugp9UpOoXrY+Nh6FtFxCFVv52IUfysjTO f17uL1TfmKtjOTFsR0/dR85KTAMq4+5wr570PKrIIhxna/40bu5WXiZIOAXn/qZg+fiN x4TS+HCzcoJH8lQSdLD6M6VkbkGXl0RSDa49Sh1NwZ1IWjWNHiMez3Gs9Abgt8l5fhMm HBJg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa40-20020a1709076d2800b00791a3dd01b6si1545019ejc.864.2022.11.30.07.48.26; Wed, 30 Nov 2022 07:48:48 -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 S229885AbiK3PTn (ORCPT + 83 others); Wed, 30 Nov 2022 10:19:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbiK3PTj (ORCPT ); Wed, 30 Nov 2022 10:19:39 -0500 Received: from maillog.nuvoton.com (maillog.nuvoton.com [202.39.227.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9EE3D7CA90; Wed, 30 Nov 2022 07:19:36 -0800 (PST) Received: from NTHCCAS04.nuvoton.com (NTHCCAS04.nuvoton.com [10.1.8.29]) by maillog.nuvoton.com (Postfix) with ESMTP id 053B41C812A6; Wed, 30 Nov 2022 23:09:02 +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; Wed, 30 Nov 2022 23:09:01 +0800 Received: from NTHCCAS01.nuvoton.com (10.1.8.28) by NTHCCAS02.nuvoton.com (10.1.9.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 30 Nov 2022 23:09:01 +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; Wed, 30 Nov 2022 23:09:01 +0800 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id 6A69763A6B; Wed, 30 Nov 2022 17:09:00 +0200 (IST) From: Tomer Maimon To: , , , , , , , , , , , , , , , CC: , , , , Tomer Maimon Subject: [PATCH v1 2/2] mmc: sdhci-npcm: Add NPCM SDHCI driver Date: Wed, 30 Nov 2022 17:08:57 +0200 Message-ID: <20221130150857.67113-3-tmaimon77@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20221130150857.67113-1-tmaimon77@gmail.com> References: <20221130150857.67113-1-tmaimon77@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=0.3 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 Add Nuvoton NPCM BMC sdhci-pltfm controller driver. Signed-off-by: Tomer Maimon --- drivers/mmc/host/Kconfig | 8 ++++ drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sdhci-npcm.c | 81 +++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 drivers/mmc/host/sdhci-npcm.c diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index fb1062a6394c..4b2d9ce4308c 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -709,6 +709,14 @@ config MMC_TMIO This provides support for the SD/MMC cell found in TC6393XB, T7L66XB and also HTC ASIC3 +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_SDHI tristate "Renesas SDHI SD/SDIO controller support" depends on SUPERH || ARCH_RENESAS || COMPILE_TEST diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index 4e4ceb32c4b4..801086613d7f 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_MMC_SPI) += of_mmc_spi.o obj-$(CONFIG_MMC_S3C) += s3cmci.o obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o +obj-$(CONFIG_MMC_SDHCI_NPCM) += sdhci-npcm.o obj-$(CONFIG_MMC_TMIO_CORE) += tmio_mmc_core.o obj-$(CONFIG_MMC_SDHI) += renesas_sdhi_core.o obj-$(CONFIG_MMC_SDHI_SYS_DMAC) += renesas_sdhi_sys_dmac.o diff --git a/drivers/mmc/host/sdhci-npcm.c b/drivers/mmc/host/sdhci-npcm.c new file mode 100644 index 000000000000..298c5f3e7c2b --- /dev/null +++ b/drivers/mmc/host/sdhci-npcm.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * NPCM SDHC MMC host controller driver. + * + */ + +#include +#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(&pdev->dev, NULL); + + if (!IS_ERR(pltfm_host->clk)) + clk_prepare_enable(pltfm_host->clk); + + 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 v2"); -- 2.33.0