162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright 2006 PathScale, Inc. All Rights Reserved. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/export.h> 762306a36Sopenharmony_ci#include <linux/io.h> 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/** 1062306a36Sopenharmony_ci * __iowrite32_copy - copy data to MMIO space, in 32-bit units 1162306a36Sopenharmony_ci * @to: destination, in MMIO space (must be 32-bit aligned) 1262306a36Sopenharmony_ci * @from: source (must be 32-bit aligned) 1362306a36Sopenharmony_ci * @count: number of 32-bit quantities to copy 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * Copy data from kernel space to MMIO space, in units of 32 bits at a 1662306a36Sopenharmony_ci * time. Order of access is not guaranteed, nor is a memory barrier 1762306a36Sopenharmony_ci * performed afterwards. 1862306a36Sopenharmony_ci */ 1962306a36Sopenharmony_civoid __attribute__((weak)) __iowrite32_copy(void __iomem *to, 2062306a36Sopenharmony_ci const void *from, 2162306a36Sopenharmony_ci size_t count) 2262306a36Sopenharmony_ci{ 2362306a36Sopenharmony_ci u32 __iomem *dst = to; 2462306a36Sopenharmony_ci const u32 *src = from; 2562306a36Sopenharmony_ci const u32 *end = src + count; 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci while (src < end) 2862306a36Sopenharmony_ci __raw_writel(*src++, dst++); 2962306a36Sopenharmony_ci} 3062306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(__iowrite32_copy); 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci/** 3362306a36Sopenharmony_ci * __ioread32_copy - copy data from MMIO space, in 32-bit units 3462306a36Sopenharmony_ci * @to: destination (must be 32-bit aligned) 3562306a36Sopenharmony_ci * @from: source, in MMIO space (must be 32-bit aligned) 3662306a36Sopenharmony_ci * @count: number of 32-bit quantities to copy 3762306a36Sopenharmony_ci * 3862306a36Sopenharmony_ci * Copy data from MMIO space to kernel space, in units of 32 bits at a 3962306a36Sopenharmony_ci * time. Order of access is not guaranteed, nor is a memory barrier 4062306a36Sopenharmony_ci * performed afterwards. 4162306a36Sopenharmony_ci */ 4262306a36Sopenharmony_civoid __ioread32_copy(void *to, const void __iomem *from, size_t count) 4362306a36Sopenharmony_ci{ 4462306a36Sopenharmony_ci u32 *dst = to; 4562306a36Sopenharmony_ci const u32 __iomem *src = from; 4662306a36Sopenharmony_ci const u32 __iomem *end = src + count; 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci while (src < end) 4962306a36Sopenharmony_ci *dst++ = __raw_readl(src++); 5062306a36Sopenharmony_ci} 5162306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(__ioread32_copy); 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci/** 5462306a36Sopenharmony_ci * __iowrite64_copy - copy data to MMIO space, in 64-bit or 32-bit units 5562306a36Sopenharmony_ci * @to: destination, in MMIO space (must be 64-bit aligned) 5662306a36Sopenharmony_ci * @from: source (must be 64-bit aligned) 5762306a36Sopenharmony_ci * @count: number of 64-bit quantities to copy 5862306a36Sopenharmony_ci * 5962306a36Sopenharmony_ci * Copy data from kernel space to MMIO space, in units of 32 or 64 bits at a 6062306a36Sopenharmony_ci * time. Order of access is not guaranteed, nor is a memory barrier 6162306a36Sopenharmony_ci * performed afterwards. 6262306a36Sopenharmony_ci */ 6362306a36Sopenharmony_civoid __attribute__((weak)) __iowrite64_copy(void __iomem *to, 6462306a36Sopenharmony_ci const void *from, 6562306a36Sopenharmony_ci size_t count) 6662306a36Sopenharmony_ci{ 6762306a36Sopenharmony_ci#ifdef CONFIG_64BIT 6862306a36Sopenharmony_ci u64 __iomem *dst = to; 6962306a36Sopenharmony_ci const u64 *src = from; 7062306a36Sopenharmony_ci const u64 *end = src + count; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci while (src < end) 7362306a36Sopenharmony_ci __raw_writeq(*src++, dst++); 7462306a36Sopenharmony_ci#else 7562306a36Sopenharmony_ci __iowrite32_copy(to, from, count * 2); 7662306a36Sopenharmony_ci#endif 7762306a36Sopenharmony_ci} 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(__iowrite64_copy); 80