1f931551bSRalph Campbell /*
2f931551bSRalph Campbell * Copyright (c) 2009 QLogic Corporation. All rights reserved.
3f931551bSRalph Campbell *
4f931551bSRalph Campbell * This software is available to you under a choice of one of two
5f931551bSRalph Campbell * licenses. You may choose to be licensed under the terms of the GNU
6f931551bSRalph Campbell * General Public License (GPL) Version 2, available from the file
7f931551bSRalph Campbell * COPYING in the main directory of this source tree, or the
8f931551bSRalph Campbell * OpenIB.org BSD license below:
9f931551bSRalph Campbell *
10f931551bSRalph Campbell * Redistribution and use in source and binary forms, with or
11f931551bSRalph Campbell * without modification, are permitted provided that the following
12f931551bSRalph Campbell * conditions are met:
13f931551bSRalph Campbell *
14f931551bSRalph Campbell * - Redistributions of source code must retain the above
15f931551bSRalph Campbell * copyright notice, this list of conditions and the following
16f931551bSRalph Campbell * disclaimer.
17f931551bSRalph Campbell *
18f931551bSRalph Campbell * - Redistributions in binary form must reproduce the above
19f931551bSRalph Campbell * copyright notice, this list of conditions and the following
20f931551bSRalph Campbell * disclaimer in the documentation and/or other materials
21f931551bSRalph Campbell * provided with the distribution.
22f931551bSRalph Campbell *
23f931551bSRalph Campbell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24f931551bSRalph Campbell * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25f931551bSRalph Campbell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26f931551bSRalph Campbell * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27f931551bSRalph Campbell * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28f931551bSRalph Campbell * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29f931551bSRalph Campbell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30f931551bSRalph Campbell * SOFTWARE.
31f931551bSRalph Campbell */
32f931551bSRalph Campbell
33f931551bSRalph Campbell #include "qib.h"
34f931551bSRalph Campbell
35f931551bSRalph Campbell /**
36f931551bSRalph Campbell * qib_pio_copy - copy data to MMIO space, in multiples of 32-bits
37f931551bSRalph Campbell * @to: destination, in MMIO space (must be 64-bit aligned)
38f931551bSRalph Campbell * @from: source (must be 64-bit aligned)
39f931551bSRalph Campbell * @count: number of 32-bit quantities to copy
40f931551bSRalph Campbell *
41f931551bSRalph Campbell * Copy data from kernel space to MMIO space, in multiples of 32 bits at a
42f931551bSRalph Campbell * time. Order of access is not guaranteed, nor is a memory barrier
43f931551bSRalph Campbell * performed afterwards.
44f931551bSRalph Campbell */
qib_pio_copy(void __iomem * to,const void * from,size_t count)45f931551bSRalph Campbell void qib_pio_copy(void __iomem *to, const void *from, size_t count)
46f931551bSRalph Campbell {
47f931551bSRalph Campbell #ifdef CONFIG_64BIT
48f931551bSRalph Campbell u64 __iomem *dst = to;
49f931551bSRalph Campbell const u64 *src = from;
50f931551bSRalph Campbell const u64 *end = src + (count >> 1);
51f931551bSRalph Campbell
52f931551bSRalph Campbell while (src < end)
53f931551bSRalph Campbell __raw_writeq(*src++, dst++);
54f931551bSRalph Campbell if (count & 1)
55f931551bSRalph Campbell __raw_writel(*(const u32 *)src, dst);
56f931551bSRalph Campbell #else
57f931551bSRalph Campbell u32 __iomem *dst = to;
58f931551bSRalph Campbell const u32 *src = from;
59f931551bSRalph Campbell const u32 *end = src + count;
60f931551bSRalph Campbell
61f931551bSRalph Campbell while (src < end)
62f931551bSRalph Campbell __raw_writel(*src++, dst++);
63f931551bSRalph Campbell #endif
64f931551bSRalph Campbell }
65