Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp459325imm; Fri, 3 Aug 2018 06:20:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdg5ZM6wLTJmIIw7p22Yy3fivPWcOBnVc25qlj3wfshG0h+aVmMHvKqOEyweQYvViLjVqGt X-Received: by 2002:a63:cd02:: with SMTP id i2-v6mr3700740pgg.93.1533302423074; Fri, 03 Aug 2018 06:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533302423; cv=none; d=google.com; s=arc-20160816; b=bSAiXOh4QAeUbB5YEQpNx9VIwob4/nf5LlZp1Va0g/hcfqhuw7MbQQLW/WhwYypblV wa6jlfs61Nxq0pVSCa/Z+u/uP4zDBIkvl44U+8wnJ/9tGu7qPmA3zsObBHUfgULrHYCj WtVekcKwWbunpvsCmEPtzz6vuhV7HkLEWFHdooux9r+STxOEYwE/oksmLBhf3gEuu8ZW moeseQUZ57LmBTmGFakoCmuvGzL3ozReWoSje8YzcVKl0o3GAxyvjM5pDHYq3B+QXfio YBuHhRsTkGImnDkmk0I3gqKyPD+VPYjxYAVv6BkYwz4+7r/KoG3b1PnB+1SLkCQew5/k DIbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=E8E+sLevJaIdmKYEw0TgigVuaC2QYUWOMocjABAeCOM=; b=fAfZjLLEV4UVIU+Ilo8TYpwNsMi9O0shpSto8rQ8q4OZiCMeNfSH9dFgKSugrurRxV WWS+Bevl+zNCtXaXU0o3UKDrA1+Ao6xSGCEIeI2bf/j8TSblF8AuGt7eUSW3QqqjnK6t juQDp1/i8CyFsytJs+37xQ55lMg9lz2HSrOzGtuoHMz2Qra9Nsurr76Vc0o1IqaJ1tgL G4BAZOjDQZ1cdETNzRvoHh06u2uweJ4gkhTpq7JCPntcn0STYlr8ss2OBrJ6YAttSgHr Kf9Pxr9HUvFQVqoxfJlDjxNjCFC2K1Gg6cvAb6XO75FPbszKyJ6z01NyiYEXynE9MeaM d8Dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si4366734pld.84.2018.08.03.06.20.08; Fri, 03 Aug 2018 06:20:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732155AbeHCPPF (ORCPT + 99 others); Fri, 3 Aug 2018 11:15:05 -0400 Received: from mga12.intel.com ([192.55.52.136]:25780 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730601AbeHCPPE (ORCPT ); Fri, 3 Aug 2018 11:15:04 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Aug 2018 06:18:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,438,1526367600"; d="scan'208";a="77068923" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.153]) ([10.237.72.153]) by fmsmga004.fm.intel.com with ESMTP; 03 Aug 2018 06:18:44 -0700 Subject: Re: [PATCH v3 2/2] mmc: host: iproc: Add ACPI support to IPROC SDHCI To: Srinath Mannam , Ulf Hansson , Ray Jui , Scott Branden , vikram.prakash@broadcom.com Cc: bcm-kernel-feedback-list@broadcom.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org References: <1532931343-9499-1-git-send-email-srinath.mannam@broadcom.com> <1532931343-9499-3-git-send-email-srinath.mannam@broadcom.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <7a67a1f9-9cd1-103e-cfa1-e032f346e164@intel.com> Date: Fri, 3 Aug 2018 16:17:03 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1532931343-9499-3-git-send-email-srinath.mannam@broadcom.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/07/18 09:15, Srinath Mannam wrote: > Add ACPI support to all IPROC SDHCI varients > > Signed-off-by: Srinath Mannam > Reviewed-by: Ray Jui > Reviewed-by: Scott Branden > Reviewed-by: Vladimir Olovyannikov One minor comment below, otherwise: Acked-by: Adrian Hunter > --- > drivers/mmc/host/Kconfig | 1 + > drivers/mmc/host/sdhci-iproc.c | 63 +++++++++++++++++++++++++++++------------- > 2 files changed, 45 insertions(+), 19 deletions(-) > > diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig > index 0581c19..bc6702e 100644 > --- a/drivers/mmc/host/Kconfig > +++ b/drivers/mmc/host/Kconfig > @@ -334,6 +334,7 @@ config MMC_SDHCI_IPROC > tristate "SDHCI support for the BCM2835 & iProc SD/MMC Controller" > depends on ARCH_BCM2835 || ARCH_BCM_IPROC || COMPILE_TEST > depends on MMC_SDHCI_PLTFM > + depends on OF || ACPI > default ARCH_BCM_IPROC > select MMC_SDHCI_IO_ACCESSORS > help > diff --git a/drivers/mmc/host/sdhci-iproc.c b/drivers/mmc/host/sdhci-iproc.c > index d0e83db..abf5269 100644 > --- a/drivers/mmc/host/sdhci-iproc.c > +++ b/drivers/mmc/host/sdhci-iproc.c > @@ -15,6 +15,7 @@ > * iProc SDHCI platform driver > */ > > +#include > #include > #include > #include > @@ -162,9 +163,19 @@ static void sdhci_iproc_writeb(struct sdhci_host *host, u8 val, int reg) > sdhci_iproc_writel(host, newval, reg & ~3); > } > > +static unsigned int sdhci_iproc_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_iproc_ops = { > .set_clock = sdhci_set_clock, > - .get_max_clock = sdhci_pltfm_clk_get_max_clock, > + .get_max_clock = sdhci_iproc_get_max_clock, > .set_bus_width = sdhci_set_bus_width, > .reset = sdhci_reset, > .set_uhs_signaling = sdhci_set_uhs_signaling, > @@ -178,7 +189,7 @@ static const struct sdhci_ops sdhci_iproc_32only_ops = { > .write_w = sdhci_iproc_writew, > .write_b = sdhci_iproc_writeb, > .set_clock = sdhci_set_clock, > - .get_max_clock = sdhci_pltfm_clk_get_max_clock, > + .get_max_clock = sdhci_iproc_get_max_clock, > .set_bus_width = sdhci_set_bus_width, > .reset = sdhci_reset, > .set_uhs_signaling = sdhci_set_uhs_signaling, > @@ -256,19 +267,29 @@ static const struct of_device_id sdhci_iproc_of_match[] = { > }; > MODULE_DEVICE_TABLE(of, sdhci_iproc_of_match); > > +static const struct acpi_device_id sdhci_iproc_acpi_ids[] = { > + { .id = "BRCM5871", .driver_data = (kernel_ulong_t)&iproc_cygnus_data }, > + { .id = "BRCM5872", .driver_data = (kernel_ulong_t)&iproc_data }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(acpi, sdhci_iproc_acpi_ids); > + > static int sdhci_iproc_probe(struct platform_device *pdev) > { > - const struct of_device_id *match; > - const struct sdhci_iproc_data *iproc_data; > + struct device *dev = &pdev->dev; > + const struct sdhci_iproc_data *iproc_data = NULL; > struct sdhci_host *host; > struct sdhci_iproc_host *iproc_host; > struct sdhci_pltfm_host *pltfm_host; > int ret; > > - match = of_match_device(sdhci_iproc_of_match, &pdev->dev); > - if (!match) > - return -EINVAL; > - iproc_data = match->data; > + if (dev->of_node) > + iproc_data = of_device_get_match_data(dev); > + else if (has_acpi_companion(dev)) > + iproc_data = acpi_device_get_match_data(dev); Can you use device_get_match_data() here > + > + if (!iproc_data) > + return -ENODEV; > > host = sdhci_pltfm_init(pdev, iproc_data->pdata, sizeof(*iproc_host)); > if (IS_ERR(host)) > @@ -280,19 +301,21 @@ static int sdhci_iproc_probe(struct platform_device *pdev) > iproc_host->data = iproc_data; > > mmc_of_parse(host->mmc); > - sdhci_get_of_property(pdev); > + sdhci_get_property(pdev); > > host->mmc->caps |= iproc_host->data->mmc_caps; > > - pltfm_host->clk = devm_clk_get(&pdev->dev, NULL); > - if (IS_ERR(pltfm_host->clk)) { > - ret = PTR_ERR(pltfm_host->clk); > - goto err; > - } > - ret = clk_prepare_enable(pltfm_host->clk); > - if (ret) { > - dev_err(&pdev->dev, "failed to enable host clk\n"); > - goto err; > + if (dev->of_node) { > + pltfm_host->clk = devm_clk_get(dev, NULL); > + if (IS_ERR(pltfm_host->clk)) { > + ret = PTR_ERR(pltfm_host->clk); > + goto err; > + } > + ret = clk_prepare_enable(pltfm_host->clk); > + if (ret) { > + dev_err(dev, "failed to enable host clk\n"); > + goto err; > + } > } > > if (iproc_host->data->pdata->quirks & SDHCI_QUIRK_MISSING_CAPS) { > @@ -307,7 +330,8 @@ static int sdhci_iproc_probe(struct platform_device *pdev) > return 0; > > err_clk: > - clk_disable_unprepare(pltfm_host->clk); > + if (dev->of_node) > + clk_disable_unprepare(pltfm_host->clk); > err: > sdhci_pltfm_free(pdev); > return ret; > @@ -317,6 +341,7 @@ static struct platform_driver sdhci_iproc_driver = { > .driver = { > .name = "sdhci-iproc", > .of_match_table = sdhci_iproc_of_match, > + .acpi_match_table = ACPI_PTR(sdhci_iproc_acpi_ids), > .pm = &sdhci_pltfm_pmops, > }, > .probe = sdhci_iproc_probe, >