Skip to content

Commit ce0eff0

Browse files
Eugeniy Paltsevvineetgarc
authored andcommitted
ARC: [plat-hsdk]: allow to switch between AXI DMAC port configurations
We want to use DW AXI DMAC on HSDK board in our automated verification to test cache & dma kernel code changes. This is perfect candidate as we don't depend on any external peripherals like MMC card / USB storage / etc. To increase test coverage we want to test both options: * DW AXI DMAC is connected through IOC port & dma direct ops used * DW AXI DMAC is connected to DDR port & dma noncoherent ops used Introduce 'arc_hsdk_axi_dmac_coherent' global variable which can be modified by debugger (same way as we patch 'ioc_enable') to switch between these options without recompiling the kernel. Depend on this value we tweak memory bridge configuration and "dma-coherent" DTS property of DW AXI DMAC. Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> Acked-by: Alexey Brodkin <abrodkin@synopsys.com> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
1 parent da31076 commit ce0eff0

2 files changed

Lines changed: 78 additions & 12 deletions

File tree

‎arch/arc/boot/dts/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ dtb-y := $(builtindtb-y).dtb
1212
# for CONFIG_OF_ALL_DTBS test
1313
dtstree := $(srctree)/$(src)
1414
dtb- := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
15+
16+
# board-specific dtc flags
17+
DTC_FLAGS_hsdk += --pad 20

‎arch/arc/plat-hsdk/platform.c‎

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
*/
77

88
#include <linux/init.h>
9+
#include <linux/of_fdt.h>
10+
#include <linux/libfdt.h>
911
#include <linux/smp.h>
1012
#include <asm/arcregs.h>
1113
#include <asm/io.h>
1214
#include <asm/mach_desc.h>
1315

16+
int arc_hsdk_axi_dmac_coherent __section(.data) = 0;
17+
1418
#define ARC_CCM_UNUSED_ADDR 0x60000000
1519

1620
static void __init hsdk_init_per_cpu(unsigned int cpu)
@@ -97,6 +101,42 @@ static void __init hsdk_enable_gpio_intc_wire(void)
97101
iowrite32(GPIO_INT_CONNECTED_MASK, (void __iomem *) GPIO_INTEN);
98102
}
99103

104+
static int __init hsdk_tweak_node_coherency(const char *path, bool coherent)
105+
{
106+
void *fdt = initial_boot_params;
107+
const void *prop;
108+
int node, ret;
109+
bool dt_coh_set;
110+
111+
node = fdt_path_offset(fdt, path);
112+
if (node < 0)
113+
goto tweak_fail;
114+
115+
prop = fdt_getprop(fdt, node, "dma-coherent", &ret);
116+
if (!prop && ret != -FDT_ERR_NOTFOUND)
117+
goto tweak_fail;
118+
119+
dt_coh_set = ret != -FDT_ERR_NOTFOUND;
120+
ret = 0;
121+
122+
/* need to remove "dma-coherent" property */
123+
if (dt_coh_set && !coherent)
124+
ret = fdt_delprop(fdt, node, "dma-coherent");
125+
126+
/* need to set "dma-coherent" property */
127+
if (!dt_coh_set && coherent)
128+
ret = fdt_setprop(fdt, node, "dma-coherent", NULL, 0);
129+
130+
if (ret < 0)
131+
goto tweak_fail;
132+
133+
return 0;
134+
135+
tweak_fail:
136+
pr_err("failed to tweak %s to %scoherent\n", path, coherent ? "" : "non");
137+
return -EFAULT;
138+
}
139+
100140
enum hsdk_axi_masters {
101141
M_HS_CORE = 0,
102142
M_HS_RTT,
@@ -162,6 +202,39 @@ enum hsdk_axi_masters {
162202
#define CREG_PAE ((void __iomem *)(CREG_BASE + 0x180))
163203
#define CREG_PAE_UPDT ((void __iomem *)(CREG_BASE + 0x194))
164204

205+
static void __init hsdk_init_memory_bridge_axi_dmac(void)
206+
{
207+
bool coherent = !!arc_hsdk_axi_dmac_coherent;
208+
u32 axi_m_slv1, axi_m_oft1;
209+
210+
/*
211+
* Don't tweak memory bridge configuration if we failed to tweak DTB
212+
* as we will end up in a inconsistent state.
213+
*/
214+
if (hsdk_tweak_node_coherency("/soc/dmac@80000", coherent))
215+
return;
216+
217+
if (coherent) {
218+
axi_m_slv1 = 0x77999999;
219+
axi_m_oft1 = 0x76DCBA98;
220+
} else {
221+
axi_m_slv1 = 0x77777777;
222+
axi_m_oft1 = 0x76543210;
223+
}
224+
225+
writel(0x77777777, CREG_AXI_M_SLV0(M_DMAC_0));
226+
writel(0xFEDCBA98, CREG_AXI_M_OFT0(M_DMAC_0));
227+
writel(axi_m_slv1, CREG_AXI_M_SLV1(M_DMAC_0));
228+
writel(axi_m_oft1, CREG_AXI_M_OFT1(M_DMAC_0));
229+
writel(UPDATE_VAL, CREG_AXI_M_UPDT(M_DMAC_0));
230+
231+
writel(0x77777777, CREG_AXI_M_SLV0(M_DMAC_1));
232+
writel(0xFEDCBA98, CREG_AXI_M_OFT0(M_DMAC_1));
233+
writel(axi_m_slv1, CREG_AXI_M_SLV1(M_DMAC_1));
234+
writel(axi_m_oft1, CREG_AXI_M_OFT1(M_DMAC_1));
235+
writel(UPDATE_VAL, CREG_AXI_M_UPDT(M_DMAC_1));
236+
}
237+
165238
static void __init hsdk_init_memory_bridge(void)
166239
{
167240
u32 reg;
@@ -227,24 +300,14 @@ static void __init hsdk_init_memory_bridge(void)
227300
writel(0x76543210, CREG_AXI_M_OFT1(M_GPU));
228301
writel(UPDATE_VAL, CREG_AXI_M_UPDT(M_GPU));
229302

230-
writel(0x77777777, CREG_AXI_M_SLV0(M_DMAC_0));
231-
writel(0x77777777, CREG_AXI_M_SLV1(M_DMAC_0));
232-
writel(0xFEDCBA98, CREG_AXI_M_OFT0(M_DMAC_0));
233-
writel(0x76543210, CREG_AXI_M_OFT1(M_DMAC_0));
234-
writel(UPDATE_VAL, CREG_AXI_M_UPDT(M_DMAC_0));
235-
236-
writel(0x77777777, CREG_AXI_M_SLV0(M_DMAC_1));
237-
writel(0x77777777, CREG_AXI_M_SLV1(M_DMAC_1));
238-
writel(0xFEDCBA98, CREG_AXI_M_OFT0(M_DMAC_1));
239-
writel(0x76543210, CREG_AXI_M_OFT1(M_DMAC_1));
240-
writel(UPDATE_VAL, CREG_AXI_M_UPDT(M_DMAC_1));
241-
242303
writel(0x00000000, CREG_AXI_M_SLV0(M_DVFS));
243304
writel(0x60000000, CREG_AXI_M_SLV1(M_DVFS));
244305
writel(0x00000000, CREG_AXI_M_OFT0(M_DVFS));
245306
writel(0x00000000, CREG_AXI_M_OFT1(M_DVFS));
246307
writel(UPDATE_VAL, CREG_AXI_M_UPDT(M_DVFS));
247308

309+
hsdk_init_memory_bridge_axi_dmac();
310+
248311
/*
249312
* PAE remapping for DMA clients does not work due to an RTL bug, so
250313
* CREG_PAE register must be programmed to all zeroes, otherwise it

0 commit comments

Comments
 (0)