From patchwork Thu Jan 24 20:24:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 156511 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2398963jaa; Thu, 24 Jan 2019 12:24:33 -0800 (PST) X-Received: by 2002:a62:8add:: with SMTP id o90mr7904460pfk.210.1548361473092; Thu, 24 Jan 2019 12:24:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548361473; cv=none; d=google.com; s=arc-20160816; b=HGkGGLiF7RW+r7aVSUohDsavgswKdID7yyW7mjAfndQS9HPQT278XoUrbMIeuhz2Mw SZU+17zqACzZ6+NPyr7SdTwLtyn4bth3XJsz0+eYit4L/n4SlViqxP9LIOkzPmfHqU2D AfmWsF/TFCVrNA9ttsjFUk8cc2LVY5TLvfrG88tLcUyEyy5Gk4HU9k8KBXm1BPRM3lWH FIlpLQj53Lb0wkyi/bHX3rQMu3l2gtMj8Z1x6PWkAUj7o+koNIsRkEIk1yXumklIcsCz aKKykF+hDXqfG0msyUei8nPaqhyLDbNXJtVfqx++5tJv9dVx+2lf+wOlUEPQWGTQbAJZ lCUQ== 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=o7egLywBx6XayJjOoobZHgYLmJpcGqlES3T4nO9IJnw=; b=1H/0Xn+CcG40KmpCZFgN3/m3sGRkOoz8QlQ8ASRe66PcqHV6hlFKjcLEyXek3Vh1p9 bz+gZym13nivfUZJtKwndpY5yf3H5fZnDMNHpDWS96LcM7jbqBRN0f9YVEhQ0m2PKA22 +17v7ImmdwwHBz5qxLnZ1LXOzkMVzVUc1TTLjo8EkDVqMMR92eWkr82b0XIclQRcgVnt m2YkgdbXNRHlTC6ObASVV03YGo5SeihYnKPrQq4bH02Xjsu+kd9J1jLGUi5n1KWLkDDB Hg/P8yBvGGumjFEDj3lC0Z04R2FMmBaY7R9QeItsbsOui3OCRFmlh2Nvcp4usKMqhp5i gC9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GxEUF/mC"; 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 n87sor33034272pfh.64.2019.01.24.12.24.33 for (Google Transport Security); Thu, 24 Jan 2019 12:24:33 -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="GxEUF/mC"; 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=o7egLywBx6XayJjOoobZHgYLmJpcGqlES3T4nO9IJnw=; b=GxEUF/mCUMVCKT5nzmeUCxVm0VYUy9eNpqskIkS+Ymqzu6rlYMnNnx6ysfuz8yhG6g /qTNwLKnIGjTKKckr3GAHNMQmOPuWddFvEB6uNTbUKkckKoVDl97luVlxizEpcBc+VNK uvQP8h7F+J13oqa9Hn0FWHDLmqf06SIcl1ujo= 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=o7egLywBx6XayJjOoobZHgYLmJpcGqlES3T4nO9IJnw=; b=rEU2plSgxbrUaDvk070UIisBHyBDdwBWPmj1WbjiiMPbjYlRR19q2BGsNWCW50GTO5 NCO3hOOOF4XyWJCUweFmHX0rVKzyZ/0veDYYzznVFyYaN28HMi724VDeq4WZyHhV/AeF bm++DpAbRCLHUrMHRvYkeNCZCqxe1LSmGrXDO34wmFxq1NbakZiGjW3lJU4m73PFapLe BkJ2z7HFQX4MshQNj4/L4MPGFoFMU5an796h/N9bjwI+8ijsPexJijrDgm0x1oVtjMtT 00jKTTpPHHpNg7noA8v8iq8xw7wzeDVrxm6GO3O6ZpVfoMKMJSmy42aB2FrlcReVphIk iiJA== X-Gm-Message-State: AJcUukfhHi/va05HVcpWol47FQeRdb2aWFIvkM26pSHu9eoNpEo0V+YR 1+iAQOyKWn7WMyJ7aUFhPK4XYzM1 X-Google-Smtp-Source: ALg8bN7PsIT7vScnvB02yRzQ1C4AY/iarOWVLV7Hm8+12JLqAvfUTagRnFwiEFOt0Qn7FXOgI+Odkg== X-Received: by 2002:a62:2f06:: with SMTP id v6mr8067333pfv.216.1548361472700; Thu, 24 Jan 2019 12:24:32 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id c72sm45263309pfb.107.2019.01.24.12.24.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Jan 2019 12:24:31 -0800 (PST) From: John Stultz To: lkml Cc: Youlin Wang , Dan Williams , Vinod Koul , Zhuangluan Su , Ryan Grachek , Manivannan Sadhasivam , dmaengine@vger.kernel.org, Tanglei Han , John Stultz Subject: [PATCH 3/8 v5] dma: k3dma: Upgrade k3dma driver to support hisi_asp_dma hardware Date: Thu, 24 Jan 2019 12:24:18 -0800 Message-Id: <1548361463-28372-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548361463-28372-1-git-send-email-john.stultz@linaro.org> References: <1548361463-28372-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 (Peripheral 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 v5: * Typo, whitespace fixes. Use BIT() macro. --- drivers/dma/k3dma.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c index fdec2b6..4dce532 100644 --- a/drivers/dma/k3dma.c +++ b/drivers/dma/k3dma.c @@ -116,6 +116,14 @@ struct k3_dma_dev { unsigned int irq; }; + +#define K3_FLAG_NOCLK BIT(1) + +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 +798,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 +831,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 +845,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 +861,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);