From patchwork Wed May 25 16:06:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 68630 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1301624qge; Wed, 25 May 2016 09:09:55 -0700 (PDT) X-Received: by 10.98.152.66 with SMTP id q63mr7070084pfd.38.1464192595542; Wed, 25 May 2016 09:09:55 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id j69si24874212pfa.97.2016.05.25.09.09.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 May 2016 09:09:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b5bMX-0005Tm-9U; Wed, 25 May 2016 16:08:49 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b5bLM-0004lH-JH for linux-arm-kernel@lists.infradead.org; Wed, 25 May 2016 16:07:37 +0000 Received: by mail-wm0-x236.google.com with SMTP id a136so133989499wme.0 for ; Wed, 25 May 2016 09:07:17 -0700 (PDT) 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=0irTd+vwUutL0Qn7RByWnEzaJFBHjnYdSfZnidaCL3Y=; b=kkRq9+hhYSMSxB2824UOXZTahExRkMID5wo7OLSvC+mvk9AQ+MbM9E71tVC+D+KvbX sRXnxMW3n+6zq5gzR4t/ccNVu8N6EcHn2UMn/Uy/fiDyxgTU7zjJfCLG1VZUXf6QT1N+ GBHNSB6KqfkKpQuJ8ilz6qjhVpqQ8w3nlWoZI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0irTd+vwUutL0Qn7RByWnEzaJFBHjnYdSfZnidaCL3Y=; b=aOsY/a6XLKfddeLxI7RfFidJIlznoUGZW22BN7PAwqnzY0yaPoYAFbNN1I0KRHwI2y S4xF/nySqFlZHc+t8aQLwhwooDMu5SL66PWL0f9q4CEwdPr86RUv5ank6Jzj71PYBlli c9FxDK0oyvQ3gD01bzbrMlt277S7C0qThob6DhgsJIZBflEJQmrtqoArHyfvgd3piHli chl8F6Nmu8dxXDLHAbfHssrEy2N7XhGdOtsDXErgcFYl9XdKL8YOobDhibN54L5okU/f Jhz+FtWmIViCcErsjKbIFqzzpp/zkJHvVIFVmx1tyU6EOe3rd8vRa5vvmfY2RRJ7psPZ h6+A== X-Gm-Message-State: ALyK8tLbl243tL7HFqAFXvieaBUSZkCT0sMZOhYyHtSmWefeMOEL/2SiJIHSBe6rIZBuSwHH X-Received: by 10.28.217.79 with SMTP id q76mr4332249wmg.83.1464192436576; Wed, 25 May 2016 09:07:16 -0700 (PDT) Received: from localhost.localdomain (cpc84731-aztw28-2-0-cust112.18-1.cable.virginm.net. [82.37.67.113]) by smtp.gmail.com with ESMTPSA id k127sm10039103wmf.21.2016.05.25.09.07.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 09:07:15 -0700 (PDT) From: Peter Griffin To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, srinivas.kandagatla@gmail.com, maxime.coquelin@st.com, patrice.chotard@st.com, vinod.koul@intel.com, ohad@wizery.com, bjorn.andersson@linaro.org, arnd@arndb.de Subject: [PATCH v4 05/18] dmaengine: st_fdma: Add STMicroelectronics FDMA driver header file Date: Wed, 25 May 2016 17:06:39 +0100 Message-Id: <1464192412-16386-7-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464192412-16386-1-git-send-email-peter.griffin@linaro.org> References: <1464192412-16386-1-git-send-email-peter.griffin@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160525_090736_922537_04E32705 X-CRM114-Status: GOOD ( 18.00 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:236 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-remoteproc@vger.kernel.org, peter.griffin@linaro.org, dmaengine@vger.kernel.org, lee.jones@linaro.org, Ludovic Barre MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org This header file will also be used by the dma xbar driver in the future. Signed-off-by: Ludovic Barre Signed-off-by: Peter Griffin --- drivers/dma/st_fdma.h | 243 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 drivers/dma/st_fdma.h -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/dma/st_fdma.h b/drivers/dma/st_fdma.h new file mode 100644 index 0000000..6921d21 --- /dev/null +++ b/drivers/dma/st_fdma.h @@ -0,0 +1,243 @@ +/* + * st_fdma.h + * + * Copyright (C) 2014 STMicroelectronics + * Author: Ludovic Barre + * License terms: GNU General Public License (GPL), version 2 + */ +#ifndef __DMA_ST_FDMA_H +#define __DMA_ST_FDMA_H + +#include +#include +#include + +#include "virt-dma.h" + +#define ST_FDMA_NR_DREQS 32 + +#define FW_NAME_SIZE 30 + +/** + * struct st_fdma_generic_node - Free running/paced generic node + * + * @length: Length in bytes of a line in a 2D mem to mem + * @sstride: Stride, in bytes, between source lines in a 2D data move + * @dstride: Stride, in bytes, between destination lines in a 2D data move + */ +struct st_fdma_generic_node { + u32 length; + u32 sstride; + u32 dstride; +}; + +/** + * struct st_fdma_hw_node - Node structure used by fdma hw + * + * @next: Pointer to next node + * @control: Transfer Control Parameters + * @nbytes: Number of Bytes to read + * @saddr: Source address + * @daddr: Destination address + * + * @generic: generic node for free running/paced transfert type + * 2 others transfert type are possible, but not yet implemented + * + * The NODE structures must be aligned to a 32 byte boundary + */ +struct st_fdma_hw_node { + u32 next; + u32 control; + u32 nbytes; + u32 saddr; + u32 daddr; + union { + struct st_fdma_generic_node generic; + }; +} __aligned(32); + +/* + * node control parameters + */ +#define NODE_CTRL_REQ_MAP_MASK GENMASK(4, 0) +#define NODE_CTRL_REQ_MAP_FREE_RUN 0x0 +#define NODE_CTRL_REQ_MAP_DREQ(n) ((n) & NODE_CTRL_REQ_MAP_MASK) +#define NODE_CTRL_REQ_MAP_EXT NODE_CTRL_REQ_MAP_MASK +#define NODE_CTRL_SRC_MASK GENMASK(6, 5) +#define NODE_CTRL_SRC_STATIC BIT(5) +#define NODE_CTRL_SRC_INCR BIT(6) +#define NODE_CTRL_DST_MASK GENMASK(8, 7) +#define NODE_CTRL_DST_STATIC BIT(7) +#define NODE_CTRL_DST_INCR BIT(8) +#define NODE_CTRL_SECURE BIT(15) +#define NODE_CTRL_PAUSE_EON BIT(30) +#define NODE_CTRL_INT_EON BIT(31) + +/** + * struct st_fdma_sw_node - descriptor structure for link list + * + * @pdesc: Physical address of desc + * @node: link used for putting this into a channel queue + */ +struct st_fdma_sw_node { + dma_addr_t pdesc; + struct st_fdma_hw_node *desc; +}; + +#define NAME_SZ 10 + +struct st_fdma_driverdata { + u32 id; + char name[NAME_SZ]; +}; + +struct st_fdma_desc { + struct virt_dma_desc vdesc; + struct st_fdma_chan *fchan; + bool iscyclic; + unsigned int n_nodes; + struct st_fdma_sw_node node[]; +}; + +enum st_fdma_type { + ST_FDMA_TYPE_FREE_RUN, + ST_FDMA_TYPE_PACED, +}; + +struct st_fdma_cfg { + struct device_node *of_node; + enum st_fdma_type type; + dma_addr_t dev_addr; + enum dma_transfer_direction dir; + int req_line; /* request line */ + long req_ctrl; /* Request control */ +}; + +struct st_fdma_chan { + struct st_fdma_dev *fdev; + struct dma_pool *node_pool; + struct dma_slave_config scfg; + struct st_fdma_cfg cfg; + + int dreq_line; + + struct virt_dma_chan vchan; + struct st_fdma_desc *fdesc; + enum dma_status status; +}; + +struct st_fdma_dev { + struct device *dev; + const struct st_fdma_driverdata *drvdata; + struct dma_device dma_device; + + struct st_xp70_rproc *xp70_rproc; + + int irq; + + struct st_fdma_chan *chans; + + spinlock_t dreq_lock; + unsigned long dreq_mask; + + u32 nr_channels; + char fw_name[FW_NAME_SIZE]; + + struct rproc *rproc; +}; + +/* Peripheral Registers*/ + +#define FDMA_CMD_STA_OFST 0xFC0 +#define FDMA_CMD_SET_OFST 0xFC4 +#define FDMA_CMD_CLR_OFST 0xFC8 +#define FDMA_CMD_MASK_OFST 0xFCC +#define FDMA_CMD_START(ch) (0x1 << (ch << 1)) +#define FDMA_CMD_PAUSE(ch) (0x2 << (ch << 1)) +#define FDMA_CMD_FLUSH(ch) (0x3 << (ch << 1)) + +#define FDMA_INT_STA_OFST 0xFD0 +#define FDMA_INT_STA_CH 0x1 +#define FDMA_INT_STA_ERR 0x2 + +#define FDMA_INT_SET_OFST 0xFD4 +#define FDMA_INT_CLR_OFST 0xFD8 +#define FDMA_INT_MASK_OFST 0xFDC + +#define fdma_read(fdev, name) \ + readl_relaxed((fdev)->xp70_rproc->peri + name) + +#define fdma_write(fdev, val, name) \ + writel_relaxed((val), (fdev)->xp70_rproc->peri + name) + +/* fchan interface (dmem)*/ +#define FDMA_CH_CMD_OFST 0x200 +#define FDMA_CH_CMD_STA_MASK GENMASK(1, 0) +#define FDMA_CH_CMD_STA_IDLE (0x0) +#define FDMA_CH_CMD_STA_START (0x1) +#define FDMA_CH_CMD_STA_RUNNING (0x2) +#define FDMA_CH_CMD_STA_PAUSED (0x3) +#define FDMA_CH_CMD_ERR_MASK GENMASK(4, 2) +#define FDMA_CH_CMD_ERR_INT (0x0 << 2) +#define FDMA_CH_CMD_ERR_NAND (0x1 << 2) +#define FDMA_CH_CMD_ERR_MCHI (0x2 << 2) +#define FDMA_CH_CMD_DATA_MASK GENMASK(31, 5) +#define fchan_read(fchan, name) \ + readl_relaxed((fchan)->fdev->xp70_rproc->mem[DMEM].cpu_addr \ + + (fchan)->vchan.chan.chan_id * 0x4 \ + + name) + +#define fchan_write(fchan, val, name) \ + writel_relaxed((val), (fchan)->fdev->xp70_rproc->mem[DMEM].cpu_addr \ + + (fchan)->vchan.chan.chan_id * 0x4 \ + + name) + +/* req interface */ +#define FDMA_REQ_CTRL_OFST 0x240 +#define dreq_write(fchan, val, name) \ + writel_relaxed((val), (fchan)->fdev->xp70_rproc->mem[DMEM].cpu_addr \ + + fchan->dreq_line * 0x04 \ + + name) +/* node interface */ +#define FDMA_NODE_SZ 128 +#define FDMA_PTRN_OFST 0x800 +#define FDMA_CNTN_OFST 0x808 +#define FDMA_SADDRN_OFST 0x80c +#define FDMA_DADDRN_OFST 0x810 +#define fnode_read(fchan, name) \ + readl_relaxed((fchan)->fdev->xp70_rproc->mem[DMEM].cpu_addr \ + + (fchan)->vchan.chan.chan_id * FDMA_NODE_SZ \ + + name) + +#define fnode_write(fchan, val, name) \ + writel_relaxed((val), (fchan)->fdev->xp70_rproc->mem[DMEM].cpu_addr \ + + (fchan)->vchan.chan.chan_id * FDMA_NODE_SZ \ + + name) + +/* + * request control bits + */ +#define REQ_CTRL_NUM_OPS_MASK GENMASK(31, 24) +#define REQ_CTRL_NUM_OPS(n) (REQ_CTRL_NUM_OPS_MASK & ((n) << 24)) +#define REQ_CTRL_INITIATOR_MASK BIT(22) +#define REQ_CTRL_INIT0 (0x0 << 22) +#define REQ_CTRL_INIT1 (0x1 << 22) +#define REQ_CTRL_INC_ADDR_ON BIT(21) +#define REQ_CTRL_DATA_SWAP_ON BIT(17) +#define REQ_CTRL_WNR BIT(14) +#define REQ_CTRL_OPCODE_MASK GENMASK(7, 4) +#define REQ_CTRL_OPCODE_LD_ST1 (0x0 << 4) +#define REQ_CTRL_OPCODE_LD_ST2 (0x1 << 4) +#define REQ_CTRL_OPCODE_LD_ST4 (0x2 << 4) +#define REQ_CTRL_OPCODE_LD_ST8 (0x3 << 4) +#define REQ_CTRL_OPCODE_LD_ST16 (0x4 << 4) +#define REQ_CTRL_OPCODE_LD_ST32 (0x5 << 4) +#define REQ_CTRL_OPCODE_LD_ST64 (0x6 << 4) +#define REQ_CTRL_HOLDOFF_MASK GENMASK(2, 0) +#define REQ_CTRL_HOLDOFF(n) ((n) & REQ_CTRL_HOLDOFF_MASK) + +/* bits used by client to configure request control */ +#define REQ_CTRL_CFG_MASK (REQ_CTRL_HOLDOFF_MASK | REQ_CTRL_DATA_SWAP_ON \ + | REQ_CTRL_INC_ADDR_ON | REQ_CTRL_INITIATOR_MASK) + +#endif /* __DMA_ST_FDMA_H */