Skip to content

Commit 3440caf

Browse files
Christoph Hellwigtsbogend
authored andcommitted
MIPS/alchemy: factor out the DMA coherent setup
Factor out a alchemy_dma_coherent helper that determines if the platform is DMA coherent. Also stop initializing the hw_coherentio variable, given that is only ever set to a non-zero value by the malta setup code. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 04e4783 commit 3440caf

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

arch/mips/alchemy/common/setup.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@
3737
extern void __init board_setup(void);
3838
extern void __init alchemy_set_lpj(void);
3939

40+
static bool alchemy_dma_coherent(void)
41+
{
42+
switch (alchemy_get_cputype()) {
43+
case ALCHEMY_CPU_AU1000:
44+
case ALCHEMY_CPU_AU1500:
45+
case ALCHEMY_CPU_AU1100:
46+
return false;
47+
case ALCHEMY_CPU_AU1200:
48+
/* Au1200 AB USB does not support coherent memory */
49+
if ((read_c0_prid() & PRID_REV_MASK) == 0)
50+
return false;
51+
return true;
52+
default:
53+
return true;
54+
}
55+
}
56+
4057
void __init plat_mem_setup(void)
4158
{
4259
alchemy_set_lpj();
@@ -48,20 +65,8 @@ void __init plat_mem_setup(void)
4865
/* Clear to obtain best system bus performance */
4966
clear_c0_config(1 << 19); /* Clear Config[OD] */
5067

51-
hw_coherentio = 0;
52-
coherentio = IO_COHERENCE_ENABLED;
53-
switch (alchemy_get_cputype()) {
54-
case ALCHEMY_CPU_AU1000:
55-
case ALCHEMY_CPU_AU1500:
56-
case ALCHEMY_CPU_AU1100:
57-
coherentio = IO_COHERENCE_DISABLED;
58-
break;
59-
case ALCHEMY_CPU_AU1200:
60-
/* Au1200 AB USB does not support coherent memory */
61-
if (0 == (read_c0_prid() & PRID_REV_MASK))
62-
coherentio = IO_COHERENCE_DISABLED;
63-
break;
64-
}
68+
coherentio = alchemy_dma_coherent() ?
69+
IO_COHERENCE_ENABLED : IO_COHERENCE_DISABLED;
6570

6671
board_setup(); /* board specific setup */
6772

0 commit comments

Comments
 (0)