From patchwork Thu Jan 10 17:34:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 155230 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2159293jaa; Thu, 10 Jan 2019 09:34:20 -0800 (PST) X-Received: by 2002:a17:902:2a89:: with SMTP id j9mr6434933plb.296.1547141660741; Thu, 10 Jan 2019 09:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547141660; cv=none; d=google.com; s=arc-20160816; b=qcBPYHCAWpfM+NE8LdnU7hEWnRyEDnRasQHJs5tu/fJqAuFRwHaIBA8kNveygqZDMI Ca+BcjvJiJwtJ6VDiCDfFd5RRrJDfHIPqi3igbmrY0dtmPpMa/iyHC3fClkImEEbxpEj DJnN1h+WkZ0pRskUmT78kC4xdprXiHDxfDONBbM5p67vA2NCpgHowQH5I1B0Ky0QqYjk DG3dSf51nNElJCS+zKheCXjaHr3wLyJUNfXTH6j3frS7qgxVKpVFrqSieiUQ0rDVB9oL PsC5STqcm3SCvWNwMDeG1w3A17Jm5tcovQ3K58iW9cAUd1E1st94XCrYVBXabC8hVZDH 3Z1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GvaGd5Qa7PcuxUq/r8GFXFG1FEuIWEy4GqPFolG9iUI=; b=WSAfFUDXqhNIQlo5tVFo2P0mw6yNk67lPsRTC2QX9FwrDkpDtCbqY4ARy+zgn1bZUj zhX7AqSeEezUgOGbT8GgCg752DtwwTmg/MJwKQkWcv1YH1G3q9k3UNBlLdqG2MXwZHsa CdUckf4ui/vQ+USgvxKF+5vpiwbKL5a4d7WUKR0ubH3Zz6PDgV+ph/UbnfwaA/1Zh1Ck ll/cx4cRXSxdfIcGv9/93XwW9dCJXMOQvpG/7f5VdORGds7ARLqHnJAKDt9weEsJjAEK MwGxhYhrfbL6l4zAF1/gzApdeKR2qd99CyQWqfdo/b3kvzj5dCgh1U1bS467J/h7ooRo rj2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jxSRrtci; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@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 j193sor52701585pge.29.2019.01.10.09.34.20 for (Google Transport Security); Thu, 10 Jan 2019 09:34:20 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@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=jxSRrtci; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@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:in-reply-to:references; bh=GvaGd5Qa7PcuxUq/r8GFXFG1FEuIWEy4GqPFolG9iUI=; b=jxSRrtciAFsvPrLOdNPhoVjarHW2x/2/ieNzhzFow+FU0K8BMwZLOe2a4Smu9h1k0R PKW4LIHA2T7w2pM2l3KXg2pwa3HsvR+0UOWMXVWL33Ev0NGPfMeEWNyUEwjuxpLdOihY joAfF444bcis6IgH48l+ZKHNIc3ECmaj1WIeY= 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; bh=GvaGd5Qa7PcuxUq/r8GFXFG1FEuIWEy4GqPFolG9iUI=; b=Lsw+OlBVU6E+WB6vXFWbglgQjCpBcbW2SFavAac4riiVkm52Gl30rYRliD6f14149O PWGhQVm4PqWqgGg6jAhQC2i+FEgfc/XF0GqDA0PqNx02+rZcv+EWIqk+C7yo0FQDoxTx ZISGcjo0qfRYUEIYs/Cpiti92PD3w8MoICZL3XVy2SWGuwBDAZ1wzxtSWM0bw3ZDtKMc 45qjeF9dlKbn4TLJsUunH7/cnpPVLT245/6btrAuan0fxskVgme/HwXVfxoIfXaDVHaL CNUgLyu68zf+ovQQYjiudnL0Qce9Qx+hOt9WQlP6XHO6MN/HxAhfxLHbcIR/ad8zPKr9 kPUA== X-Gm-Message-State: AJcUukf4+69L+izF8S9r+TAFZXpJR1QBedtp9gO6nEQ934+II/kUABNR XBzmQvxyS95DFo7qfI81UQt0S0ie X-Google-Smtp-Source: ALg8bN4hH6OpNpCbHKtQeZyVFIwzVI9NPTlgoq4ItvQtEK7rYgtlbysusiurz+Jp1hkGwNWFvLMIbw== X-Received: by 2002:a63:83c1:: with SMTP id h184mr4506117pge.437.1547141660281; Thu, 10 Jan 2019 09:34:20 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id k15sm125977409pfb.147.2019.01.10.09.34.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jan 2019 09:34:19 -0800 (PST) From: John Stultz To: lkml Cc: Dan Williams , Vinod Koul , Zhuangluan Su , Ryan Grachek , Manivannan Sadhasivam , dmaengine@vger.kernel.org, Youlin Wang , Tanglei Han , John Stultz Subject: [PATCH 3/8 v3] dma: k3dma: Upgrade k3dma driver to support hisi_asp_dma hardware Date: Thu, 10 Jan 2019 09:34:07 -0800 Message-Id: <1547141652-8660-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547141652-8660-1-git-send-email-john.stultz@linaro.org> References: <1547141652-8660-1-git-send-email-john.stultz@linaro.org> From: Youlin Wang On the hi3660 hardware there are two (at least) DMA controllers, the DMA-P (Peripherial DMA) and the DMA-A (Audio DMA). The two blocks are similar, but have some slight differences. This resulted in the vendor implementing two separate drivers, which after review, they have been able to condense and re-use the existing k3dma driver. Thus, this patch adds support for the new "hisi-pcm-asp-dma-1.0" compatible string in the binding. One difference with the DMA-A controller, is that it does not need to initialize a clock. So we skip this by adding and using soc data flags. After above this driver will support both k3 and hisi_asp dma hardware. Cc: Dan Williams Cc: Vinod Koul Cc: Zhuangluan Su Cc: Ryan Grachek Cc: Manivannan Sadhasivam Cc: dmaengine@vger.kernel.org Acked-by: Manivannan Sadhasivam Signed-off-by: Youlin Wang Signed-off-by: Tanglei Han [jstultz: Reworked to use of_match_data, commit msg improvements] Signed-off-by: John Stultz --- v2: * Reworked to use of_match_data v3: * Further rework of the commit message --- drivers/dma/k3dma.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c index fdec2b6..df61406 100644 --- a/drivers/dma/k3dma.c +++ b/drivers/dma/k3dma.c @@ -116,6 +116,13 @@ struct k3_dma_dev { unsigned int irq; }; + +#define K3_FLAG_NOCLK (1<<0) +struct k3dma_soc_data { + unsigned long flags; +}; + + #define to_k3_dma(dmadev) container_of(dmadev, struct k3_dma_dev, slave) static int k3_dma_config_write(struct dma_chan *chan, @@ -790,8 +797,21 @@ static int k3_dma_transfer_resume(struct dma_chan *chan) return 0; } +static const struct k3dma_soc_data k3_v1_dma_data = { + .flags = 0, +}; + +static const struct k3dma_soc_data asp_v1_dma_data = { + .flags = K3_FLAG_NOCLK, +}; + static const struct of_device_id k3_pdma_dt_ids[] = { - { .compatible = "hisilicon,k3-dma-1.0", }, + { .compatible = "hisilicon,k3-dma-1.0", + .data = &k3_v1_dma_data + }, + { .compatible = "hisilicon,hisi-pcm-asp-dma-1.0", + .data = &asp_v1_dma_data + }, {} }; MODULE_DEVICE_TABLE(of, k3_pdma_dt_ids); @@ -810,6 +830,7 @@ static struct dma_chan *k3_of_dma_simple_xlate(struct of_phandle_args *dma_spec, static int k3_dma_probe(struct platform_device *op) { + const struct k3dma_soc_data *soc_data; struct k3_dma_dev *d; const struct of_device_id *of_id; struct resource *iores; @@ -823,6 +844,10 @@ static int k3_dma_probe(struct platform_device *op) if (!d) return -ENOMEM; + soc_data = device_get_match_data(&op->dev); + if (!soc_data) + return -EINVAL; + d->base = devm_ioremap_resource(&op->dev, iores); if (IS_ERR(d->base)) return PTR_ERR(d->base); @@ -835,10 +860,12 @@ static int k3_dma_probe(struct platform_device *op) "dma-requests", &d->dma_requests); } - d->clk = devm_clk_get(&op->dev, NULL); - if (IS_ERR(d->clk)) { - dev_err(&op->dev, "no dma clk\n"); - return PTR_ERR(d->clk); + if (!(soc_data->flags & K3_FLAG_NOCLK)) { + d->clk = devm_clk_get(&op->dev, NULL); + if (IS_ERR(d->clk)) { + dev_err(&op->dev, "no dma clk\n"); + return PTR_ERR(d->clk); + } } irq = platform_get_irq(op, 0);