18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
38c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
48c2ecf20Sopenharmony_ci * for more details.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 2006  Ralf Baechle <ralf@linux-mips.org>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#ifndef __ASM_DMA_COHERENCE_H
108c2ecf20Sopenharmony_ci#define __ASM_DMA_COHERENCE_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cienum coherent_io_user_state {
138c2ecf20Sopenharmony_ci	IO_COHERENCE_DEFAULT,
148c2ecf20Sopenharmony_ci	IO_COHERENCE_ENABLED,
158c2ecf20Sopenharmony_ci	IO_COHERENCE_DISABLED,
168c2ecf20Sopenharmony_ci};
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#if defined(CONFIG_DMA_PERDEV_COHERENT)
198c2ecf20Sopenharmony_ci/* Don't provide (hw_)coherentio to avoid misuse */
208c2ecf20Sopenharmony_ci#elif defined(CONFIG_DMA_MAYBE_COHERENT)
218c2ecf20Sopenharmony_ciextern enum coherent_io_user_state coherentio;
228c2ecf20Sopenharmony_ciextern int hw_coherentio;
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistatic inline bool dev_is_dma_coherent(struct device *dev)
258c2ecf20Sopenharmony_ci{
268c2ecf20Sopenharmony_ci	return coherentio == IO_COHERENCE_ENABLED ||
278c2ecf20Sopenharmony_ci		(coherentio == IO_COHERENCE_DEFAULT && hw_coherentio);
288c2ecf20Sopenharmony_ci}
298c2ecf20Sopenharmony_ci#else
308c2ecf20Sopenharmony_ci#ifdef CONFIG_DMA_NONCOHERENT
318c2ecf20Sopenharmony_ci#define coherentio	IO_COHERENCE_DISABLED
328c2ecf20Sopenharmony_ci#else
338c2ecf20Sopenharmony_ci#define coherentio	IO_COHERENCE_ENABLED
348c2ecf20Sopenharmony_ci#endif
358c2ecf20Sopenharmony_ci#define hw_coherentio	0
368c2ecf20Sopenharmony_ci#endif /* CONFIG_DMA_MAYBE_COHERENT */
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#endif
39