io.c (da733563be5a9da26fe81d9f007262d00b846e22) | io.c (c5ca95b507c8a2a69e49eeda539b41bd76922d7f) |
---|---|
1#include <linux/export.h> 2#include <linux/types.h> 3#include <linux/io.h> | 1#include <linux/export.h> 2#include <linux/types.h> 3#include <linux/io.h> |
4#include <linux/spinlock.h> |
|
4 | 5 |
6static DEFINE_RAW_SPINLOCK(__io_lock); 7 |
|
5/* | 8/* |
9 * Generic atomic MMIO modify. 10 * 11 * Allows thread-safe access to registers shared by unrelated subsystems. 12 * The access is protected by a single MMIO-wide lock. 13 */ 14void atomic_io_modify_relaxed(void __iomem *reg, u32 mask, u32 set) 15{ 16 unsigned long flags; 17 u32 value; 18 19 raw_spin_lock_irqsave(&__io_lock, flags); 20 value = readl_relaxed(reg) & ~mask; 21 value |= (set & mask); 22 writel_relaxed(value, reg); 23 raw_spin_unlock_irqrestore(&__io_lock, flags); 24} 25EXPORT_SYMBOL(atomic_io_modify_relaxed); 26 27void atomic_io_modify(void __iomem *reg, u32 mask, u32 set) 28{ 29 unsigned long flags; 30 u32 value; 31 32 raw_spin_lock_irqsave(&__io_lock, flags); 33 value = readl_relaxed(reg) & ~mask; 34 value |= (set & mask); 35 writel(value, reg); 36 raw_spin_unlock_irqrestore(&__io_lock, flags); 37} 38EXPORT_SYMBOL(atomic_io_modify); 39 40/* |
|
6 * Copy data from IO memory space to "real" memory space. 7 * This needs to be optimized. 8 */ 9void _memcpy_fromio(void *to, const volatile void __iomem *from, size_t count) 10{ 11 unsigned char *t = to; 12 while (count) { 13 count--; --- 37 unchanged lines hidden --- | 41 * Copy data from IO memory space to "real" memory space. 42 * This needs to be optimized. 43 */ 44void _memcpy_fromio(void *to, const volatile void __iomem *from, size_t count) 45{ 46 unsigned char *t = to; 47 while (count) { 48 count--; --- 37 unchanged lines hidden --- |