10
10
#include <linux/of.h>
11
11
#include <linux/platform_device.h>
12
12
#include <linux/rtc.h>
13
+ #include <linux/goldfish.h>
13
14
14
15
#define TIMER_TIME_LOW 0x00 /* get low bits of current time */
15
16
/* and update TIMER_TIME_HIGH */
@@ -41,16 +42,16 @@ static int goldfish_rtc_read_alarm(struct device *dev,
41
42
rtcdrv = dev_get_drvdata (dev );
42
43
base = rtcdrv -> base ;
43
44
44
- rtc_alarm_low = readl (base + TIMER_ALARM_LOW );
45
- rtc_alarm_high = readl (base + TIMER_ALARM_HIGH );
45
+ rtc_alarm_low = gf_ioread32 (base + TIMER_ALARM_LOW );
46
+ rtc_alarm_high = gf_ioread32 (base + TIMER_ALARM_HIGH );
46
47
rtc_alarm = (rtc_alarm_high << 32 ) | rtc_alarm_low ;
47
48
48
49
do_div (rtc_alarm , NSEC_PER_SEC );
49
50
memset (alrm , 0 , sizeof (struct rtc_wkalrm ));
50
51
51
52
rtc_time64_to_tm (rtc_alarm , & alrm -> time );
52
53
53
- if (readl (base + TIMER_ALARM_STATUS ))
54
+ if (gf_ioread32 (base + TIMER_ALARM_STATUS ))
54
55
alrm -> enabled = 1 ;
55
56
else
56
57
alrm -> enabled = 0 ;
@@ -71,18 +72,18 @@ static int goldfish_rtc_set_alarm(struct device *dev,
71
72
72
73
if (alrm -> enabled ) {
73
74
rtc_alarm64 = rtc_tm_to_time64 (& alrm -> time ) * NSEC_PER_SEC ;
74
- writel ((rtc_alarm64 >> 32 ), base + TIMER_ALARM_HIGH );
75
- writel (rtc_alarm64 , base + TIMER_ALARM_LOW );
76
- writel (1 , base + TIMER_IRQ_ENABLED );
75
+ gf_iowrite32 ((rtc_alarm64 >> 32 ), base + TIMER_ALARM_HIGH );
76
+ gf_iowrite32 (rtc_alarm64 , base + TIMER_ALARM_LOW );
77
+ gf_iowrite32 (1 , base + TIMER_IRQ_ENABLED );
77
78
} else {
78
79
/*
79
80
* if this function was called with enabled=0
80
81
* then it could mean that the application is
81
82
* trying to cancel an ongoing alarm
82
83
*/
83
- rtc_status_reg = readl (base + TIMER_ALARM_STATUS );
84
+ rtc_status_reg = gf_ioread32 (base + TIMER_ALARM_STATUS );
84
85
if (rtc_status_reg )
85
- writel (1 , base + TIMER_CLEAR_ALARM );
86
+ gf_iowrite32 (1 , base + TIMER_CLEAR_ALARM );
86
87
}
87
88
88
89
return 0 ;
@@ -98,9 +99,9 @@ static int goldfish_rtc_alarm_irq_enable(struct device *dev,
98
99
base = rtcdrv -> base ;
99
100
100
101
if (enabled )
101
- writel (1 , base + TIMER_IRQ_ENABLED );
102
+ gf_iowrite32 (1 , base + TIMER_IRQ_ENABLED );
102
103
else
103
- writel (0 , base + TIMER_IRQ_ENABLED );
104
+ gf_iowrite32 (0 , base + TIMER_IRQ_ENABLED );
104
105
105
106
return 0 ;
106
107
}
@@ -110,7 +111,7 @@ static irqreturn_t goldfish_rtc_interrupt(int irq, void *dev_id)
110
111
struct goldfish_rtc * rtcdrv = dev_id ;
111
112
void __iomem * base = rtcdrv -> base ;
112
113
113
- writel (1 , base + TIMER_CLEAR_INTERRUPT );
114
+ gf_iowrite32 (1 , base + TIMER_CLEAR_INTERRUPT );
114
115
115
116
rtc_update_irq (rtcdrv -> rtc , 1 , RTC_IRQF | RTC_AF );
116
117
@@ -128,8 +129,8 @@ static int goldfish_rtc_read_time(struct device *dev, struct rtc_time *tm)
128
129
rtcdrv = dev_get_drvdata (dev );
129
130
base = rtcdrv -> base ;
130
131
131
- time_low = readl (base + TIMER_TIME_LOW );
132
- time_high = readl (base + TIMER_TIME_HIGH );
132
+ time_low = gf_ioread32 (base + TIMER_TIME_LOW );
133
+ time_high = gf_ioread32 (base + TIMER_TIME_HIGH );
133
134
time = (time_high << 32 ) | time_low ;
134
135
135
136
do_div (time , NSEC_PER_SEC );
@@ -149,8 +150,8 @@ static int goldfish_rtc_set_time(struct device *dev, struct rtc_time *tm)
149
150
base = rtcdrv -> base ;
150
151
151
152
now64 = rtc_tm_to_time64 (tm ) * NSEC_PER_SEC ;
152
- writel ((now64 >> 32 ), base + TIMER_TIME_HIGH );
153
- writel (now64 , base + TIMER_TIME_LOW );
153
+ gf_iowrite32 ((now64 >> 32 ), base + TIMER_TIME_HIGH );
154
+ gf_iowrite32 (now64 , base + TIMER_TIME_LOW );
154
155
155
156
return 0 ;
156
157
}
0 commit comments