Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4763533imm; Mon, 18 Jun 2018 22:42:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJuA7rF7bldKIEiHZQJpRn75OjHstwgbyl8E5qPLwel/r36zA/ZWfkBXAeLLsdVAEIwS67P X-Received: by 2002:a62:5d83:: with SMTP id n3-v6mr16691541pfj.68.1529386925126; Mon, 18 Jun 2018 22:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529386925; cv=none; d=google.com; s=arc-20160816; b=OnELhVSz0xsVbHCH87JqbeXj5/SnDHAjGSwUMgjyc2gh0ERB5r7Ar51FM0JxQ2YxpW 0BpYZ6TmboPUDAP4BHydVYRnMdb59+JWpnCyM03IUsm3ZvLTWxtTDy6fkie/rZBhnpQb nnTfbmYvK1OtyvYZ31XcEWDeRVOctxoRupQtQYUbERccC6WndPqh/010QUZvHM/6Nqxd jzT55U1PQvsHfnQ1Q8nElPDa7AZITMND5FLqBvyP9W3sHO4AbykBF5lXpzgJayvoSIjf 3HzHQG02jAf2EMp1gA28QSdarNAQHSeEB4wWd7bVV1/DAZ/fhrfmIDbC1g2HkAAiLuvw QIAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=Zr0b1DZ0xHZTHWV2h/kLq4/aBUqmfebUBSnMswvYoC4=; b=gUSU705h5NO4Zz3GFUycJ5cRO/a1w1RwRnXFLD7zpanAN1Uj4hiHGazybwuJmfWAFy zSxMm/lqgC2gybOOkVm4/Fd83uaX/m4pkUrYrUSBbUcXoC1lhOdKV/cx71UbyNuSnu9c /qjWNY7YoHdeOYeNgunPgIX9LEZfFUKGr2lm5Ky2sERVbgHoQQQ6RY2W0n6fXwFabNOM qN++I8P/yg1ZzRCYcHdW3HfuFxa0vQXEeZSMzW6MuiKNWk1vmS3tfyaYwTMpipXAwsZH uL/SPsika87T8QjJR7f+ck68ULo+Vc/7NzzJM4vgjpcxc3xsEkq/GQLdjjJhhpTYUdoR hfJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=GKHA+3Vx; dkim=pass header.i=@codeaurora.org header.s=default header.b=YWiGLd4L; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a21-v6si16310713pls.237.2018.06.18.22.41.51; Mon, 18 Jun 2018 22:42:05 -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=@codeaurora.org header.s=default header.b=GKHA+3Vx; dkim=pass header.i=@codeaurora.org header.s=default header.b=YWiGLd4L; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965389AbeFSFj7 (ORCPT + 99 others); Tue, 19 Jun 2018 01:39:59 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:58300 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964895AbeFSFjz (ORCPT ); Tue, 19 Jun 2018 01:39:55 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D89FF60B16; Tue, 19 Jun 2018 05:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529386794; bh=Iy240IvJJ8UVY1+LPtXoR58T2ywWggPYYy7Gplm9UKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GKHA+3Vx55bkbZ/j7OuplPAkudIOGlWrUKKK14R8SbBcLFh7aQu1UZnJooE4t86e3 gYFQ8DuB8ednLzyvCK2P1OcOAz7L/5YWm3RcG3g0NW6reAKU9ri1aIR4McET45UhQo vZrxZAtBR+CFxx5vGRNLL/7wJvRCd3cyhUBob6Ec= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from hydcbspbld03.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vviswana@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id EF51A604A6; Tue, 19 Jun 2018 05:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529386793; bh=Iy240IvJJ8UVY1+LPtXoR58T2ywWggPYYy7Gplm9UKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YWiGLd4Lg0c6HJ3KT3Al7TJG/CA8vduVpC8AzbmOx8ZplNMwIGJ8RzC3SllQU/OJ4 jWkmR8TMVMOy0kiXQka2q93Sws+rTZuHWp3sZHpPCeHtRCxg7V88ig9XoBvX3cMziK 362wE2UuFMFw696gpXxUIus3I9ZQxm1tRIWlFxAE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org EF51A604A6 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vviswana@codeaurora.org From: Vijay Viswanath To: adrian.hunter@intel.com, ulf.hansson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, shawn.lin@rock-chips.com, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org, devicetree@vger.kernel.org, asutoshd@codeaurora.org, stummala@codeaurora.org, venkatg@codeaurora.org, jeremymc@redhat.com, vviswana@codeaurora.org, bjorn.andersson@linaro.org, riteshh@codeaurora.org, vbadigan@codeaurora.org, dianders@google.com, sayalil@codeaurora.org Subject: [PATCH V3 2/4] mmc: sdhci-msm: Add msm version specific ops and data structures Date: Tue, 19 Jun 2018 11:09:19 +0530 Message-Id: <1529386761-4923-3-git-send-email-vviswana@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1529386761-4923-1-git-send-email-vviswana@codeaurora.org> References: <1529386761-4923-1-git-send-email-vviswana@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In addition to offsets of certain registers changing, the registers in core_mem have been shifted to HC mem as well. To access these registers, define msm version specific functions. These functions can be loaded into the function pointers at the time of probe based on the msm version detected. Also defind new data structure to hold version specific Ops and register addresses. Signed-off-by: Sayali Lokhande Signed-off-by: Vijay Viswanath Reviewed-by: Evan Green --- drivers/mmc/host/sdhci-msm.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 4050c99..3d01bc2 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -226,6 +226,22 @@ struct sdhci_msm_offset { .core_ddr_config_2 = 0x1bc, }; +struct sdhci_msm_variant_ops { + u32 (*msm_readl_relaxed)(struct sdhci_host *host, u32 offset); + void (*msm_writel_relaxed)(u32 val, struct sdhci_host *host, + u32 offset); +}; + +/* + * From V5, register spaces have changed. Wrap this info in a structure + * and choose the data_structure based on version info mentioned in DT. + */ +struct sdhci_msm_variant_info { + bool mci_removed; + const struct sdhci_msm_variant_ops *var_ops; + const struct sdhci_msm_offset *offset; +}; + struct sdhci_msm_host { struct platform_device *pdev; void __iomem *core_mem; /* MSM SDCC mapped address */ @@ -245,8 +261,45 @@ struct sdhci_msm_host { wait_queue_head_t pwr_irq_wait; bool pwr_irq_flag; u32 caps_0; + bool mci_removed; + const struct sdhci_msm_variant_ops *var_ops; + const struct sdhci_msm_offset *offset; }; +/* + * APIs to read/write to vendor specific registers which were there in the + * core_mem region before MCI was removed. + */ +static u32 sdhci_msm_mci_variant_readl_relaxed(struct sdhci_host *host, + u32 offset) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); + + return readl_relaxed(msm_host->core_mem + offset); +} + +static u32 sdhci_msm_v5_variant_readl_relaxed(struct sdhci_host *host, + u32 offset) +{ + return readl_relaxed(host->ioaddr + offset); +} + +static void sdhci_msm_mci_variant_writel_relaxed(u32 val, + struct sdhci_host *host, u32 offset) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); + + writel_relaxed(val, msm_host->core_mem + offset); +} + +static void sdhci_msm_v5_variant_writel_relaxed(u32 val, + struct sdhci_host *host, u32 offset) +{ + writel_relaxed(val, host->ioaddr + offset); +} + static unsigned int msm_get_clock_rate_for_bus_mode(struct sdhci_host *host, unsigned int clock) { @@ -1481,6 +1534,28 @@ static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host) pr_debug("%s: supported caps: 0x%08x\n", mmc_hostname(mmc), caps); } +static const struct sdhci_msm_variant_ops mci_var_ops = { + .msm_readl_relaxed = sdhci_msm_mci_variant_readl_relaxed, + .msm_writel_relaxed = sdhci_msm_mci_variant_writel_relaxed, +}; + +static const struct sdhci_msm_variant_ops v5_var_ops = { + .msm_readl_relaxed = sdhci_msm_v5_variant_readl_relaxed, + .msm_writel_relaxed = sdhci_msm_v5_variant_writel_relaxed, +}; + +static const struct sdhci_msm_variant_info sdhci_msm_mci_var = { + .mci_removed = false, + .var_ops = &mci_var_ops, + .offset = &sdhci_msm_mci_offset, +}; + +static const struct sdhci_msm_variant_info sdhci_msm_v5_var = { + .mci_removed = true, + .var_ops = &v5_var_ops, + .offset = &sdhci_msm_v5_offset, +}; + static const struct of_device_id sdhci_msm_dt_match[] = { { .compatible = "qcom,sdhci-msm-v4" }, {}, -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.