Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp870074imm; Fri, 27 Jul 2018 07:32:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpexHc1VRK54JeurwsOOjyo6D33mSuEL9jdvqcIkZVOrAg4+l2rQdeJaNxVB1VwPw5ntQl7/ X-Received: by 2002:a63:fd52:: with SMTP id m18-v6mr1623215pgj.304.1532701965194; Fri, 27 Jul 2018 07:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532701965; cv=none; d=google.com; s=arc-20160816; b=gzC+AXDq8cZe0GUQa9v6ODrZOX9T0i9EQvFbiV54/MHUGCwTboL1+22vLtfIM4Zv2K 7Raat53piYD0yO3a/NqyDUNdUmqX69bo9qmmuExTf1gV5Z3dMuDKOFqn0i9N8bKf7iR5 u7alf3Sxkt9yGwVVNVKBpiqWLjxm+rJoBRgVPxQEbWLQ0fyEfVUA4EkuLbsWvuv40/lX 1FYidKBjwewrRzVzAPkJvs/wV8uLfw/L0Wagyzyh5z5fhar9fJLl3Oj29qab54E6MXQq Id1YWK+jMx5Kv1++EoHRgZ7x7QTj2+a2egmeQNtDy/M2HzlELQupnNSrwR+WgsvpzDJ4 aYRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=VFz7J5VRDZyOdTcu1os9HQmHCL2MWejhtVbIRwY0da0=; b=JMWekx0XMs0q4P1Or0GCre5vH1Vhfrom8xFi9mIdrjJAmdYZzHev9jd/2cCQiIkbky crTdLrjFEh+kt5u7ET/wlHpl+mpYRToSjcl35fyML3dL4pjEYmhHXIV9EMx7Q6kbzOLk RIApS46q3FwkwIJnbGNegyzn/SH3dha3bDuLQD7U7SU/9qZ97VldNwBM63Wu2yhqX7cn ZdOK1EnX2ny/Ug9rniXA6qixMlC7U42gkzoIrhoPricz7w3K6DOTjWhqUtdgqrDaEset 6lRWetnXgFia3FWLyVR1TcUCxzBsz+f1px7f8nkATf98MO9LIvfyOfYiHiSBs8jFV4S2 HMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=cDww3Vp1; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61-v6si3605934plc.155.2018.07.27.07.32.27; Fri, 27 Jul 2018 07:32:45 -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; dkim=pass header.i=@broadcom.com header.s=google header.b=cDww3Vp1; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388472AbeG0Pwo (ORCPT + 99 others); Fri, 27 Jul 2018 11:52:44 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:37333 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730709AbeG0Pwo (ORCPT ); Fri, 27 Jul 2018 11:52:44 -0400 Received: by mail-oi0-f66.google.com with SMTP id k81-v6so9371260oib.4 for ; Fri, 27 Jul 2018 07:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VFz7J5VRDZyOdTcu1os9HQmHCL2MWejhtVbIRwY0da0=; b=cDww3Vp1ZQQp/dsGbUvVG0qKcTy3Il3MiAWNXZYMvWn3kZkG9Qs7/w39+0tRFW/G9R /0WXrG1hxX1Tb/SfJFWIJAQmAC4t0oCAuH6Fg3c/9NeFuIKDtG0rVUoC+b7HWI6oDf1q ez7oWLt/Wa8qQTEuZvx5ewoCEh6KFEetieECM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VFz7J5VRDZyOdTcu1os9HQmHCL2MWejhtVbIRwY0da0=; b=DmI5b4menm/BvElaK+97YNnGQAF7ksoZPT0XG0sUKTDEUoYNNQmYWc9l0q1CPecVzt lYaCATioKUMk0tjUoXrIayh2KGTnsKl+ccMHY1j0CnorNTDmURUDVkc8AFBVOMun87of cGTeuc32NrUKE2NG+F7H8bDGLkohKG70EzDGo7DuA5diCy32XwFlr6RrvZdKUea6J+Rl 8WhyiCy3SAYnCbZkbEGuExqNOuaLQ8iXzloL5DVz+4hzVU4QZ4SWn9lPIF3ynSaJlAnz vivMSD01O1mTEH6I+z8KA1fgoAKsZFnY48W3+aojaMMi6zX+0cQFpKi2/fH25qPZkvpe 6EmQ== X-Gm-Message-State: AOUpUlEeCJp3i2I97aJ2oBpoxQXfAQ7PdJHQrYq7z/3H3KDEO4DI6mEK 8YOfsgUbJuykqZ5TE9Vav+XQ3tBmA0ENi9EQOzlD1Q== X-Received: by 2002:aca:afcc:: with SMTP id y195-v6mr7115484oie.322.1532701831984; Fri, 27 Jul 2018 07:30:31 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:6043:0:0:0:0:0 with HTTP; Fri, 27 Jul 2018 07:30:31 -0700 (PDT) In-Reply-To: <9365e83f-e638-7f83-c520-f27f5c9ca532@intel.com> References: <1531845907-26213-1-git-send-email-srinath.mannam@broadcom.com> <9365e83f-e638-7f83-c520-f27f5c9ca532@intel.com> From: Srinath Mannam Date: Fri, 27 Jul 2018 20:00:31 +0530 Message-ID: Subject: Re: [PATCH] mmc: host: iproc: Add ACPI support to IPROC SDHCI To: Adrian Hunter Cc: Ulf Hansson , Ray Jui , Scott Branden , Jon Mason , BCM Kernel Feedback , linux-mmc@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Adrian Hunter, Thank you very much for your inputs. I will send next patch set with all your suggested modifications. Regards, Srinath. On Fri, Jul 27, 2018 at 4:45 PM, Adrian Hunter wrote: > On 27/07/18 11:59, Srinath Mannam wrote: >> Hi Adrian Hunter, >> >> Thank you very much for review and feedback. >> Please find my comments inline.. >> >> On Fri, Jul 27, 2018 at 11:50 AM, Adrian Hunter wrote: >>> On 17/07/18 19:45, 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 >>>> --- >>>> drivers/mmc/host/Kconfig | 1 + >>>> drivers/mmc/host/sdhci-iproc.c | 187 ++++++++++++++++++++++++++++------------- >>>> 2 files changed, 128 insertions(+), 60 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..7c5c923 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,34 +189,24 @@ 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, >>>> }; >>>> >>>> +enum sdhci_pltfm_type { >>>> + SDHCI_PLTFM_IPROC_CYGNUS, >>>> + SDHCI_PLTFM_IPROC, >>>> + SDHCI_PLTFM_BCM2835, >>>> +}; >>>> + >>>> static const struct sdhci_pltfm_data sdhci_iproc_cygnus_pltfm_data = { >>>> .quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK, >>>> .quirks2 = SDHCI_QUIRK2_ACMD23_BROKEN | SDHCI_QUIRK2_HOST_OFF_CARD_ON, >>>> .ops = &sdhci_iproc_32only_ops, >>>> }; >>>> >>>> -static const struct sdhci_iproc_data iproc_cygnus_data = { >>>> - .pdata = &sdhci_iproc_cygnus_pltfm_data, >>>> - .caps = ((0x1 << SDHCI_MAX_BLOCK_SHIFT) >>>> - & SDHCI_MAX_BLOCK_MASK) | >>>> - SDHCI_CAN_VDD_330 | >>>> - SDHCI_CAN_VDD_180 | >>>> - SDHCI_CAN_DO_SUSPEND | >>>> - SDHCI_CAN_DO_HISPD | >>>> - SDHCI_CAN_DO_ADMA2 | >>>> - SDHCI_CAN_DO_SDMA, >>>> - .caps1 = SDHCI_DRIVER_TYPE_C | >>>> - SDHCI_DRIVER_TYPE_D | >>>> - SDHCI_SUPPORT_DDR50, >>>> - .mmc_caps = MMC_CAP_1_8V_DDR, >>>> -}; >>>> - >>>> static const struct sdhci_pltfm_data sdhci_iproc_pltfm_data = { >>>> .quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | >>>> SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12, >>>> @@ -213,21 +214,6 @@ static const struct sdhci_pltfm_data sdhci_iproc_pltfm_data = { >>>> .ops = &sdhci_iproc_ops, >>>> }; >>>> >>>> -static const struct sdhci_iproc_data iproc_data = { >>>> - .pdata = &sdhci_iproc_pltfm_data, >>>> - .caps = ((0x1 << SDHCI_MAX_BLOCK_SHIFT) >>>> - & SDHCI_MAX_BLOCK_MASK) | >>>> - SDHCI_CAN_VDD_330 | >>>> - SDHCI_CAN_VDD_180 | >>>> - SDHCI_CAN_DO_SUSPEND | >>>> - SDHCI_CAN_DO_HISPD | >>>> - SDHCI_CAN_DO_ADMA2 | >>>> - SDHCI_CAN_DO_SDMA, >>>> - .caps1 = SDHCI_DRIVER_TYPE_C | >>>> - SDHCI_DRIVER_TYPE_D | >>>> - SDHCI_SUPPORT_DDR50, >>>> -}; >>>> - >>>> static const struct sdhci_pltfm_data sdhci_bcm2835_pltfm_data = { >>>> .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION | >>>> SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | >>>> @@ -237,38 +223,104 @@ static const struct sdhci_pltfm_data sdhci_bcm2835_pltfm_data = { >>>> .ops = &sdhci_iproc_32only_ops, >>>> }; >>>> >>>> -static const struct sdhci_iproc_data bcm2835_data = { >>>> - .pdata = &sdhci_bcm2835_pltfm_data, >>>> - .caps = ((0x1 << SDHCI_MAX_BLOCK_SHIFT) >>>> - & SDHCI_MAX_BLOCK_MASK) | >>>> - SDHCI_CAN_VDD_330 | >>>> - SDHCI_CAN_DO_HISPD, >>>> - .caps1 = SDHCI_DRIVER_TYPE_A | >>>> - SDHCI_DRIVER_TYPE_C, >>>> - .mmc_caps = 0x00000000, >>>> +static const struct sdhci_iproc_data sdhci_iproc_data_list[] = { >>> >>> Why change to an array? Also would need to be a separate patch. >> In the existing device tree support, data parameter of of_device_id >> list contains pointers of "sdhci_iproc_data" structure. >> But driver_data parameter in acpi_device_id list is ulong. so we can't >> assign "sdhci_iproc_data" structure pointer which can be 64bit. > > kernel_ulong_t is always the same size as a pointer. > >> Hence, it is required to take array of "sdhci_iproc_data" structures, >> so that array index can assign to both data and driver_data >> parameters of of_device_id and acpi_device_id lists respectively. same >> pattern found in some other drivers. >> This method is required to use in the part of adding ACPI support. so >> I keep in single patch. >> >>> >>>> + [SDHCI_PLTFM_IPROC_CYGNUS] = { >>>> + /* SDHCI IPROC CYGNUS */ >>>> + .pdata = &sdhci_iproc_cygnus_pltfm_data, >>>> + .caps = ((0x1 << SDHCI_MAX_BLOCK_SHIFT) >>>> + & SDHCI_MAX_BLOCK_MASK) | >>>> + SDHCI_CAN_VDD_330 | >>>> + SDHCI_CAN_VDD_180 | >>>> + SDHCI_CAN_DO_SUSPEND | >>>> + SDHCI_CAN_DO_HISPD | >>>> + SDHCI_CAN_DO_ADMA2 | >>>> + SDHCI_CAN_DO_SDMA, >>>> + .caps1 = SDHCI_DRIVER_TYPE_C | >>>> + SDHCI_DRIVER_TYPE_D | >>>> + SDHCI_SUPPORT_DDR50, >>>> + .mmc_caps = MMC_CAP_1_8V_DDR, >>>> + }, >>>> + [SDHCI_PLTFM_IPROC] = { >>>> + /* SDHCI IPROC */ >>>> + .pdata = &sdhci_iproc_pltfm_data, >>>> + .caps = ((0x1 << SDHCI_MAX_BLOCK_SHIFT) >>>> + & SDHCI_MAX_BLOCK_MASK) | >>>> + SDHCI_CAN_VDD_330 | >>>> + SDHCI_CAN_VDD_180 | >>>> + SDHCI_CAN_DO_SUSPEND | >>>> + SDHCI_CAN_DO_HISPD | >>>> + SDHCI_CAN_DO_ADMA2 | >>>> + SDHCI_CAN_DO_SDMA, >>>> + .caps1 = SDHCI_DRIVER_TYPE_C | >>>> + SDHCI_DRIVER_TYPE_D | >>>> + SDHCI_SUPPORT_DDR50, >>>> + }, >>>> + [SDHCI_PLTFM_BCM2835] = { >>>> + /* SDHCI BCM2835 */ >>>> + .pdata = &sdhci_bcm2835_pltfm_data, >>>> + .caps = ((0x1 << SDHCI_MAX_BLOCK_SHIFT) >>>> + & SDHCI_MAX_BLOCK_MASK) | >>>> + SDHCI_CAN_VDD_330 | >>>> + SDHCI_CAN_DO_HISPD, >>>> + .caps1 = SDHCI_DRIVER_TYPE_A | >>>> + SDHCI_DRIVER_TYPE_C, >>>> + .mmc_caps = 0x00000000, >>>> + >>>> + }, >>>> }; >>>> >>>> static const struct of_device_id sdhci_iproc_of_match[] = { >>>> - { .compatible = "brcm,bcm2835-sdhci", .data = &bcm2835_data }, >>>> - { .compatible = "brcm,sdhci-iproc-cygnus", .data = &iproc_cygnus_data}, >>>> - { .compatible = "brcm,sdhci-iproc", .data = &iproc_data }, >>>> + { >>>> + .compatible = "brcm,bcm2835-sdhci", >>>> + .data = (void *)SDHCI_PLTFM_BCM2835 >>>> + }, >>>> + { >>>> + .compatible = "brcm,sdhci-iproc-cygnus", >>>> + .data = (void *)SDHCI_PLTFM_IPROC_CYGNUS >>>> + }, >>>> + { >>>> + .compatible = "brcm,sdhci-iproc", >>>> + .data = (void *)SDHCI_PLTFM_IPROC >>>> + }, >>>> { } >>>> }; >>>> MODULE_DEVICE_TABLE(of, sdhci_iproc_of_match); >>>> >>>> +static const struct acpi_device_id sdhci_iproc_acpi_ids[] = { >>>> + { .id = "BRCM5871", .driver_data = SDHCI_PLTFM_IPROC_CYGNUS }, >>>> + { .id = "BRCM5872", .driver_data = SDHCI_PLTFM_IPROC }, >>>> + { /* sentinel */ } >>>> +}; >>>> +MODULE_DEVICE_TABLE(acpi, sdhci_iproc_acpi_ids); >>>> + >>>> static int sdhci_iproc_probe(struct platform_device *pdev) >>>> { >>>> + struct device *dev = &pdev->dev; >>>> const struct of_device_id *match; >>>> + const struct acpi_device_id *acpi_id; >>>> const struct sdhci_iproc_data *iproc_data; >>>> struct sdhci_host *host; >>>> struct sdhci_iproc_host *iproc_host; >>>> struct sdhci_pltfm_host *pltfm_host; >>>> int ret; >>>> + enum sdhci_pltfm_type plat_type; >>>> + >>>> + if (dev->of_node) { >>>> + match = of_match_device(sdhci_iproc_of_match, dev); >>>> + if (match) >>>> + plat_type = (enum sdhci_pltfm_type)match->data; >>>> + else >>>> + return -ENODEV; >>>> + } else if (has_acpi_companion(dev)) { >>>> + acpi_id = acpi_match_device(sdhci_iproc_acpi_ids, dev); >>>> + if (acpi_id) >>>> + plat_type = (enum sdhci_pltfm_type)acpi_id->driver_data; >>>> + else >>>> + return -ENODEV; >>>> + } else >>>> + return -ENODEV; >>>> >>>> - match = of_match_device(sdhci_iproc_of_match, &pdev->dev); >>>> - if (!match) >>>> - return -EINVAL; >>>> - iproc_data = match->data; >>>> + iproc_data = &sdhci_iproc_data_list[plat_type]; >>>> >>>> host = sdhci_pltfm_init(pdev, iproc_data->pdata, sizeof(*iproc_host)); >>>> if (IS_ERR(host)) >>>> @@ -284,17 +336,30 @@ static int sdhci_iproc_probe(struct platform_device *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; >>>> + } >>>> + } else if (has_acpi_companion(dev)) { >>>> + /* >>>> + * When Driver probe with ACPI device, clock devices >>>> + * are not available, so sdhci clock get from >>>> + * clock-frequency property given in _DSD object. >>>> + */ >>>> + device_property_read_u32(dev, "clock-frequency", >>>> + &pltfm_host->clock); >>> >>> Is this a new property, or is it documented? Did you consider enhancing >>> __sdhci_read_caps() and using the existing "sdhci-caps" and >>> "sdhci-caps-mask" properties? >>> >> "clock-frequency" is not a new property also used in "sdhci-pltfm.c" >> to get clock >> frequency and use in the case of clock device node is not passed from >> device tree node. >> But In the case of ACPI support, ACPI does not support common clock framework. >> so clock frequency get by "clock-frequency" property given in _DSD >> object of ACPI device node. > > So we should convert to generic device properties i.e. add the patch below and > call sdhci_get_property(pdev): > > From: Adrian Hunter > Date: Fri, 27 Jul 2018 13:52:02 +0300 > Subject: [PATCH] mmc: sdhci-pltfm: Convert DT properties to generic device > properties > > Convert DT properties to generic device properties so that drivers can get > properties from DT or ACPI. > > Signed-off-by: Adrian Hunter > --- > drivers/mmc/host/sdhci-pltfm.c | 68 +++++++++++++++++++++++++----------------- > drivers/mmc/host/sdhci-pltfm.h | 7 ++++- > 2 files changed, 46 insertions(+), 29 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c > index 02bea6159d79..b231c9a3f888 100644 > --- a/drivers/mmc/host/sdhci-pltfm.c > +++ b/drivers/mmc/host/sdhci-pltfm.c > @@ -30,6 +30,7 @@ > > #include > #include > +#include > #include > #ifdef CONFIG_PPC > #include > @@ -51,11 +52,10 @@ unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host) > .set_uhs_signaling = sdhci_set_uhs_signaling, > }; > > -#ifdef CONFIG_OF > -static bool sdhci_of_wp_inverted(struct device_node *np) > +static bool sdhci_wp_inverted(struct device *dev) > { > - if (of_get_property(np, "sdhci,wp-inverted", NULL) || > - of_get_property(np, "wp-inverted", NULL)) > + if (device_property_present(dev, "sdhci,wp-inverted") || > + device_property_present(dev, "wp-inverted")) > return true; > > /* Old device trees don't have the wp-inverted property. */ > @@ -66,52 +66,64 @@ static bool sdhci_of_wp_inverted(struct device_node *np) > #endif /* CONFIG_PPC */ > } > > -void sdhci_get_of_property(struct platform_device *pdev) > +#ifdef CONFIG_OF > +static void sdhci_get_compatibility(struct platform_device *pdev) > { > + struct sdhci_host *host = platform_get_drvdata(pdev); > struct device_node *np = pdev->dev.of_node; > + > + if (!np) > + return; > + > + if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc")) > + host->quirks |= SDHCI_QUIRK_BROKEN_DMA; > + > + if (of_device_is_compatible(np, "fsl,p2020-esdhc") || > + of_device_is_compatible(np, "fsl,p1010-esdhc") || > + of_device_is_compatible(np, "fsl,t4240-esdhc") || > + of_device_is_compatible(np, "fsl,mpc8536-esdhc")) > + host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; > +} > +#else > +void sdhci_get_compatibility(struct platform_device *pdev) {} > +#endif /* CONFIG_OF */ > + > +void sdhci_get_property(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > struct sdhci_host *host = platform_get_drvdata(pdev); > struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > u32 bus_width; > > - if (of_get_property(np, "sdhci,auto-cmd12", NULL)) > + if (device_property_present(dev, "sdhci,auto-cmd12")) > host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12; > > - if (of_get_property(np, "sdhci,1-bit-only", NULL) || > - (of_property_read_u32(np, "bus-width", &bus_width) == 0 && > + if (device_property_present(dev, "sdhci,1-bit-only") || > + (device_property_read_u32(dev, "bus-width", &bus_width) == 0 && > bus_width == 1)) > host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA; > > - if (sdhci_of_wp_inverted(np)) > + if (sdhci_wp_inverted(dev)) > host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT; > > - if (of_get_property(np, "broken-cd", NULL)) > + if (device_property_present(dev, "broken-cd")) > host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; > > - if (of_get_property(np, "no-1-8-v", NULL)) > + if (device_property_present(dev, "no-1-8-v")) > host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; > > - if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc")) > - host->quirks |= SDHCI_QUIRK_BROKEN_DMA; > - > - if (of_device_is_compatible(np, "fsl,p2020-esdhc") || > - of_device_is_compatible(np, "fsl,p1010-esdhc") || > - of_device_is_compatible(np, "fsl,t4240-esdhc") || > - of_device_is_compatible(np, "fsl,mpc8536-esdhc")) > - host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; > + sdhci_get_compatibility(pdev); > > - of_property_read_u32(np, "clock-frequency", &pltfm_host->clock); > + device_property_read_u32(dev, "clock-frequency", &pltfm_host->clock); > > - if (of_find_property(np, "keep-power-in-suspend", NULL)) > + if (device_property_present(dev, "keep-power-in-suspend")) > host->mmc->pm_caps |= MMC_PM_KEEP_POWER; > > - if (of_property_read_bool(np, "wakeup-source") || > - of_property_read_bool(np, "enable-sdio-wakeup")) /* legacy */ > + if (device_property_read_bool(dev, "wakeup-source") || > + device_property_read_bool(dev, "enable-sdio-wakeup")) /* legacy */ > host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; > } > -#else > -void sdhci_get_of_property(struct platform_device *pdev) {} > -#endif /* CONFIG_OF */ > -EXPORT_SYMBOL_GPL(sdhci_get_of_property); > +EXPORT_SYMBOL_GPL(sdhci_get_property); > > struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, > const struct sdhci_pltfm_data *pdata, > @@ -184,7 +196,7 @@ int sdhci_pltfm_register(struct platform_device *pdev, > if (IS_ERR(host)) > return PTR_ERR(host); > > - sdhci_get_of_property(pdev); > + sdhci_get_property(pdev); > > ret = sdhci_add_host(host); > if (ret) > diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h > index 1e91fb1c020e..6109987fc3b5 100644 > --- a/drivers/mmc/host/sdhci-pltfm.h > +++ b/drivers/mmc/host/sdhci-pltfm.h > @@ -90,7 +90,12 @@ static inline void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg) > } > #endif /* CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER */ > > -extern void sdhci_get_of_property(struct platform_device *pdev); > +void sdhci_get_property(struct platform_device *pdev); > + > +static inline void sdhci_get_of_property(struct platform_device *pdev) > +{ > + return sdhci_get_property(pdev); > +} > > extern struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, > const struct sdhci_pltfm_data *pdata, > -- > 1.9.1 > > > >> >>>> + if (!pltfm_host->clock) { >>>> + ret = -ENODEV; >>>> + goto err; >>>> + } >>>> } >>>> - >>>> if (iproc_host->data->pdata->quirks & SDHCI_QUIRK_MISSING_CAPS) { >>>> host->caps = iproc_host->data->caps; >>>> host->caps1 = iproc_host->data->caps1; >>>> @@ -307,7 +372,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 +383,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, >>>> >>> >> Regards, >> Srinath. >> >