From patchwork Wed Dec 2 18:51:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 11946835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98DCCC83013 for ; Wed, 2 Dec 2020 18:52:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FD2021D7F for ; Wed, 2 Dec 2020 18:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389663AbgLBSwm (ORCPT ); Wed, 2 Dec 2020 13:52:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387805AbgLBSwm (ORCPT ); Wed, 2 Dec 2020 13:52:42 -0500 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8C2DC0613D6 for ; Wed, 2 Dec 2020 10:51:55 -0800 (PST) Received: by mail-lj1-x244.google.com with SMTP id y7so5018112lji.8 for ; Wed, 02 Dec 2020 10:51:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iDSZ9LQfiI7RAcYP99dceWkwh9+x1mJX2TPk+zqGzss=; b=NMiwARSCvvUaEEPbp4WsfuZAT8L1Fmxn63F54s3S/pAuEDOdzOE7ndfhAHhVgXAAxw M6L/DG8ZR9ZRc1IuuBlNbYTEm+Gt0/eEvxAwlinf7sHlPJvlt4n0lV3KIK1M8PJsj5Aq LZOT1edihJPk8635E7OqSG0RDJOeAfXK2GZyZPIIXzS4PUKMEwbFLe/vMOsqE0Ee3ZAh TuxNVcM7m0PB3OH5O822frSRLwK82op1XtaZ8z4pc6AzE41H8FLhYQi23lQaWdycB3Qu 6oTLZjwLkyghaloSH3n3PmTULBP6LnVrqxSzk+gQWqZUXMtmPuInQ8k5Q3IAxg0V4x9q 97HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iDSZ9LQfiI7RAcYP99dceWkwh9+x1mJX2TPk+zqGzss=; b=TlZfB4AaBZ+PFossL9IRr2xUk2aPMVR1PxX4lOJvqHbmpOmcQAstV08OynXsZ6Mi4I k9U6uNLkfskFOemK9HGfV/0IARUfEDhbopfCU05sxCmrIoE/4TACLAlmgZITJ2fUuzwh o572NzXDcbMfJXNSdom+FqouJYwBxhkUbVDze3/NgVzzr4fu702qPFK2BCzND/lGdSIo qfFc9f18zl++P7NMgosDygAUlwJGaxepq68ODcpZa7ZHDMSZFLh0pH4eS+8WoJfbJBKL VxtzBqS7Z1C3lRCIMartBztf1ldkwFu1bAqC+StZjr8ko8u84TkrAd/wyC+62SBfosqx csww== X-Gm-Message-State: AOAM532jZeHzAfKZ/3P9gWv9hmmN/mZlBID7MkTFtBNAcife281aXDrQ KtNNhB8iafbioxcWhyBmAqF78A== X-Google-Smtp-Source: ABdhPJwT9WnyVczi4HuabClulH6LU7mz9RvmCawt8ItaFY5zzsrwHhXkWm7/ZrTZ8V24xprKazb+gw== X-Received: by 2002:a2e:924f:: with SMTP id v15mr1733918ljg.6.1606935114251; Wed, 02 Dec 2020 10:51:54 -0800 (PST) Received: from gilgamesh.semihalf.com (193-106-246-138.noc.fibertech.net.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id y134sm666365lff.162.2020.12.02.10.51.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Dec 2020 10:51:53 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, huziji@marvell.com, adrian.hunter@intel.com, jaz@semihalf.com, tn@semihalf.com, ard.biesheuvel@arm.com, kostap@marvell.com, Marcin Wojtas Subject: [PATCH v3 1/4] mmc: sdhci-xenon: use match data for controllers variants Date: Wed, 2 Dec 2020 19:51:15 +0100 Message-Id: <20201202185118.29076-2-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20201202185118.29076-1-mw@semihalf.com> References: <20201202185118.29076-1-mw@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org As a part of the ACPI support preparation resign from checking compatible strings in the driver. Instead of that use a new enum and assign the values to match data accordingly. Signed-off-by: Marcin Wojtas Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-xenon.h | 8 ++++++++ drivers/mmc/host/sdhci-xenon-phy.c | 4 +++- drivers/mmc/host/sdhci-xenon.c | 10 ++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-xenon.h b/drivers/mmc/host/sdhci-xenon.h index 593b82d7b68a..39e898605937 100644 --- a/drivers/mmc/host/sdhci-xenon.h +++ b/drivers/mmc/host/sdhci-xenon.h @@ -53,6 +53,13 @@ #define XENON_CTRL_HS200 0x5 #define XENON_CTRL_HS400 0x6 +enum xenon_variant { + XENON_A3700, + XENON_AP806, + XENON_AP807, + XENON_CP110 +}; + struct xenon_priv { unsigned char tuning_count; /* idx of SDHC */ @@ -90,6 +97,7 @@ struct xenon_priv { void *phy_params; struct xenon_emmc_phy_regs *emmc_phy_regs; bool restore_needed; + enum xenon_variant hw_version; }; int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios); diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c index 03ce57ef4585..c33e0cddc81a 100644 --- a/drivers/mmc/host/sdhci-xenon-phy.c +++ b/drivers/mmc/host/sdhci-xenon-phy.c @@ -651,11 +651,13 @@ static int get_dt_pad_ctrl_data(struct sdhci_host *host, struct device_node *np, struct xenon_emmc_phy_params *params) { + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host); int ret = 0; const char *name; struct resource iomem; - if (of_device_is_compatible(np, "marvell,armada-3700-sdhci")) + if (priv->hw_version == XENON_A3700) params->pad_ctrl.set_soc_pad = armada_3700_soc_pad_voltage_set; else return 0; diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c index 24c978de2a3f..1e7ce9b1a143 100644 --- a/drivers/mmc/host/sdhci-xenon.c +++ b/drivers/mmc/host/sdhci-xenon.c @@ -418,7 +418,7 @@ static int xenon_probe_dt(struct platform_device *pdev) u32 tuning_count; /* Disable HS200 on Armada AP806 */ - if (of_device_is_compatible(np, "marvell,armada-ap806-sdhci")) + if (priv->hw_version == XENON_AP806) host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200; sdhc_id = 0x0; @@ -495,6 +495,8 @@ static int xenon_probe(struct platform_device *pdev) pltfm_host = sdhci_priv(host); priv = sdhci_pltfm_priv(pltfm_host); + priv->hw_version = (unsigned long)device_get_match_data(&pdev->dev); + /* * Link Xenon specific mmc_host_ops function, * to replace standard ones in sdhci_ops. @@ -667,9 +669,9 @@ static const struct dev_pm_ops sdhci_xenon_dev_pm_ops = { }; static const struct of_device_id sdhci_xenon_dt_ids[] = { - { .compatible = "marvell,armada-ap806-sdhci",}, - { .compatible = "marvell,armada-cp110-sdhci",}, - { .compatible = "marvell,armada-3700-sdhci",}, + { .compatible = "marvell,armada-ap806-sdhci", .data = (void *)XENON_AP806}, + { .compatible = "marvell,armada-cp110-sdhci", .data = (void *)XENON_CP110}, + { .compatible = "marvell,armada-3700-sdhci", .data = (void *)XENON_A3700}, {} }; MODULE_DEVICE_TABLE(of, sdhci_xenon_dt_ids); From patchwork Wed Dec 2 18:51:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 11946837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0048C71155 for ; Wed, 2 Dec 2020 18:53:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5985D2224C for ; Wed, 2 Dec 2020 18:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389693AbgLBSxV (ORCPT ); Wed, 2 Dec 2020 13:53:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389692AbgLBSxV (ORCPT ); Wed, 2 Dec 2020 13:53:21 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B27ACC061A04 for ; Wed, 2 Dec 2020 10:51:58 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id y7so5018262lji.8 for ; Wed, 02 Dec 2020 10:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6ncZs/IR7JzQOVuo0XqrIE/a8XPUbc5Auv1rUmXVoLg=; b=xot8FCJhv3RJLa6AUca7FBS43ywiX5KOdnwc9A7eJL5BjXsOdqW3CCj8QqOz7XxCRU NzYZpdNZ92xhMqTDN1wVz1B4Hskn0Nbil2th3hvF6BFQ+mNjL7bT5Mmv6chA+6Xttn7B S7uPt0H9e7ohhFS3rF/x3PC/6ndLMhxUYTz55Fg9WNGx61qC2mUhWqDloQ6RH+nuibbY elnkfpXeeyECEkdiIWPU2gzULirMPgfXKCouJvlZVzAU76c2SJkMA9ed5Z0xVuVGXAIN 1dc7oit5gebUG3+BelisxJXI8+zDT9cA9DQqCL5sSLixTF+YVI94sWvow/I2PSpQftBu itqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6ncZs/IR7JzQOVuo0XqrIE/a8XPUbc5Auv1rUmXVoLg=; b=ZP1Ea8dTmcMDLrVEEfqZ3+61bqkfyGE5WO2X0SUjxUQN6PyJifCo2lqIdORXTmIY4R 8rWOTUTEIAWzok6oFdTzxakEEccZs5/YkR79bmoQ7H2lD2TD7P4hitpeBq8kI1ilvkYf lAAtB+TF7PEEVzpiu7RVyQGKxi0Cfl5URT3aGuN29DZPb1shzIkzSV4QPTpzVBTgsnbo h5feu6z9AuR1HwzZAdDn6HIFKsL6kay3Bt57LtUuK7c1KeY1oEeD2hthpocAFfI7tGac h+3xzvq7wONB/WieuHGWOqmf0q4ROOZ00B40l+2PbhoydJOSth2TLHw6SOd9U9PmapA4 WR3A== X-Gm-Message-State: AOAM532N5aBNOL2uixibSsX/v43dtwAg5SY2X9xZgjf7hwjcbN/ciXv/ 0WdjRRSNk53HgmlbywLcPCxqlg== X-Google-Smtp-Source: ABdhPJz8POjApU56ougDzxWT091tFN1fD00wHSYKgD5GcXZ32TU98BtlBM+MgyrKVNl2A3zlukP99Q== X-Received: by 2002:a2e:a547:: with SMTP id e7mr1683201ljn.108.1606935115603; Wed, 02 Dec 2020 10:51:55 -0800 (PST) Received: from gilgamesh.semihalf.com (193-106-246-138.noc.fibertech.net.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id y134sm666365lff.162.2020.12.02.10.51.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Dec 2020 10:51:54 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, huziji@marvell.com, adrian.hunter@intel.com, jaz@semihalf.com, tn@semihalf.com, ard.biesheuvel@arm.com, kostap@marvell.com, Marcin Wojtas Subject: [PATCH v3 2/4] mmc: sdhci-xenon: switch to device_* API Date: Wed, 2 Dec 2020 19:51:16 +0100 Message-Id: <20201202185118.29076-3-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20201202185118.29076-1-mw@semihalf.com> References: <20201202185118.29076-1-mw@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org In order to support both ACPI and DT, modify the driver to use device_* routines for obtaining the properties values. Signed-off-by: Marcin Wojtas Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-xenon.h | 4 +-- drivers/mmc/host/sdhci-xenon-phy.c | 36 +++++++++++--------- drivers/mmc/host/sdhci-xenon.c | 18 +++++----- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/drivers/mmc/host/sdhci-xenon.h b/drivers/mmc/host/sdhci-xenon.h index 39e898605937..3e9c6c908a79 100644 --- a/drivers/mmc/host/sdhci-xenon.h +++ b/drivers/mmc/host/sdhci-xenon.h @@ -101,8 +101,8 @@ struct xenon_priv { }; int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios); -int xenon_phy_parse_dt(struct device_node *np, - struct sdhci_host *host); +int xenon_phy_parse_params(struct device *dev, + struct sdhci_host *host); void xenon_soc_pad_ctrl(struct sdhci_host *host, unsigned char signal_voltage); #endif diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c index c33e0cddc81a..8cf3a375de65 100644 --- a/drivers/mmc/host/sdhci-xenon-phy.c +++ b/drivers/mmc/host/sdhci-xenon-phy.c @@ -691,35 +691,37 @@ static int get_dt_pad_ctrl_data(struct sdhci_host *host, return ret; } -static int xenon_emmc_phy_parse_param_dt(struct sdhci_host *host, - struct device_node *np, - struct xenon_emmc_phy_params *params) +static int xenon_emmc_phy_parse_params(struct sdhci_host *host, + struct device *dev, + struct xenon_emmc_phy_params *params) { u32 value; params->slow_mode = false; - if (of_property_read_bool(np, "marvell,xenon-phy-slow-mode")) + if (device_property_read_bool(dev, "marvell,xenon-phy-slow-mode")) params->slow_mode = true; params->znr = XENON_ZNR_DEF_VALUE; - if (!of_property_read_u32(np, "marvell,xenon-phy-znr", &value)) + if (!device_property_read_u32(dev, "marvell,xenon-phy-znr", &value)) params->znr = value & XENON_ZNR_MASK; params->zpr = XENON_ZPR_DEF_VALUE; - if (!of_property_read_u32(np, "marvell,xenon-phy-zpr", &value)) + if (!device_property_read_u32(dev, "marvell,xenon-phy-zpr", &value)) params->zpr = value & XENON_ZPR_MASK; params->nr_tun_times = XENON_TUN_CONSECUTIVE_TIMES; - if (!of_property_read_u32(np, "marvell,xenon-phy-nr-success-tun", - &value)) + if (!device_property_read_u32(dev, "marvell,xenon-phy-nr-success-tun", + &value)) params->nr_tun_times = value & XENON_TUN_CONSECUTIVE_TIMES_MASK; params->tun_step_divider = XENON_TUNING_STEP_DIVIDER; - if (!of_property_read_u32(np, "marvell,xenon-phy-tun-step-divider", - &value)) + if (!device_property_read_u32(dev, "marvell,xenon-phy-tun-step-divider", + &value)) params->tun_step_divider = value & 0xFF; - return get_dt_pad_ctrl_data(host, np, params); + if (dev->of_node) + return get_dt_pad_ctrl_data(host, dev->of_node, params); + return 0; } /* Set SoC PHY Voltage PAD */ @@ -813,7 +815,7 @@ int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios) return ret; } -static int xenon_add_phy(struct device_node *np, struct sdhci_host *host, +static int xenon_add_phy(struct device *dev, struct sdhci_host *host, const char *phy_name) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -832,15 +834,15 @@ static int xenon_add_phy(struct device_node *np, struct sdhci_host *host, if (ret) return ret; - return xenon_emmc_phy_parse_param_dt(host, np, priv->phy_params); + return xenon_emmc_phy_parse_params(host, dev, priv->phy_params); } -int xenon_phy_parse_dt(struct device_node *np, struct sdhci_host *host) +int xenon_phy_parse_params(struct device *dev, struct sdhci_host *host) { const char *phy_type = NULL; - if (!of_property_read_string(np, "marvell,xenon-phy-type", &phy_type)) - return xenon_add_phy(np, host, phy_type); + if (!device_property_read_string(dev, "marvell,xenon-phy-type", &phy_type)) + return xenon_add_phy(dev, host, phy_type); - return xenon_add_phy(np, host, "emmc 5.1 phy"); + return xenon_add_phy(dev, host, "emmc 5.1 phy"); } diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c index 1e7ce9b1a143..bfc76b0e3eaa 100644 --- a/drivers/mmc/host/sdhci-xenon.c +++ b/drivers/mmc/host/sdhci-xenon.c @@ -407,9 +407,9 @@ static void xenon_replace_mmc_host_ops(struct sdhci_host *host) * Refer to XENON_SYS_CFG_INFO register * tun-count: the interval between re-tuning */ -static int xenon_probe_dt(struct platform_device *pdev) +static int xenon_probe_params(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; struct sdhci_host *host = platform_get_drvdata(pdev); struct mmc_host *mmc = host->mmc; struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -422,7 +422,7 @@ static int xenon_probe_dt(struct platform_device *pdev) host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200; sdhc_id = 0x0; - if (!of_property_read_u32(np, "marvell,xenon-sdhc-id", &sdhc_id)) { + if (!device_property_read_u32(dev, "marvell,xenon-sdhc-id", &sdhc_id)) { nr_sdhc = sdhci_readl(host, XENON_SYS_CFG_INFO); nr_sdhc &= XENON_NR_SUPPORTED_SLOT_MASK; if (unlikely(sdhc_id > nr_sdhc)) { @@ -434,8 +434,8 @@ static int xenon_probe_dt(struct platform_device *pdev) priv->sdhc_id = sdhc_id; tuning_count = XENON_DEF_TUNING_COUNT; - if (!of_property_read_u32(np, "marvell,xenon-tun-count", - &tuning_count)) { + if (!device_property_read_u32(dev, "marvell,xenon-tun-count", + &tuning_count)) { if (unlikely(tuning_count >= XENON_TMR_RETUN_NO_PRESENT)) { dev_err(mmc_dev(mmc), "Wrong Re-tuning Count. Set default value %d\n", XENON_DEF_TUNING_COUNT); @@ -444,7 +444,7 @@ static int xenon_probe_dt(struct platform_device *pdev) } priv->tuning_count = tuning_count; - return xenon_phy_parse_dt(np, host); + return xenon_phy_parse_params(dev, host); } static int xenon_sdhc_prepare(struct sdhci_host *host) @@ -528,12 +528,12 @@ static int xenon_probe(struct platform_device *pdev) if (err) goto err_clk_axi; - sdhci_get_of_property(pdev); + sdhci_get_property(pdev); xenon_set_acg(host, false); - /* Xenon specific dt parse */ - err = xenon_probe_dt(pdev); + /* Xenon specific parameters parse */ + err = xenon_probe_params(pdev); if (err) goto err_clk_axi; From patchwork Wed Dec 2 18:51:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 11946831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54531C8300F for ; Wed, 2 Dec 2020 18:52:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0002022240 for ; Wed, 2 Dec 2020 18:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389625AbgLBSwj (ORCPT ); Wed, 2 Dec 2020 13:52:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387805AbgLBSwj (ORCPT ); Wed, 2 Dec 2020 13:52:39 -0500 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 932A8C0617A7 for ; Wed, 2 Dec 2020 10:51:58 -0800 (PST) Received: by mail-lj1-x244.google.com with SMTP id f24so4968716ljk.13 for ; Wed, 02 Dec 2020 10:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F3xpXE/TuWKwCPEX3+RhalyC0nSYPCE9cK2LWGjqF2g=; b=cBV3lrSqHEhVTmOGmrlqL74YWk850oy735IjRpqT1NU37bWz/pJRqBmLbyj27tO9kd 1ICwPRyEijphFXkHOSeHrBCxa0J6S43XWDmn0aRvMfA73s0uR1cFyez+gnkpNFBqNk9S PbtFBAW6k+5Iw8K/myRNMoJyHM7bEY4E5gMRcO9mniKJDfr3Kip7pB/r/mrBCKi7jsYu +OoS2uYmvXxSg4+OuKAoQI+PIlTBo7o+4BUtPhFMiEOU4NwUxvBWLOiRYGO65XC69zDR k+shQAiSrLZl4oEyN5XrBO5VIUtzPmQvnNR4H5wKDMoiCWSn2EzoFhvLjAvF5Rn9W8cB PrQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F3xpXE/TuWKwCPEX3+RhalyC0nSYPCE9cK2LWGjqF2g=; b=RCzTLGSZzuLSpcTvGGJUC1+CESrJdJVkHyxe9E2DzSTXEa232nSCQEIIW65lU30v5t eezaltBoAdDIi5jBU4VeuPAs7xPbsSS6OuphnPA/ZvjC/3ewiotjsTWX3j8H0x37Lpxg ziO8Dh2/sDJGloLqqWxJe4Z8asgT6XqNrXjb1ccK22WBOfH9DreCuErqTf2FwXhQULXT 0T8ZPhOjBuFv3Vrm/j9oyiyl2EN/cq1yEJapxpTB9o6AZt0L8EBlep7KBZ6pZJUShlsw vY6qb/1Maj1K9+MP953DUAzjovWIVgXrRTpz0KyCAUH3EDZOTVc2Gjg6ooKW04GH3Obg Gk0g== X-Gm-Message-State: AOAM533zweVWGP0MdqQsQUNQnkd+rnzi14WTEMmavjJFw8sl/8ZAVvMq 6wMNlOcHeA3LWYaqbmwKfiL0MoUYAu/002mb X-Google-Smtp-Source: ABdhPJxXHJbBix9Ht7T9XduoA4gE/Nv2ipqExZmdTQD3nsNX98FAKtb1y61hePLw2yUephUORUn58g== X-Received: by 2002:a2e:9550:: with SMTP id t16mr1763793ljh.117.1606935117035; Wed, 02 Dec 2020 10:51:57 -0800 (PST) Received: from gilgamesh.semihalf.com (193-106-246-138.noc.fibertech.net.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id y134sm666365lff.162.2020.12.02.10.51.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Dec 2020 10:51:56 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, huziji@marvell.com, adrian.hunter@intel.com, jaz@semihalf.com, tn@semihalf.com, ard.biesheuvel@arm.com, kostap@marvell.com, Marcin Wojtas Subject: [PATCH v3 3/4] mmc: sdhci-xenon: use clk only with DT Date: Wed, 2 Dec 2020 19:51:17 +0100 Message-Id: <20201202185118.29076-4-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20201202185118.29076-1-mw@semihalf.com> References: <20201202185118.29076-1-mw@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org As a preparation for supporting ACPI, modify the driver to use the clk framework only when booting with DT - otherwise rely on the configuration done by firmware. For that purpose introduce also a custom SDHCI get_max_clock callback. Signed-off-by: Marcin Wojtas Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-xenon.c | 61 ++++++++++++-------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c index bfc76b0e3eaa..cc0fcc646b0e 100644 --- a/drivers/mmc/host/sdhci-xenon.c +++ b/drivers/mmc/host/sdhci-xenon.c @@ -247,6 +247,16 @@ static void xenon_voltage_switch(struct sdhci_host *host) sdhci_readw(host, SDHCI_HOST_CONTROL2); } +static unsigned int xenon_get_max_clock(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + + if (pltfm_host->clk) + return sdhci_pltfm_clk_get_max_clock(host); + else + return pltfm_host->clock; +} + static const struct sdhci_ops sdhci_xenon_ops = { .voltage_switch = xenon_voltage_switch, .set_clock = sdhci_set_clock, @@ -254,7 +264,7 @@ static const struct sdhci_ops sdhci_xenon_ops = { .set_bus_width = sdhci_set_bus_width, .reset = xenon_reset, .set_uhs_signaling = xenon_set_uhs_signaling, - .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .get_max_clock = xenon_get_max_clock, }; static const struct sdhci_pltfm_data sdhci_xenon_pdata = { @@ -483,6 +493,7 @@ static void xenon_sdhc_unprepare(struct sdhci_host *host) static int xenon_probe(struct platform_device *pdev) { struct sdhci_pltfm_host *pltfm_host; + struct device *dev = &pdev->dev; struct sdhci_host *host; struct xenon_priv *priv; int err; @@ -503,25 +514,27 @@ static int xenon_probe(struct platform_device *pdev) */ xenon_replace_mmc_host_ops(host); - pltfm_host->clk = devm_clk_get(&pdev->dev, "core"); - if (IS_ERR(pltfm_host->clk)) { - err = PTR_ERR(pltfm_host->clk); - dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err); - goto free_pltfm; - } - err = clk_prepare_enable(pltfm_host->clk); - if (err) - goto free_pltfm; - - priv->axi_clk = devm_clk_get(&pdev->dev, "axi"); - if (IS_ERR(priv->axi_clk)) { - err = PTR_ERR(priv->axi_clk); - if (err == -EPROBE_DEFER) - goto err_clk; - } else { - err = clk_prepare_enable(priv->axi_clk); + if (dev->of_node) { + pltfm_host->clk = devm_clk_get(&pdev->dev, "core"); + if (IS_ERR(pltfm_host->clk)) { + err = PTR_ERR(pltfm_host->clk); + dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err); + goto free_pltfm; + } + err = clk_prepare_enable(pltfm_host->clk); if (err) - goto err_clk; + goto free_pltfm; + + priv->axi_clk = devm_clk_get(&pdev->dev, "axi"); + if (IS_ERR(priv->axi_clk)) { + err = PTR_ERR(priv->axi_clk); + if (err == -EPROBE_DEFER) + goto err_clk; + } else { + err = clk_prepare_enable(priv->axi_clk); + if (err) + goto err_clk; + } } err = mmc_of_parse(host->mmc); @@ -637,10 +650,12 @@ static int xenon_runtime_resume(struct device *dev) struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host); int ret; - ret = clk_prepare_enable(pltfm_host->clk); - if (ret) { - dev_err(dev, "can't enable mainck\n"); - return ret; + if (dev->of_node) { + ret = clk_prepare_enable(pltfm_host->clk); + if (ret) { + dev_err(dev, "can't enable mainck\n"); + return ret; + } } if (priv->restore_needed) { From patchwork Wed Dec 2 18:51:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 11946839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A80FC8300F for ; Wed, 2 Dec 2020 18:53:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDEA922249 for ; Wed, 2 Dec 2020 18:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389696AbgLBSxX (ORCPT ); Wed, 2 Dec 2020 13:53:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389691AbgLBSxW (ORCPT ); Wed, 2 Dec 2020 13:53:22 -0500 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6009C061A49 for ; Wed, 2 Dec 2020 10:51:59 -0800 (PST) Received: by mail-lj1-x241.google.com with SMTP id f24so4968814ljk.13 for ; Wed, 02 Dec 2020 10:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1NuGhfuvRRKOKlvmGuyTpm1ODDVJaYuPLibVtVX+cAw=; b=JUgL2AM6DmI2EpgyTDkl59NOl0Zr+9aN1RxFubkrpYhknsvjEYvZCwKqEOsQftX4q7 nmnFYojGFKsYxdrodt/Zb4BpwK7lwoOclnG8M1DQC1CkFgtL93rPY2anhgGKfgTbRmmq z6kDtn5T1mde7VX4pwC6XZJ1NilHmzFTr83/nKMeuQAAJihOH/cfTVmKzQCzKQcnYMiM A6y1piNZ3IGCJCc1fDBNskSfLToGTxnk5WiFpiAtY+9rIgDS3AwHnplFmHtBOauJ90AJ S5fru9lcUMWcXuabSNdWRm6cdbjSYFeQvzi4JEhwzniTgosrgk4K6L3xlc0V/4++Du9Y AouQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1NuGhfuvRRKOKlvmGuyTpm1ODDVJaYuPLibVtVX+cAw=; b=cCNEcq9XQtw6SX78bnB52Jpkv3WvZOH257x8QM/nYjrXdTX5GZmk5pp0q8JMuH1pZo p/9oSO8z+HAE0nbj5wSG6c30jH5LGh0802nQwTsF8WZ+lLJYQFvIpNY3ard+/oiuYNca ctwC7c+w+7+FXVehxohEw3H2PjTpFBWWz0pX7d5Z5QCjThGXGYTramDiy3jxRVB/AJ2i xcgLKcX+qrffMaMoPieBpSjPw4U+Ja89AM2HCphbtN2sfUwX56RKViWUNodOCV55dGpg UnbAA0DhbN4IAu+rLTQMfeDaHHwHNMPRxI9S2EFwQA/F1EL1OEGkIrwqZQ2wdpJFn1DD 07kQ== X-Gm-Message-State: AOAM530FhPrkmzufVaBmtFrRiEB2ZrKCSplIlmYAa4EH5A7QmnxX3+eE P82A2mqkNTHRF4+pkE9sVv33kw== X-Google-Smtp-Source: ABdhPJwrRiEy0fs8Q+QwaCDiefxGize4mIrq4/m6zVpn0hSKS++joUOI79kdZW7mNZmx/jH40RwS+A== X-Received: by 2002:a05:651c:1121:: with SMTP id e1mr1761753ljo.227.1606935118392; Wed, 02 Dec 2020 10:51:58 -0800 (PST) Received: from gilgamesh.semihalf.com (193-106-246-138.noc.fibertech.net.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id y134sm666365lff.162.2020.12.02.10.51.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Dec 2020 10:51:57 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, huziji@marvell.com, adrian.hunter@intel.com, jaz@semihalf.com, tn@semihalf.com, ard.biesheuvel@arm.com, kostap@marvell.com, Marcin Wojtas Subject: [PATCH v3 4/4] mmc: sdhci-xenon: introduce ACPI support Date: Wed, 2 Dec 2020 19:51:18 +0100 Message-Id: <20201202185118.29076-5-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20201202185118.29076-1-mw@semihalf.com> References: <20201202185118.29076-1-mw@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Previous patches dropped the strict dependency on the OF_* in the sdhci-xenon driver. As a result the ACPI support can be introduced (except for the XENON_A3700 variant) by adding the necessary ID's in the acpi_match_table. Signed-off-by: Marcin Wojtas Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-xenon.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c index cc0fcc646b0e..395f7c3064ce 100644 --- a/drivers/mmc/host/sdhci-xenon.c +++ b/drivers/mmc/host/sdhci-xenon.c @@ -11,6 +11,7 @@ * Special thanks to Video BG4 project team. */ +#include #include #include #include @@ -691,11 +692,22 @@ static const struct of_device_id sdhci_xenon_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, sdhci_xenon_dt_ids); +#ifdef CONFIG_ACPI +static const struct acpi_device_id sdhci_xenon_acpi_ids[] = { + { .id = "MRVL0002", XENON_AP806}, + { .id = "MRVL0003", XENON_AP807}, + { .id = "MRVL0004", XENON_CP110}, + {} +}; +MODULE_DEVICE_TABLE(acpi, sdhci_xenon_acpi_ids); +#endif + static struct platform_driver sdhci_xenon_driver = { .driver = { .name = "xenon-sdhci", .probe_type = PROBE_PREFER_ASYNCHRONOUS, .of_match_table = sdhci_xenon_dt_ids, + .acpi_match_table = ACPI_PTR(sdhci_xenon_acpi_ids), .pm = &sdhci_xenon_dev_pm_ops, }, .probe = xenon_probe,