From patchwork Sat Feb 1 16:06:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mauro Condarelli X-Patchwork-Id: 11361197 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9FA8921 for ; Sat, 1 Feb 2020 16:06:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 910A5206E3 for ; Sat, 1 Feb 2020 16:06:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uo1PshDT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 910A5206E3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mclink.it Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Date:Message-ID:Subject: From:To:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=m4IpH3mWig94uT+qv+jsjNvanBhth8wJIrDM7QxcV+A=; b=uo1PshDToPU5yL 8PCSyQWOt3X4P5Hk5Axg2vNdkNm3qM+dA/+Uw7Ni7lj+YQ122t+ST0ZPgV7hEt+8uNy/8hvDewXX6 XTpnzteQjsYlMHjzEIwSHai6HfC1NaUcB0lXaR/OwUYfwFDmLzz/uZMm8O4s4VH9pRtcCcXgTLo48 8/OGJ1kK4UbvogCzxYv2iXycYZoKyGinE2NojpmLgI4wuqmEeH02ZopT8t2BpX2Rj6tOMzs2CB+Ec vfXX/9lnk7xTfYU8cGDPRXa0qfGmZYgg9MkB7nRJ6AbRNBRsdFzsNHTPbvkKpuWhRjOhpwA5qdjYv xKOuhEQAV+TJPtzXXftA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixvIB-0007tr-0q; Sat, 01 Feb 2020 16:06:43 +0000 Received: from relaygw4-1.mclink.it ([213.21.178.144]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixvI7-0007tJ-LL for linux-mediatek@lists.infradead.org; Sat, 01 Feb 2020 16:06:41 +0000 Received: from [172.24.30.42] (HELO smtpoutgw2.mclink.it) by relaygw4-1.mclink.it (CommuniGate Pro SMTP 6.0.6) with ESMTP id 167725209 for linux-mediatek@lists.infradead.org; Sat, 01 Feb 2020 17:06:22 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CGAgCfoDVe/6vbFVcNWB4BCxyKVZUMhgGBPZAMCQEBAQEBAQEBATcBAYcXOBMCEAEBBQEBAQEBBQSMQAQLAV8cAiYCbAgBAYMigleRCJsDdX8zhUqDQoE+gQ4qjHmBQYERJ4QuhBSCQ4JeBIE/AQEBrh8BBgKBY1qWOgYbmwilcoYagXqCXoFPTyWOKQwLjiSQEwEB Received: from host171-219-dynamic.21-87-r.retail.telecomitalia.it (HELO [192.168.7.101]) ([87.21.219.171]) by smtpoutgw2.mclink.it with ESMTP; 01 Feb 2020 17:06:08 +0100 To: linux-mediatek@lists.infradead.org From: Mauro Condarelli Subject: Enabling MMC on MT7628 SoC Message-ID: Date: Sat, 1 Feb 2020 17:06:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200201_080640_020859_6D3FF667 X-CRM114-Status: UNSURE ( 7.97 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Hi, I'm trying to enable MMC/SD access on a VoCore2 SOM (based on MT7628) using mtk_sd driver. Just enabling mtk_sd will bomb wit undefined function `clk_get_parent`; this can be trivially cured with:  } @@ -2211,6 +2215,7 @@ static int msdc_drv_probe(struct platform_device *pdev)      if (ret)          goto host_free;   +#ifdef CONFIG_COMMON_CLK      host->src_clk = devm_clk_get(&pdev->dev, "source");      if (IS_ERR(host->src_clk)) {          ret = PTR_ERR(host->src_clk); @@ -2230,6 +2235,12 @@ static int msdc_drv_probe(struct platform_device *pdev)      host->src_clk_cg = devm_clk_get(&pdev->dev, "source_cg");      if (IS_ERR(host->src_clk_cg))          host->src_clk_cg = NULL; +#else +    host->src_clk = NULL; +    host->h_clk = NULL; +    host->bus_clk = NULL; +    host->src_clk_cg = NULL; +#endif        host->irq = platform_get_irq(pdev, 0);      if (host->irq < 0) { ... but I'm unsure this hack-and-slash approach is the Right Thing to do ;) As said: this works for me, but I would like to fix it properly and have the fix sent upstream together with my SoM defconfig. Any hint welcome Regards Mauro Condarelli diff --git a/arch/mips/ralink/clk.c b/arch/mips/ralink/clk.c index 2f9d5acb38ea..930c2776f6fd 100644 --- a/arch/mips/ralink/clk.c +++ b/arch/mips/ralink/clk.c @@ -85,3 +85,9 @@ void __init plat_time_init(void)         clk_put(clk);         timer_probe();  } + +struct clk *clk_get_parent(struct clk *clk) +{ +       return NULL; +} +EXPORT_SYMBOL_GPL(clk_get_parent); Naive implementation fails runtime with ENOENT in devm_clk_get("10130000.mmc", "source") in spite of clock definition in .dts. I traced the problem to CONFIG_COMMON_CLK not being defined for RALINK. It cannot be enabled because it will lead to multiple definition of several clock-related functions (e.g.: `clk_get_rate`). I found completely disabling clock handling in mtk_sd.c leads to a (for me) fully working SD card. diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index 7726dcf48f2c..464f64bea7c6 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -730,18 +730,22 @@ static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks)    static void msdc_gate_clock(struct msdc_host *host)  { +#ifdef CONFIG_COMMON_CLK      clk_disable_unprepare(host->src_clk_cg);      clk_disable_unprepare(host->src_clk);      clk_disable_unprepare(host->bus_clk);      clk_disable_unprepare(host->h_clk); +#endif  }    static void msdc_ungate_clock(struct msdc_host *host)  { +#ifdef CONFIG_COMMON_CLK      clk_prepare_enable(host->h_clk);      clk_prepare_enable(host->bus_clk);      clk_prepare_enable(host->src_clk);      clk_prepare_enable(host->src_clk_cg); +#endif      while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB))          cpu_relax();