Back to home page

LXR

 
 

    


0001 /*
0002  * Copyright 2006 PathScale, Inc.  All Rights Reserved.
0003  *
0004  * This file is free software; you can redistribute it and/or modify
0005  * it under the terms of version 2 of the GNU General Public License
0006  * as published by the Free Software Foundation.
0007  *
0008  * This program is distributed in the hope that it will be useful,
0009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0011  * GNU General Public License for more details.
0012  *
0013  * You should have received a copy of the GNU General Public License
0014  * along with this program; if not, write to the Free Software Foundation,
0015  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
0016  */
0017 
0018 #include <linux/export.h>
0019 #include <linux/io.h>
0020 
0021 /**
0022  * __iowrite32_copy - copy data to MMIO space, in 32-bit units
0023  * @to: destination, in MMIO space (must be 32-bit aligned)
0024  * @from: source (must be 32-bit aligned)
0025  * @count: number of 32-bit quantities to copy
0026  *
0027  * Copy data from kernel space to MMIO space, in units of 32 bits at a
0028  * time.  Order of access is not guaranteed, nor is a memory barrier
0029  * performed afterwards.
0030  */
0031 void __attribute__((weak)) __iowrite32_copy(void __iomem *to,
0032                         const void *from,
0033                         size_t count)
0034 {
0035     u32 __iomem *dst = to;
0036     const u32 *src = from;
0037     const u32 *end = src + count;
0038 
0039     while (src < end)
0040         __raw_writel(*src++, dst++);
0041 }
0042 EXPORT_SYMBOL_GPL(__iowrite32_copy);
0043 
0044 /**
0045  * __ioread32_copy - copy data from MMIO space, in 32-bit units
0046  * @to: destination (must be 32-bit aligned)
0047  * @from: source, in MMIO space (must be 32-bit aligned)
0048  * @count: number of 32-bit quantities to copy
0049  *
0050  * Copy data from MMIO space to kernel space, in units of 32 bits at a
0051  * time.  Order of access is not guaranteed, nor is a memory barrier
0052  * performed afterwards.
0053  */
0054 void __ioread32_copy(void *to, const void __iomem *from, size_t count)
0055 {
0056     u32 *dst = to;
0057     const u32 __iomem *src = from;
0058     const u32 __iomem *end = src + count;
0059 
0060     while (src < end)
0061         *dst++ = __raw_readl(src++);
0062 }
0063 EXPORT_SYMBOL_GPL(__ioread32_copy);
0064 
0065 /**
0066  * __iowrite64_copy - copy data to MMIO space, in 64-bit or 32-bit units
0067  * @to: destination, in MMIO space (must be 64-bit aligned)
0068  * @from: source (must be 64-bit aligned)
0069  * @count: number of 64-bit quantities to copy
0070  *
0071  * Copy data from kernel space to MMIO space, in units of 32 or 64 bits at a
0072  * time.  Order of access is not guaranteed, nor is a memory barrier
0073  * performed afterwards.
0074  */
0075 void __attribute__((weak)) __iowrite64_copy(void __iomem *to,
0076                         const void *from,
0077                         size_t count)
0078 {
0079 #ifdef CONFIG_64BIT
0080     u64 __iomem *dst = to;
0081     const u64 *src = from;
0082     const u64 *end = src + count;
0083 
0084     while (src < end)
0085         __raw_writeq(*src++, dst++);
0086 #else
0087     __iowrite32_copy(to, from, count * 2);
0088 #endif
0089 }
0090 
0091 EXPORT_SYMBOL_GPL(__iowrite64_copy);