Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/hexagon/include/asm/io.h
26481 views
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
/*
3
* IO definitions for the Hexagon architecture
4
*
5
* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
6
*/
7
8
#ifndef _ASM_IO_H
9
#define _ASM_IO_H
10
11
#include <linux/types.h>
12
#include <asm/page.h>
13
#include <asm/cacheflush.h>
14
15
extern int remap_area_pages(unsigned long start, unsigned long phys_addr,
16
unsigned long end, unsigned long flags);
17
18
/*
19
* virt_to_phys - map virtual address to physical
20
* @address: address to map
21
*/
22
static inline unsigned long virt_to_phys(volatile void *address)
23
{
24
return __pa(address);
25
}
26
27
/*
28
* phys_to_virt - map physical address to virtual
29
* @address: address to map
30
*/
31
static inline void *phys_to_virt(unsigned long address)
32
{
33
return __va(address);
34
}
35
36
/*
37
* readb - read byte from memory mapped device
38
* @addr: pointer to memory
39
*
40
*/
41
static inline u8 __raw_readb(const volatile void __iomem *addr)
42
{
43
u8 val;
44
asm volatile(
45
"%0 = memb(%1);"
46
: "=&r" (val)
47
: "r" (addr)
48
);
49
return val;
50
}
51
#define __raw_readb __raw_readb
52
53
static inline u16 __raw_readw(const volatile void __iomem *addr)
54
{
55
u16 val;
56
asm volatile(
57
"%0 = memh(%1);"
58
: "=&r" (val)
59
: "r" (addr)
60
);
61
return val;
62
}
63
#define __raw_readw __raw_readw
64
65
static inline u32 __raw_readl(const volatile void __iomem *addr)
66
{
67
u32 val;
68
asm volatile(
69
"%0 = memw(%1);"
70
: "=&r" (val)
71
: "r" (addr)
72
);
73
return val;
74
}
75
#define __raw_readl __raw_readl
76
77
/*
78
* writeb - write a byte to a memory location
79
* @data: data to write to
80
* @addr: pointer to memory
81
*
82
*/
83
static inline void __raw_writeb(u8 data, volatile void __iomem *addr)
84
{
85
asm volatile(
86
"memb(%0) = %1;"
87
:
88
: "r" (addr), "r" (data)
89
: "memory"
90
);
91
}
92
#define __raw_writeb __raw_writeb
93
94
static inline void __raw_writew(u16 data, volatile void __iomem *addr)
95
{
96
asm volatile(
97
"memh(%0) = %1;"
98
:
99
: "r" (addr), "r" (data)
100
: "memory"
101
);
102
103
}
104
#define __raw_writew __raw_writew
105
106
static inline void __raw_writel(u32 data, volatile void __iomem *addr)
107
{
108
asm volatile(
109
"memw(%0) = %1;"
110
:
111
: "r" (addr), "r" (data)
112
: "memory"
113
);
114
}
115
#define __raw_writel __raw_writel
116
117
/*
118
* I/O memory mapping functions.
119
*/
120
#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
121
(__HEXAGON_C_DEV << 6))
122
123
/*
124
* These defines are necessary to use the generic io.h for filling in
125
* the missing parts of the API contract. This is because the platform
126
* uses (inline) functions rather than defines and the generic helper
127
* fills in the undefined.
128
*/
129
#define virt_to_phys virt_to_phys
130
#define phys_to_virt phys_to_virt
131
#include <asm-generic/io.h>
132
133
#endif
134
135