Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: at_xdmac: add AXI priority support and recommended settings

The sama7g5 version of the XDMAC supports priority configuration and
outstanding capabilities.
Add defines for the specific registers for this configuration, together
with recommended settings.
However the settings are very different if the XDMAC is a mem2mem or a
per2mem controller.
Thus, we need to differentiate according to device tree property.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Link: https://lore.kernel.org/r/20201016093918.290137-1-eugen.hristev@microchip.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Eugen Hristev and committed by
Vinod Koul
f40566f2 2bec35a5

+47
+47
drivers/dma/at_xdmac.c
··· 30 30 #define AT_XDMAC_FIFO_SZ(i) (((i) >> 5) & 0x7FF) /* Number of Bytes */ 31 31 #define AT_XDMAC_NB_REQ(i) ((((i) >> 16) & 0x3F) + 1) /* Number of Peripheral Requests Minus One */ 32 32 #define AT_XDMAC_GCFG 0x04 /* Global Configuration Register */ 33 + #define AT_XDMAC_WRHP(i) (((i) & 0xF) << 4) 34 + #define AT_XDMAC_WRMP(i) (((i) & 0xF) << 8) 35 + #define AT_XDMAC_WRLP(i) (((i) & 0xF) << 12) 36 + #define AT_XDMAC_RDHP(i) (((i) & 0xF) << 16) 37 + #define AT_XDMAC_RDMP(i) (((i) & 0xF) << 20) 38 + #define AT_XDMAC_RDLP(i) (((i) & 0xF) << 24) 39 + #define AT_XDMAC_RDSG(i) (((i) & 0xF) << 28) 40 + #define AT_XDMAC_GCFG_M2M (AT_XDMAC_RDLP(0xF) | AT_XDMAC_WRLP(0xF)) 41 + #define AT_XDMAC_GCFG_P2M (AT_XDMAC_RDSG(0x1) | AT_XDMAC_RDHP(0x3) | \ 42 + AT_XDMAC_WRHP(0x5)) 33 43 #define AT_XDMAC_GWAC 0x08 /* Global Weighted Arbiter Configuration Register */ 44 + #define AT_XDMAC_PW0(i) (((i) & 0xF) << 0) 45 + #define AT_XDMAC_PW1(i) (((i) & 0xF) << 4) 46 + #define AT_XDMAC_PW2(i) (((i) & 0xF) << 8) 47 + #define AT_XDMAC_PW3(i) (((i) & 0xF) << 12) 48 + #define AT_XDMAC_GWAC_M2M 0 49 + #define AT_XDMAC_GWAC_P2M (AT_XDMAC_PW0(0xF) | AT_XDMAC_PW2(0xF)) 50 + 34 51 #define AT_XDMAC_GIE 0x0C /* Global Interrupt Enable Register */ 35 52 #define AT_XDMAC_GID 0x10 /* Global Interrupt Disable Register */ 36 53 #define AT_XDMAC_GIM 0x14 /* Global Interrupt Mask Register */ ··· 206 189 u8 chan_cc_reg_base; 207 190 /* Source/Destination Interface must be specified or not */ 208 191 bool sdif; 192 + /* AXI queue priority configuration supported */ 193 + bool axi_config; 209 194 }; 210 195 211 196 /* ----- Channels ----- */ ··· 286 267 .gswf = 0x40, 287 268 .chan_cc_reg_base = 0x50, 288 269 .sdif = true, 270 + .axi_config = false, 289 271 }; 290 272 291 273 static const struct at_xdmac_layout at_xdmac_sama7g5_layout = { ··· 299 279 .gswf = 0x50, 300 280 .chan_cc_reg_base = 0x60, 301 281 .sdif = false, 282 + .axi_config = true, 302 283 }; 303 284 304 285 static inline void __iomem *at_xdmac_chan_reg_base(struct at_xdmac *atxdmac, unsigned int chan_nb) ··· 2018 1997 } 2019 1998 #endif /* CONFIG_PM_SLEEP */ 2020 1999 2000 + static void at_xdmac_axi_config(struct platform_device *pdev) 2001 + { 2002 + struct at_xdmac *atxdmac = (struct at_xdmac *)platform_get_drvdata(pdev); 2003 + bool dev_m2m = false; 2004 + u32 dma_requests; 2005 + 2006 + if (!atxdmac->layout->axi_config) 2007 + return; /* Not supported */ 2008 + 2009 + if (!of_property_read_u32(pdev->dev.of_node, "dma-requests", 2010 + &dma_requests)) { 2011 + dev_info(&pdev->dev, "controller in mem2mem mode.\n"); 2012 + dev_m2m = true; 2013 + } 2014 + 2015 + if (dev_m2m) { 2016 + at_xdmac_write(atxdmac, AT_XDMAC_GCFG, AT_XDMAC_GCFG_M2M); 2017 + at_xdmac_write(atxdmac, AT_XDMAC_GWAC, AT_XDMAC_GWAC_M2M); 2018 + } else { 2019 + at_xdmac_write(atxdmac, AT_XDMAC_GCFG, AT_XDMAC_GCFG_P2M); 2020 + at_xdmac_write(atxdmac, AT_XDMAC_GWAC, AT_XDMAC_GWAC_P2M); 2021 + } 2022 + } 2023 + 2021 2024 static int at_xdmac_probe(struct platform_device *pdev) 2022 2025 { 2023 2026 struct at_xdmac *atxdmac; ··· 2185 2140 2186 2141 dev_info(&pdev->dev, "%d channels, mapped at 0x%p\n", 2187 2142 nr_channels, atxdmac->regs); 2143 + 2144 + at_xdmac_axi_config(pdev); 2188 2145 2189 2146 return 0; 2190 2147