1*97549c34SHans Petter Selasky /*
2*97549c34SHans Petter Selasky * Copyright (c) 2006-2007 Mellanox Technologies. All rights reserved.
3*97549c34SHans Petter Selasky *
4*97549c34SHans Petter Selasky * This software is available to you under a choice of one of two
5*97549c34SHans Petter Selasky * licenses. You may choose to be licensed under the terms of the GNU
6*97549c34SHans Petter Selasky * General Public License (GPL) Version 2, available from the file
7*97549c34SHans Petter Selasky * COPYING in the main directory of this source tree, or the
8*97549c34SHans Petter Selasky * OpenIB.org BSD license below:
9*97549c34SHans Petter Selasky *
10*97549c34SHans Petter Selasky * Redistribution and use in source and binary forms, with or
11*97549c34SHans Petter Selasky * without modification, are permitted provided that the following
12*97549c34SHans Petter Selasky * conditions are met:
13*97549c34SHans Petter Selasky *
14*97549c34SHans Petter Selasky * - Redistributions of source code must retain the above
15*97549c34SHans Petter Selasky * copyright notice, this list of conditions and the following
16*97549c34SHans Petter Selasky * disclaimer.
17*97549c34SHans Petter Selasky *
18*97549c34SHans Petter Selasky * - Redistributions in binary form must reproduce the above
19*97549c34SHans Petter Selasky * copyright notice, this list of conditions and the following
20*97549c34SHans Petter Selasky * disclaimer in the documentation and/or other materials
21*97549c34SHans Petter Selasky * provided with the distribution.
22*97549c34SHans Petter Selasky *
23*97549c34SHans Petter Selasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24*97549c34SHans Petter Selasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25*97549c34SHans Petter Selasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26*97549c34SHans Petter Selasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27*97549c34SHans Petter Selasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28*97549c34SHans Petter Selasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29*97549c34SHans Petter Selasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30*97549c34SHans Petter Selasky * SOFTWARE.
31*97549c34SHans Petter Selasky */
32*97549c34SHans Petter Selasky
33*97549c34SHans Petter Selasky #include <linux/pci.h>
34*97549c34SHans Petter Selasky #include "wc.h"
35*97549c34SHans Petter Selasky
36*97549c34SHans Petter Selasky #if defined(__i386__) || defined(__x86_64__)
37*97549c34SHans Petter Selasky
pgprot_wc(pgprot_t _prot)38*97549c34SHans Petter Selasky pgprot_t pgprot_wc(pgprot_t _prot)
39*97549c34SHans Petter Selasky {
40*97549c34SHans Petter Selasky return pgprot_writecombine(_prot);
41*97549c34SHans Petter Selasky }
42*97549c34SHans Petter Selasky
mlx4_wc_enabled(void)43*97549c34SHans Petter Selasky int mlx4_wc_enabled(void)
44*97549c34SHans Petter Selasky {
45*97549c34SHans Petter Selasky return 1;
46*97549c34SHans Petter Selasky }
47*97549c34SHans Petter Selasky
48*97549c34SHans Petter Selasky #elif defined(CONFIG_PPC64)
49*97549c34SHans Petter Selasky
pgprot_wc(pgprot_t _prot)50*97549c34SHans Petter Selasky pgprot_t pgprot_wc(pgprot_t _prot)
51*97549c34SHans Petter Selasky {
52*97549c34SHans Petter Selasky return __pgprot((pgprot_val(_prot) | _PAGE_NO_CACHE) &
53*97549c34SHans Petter Selasky ~(pgprot_t)_PAGE_GUARDED);
54*97549c34SHans Petter Selasky }
55*97549c34SHans Petter Selasky
mlx4_wc_enabled(void)56*97549c34SHans Petter Selasky int mlx4_wc_enabled(void)
57*97549c34SHans Petter Selasky {
58*97549c34SHans Petter Selasky return 1;
59*97549c34SHans Petter Selasky }
60*97549c34SHans Petter Selasky
61*97549c34SHans Petter Selasky #else /* !(defined(__i386__) || defined(__x86_64__)) */
62*97549c34SHans Petter Selasky
pgprot_wc(pgprot_t _prot)63*97549c34SHans Petter Selasky pgprot_t pgprot_wc(pgprot_t _prot)
64*97549c34SHans Petter Selasky {
65*97549c34SHans Petter Selasky return pgprot_noncached(_prot);
66*97549c34SHans Petter Selasky }
67*97549c34SHans Petter Selasky
mlx4_wc_enabled(void)68*97549c34SHans Petter Selasky int mlx4_wc_enabled(void)
69*97549c34SHans Petter Selasky {
70*97549c34SHans Petter Selasky return 0;
71*97549c34SHans Petter Selasky }
72*97549c34SHans Petter Selasky
73*97549c34SHans Petter Selasky #endif
74