From patchwork Mon Jul 16 11:08:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 141993 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2283587ljj; Mon, 16 Jul 2018 04:08:25 -0700 (PDT) X-Received: by 2002:a2e:8514:: with SMTP id j20-v6mr10903218lji.10.1531739305559; Mon, 16 Jul 2018 04:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531739305; cv=none; d=google.com; s=arc-20160816; b=orwLhimE8uVv7RH72Bg56/Av741xZC6XSVZXLpHdOhS4U5azLE/Y7IFWhHuqXLBeBR wTuSIl8sXXqZC1EkTF8GrgRtjTTsVVg8JUJ0cqxXO4YlGFhuhVfu8rv1p7Bd10OUli4u qQUWLpadHK1FmpJoqYn/FhHRgqzQfi2kD9OGPHGWX6gz9FW/0ELZ1DO8vtcP0xqTUKRl BuzTv2wMkM8t+t92c7VcrsiSHYJ54ZXNsQkknbxgn6iiW5rQFgRUh2CgSzFpVNNiO1VO f7djtGsJdPHVM5HxIEx3b3YgWGrz4O37wR45NrLAHPaB4VAFbuVQbasaTBkvGmifvWXt 29Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=4fBH6wYFZESPaWkF/sjeRHpOKj5tWGlplXdp/3tCNHw=; b=P8IP2/6u8GaYJustu2Zs5cFt9WmKG9R1uukObCQnYCiuWP/M+mSDMK05i+cXME4NGS bmQFGLwS9FDRNWRFLE8ycT3pmp3v3XRNRBjU411pV8T6NMk9uCLSj/8KRH2p//eKrD0o 3tm8+t1MxTQ3urAmeKT1yvOQMnV93abIjSRtxPsw3Yl/uaZEJEbQd1cEeV12BC8TmtPO n1QkENunWrK9v0Qamqo4KyZNRhvOM9WkxIZpRMx2onYDQH/k3Aw7eQsgDQcqcbiIh6Ss ZPjoeQ1XFDYeBxfrDe4Z46eoYDSoQbyqbGOpSnoW7B+QifoVBO9aTUu3QMWv6r7iXwZr dbUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sf0zU12D; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i123-v6sor2829052lji.27.2018.07.16.04.08.25 for (Google Transport Security); Mon, 16 Jul 2018 04:08:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sf0zU12D; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=4fBH6wYFZESPaWkF/sjeRHpOKj5tWGlplXdp/3tCNHw=; b=Sf0zU12DxaJgZztlUZsNY2PMJL0MyO8GvAtQFStbgaqacsllN2VqITehqkhKJRS6Of c4fbPWgJomdgXUpM+957FMikNhvct2Qixcg8xQbFfwmGoTe0JiUnOH/Z2wRbxIMb/LVY ItVN5Egqjf/IbkGKH2FdUpX/Dy2yb8oTajRSM= 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; bh=4fBH6wYFZESPaWkF/sjeRHpOKj5tWGlplXdp/3tCNHw=; b=Eh2iU5Pcq9iTyQMAN7Cw78bbekx/DePmWK9Ps1xFY9zlZLDFmWcoPtgyrJB5EAc6+F X+j/aLIjXxMMUrrb7qcVmhviewOrr4U5i562cYOS+sCxJS8xoZagKGokoqc9VsbmNI9R fxPQwcFaKa0cMNUOJK+Z+YKOcoI7jqPie+eM4XqvDPsA5mZ62yQ/1CjdRdhOMSFUvPfT GDMFGkOPOYWqOorYoE9TH11whyykdPyIftY60E8qZfga9vTtejKiokPFngzLVdkxF/ZB FF+h8DWOVHwjNQGwvTouOb+RgYb52zgG3yC2w5EE/SIlCb3N9FnF5o5mTVQsGJ+tdzFu Oapw== X-Gm-Message-State: AOUpUlGS/ta28AC+OhxnBE32/3GgmoDbaUDL+PlCGyHYZhxUp4g2MH7I arGecnyT31PtnuM+8g2LwU1iuX38 X-Google-Smtp-Source: AAOMgpcKJni8uabL+TTWNptf0maRAdyP2Ixi/+0x9BmXXv93RKTlQw6Yr/QERTPwgMgnM2g/w8PqNA== X-Received: by 2002:a2e:1dc8:: with SMTP id w69-v6mr9507670lje.110.1531739305341; Mon, 16 Jul 2018 04:08:25 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id g12-v6sm8077644lfe.1.2018.07.16.04.08.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 04:08:24 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Ludovic Barre Cc: Russell King , Linus Walleij , Srinivas Kandagatla Subject: [PATCH v2 2/2] mmc: mmci: Add and implement a ->dma_setup() callback for qcom dml Date: Mon, 16 Jul 2018 13:08:18 +0200 Message-Id: <20180716110818.30837-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 As a first step to improve the variant specific code for mmci, add a ->dma_setup() callback to the struct mmci_host_ops. To show its use, let's deploy the callback for the qcom dml, which involves also to the assign the mmci_host_ops pointer from the variant ->init() callback. Signed-off-by: Ulf Hansson Reviewed-by: Ludovic Barre --- Changes in v2: - Fixed compile errors. - Add Ludo's reviewed by tags (received off-list). These two patches came out of a diuscussion with Ludovic, who are trying to add support for a new ST variant. I consider this as potentiall being the first steps of how we could move forward to better support variants. If we think this makes sense, a third step is to figure out if for example, mmci_dma_setup(), should be turned into a library function, which means the qcom dml ->dma_setup() callback should call it, rather than the opposite as of now. --- drivers/mmc/host/mmci.c | 6 ++---- drivers/mmc/host/mmci.h | 1 + drivers/mmc/host/mmci_qcom_dml.c | 18 ++++++++++++++---- drivers/mmc/host/mmci_qcom_dml.h | 5 ++--- 4 files changed, 19 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index e907a0a866da..71e93360fa6f 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -417,7 +417,6 @@ static void mmci_init_sg(struct mmci_host *host, struct mmc_data *data) static void mmci_dma_setup(struct mmci_host *host) { const char *rxname, *txname; - struct variant_data *variant = host->variant; host->dma_rx_channel = dma_request_slave_channel(mmc_dev(host->mmc), "rx"); host->dma_tx_channel = dma_request_slave_channel(mmc_dev(host->mmc), "tx"); @@ -465,9 +464,8 @@ static void mmci_dma_setup(struct mmci_host *host) host->mmc->max_seg_size = max_seg_size; } - if (variant->qcom_dml && host->dma_rx_channel && host->dma_tx_channel) - if (dml_hw_init(host, host->mmc->parent->of_node)) - variant->qcom_dml = false; + if (host->ops && host->ops->dma_setup) + host->ops->dma_setup(host); } /* diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index f2eff0cc6934..517591d219e9 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -273,6 +273,7 @@ struct variant_data { /* mmci variant callbacks */ struct mmci_host_ops { + void (*dma_setup)(struct mmci_host *host); }; struct mmci_host_next { diff --git a/drivers/mmc/host/mmci_qcom_dml.c b/drivers/mmc/host/mmci_qcom_dml.c index 00750c9d3514..be3fab5db83f 100644 --- a/drivers/mmc/host/mmci_qcom_dml.c +++ b/drivers/mmc/host/mmci_qcom_dml.c @@ -119,17 +119,20 @@ static int of_get_dml_pipe_index(struct device_node *np, const char *name) } /* Initialize the dml hardware connected to SD Card controller */ -int dml_hw_init(struct mmci_host *host, struct device_node *np) +static void qcom_dma_setup(struct mmci_host *host) { u32 config; void __iomem *base; int consumer_id, producer_id; + struct device_node *np = host->mmc->parent->of_node; consumer_id = of_get_dml_pipe_index(np, "tx"); producer_id = of_get_dml_pipe_index(np, "rx"); - if (producer_id < 0 || consumer_id < 0) - return -ENODEV; + if (producer_id < 0 || consumer_id < 0) { + host->variant->qcom_dml = false; + return; + } base = host->base + DML_OFFSET; @@ -172,6 +175,13 @@ int dml_hw_init(struct mmci_host *host, struct device_node *np) /* Make sure dml initialization is finished */ mb(); +} - return 0; +static struct mmci_host_ops qcom_variant_ops = { + .dma_setup = qcom_dma_setup, +}; + +void qcom_variant_init(struct mmci_host *host) +{ + host->ops = &qcom_variant_ops; } diff --git a/drivers/mmc/host/mmci_qcom_dml.h b/drivers/mmc/host/mmci_qcom_dml.h index 6e405d09d534..fa16f6f4d4ad 100644 --- a/drivers/mmc/host/mmci_qcom_dml.h +++ b/drivers/mmc/host/mmci_qcom_dml.h @@ -16,12 +16,11 @@ #define __MMC_QCOM_DML_H__ #ifdef CONFIG_MMC_QCOM_DML -int dml_hw_init(struct mmci_host *host, struct device_node *np); +void qcom_variant_init(struct mmci_host *host); void dml_start_xfer(struct mmci_host *host, struct mmc_data *data); #else -static inline int dml_hw_init(struct mmci_host *host, struct device_node *np) +static inline void qcom_variant_init(struct mmci_host *host) { - return -ENOSYS; } static inline void dml_start_xfer(struct mmci_host *host, struct mmc_data *data) {