1
2
3
4
5
6
7
8
9#include <linux/rio.h>
10#include <linux/module.h>
11
12
13
14
15
16
17#define RIO_8_BAD 0
18#define RIO_16_BAD (offset & 1)
19#define RIO_32_BAD (offset & 3)
20
21
22
23
24
25
26
27
28
29
30#define RIO_LOP_READ(size,type,len) \
31int __rio_local_read_config_##size \
32 (struct rio_mport *mport, u32 offset, type *value) \
33{ \
34 int res; \
35 u32 data = 0; \
36 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
37 res = mport->ops->lcread(mport, mport->id, offset, len, &data); \
38 *value = (type)data; \
39 return res; \
40}
41
42
43
44
45
46
47
48
49
50
51#define RIO_LOP_WRITE(size,type,len) \
52int __rio_local_write_config_##size \
53 (struct rio_mport *mport, u32 offset, type value) \
54{ \
55 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
56 return mport->ops->lcwrite(mport, mport->id, offset, len, value);\
57}
58
59RIO_LOP_READ(8, u8, 1)
60RIO_LOP_READ(16, u16, 2)
61RIO_LOP_READ(32, u32, 4)
62RIO_LOP_WRITE(8, u8, 1)
63RIO_LOP_WRITE(16, u16, 2)
64RIO_LOP_WRITE(32, u32, 4)
65
66EXPORT_SYMBOL_GPL(__rio_local_read_config_8);
67EXPORT_SYMBOL_GPL(__rio_local_read_config_16);
68EXPORT_SYMBOL_GPL(__rio_local_read_config_32);
69EXPORT_SYMBOL_GPL(__rio_local_write_config_8);
70EXPORT_SYMBOL_GPL(__rio_local_write_config_16);
71EXPORT_SYMBOL_GPL(__rio_local_write_config_32);
72
73
74
75
76
77
78
79
80
81
82#define RIO_OP_READ(size,type,len) \
83int rio_mport_read_config_##size \
84 (struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type *value) \
85{ \
86 int res; \
87 u32 data = 0; \
88 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
89 res = mport->ops->cread(mport, mport->id, destid, hopcount, offset, len, &data); \
90 *value = (type)data; \
91 return res; \
92}
93
94
95
96
97
98
99
100
101
102
103#define RIO_OP_WRITE(size,type,len) \
104int rio_mport_write_config_##size \
105 (struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type value) \
106{ \
107 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
108 return mport->ops->cwrite(mport, mport->id, destid, hopcount, \
109 offset, len, value); \
110}
111
112RIO_OP_READ(8, u8, 1)
113RIO_OP_READ(16, u16, 2)
114RIO_OP_READ(32, u32, 4)
115RIO_OP_WRITE(8, u8, 1)
116RIO_OP_WRITE(16, u16, 2)
117RIO_OP_WRITE(32, u32, 4)
118
119EXPORT_SYMBOL_GPL(rio_mport_read_config_8);
120EXPORT_SYMBOL_GPL(rio_mport_read_config_16);
121EXPORT_SYMBOL_GPL(rio_mport_read_config_32);
122EXPORT_SYMBOL_GPL(rio_mport_write_config_8);
123EXPORT_SYMBOL_GPL(rio_mport_write_config_16);
124EXPORT_SYMBOL_GPL(rio_mport_write_config_32);
125
126
127
128
129
130
131
132
133
134
135
136int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, u16 data)
137{
138 return mport->ops->dsend(mport, mport->id, destid, data);
139}
140
141EXPORT_SYMBOL_GPL(rio_mport_send_doorbell);
142