diff options
-rw-r--r-- | drivers/rtc/rtc-asm9260.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/drivers/rtc/rtc-asm9260.c b/drivers/rtc/rtc-asm9260.c index 5219916ce11d..18a93d3e3f93 100644 --- a/drivers/rtc/rtc-asm9260.c +++ b/drivers/rtc/rtc-asm9260.c | |||
@@ -112,8 +112,6 @@ struct asm9260_rtc_priv { | |||
112 | void __iomem *iobase; | 112 | void __iomem *iobase; |
113 | struct rtc_device *rtc; | 113 | struct rtc_device *rtc; |
114 | struct clk *clk; | 114 | struct clk *clk; |
115 | /* io lock */ | ||
116 | spinlock_t lock; | ||
117 | }; | 115 | }; |
118 | 116 | ||
119 | static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id) | 117 | static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id) |
@@ -122,11 +120,15 @@ static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id) | |||
122 | u32 isr; | 120 | u32 isr; |
123 | unsigned long events = 0; | 121 | unsigned long events = 0; |
124 | 122 | ||
123 | mutex_lock(&priv->rtc->ops_lock); | ||
125 | isr = ioread32(priv->iobase + HW_CIIR); | 124 | isr = ioread32(priv->iobase + HW_CIIR); |
126 | if (!isr) | 125 | if (!isr) { |
126 | mutex_unlock(&priv->rtc->ops_lock); | ||
127 | return IRQ_NONE; | 127 | return IRQ_NONE; |
128 | } | ||
128 | 129 | ||
129 | iowrite32(0, priv->iobase + HW_CIIR); | 130 | iowrite32(0, priv->iobase + HW_CIIR); |
131 | mutex_unlock(&priv->rtc->ops_lock); | ||
130 | 132 | ||
131 | events |= RTC_AF | RTC_IRQF; | 133 | events |= RTC_AF | RTC_IRQF; |
132 | 134 | ||
@@ -139,9 +141,7 @@ static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
139 | { | 141 | { |
140 | struct asm9260_rtc_priv *priv = dev_get_drvdata(dev); | 142 | struct asm9260_rtc_priv *priv = dev_get_drvdata(dev); |
141 | u32 ctime0, ctime1, ctime2; | 143 | u32 ctime0, ctime1, ctime2; |
142 | unsigned long irq_flags; | ||
143 | 144 | ||
144 | spin_lock_irqsave(&priv->lock, irq_flags); | ||
145 | ctime0 = ioread32(priv->iobase + HW_CTIME0); | 145 | ctime0 = ioread32(priv->iobase + HW_CTIME0); |
146 | ctime1 = ioread32(priv->iobase + HW_CTIME1); | 146 | ctime1 = ioread32(priv->iobase + HW_CTIME1); |
147 | ctime2 = ioread32(priv->iobase + HW_CTIME2); | 147 | ctime2 = ioread32(priv->iobase + HW_CTIME2); |
@@ -155,7 +155,6 @@ static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
155 | ctime1 = ioread32(priv->iobase + HW_CTIME1); | 155 | ctime1 = ioread32(priv->iobase + HW_CTIME1); |
156 | ctime2 = ioread32(priv->iobase + HW_CTIME2); | 156 | ctime2 = ioread32(priv->iobase + HW_CTIME2); |
157 | } | 157 | } |
158 | spin_unlock_irqrestore(&priv->lock, irq_flags); | ||
159 | 158 | ||
160 | tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M; | 159 | tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M; |
161 | tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M; | 160 | tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M; |
@@ -174,9 +173,7 @@ static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
174 | static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm) | 173 | static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm) |
175 | { | 174 | { |
176 | struct asm9260_rtc_priv *priv = dev_get_drvdata(dev); | 175 | struct asm9260_rtc_priv *priv = dev_get_drvdata(dev); |
177 | unsigned long irq_flags; | ||
178 | 176 | ||
179 | spin_lock_irqsave(&priv->lock, irq_flags); | ||
180 | /* | 177 | /* |
181 | * make sure SEC counter will not flip other counter on write time, | 178 | * make sure SEC counter will not flip other counter on write time, |
182 | * real value will be written at the enf of sequence. | 179 | * real value will be written at the enf of sequence. |
@@ -191,7 +188,6 @@ static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
191 | iowrite32(tm->tm_hour, priv->iobase + HW_HOUR); | 188 | iowrite32(tm->tm_hour, priv->iobase + HW_HOUR); |
192 | iowrite32(tm->tm_min, priv->iobase + HW_MIN); | 189 | iowrite32(tm->tm_min, priv->iobase + HW_MIN); |
193 | iowrite32(tm->tm_sec, priv->iobase + HW_SEC); | 190 | iowrite32(tm->tm_sec, priv->iobase + HW_SEC); |
194 | spin_unlock_irqrestore(&priv->lock, irq_flags); | ||
195 | 191 | ||
196 | return 0; | 192 | return 0; |
197 | } | 193 | } |
@@ -199,9 +195,7 @@ static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
199 | static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 195 | static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
200 | { | 196 | { |
201 | struct asm9260_rtc_priv *priv = dev_get_drvdata(dev); | 197 | struct asm9260_rtc_priv *priv = dev_get_drvdata(dev); |
202 | unsigned long irq_flags; | ||
203 | 198 | ||
204 | spin_lock_irqsave(&priv->lock, irq_flags); | ||
205 | alrm->time.tm_year = ioread32(priv->iobase + HW_ALYEAR); | 199 | alrm->time.tm_year = ioread32(priv->iobase + HW_ALYEAR); |
206 | alrm->time.tm_mon = ioread32(priv->iobase + HW_ALMON); | 200 | alrm->time.tm_mon = ioread32(priv->iobase + HW_ALMON); |
207 | alrm->time.tm_mday = ioread32(priv->iobase + HW_ALDOM); | 201 | alrm->time.tm_mday = ioread32(priv->iobase + HW_ALDOM); |
@@ -213,7 +207,6 @@ static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
213 | 207 | ||
214 | alrm->enabled = ioread32(priv->iobase + HW_AMR) ? 1 : 0; | 208 | alrm->enabled = ioread32(priv->iobase + HW_AMR) ? 1 : 0; |
215 | alrm->pending = ioread32(priv->iobase + HW_CIIR) ? 1 : 0; | 209 | alrm->pending = ioread32(priv->iobase + HW_CIIR) ? 1 : 0; |
216 | spin_unlock_irqrestore(&priv->lock, irq_flags); | ||
217 | 210 | ||
218 | return rtc_valid_tm(&alrm->time); | 211 | return rtc_valid_tm(&alrm->time); |
219 | } | 212 | } |
@@ -221,9 +214,7 @@ static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
221 | static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 214 | static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
222 | { | 215 | { |
223 | struct asm9260_rtc_priv *priv = dev_get_drvdata(dev); | 216 | struct asm9260_rtc_priv *priv = dev_get_drvdata(dev); |
224 | unsigned long irq_flags; | ||
225 | 217 | ||
226 | spin_lock_irqsave(&priv->lock, irq_flags); | ||
227 | iowrite32(alrm->time.tm_year, priv->iobase + HW_ALYEAR); | 218 | iowrite32(alrm->time.tm_year, priv->iobase + HW_ALYEAR); |
228 | iowrite32(alrm->time.tm_mon, priv->iobase + HW_ALMON); | 219 | iowrite32(alrm->time.tm_mon, priv->iobase + HW_ALMON); |
229 | iowrite32(alrm->time.tm_mday, priv->iobase + HW_ALDOM); | 220 | iowrite32(alrm->time.tm_mday, priv->iobase + HW_ALDOM); |
@@ -234,7 +225,6 @@ static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
234 | iowrite32(alrm->time.tm_sec, priv->iobase + HW_ALSEC); | 225 | iowrite32(alrm->time.tm_sec, priv->iobase + HW_ALSEC); |
235 | 226 | ||
236 | iowrite32(alrm->enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR); | 227 | iowrite32(alrm->enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR); |
237 | spin_unlock_irqrestore(&priv->lock, irq_flags); | ||
238 | 228 | ||
239 | return 0; | 229 | return 0; |
240 | } | 230 | } |