Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753309AbbH0QES (ORCPT ); Thu, 27 Aug 2015 12:04:18 -0400 Received: from mail-by2on0088.outbound.protection.outlook.com ([207.46.100.88]:27072 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752471AbbH0QEO (ORCPT ); Thu, 27 Aug 2015 12:04:14 -0400 X-Greylist: delayed 878 seconds by postgrey-1.27 at vger.kernel.org; Thu, 27 Aug 2015 12:04:14 EDT Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; From: Anurag Kumar Vulisha To: Rob Herring , Pawel Moll , "Mark Rutland" , Ian Campbell , Kumar Gala , Michal Simek , , Dan Williams , "Vinod Koul" , , Maxime Ripard , Laurent Pinchart , Kedareswara rao Appana , , CC: , , , , "Anurag Kumar Vulisha" Subject: [PATCH v2] dmaengine: vdma: Add 64 bit addressing support to the driver Date: Thu, 27 Aug 2015 21:19:18 +0530 Message-ID: <1440690558-39822-1-git-send-email-anuragku@xilinx.com> X-Mailer: git-send-email 1.7.4 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21774.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD041;1:mxvJXWEGdTvF58qyIgDJouGSRl7eDuCK4dN4GBg2hae72x7FUeBSCjg31CEy1sCWWarb3LbTeOl1eth3aP9SJr2X36T8DLONgirY1LuTi+R69gfHEz05eSebB2U2AsDKBZfuBvLhpYlWDmry6a8BW/PQh2UoRWcnlE9YQqApP5tMEJVNAO/AKUSaezwnP6ZVHPCZSaUsh3iN4a85adHz/9/Gotx/e5f61NB430VDRWf7cTGWkDyJsgVza9QeUWoarO0PiYsJ1x7bOzFse0e43B+sC80CXOvrCTVd/amj9aQzI+C/LoipQj4QQVTxZSsjdNyh0l6qXar3D8TOlTnXilEMXlSEOF7bjbaIvtn/RWYeiS4CGgwBaoZRz5DA0uiEAjoe/lqcEr9kqay1vxu/hQ== X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(3050300001)(189002)(199003)(229853001)(50226001)(50986999)(103686003)(19580395003)(86362001)(575784001)(6806004)(47776003)(52956003)(2201001)(106466001)(87936001)(5007970100001)(4001450100002)(64706001)(62966003)(33646002)(19580405001)(77156002)(5001960100002)(92566002)(63266004)(48376002)(50466002)(46386002)(5001830100001)(5001860100001)(5003940100001)(189998001)(5001770100001)(45336002)(107886002)(5001920100001)(42186005)(36756003)(46102003)(36386004)(4001540100001)(81156007)(921003)(107986001)(90966001)(1121003)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2FFO11HUB027;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB027;2:96XQMlKPKie9sAkqphXdK50NOzxVrn0C6TnQV1C8sdmYCbRBVX5JCYEr25kjoTvqonMpOUHALLO+fdZm5YuXpitNPK86RJRfX+TWr0SuBP88VSzHb1AGctRwbwS6kKr2W2NVEgFWlewmr6Lh/AucMzmQGOK+z/3AUv82ATU9yME=;3:vTMz7UR3kbLwlwKDA+Sm6aNR3Mtp3elkJqEq9xBqsOKnkSvc5Lpcf5PWCwiaozGyuxM0lcl8wv63QwB2NV+XPY6tcheqwsfAku1eXWeGcba0GezvetfJ7cfT+LE9VWzRQjvgpvk3CDnr+VIJYOI3kPLRQDmu/zvrGwJKK0Rcib7lP1TykJy8EJLAAZ8gtXd2CWubQSRSRphoqNEWEy9ZpzJY4A2vi29Xm5f2aruwwRS0XsdzYTubNb6MTs3UUKE8rfTfBiJpza8I1D9pYWscmg==;25:vD2zuw23zU6mGPfAJU+a4Xf5sGqQXv1JJJnZSxS24ClQw2vLLxG20yQErssl3NA+HIFhmyR2dS9PaGYMcyMULVA0edi6ASPJW17ruXTbhjiigF2uolMD2VSsbVmRonREdkRhS6F/ulHNh36QV81NyUA2JxW0ScDFWYntALskyDgf2de5UAw+oyD3ACRwzem1D3zdd8dkOB0kH4380F1WQtMruf71B+KHg9J6gQ6W2TAaIK6+xzoJws1BzxTTtxlloRr/8pA4x3fgspvRKdVwPg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501001);SRVR:BL2FFO11HUB027; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB027;20:ax6r5i8Y7SYlx3h6rcnZn9fYWOUoh624BaY6HPGCLcbVm6yyQJTscFznYCoNCnUHvESTRZYqMIu/VLIsZ8vFIG55SyKZlfEIt4IlI2tp56He4pqZ3xL86kf6WFxehtdXIO71sMz5NYnM5g+8WlyZ8A01jGCMM5o+DdNmPZNKXh/xZisvmKgtsemo5mA6Pa8ChisE1j93IpIh8mpCKAlcNJ8iV40sEwjA8PwNkVTxOBJm1nojmvvD1t/sEFT2pI9AmcQIZEAydKE9h4t+peKwBH/Zk8vggpby0b0FZ8gOtQJJLRgxQCEx4KN2pTHaOMfBdix9mTT4G3EIAIWuhtzFIR1quWykEij1NEUPOPU6xwVmXOSnBEZqiJ1+zNxDsMmY/XONmhHiQBQWMfD5dxIxhGxPauLLc7qUl7ADh5q8RSVjqofvCGVtUeIybbtCmG1uFKU+Tr5B3M2bzBlOJSa89VurpO219J4sYbazoJ552JnHo8jki4MM5tQimlnmMy7n;4:T1UggI9ODshr3VALAi3t3n50LeoqY13E7ZUQ6MuIoljy248nQ/hkTrkV9S78V3ex4wf1xrUzgGahSss/WSUj/u4aWMzV1AL1vevaj7fiFTRu/yAfpQUUtdee1ZP//YxWtpejS/1UrIUSqPm7k4Gx5Sizxtl65RvL3D/RJOwih6BHaqKjJAGub/S+xwBxvaB27L4eKJsd1lna2Z35H0MeMKPqj68etmqQZyj2sYUGP5QO0DTUWZU6zxMnbMSK/6aZMY+VwQQ4aaWy3ucwUrefbzoGoTWrYv5mMK5l7Y8Ju4G1brVJe/wB8ijQel3Gocyhp6Wv7T/r6Rs0jWYJct/7Pg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(8121501046)(5005006)(3002001);SRVR:BL2FFO11HUB027;BCL:0;PCL:0;RULEID:;SRVR:BL2FFO11HUB027; X-Forefront-PRVS: 06818431B9 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2FFO11HUB027;23:RGnC8QIbYy8mIIYlZhf8ovj2JCwGykpZhbl13QSX?= =?us-ascii?Q?+heAqo4mYmbtCcoepG94+rHWTtWz+zbQe+RKSho8u2Rzfn6EYvgtXaeb536P?= =?us-ascii?Q?MDbeQ23Lnjprt9WVP3+R2/RY+IRyToheUT6pyEH+pAWMky3aWfrBIxEE8tj7?= =?us-ascii?Q?Tz6Wo7jkW9fZffUXRcyE/lxH5ZloU9dUUodvX/W3VWGqMg1MddHNyJPuedEq?= =?us-ascii?Q?NG11fW657X/gT+bFYk6YHqfBX1rNuqUIKCbpRlRMsbRrRpiEKpeVnzcMeVqz?= =?us-ascii?Q?4LfOCgtLQd+0aLRK8biZFznsi6ygC8tGr75rEDYG1dPo24LAckT1aPq9Od6q?= =?us-ascii?Q?re/+LGqrPc1Zv72LoDEk61bXbBnW3tzqF/mg6sH11zYn1VJwyINbe8xmIkP4?= =?us-ascii?Q?f22Y1p5xZeKXho1rTDB+YtUD0A1q0CcHJySk3PvRo7+ne7ivMAgJ+xRxiq5P?= =?us-ascii?Q?GSXBZghQKtHkaJ+71RPmjyHmWx2D0/Okm+A8feUveWkvH5SuXpmqfyHT4Icq?= =?us-ascii?Q?u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HUB027;5:AhWgT8gwa0AzFzIFPqeCUTHZJW45+O4x9QA0qyKv8hM9ZXGr+shOe8/XgWDjYYDx4kcdfxOdx4hWVJ69N8TpnTlZuoux0yyqt7o6qhawcFMV51Za3SGmU14kjU1uj/ODbpj3A0JuhcoO4GIF4AH+Tw==;24:31kWBBJZavTAVswmYD7sLCQt3nfucfRa/40aV6cXodla6d9kalsTIW6G/2cgXh4xZo3dI8lc5R39LIZBxstMSg5Nsas7jv5RZC/gPgOCKn0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2015 15:49:33.6691 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2FFO11HUB027 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8668 Lines: 252 This VDMA is a soft ip, which can be programmed to support 32 bit addressing or greater than 32 bit addressing. When the VDMA ip is configured for 32 bit address space the transfer start address is specified by a single register. When the VDMA core is configured for an address space greater than 32 then each start address is specified by a combination of two registers. The first register specifies the LSB 32 bits of address, while the next register specifies the MSB 32 bits of address.For example,5Ch will specify the LSB 32 bits while 60h will specify the MSB 32 bits of the first start address.So we need to program two registers at a time. This patch adds the 64 bit addressing support to the vdma driver. Signed-off-by: Anurag Kumar Vulisha --- Changes in v2: 1. Added dma-ranges property in device tree as suggested by Arnd Bergmann. 2. Added device tree property(xlnx,addrwidth) for an identification of whether the IP block itself is configured in 64-bit or 32-bit mode as suggested by Laurent Pinchart. 3. Modified the driver code based on the xlnx,addrwidth. --- .../devicetree/bindings/dma/xilinx/xilinx_vdma.txt | 4 + drivers/dma/Kconfig | 2 +- drivers/dma/xilinx/xilinx_vdma.c | 81 +++++++++++++++++--- 3 files changed, 76 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/dma/xilinx/xilinx_vdma.txt b/Documentation/devicetree/bindings/dma/xilinx/xilinx_vdma.txt index e4c4d47..434d380 100644 --- a/Documentation/devicetree/bindings/dma/xilinx/xilinx_vdma.txt +++ b/Documentation/devicetree/bindings/dma/xilinx/xilinx_vdma.txt @@ -8,6 +8,8 @@ Required properties: - #dma-cells: Should be <1>, see "dmas" property below - reg: Should contain VDMA registers location and length. - xlnx,num-fstores: Should be the number of framebuffers as configured in h/w. +- xlnx,addrwidth: Should be the vdma addressing size in bits(ex: 32 bits). +- dma-ranges: Should be as the following - dma-channel child node: Should have at least one channel and can have up to two channels per device. This node specifies the properties of each DMA channel (see child node properties below). @@ -41,8 +43,10 @@ axi_vdma_0: axivdma@40030000 { compatible = "xlnx,axi-vdma-1.00.a"; #dma_cells = <1>; reg = < 0x40030000 0x10000 >; + dma-ranges = <0x00000000 0x00000000 0x40000000>; xlnx,num-fstores = <0x8>; xlnx,flush-fsync = <0x1>; + xlnx,addrwidth = <0x20>; dma-channel@40030000 { compatible = "xlnx,axi-vdma-mm2s-channel"; interrupts = < 0 54 4 >; diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index bda2cb0..a7cd0a8 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -398,7 +398,7 @@ config FSL_EDMA config XILINX_VDMA tristate "Xilinx AXI VDMA Engine" - depends on (ARCH_ZYNQ || MICROBLAZE) + depends on (ARCH_ZYNQ || MICROBLAZE || ARM64) select DMA_ENGINE help Enable support for Xilinx AXI VDMA Soft IP. diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c index d8434d4..d4eebc9 100644 --- a/drivers/dma/xilinx/xilinx_vdma.c +++ b/drivers/dma/xilinx/xilinx_vdma.c @@ -98,6 +98,8 @@ #define XILINX_VDMA_FRMDLY_STRIDE_FRMDLY_SHIFT 24 #define XILINX_VDMA_FRMDLY_STRIDE_STRIDE_SHIFT 0 +#define XILINX_VDMA_REG_START_ADDRESS_64(n) (0x000c + 8 * (n)) + #define XILINX_VDMA_REG_START_ADDRESS(n) (0x000c + 4 * (n)) /* HW specific definitions */ @@ -143,16 +145,18 @@ * @next_desc: Next Descriptor Pointer @0x00 * @pad1: Reserved @0x04 * @buf_addr: Buffer address @0x08 - * @pad2: Reserved @0x0C - * @vsize: Vertical Size @0x10 - * @hsize: Horizontal Size @0x14 + * @buf_addr_msb: Buffer msb address @0x0c + * @pad2: Reserved @0x10 + * @vsize: Vertical Size @0x14 + * @hsize: Horizontal Size @0x18 * @stride: Number of bytes between the first - * pixels of each horizontal line @0x18 + * pixels of each horizontal line @0x1C */ struct xilinx_vdma_desc_hw { u32 next_desc; u32 pad1; u32 buf_addr; + u32 buf_addr_msb; u32 pad2; u32 vsize; u32 hsize; @@ -206,6 +210,7 @@ struct xilinx_vdma_tx_descriptor { * @tasklet: Cleanup work after irq * @config: Device configuration info * @flush_on_fsync: Flush on Frame sync + * @ext_addr: Indicates 64 bit addressing is supported by dma channel */ struct xilinx_vdma_chan { struct xilinx_vdma_device *xdev; @@ -229,6 +234,7 @@ struct xilinx_vdma_chan { struct tasklet_struct tasklet; struct xilinx_vdma_config config; bool flush_on_fsync; + bool ext_addr; }; /** @@ -239,6 +245,7 @@ struct xilinx_vdma_chan { * @chan: Driver specific VDMA channel * @has_sg: Specifies whether Scatter-Gather is present or not * @flush_on_fsync: Flush on frame sync + * @ext_addr: Indicates 64 bit addressing is supported by dma device */ struct xilinx_vdma_device { void __iomem *regs; @@ -247,6 +254,7 @@ struct xilinx_vdma_device { struct xilinx_vdma_chan *chan[XILINX_VDMA_MAX_CHANS_PER_DEVICE]; bool has_sg; u32 flush_on_fsync; + bool ext_addr; }; /* Macros */ @@ -272,6 +280,22 @@ static inline void vdma_desc_write(struct xilinx_vdma_chan *chan, u32 reg, vdma_write(chan, chan->desc_offset + reg, value); } + +/* Since vdma driver is trying to write to a register offset which is not a + * multiple of 64 bits(ex : 0x5c), we are writing as two separate 32 bits + * instead of a single 64 bit register write. + */ + +static inline void vdma_desc_write_64(struct xilinx_vdma_chan *chan, u32 reg, + u32 value_lsb, u32 value_msb) +{ + /* Write the lsb 32 bits*/ + writel(value_lsb, chan->xdev->regs + chan->desc_offset + reg); + + /* Write the msb 32 bits */ + writel(value_msb, chan->xdev->regs + chan->desc_offset + reg + 4); +} + static inline u32 vdma_ctrl_read(struct xilinx_vdma_chan *chan, u32 reg) { return vdma_read(chan, chan->ctrl_offset + reg); @@ -700,9 +724,17 @@ static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan) int i = 0; list_for_each_entry(segment, &desc->segments, node) { - vdma_desc_write(chan, + if (chan->ext_addr == true) { + /* vdma supports 64 bit addressing */ + vdma_desc_write_64(chan, + XILINX_VDMA_REG_START_ADDRESS_64(i++), + segment->hw.buf_addr, + segment->hw.buf_addr_msb); + } else { + vdma_desc_write(chan, XILINX_VDMA_REG_START_ADDRESS(i++), segment->hw.buf_addr); + } last = segment; } @@ -968,10 +1000,21 @@ xilinx_vdma_dma_prep_interleaved(struct dma_chan *dchan, hw->stride |= chan->config.frm_dly << XILINX_VDMA_FRMDLY_STRIDE_FRMDLY_SHIFT; - if (xt->dir != DMA_MEM_TO_DEV) - hw->buf_addr = xt->dst_start; - else - hw->buf_addr = xt->src_start; + if (xt->dir != DMA_MEM_TO_DEV) { + if (chan->ext_addr == true) { + hw->buf_addr = lower_32_bits(xt->dst_start); + hw->buf_addr_msb = upper_32_bits(xt->dst_start); + } else { + hw->buf_addr = xt->dst_start; + } + } else { + if (chan->ext_addr == true) { + hw->buf_addr = lower_32_bits(xt->src_start); + hw->buf_addr_msb = upper_32_bits(xt->src_start); + } else { + hw->buf_addr = xt->src_start; + } + } /* Link the previous next descriptor to current */ if (!list_empty(&desc->segments)) { @@ -1124,6 +1167,7 @@ static int xilinx_vdma_chan_probe(struct xilinx_vdma_device *xdev, if (!chan) return -ENOMEM; + chan->ext_addr = xdev->ext_addr; chan->dev = xdev->dev; chan->xdev = xdev; chan->has_sg = xdev->has_sg; @@ -1240,7 +1284,7 @@ static int xilinx_vdma_probe(struct platform_device *pdev) struct xilinx_vdma_device *xdev; struct device_node *child; struct resource *io; - u32 num_frames; + u32 num_frames, addr_width; int i, err; /* Allocate and initialize the DMA engine structure */ @@ -1270,6 +1314,23 @@ static int xilinx_vdma_probe(struct platform_device *pdev) if (err < 0) dev_warn(xdev->dev, "missing xlnx,flush-fsync property\n"); + err = of_property_read_u32(node, "xlnx,addrwidth", &addr_width); + + if (err < 0) { + /* Setting addr_width property to default 32 bits */ + addr_width = 32; + } + + if (addr_width > 32) { + /* VDMA device supports greater than 32 bit addressing*/ + xdev->ext_addr = true; + } else { + xdev->ext_addr = false; + } + + /* Set the dma mask bits */ + dma_set_mask(xdev->dev, DMA_BIT_MASK(addr_width)); + /* Initialize the DMA engine */ xdev->common.dev = &pdev->dev; -- 1.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/