Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright 2006 PathScale, Inc.  All Rights Reserved.
0004  */
0005 
0006 #include <linux/export.h>
0007 #include <linux/io.h>
0008 
0009 /**
0010  * __iowrite32_copy - copy data to MMIO space, in 32-bit units
0011  * @to: destination, in MMIO space (must be 32-bit aligned)
0012  * @from: source (must be 32-bit aligned)
0013  * @count: number of 32-bit quantities to copy
0014  *
0015  * Copy data from kernel space to MMIO space, in units of 32 bits at a
0016  * time.  Order of access is not guaranteed, nor is a memory barrier
0017  * performed afterwards.
0018  */
0019 void __attribute__((weak)) __iowrite32_copy(void __iomem *to,
0020                         const void *from,
0021                         size_t count)
0022 {
0023     u32 __iomem *dst = to;
0024     const u32 *src = from;
0025     const u32 *end = src + count;
0026 
0027     while (src < end)
0028         __raw_writel(*src++, dst++);
0029 }
0030 EXPORT_SYMBOL_GPL(__iowrite32_copy);
0031 
0032 /**
0033  * __ioread32_copy - copy data from MMIO space, in 32-bit units
0034  * @to: destination (must be 32-bit aligned)
0035  * @from: source, in MMIO space (must be 32-bit aligned)
0036  * @count: number of 32-bit quantities to copy
0037  *
0038  * Copy data from MMIO space to kernel space, in units of 32 bits at a
0039  * time.  Order of access is not guaranteed, nor is a memory barrier
0040  * performed afterwards.
0041  */
0042 void __ioread32_copy(void *to, const void __iomem *from, size_t count)
0043 {
0044     u32 *dst = to;
0045     const u32 __iomem *src = from;
0046     const u32 __iomem *end = src + count;
0047 
0048     while (src < end)
0049         *dst++ = __raw_readl(src++);
0050 }
0051 EXPORT_SYMBOL_GPL(__ioread32_copy);
0052 
0053 /**
0054  * __iowrite64_copy - copy data to MMIO space, in 64-bit or 32-bit units
0055  * @to: destination, in MMIO space (must be 64-bit aligned)
0056  * @from: source (must be 64-bit aligned)
0057  * @count: number of 64-bit quantities to copy
0058  *
0059  * Copy data from kernel space to MMIO space, in units of 32 or 64 bits at a
0060  * time.  Order of access is not guaranteed, nor is a memory barrier
0061  * performed afterwards.
0062  */
0063 void __attribute__((weak)) __iowrite64_copy(void __iomem *to,
0064                         const void *from,
0065                         size_t count)
0066 {
0067 #ifdef CONFIG_64BIT
0068     u64 __iomem *dst = to;
0069     const u64 *src = from;
0070     const u64 *end = src + count;
0071 
0072     while (src < end)
0073         __raw_writeq(*src++, dst++);
0074 #else
0075     __iowrite32_copy(to, from, count * 2);
0076 #endif
0077 }
0078 
0079 EXPORT_SYMBOL_GPL(__iowrite64_copy);