1From 5c0a443ba336f10a8db6a99c769aa84ad37ed4d2 Mon Sep 17 00:00:00 2001
2From: Vadim Kochan <vadim4j@gmail.com>
3Date: Wed, 20 Feb 2019 02:48:43 +0200
4Subject: [PATCH] meminfo: Access to io memory via pointers
5
6The main reason for this is to be able compile with musl library,
7because there is no support of inx/outx functions for ARM platform.
8
9Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
10---
11 meminfo.c | 11 ++++++-----
12 1 file changed, 6 insertions(+), 5 deletions(-)
13
14diff --git a/meminfo.c b/meminfo.c
15index 0b0ff23..7d9f10f 100644
16--- a/meminfo.c
17+++ b/meminfo.c
18@@ -22,7 +22,6 @@
19 #include <sys/mman.h>
20 #include <stdint.h>
21 #include <errno.h>
22-#include <sys/io.h>
23 #include <stdbool.h>
24
25 #include "common.h"
26@@ -74,24 +73,26 @@ static enum sunxi_soc_version soc_version;
27 unsigned int
28 sunxi_io_read(void *base, int offset)
29 {
30-	return inl((unsigned long) (base + offset));
31+	unsigned long port = (unsigned long) (base + offset);
32+	return *((volatile unsigned long *) port);
33 }
34
35 void
36 sunxi_io_write(void *base, int offset, unsigned int value)
37 {
38-	outl(value, (unsigned long) (base + offset));
39+	unsigned long port = (unsigned long) (base + offset);
40+	*((volatile unsigned long *) port) = value;
41 }
42
43 void
44 sunxi_io_mask(void *base, int offset, unsigned int value, unsigned int mask)
45 {
46-	unsigned int tmp = inl((unsigned long) (base + offset));
47+	unsigned int tmp = sunxi_io_read(base, offset);
48
49 	tmp &= ~mask;
50 	tmp |= value & mask;
51
52-	outl(tmp, (unsigned long) (base + offset));
53+	sunxi_io_write(base, offset, tmp);
54 }
55
56
57--
582.14.1
59
60