@@ -74,6 +74,12 @@ static void regmap_mmio_write8_relaxed(struct regmap_mmio_context *ctx,
74
74
writeb_relaxed (val , ctx -> regs + reg );
75
75
}
76
76
77
+ static void regmap_mmio_iowrite8 (struct regmap_mmio_context * ctx ,
78
+ unsigned int reg , unsigned int val )
79
+ {
80
+ iowrite8 (val , ctx -> regs + reg );
81
+ }
82
+
77
83
static void regmap_mmio_write16le (struct regmap_mmio_context * ctx ,
78
84
unsigned int reg ,
79
85
unsigned int val )
@@ -88,13 +94,25 @@ static void regmap_mmio_write16le_relaxed(struct regmap_mmio_context *ctx,
88
94
writew_relaxed (val , ctx -> regs + reg );
89
95
}
90
96
97
+ static void regmap_mmio_iowrite16le (struct regmap_mmio_context * ctx ,
98
+ unsigned int reg , unsigned int val )
99
+ {
100
+ iowrite16 (val , ctx -> regs + reg );
101
+ }
102
+
91
103
static void regmap_mmio_write16be (struct regmap_mmio_context * ctx ,
92
104
unsigned int reg ,
93
105
unsigned int val )
94
106
{
95
107
iowrite16be (val , ctx -> regs + reg );
96
108
}
97
109
110
+ static void regmap_mmio_iowrite16be (struct regmap_mmio_context * ctx ,
111
+ unsigned int reg , unsigned int val )
112
+ {
113
+ iowrite16be (val , ctx -> regs + reg );
114
+ }
115
+
98
116
static void regmap_mmio_write32le (struct regmap_mmio_context * ctx ,
99
117
unsigned int reg ,
100
118
unsigned int val )
@@ -109,13 +127,25 @@ static void regmap_mmio_write32le_relaxed(struct regmap_mmio_context *ctx,
109
127
writel_relaxed (val , ctx -> regs + reg );
110
128
}
111
129
130
+ static void regmap_mmio_iowrite32le (struct regmap_mmio_context * ctx ,
131
+ unsigned int reg , unsigned int val )
132
+ {
133
+ iowrite32 (val , ctx -> regs + reg );
134
+ }
135
+
112
136
static void regmap_mmio_write32be (struct regmap_mmio_context * ctx ,
113
137
unsigned int reg ,
114
138
unsigned int val )
115
139
{
116
140
iowrite32be (val , ctx -> regs + reg );
117
141
}
118
142
143
+ static void regmap_mmio_iowrite32be (struct regmap_mmio_context * ctx ,
144
+ unsigned int reg , unsigned int val )
145
+ {
146
+ iowrite32be (val , ctx -> regs + reg );
147
+ }
148
+
119
149
static int regmap_mmio_write (void * context , unsigned int reg , unsigned int val )
120
150
{
121
151
struct regmap_mmio_context * ctx = context ;
@@ -147,6 +177,12 @@ static unsigned int regmap_mmio_read8_relaxed(struct regmap_mmio_context *ctx,
147
177
return readb_relaxed (ctx -> regs + reg );
148
178
}
149
179
180
+ static unsigned int regmap_mmio_ioread8 (struct regmap_mmio_context * ctx ,
181
+ unsigned int reg )
182
+ {
183
+ return ioread8 (ctx -> regs + reg );
184
+ }
185
+
150
186
static unsigned int regmap_mmio_read16le (struct regmap_mmio_context * ctx ,
151
187
unsigned int reg )
152
188
{
@@ -159,12 +195,24 @@ static unsigned int regmap_mmio_read16le_relaxed(struct regmap_mmio_context *ctx
159
195
return readw_relaxed (ctx -> regs + reg );
160
196
}
161
197
198
+ static unsigned int regmap_mmio_ioread16le (struct regmap_mmio_context * ctx ,
199
+ unsigned int reg )
200
+ {
201
+ return ioread16 (ctx -> regs + reg );
202
+ }
203
+
162
204
static unsigned int regmap_mmio_read16be (struct regmap_mmio_context * ctx ,
163
205
unsigned int reg )
164
206
{
165
207
return ioread16be (ctx -> regs + reg );
166
208
}
167
209
210
+ static unsigned int regmap_mmio_ioread16be (struct regmap_mmio_context * ctx ,
211
+ unsigned int reg )
212
+ {
213
+ return ioread16be (ctx -> regs + reg );
214
+ }
215
+
168
216
static unsigned int regmap_mmio_read32le (struct regmap_mmio_context * ctx ,
169
217
unsigned int reg )
170
218
{
@@ -177,12 +225,24 @@ static unsigned int regmap_mmio_read32le_relaxed(struct regmap_mmio_context *ctx
177
225
return readl_relaxed (ctx -> regs + reg );
178
226
}
179
227
228
+ static unsigned int regmap_mmio_ioread32le (struct regmap_mmio_context * ctx ,
229
+ unsigned int reg )
230
+ {
231
+ return ioread32 (ctx -> regs + reg );
232
+ }
233
+
180
234
static unsigned int regmap_mmio_read32be (struct regmap_mmio_context * ctx ,
181
235
unsigned int reg )
182
236
{
183
237
return ioread32be (ctx -> regs + reg );
184
238
}
185
239
240
+ static unsigned int regmap_mmio_ioread32be (struct regmap_mmio_context * ctx ,
241
+ unsigned int reg )
242
+ {
243
+ return ioread32be (ctx -> regs + reg );
244
+ }
245
+
186
246
static int regmap_mmio_read (void * context , unsigned int reg , unsigned int * val )
187
247
{
188
248
struct regmap_mmio_context * ctx = context ;
@@ -245,6 +305,9 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
245
305
if (config -> reg_stride < min_stride )
246
306
return ERR_PTR (- EINVAL );
247
307
308
+ if (config -> use_relaxed_mmio && config -> io_port )
309
+ return ERR_PTR (- EINVAL );
310
+
248
311
ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
249
312
if (!ctx )
250
313
return ERR_PTR (- ENOMEM );
@@ -261,7 +324,10 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
261
324
#endif
262
325
switch (config -> val_bits ) {
263
326
case 8 :
264
- if (config -> use_relaxed_mmio ) {
327
+ if (config -> io_port ) {
328
+ ctx -> reg_read = regmap_mmio_ioread8 ;
329
+ ctx -> reg_write = regmap_mmio_iowrite8 ;
330
+ } else if (config -> use_relaxed_mmio ) {
265
331
ctx -> reg_read = regmap_mmio_read8_relaxed ;
266
332
ctx -> reg_write = regmap_mmio_write8_relaxed ;
267
333
} else {
@@ -270,7 +336,10 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
270
336
}
271
337
break ;
272
338
case 16 :
273
- if (config -> use_relaxed_mmio ) {
339
+ if (config -> io_port ) {
340
+ ctx -> reg_read = regmap_mmio_ioread16le ;
341
+ ctx -> reg_write = regmap_mmio_iowrite16le ;
342
+ } else if (config -> use_relaxed_mmio ) {
274
343
ctx -> reg_read = regmap_mmio_read16le_relaxed ;
275
344
ctx -> reg_write = regmap_mmio_write16le_relaxed ;
276
345
} else {
@@ -279,7 +348,10 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
279
348
}
280
349
break ;
281
350
case 32 :
282
- if (config -> use_relaxed_mmio ) {
351
+ if (config -> io_port ) {
352
+ ctx -> reg_read = regmap_mmio_ioread32le ;
353
+ ctx -> reg_write = regmap_mmio_iowrite32le ;
354
+ } else if (config -> use_relaxed_mmio ) {
283
355
ctx -> reg_read = regmap_mmio_read32le_relaxed ;
284
356
ctx -> reg_write = regmap_mmio_write32le_relaxed ;
285
357
} else {
@@ -298,16 +370,31 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
298
370
#endif
299
371
switch (config -> val_bits ) {
300
372
case 8 :
301
- ctx -> reg_read = regmap_mmio_read8 ;
302
- ctx -> reg_write = regmap_mmio_write8 ;
373
+ if (config -> io_port ) {
374
+ ctx -> reg_read = regmap_mmio_ioread8 ;
375
+ ctx -> reg_write = regmap_mmio_iowrite8 ;
376
+ } else {
377
+ ctx -> reg_read = regmap_mmio_read8 ;
378
+ ctx -> reg_write = regmap_mmio_write8 ;
379
+ }
303
380
break ;
304
381
case 16 :
305
- ctx -> reg_read = regmap_mmio_read16be ;
306
- ctx -> reg_write = regmap_mmio_write16be ;
382
+ if (config -> io_port ) {
383
+ ctx -> reg_read = regmap_mmio_ioread16be ;
384
+ ctx -> reg_write = regmap_mmio_iowrite16be ;
385
+ } else {
386
+ ctx -> reg_read = regmap_mmio_read16be ;
387
+ ctx -> reg_write = regmap_mmio_write16be ;
388
+ }
307
389
break ;
308
390
case 32 :
309
- ctx -> reg_read = regmap_mmio_read32be ;
310
- ctx -> reg_write = regmap_mmio_write32be ;
391
+ if (config -> io_port ) {
392
+ ctx -> reg_read = regmap_mmio_ioread32be ;
393
+ ctx -> reg_write = regmap_mmio_iowrite32be ;
394
+ } else {
395
+ ctx -> reg_read = regmap_mmio_read32be ;
396
+ ctx -> reg_write = regmap_mmio_write32be ;
397
+ }
311
398
break ;
312
399
default :
313
400
ret = - EINVAL ;
0 commit comments