aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-at32ap700x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-at32ap700x.c')
-rw-r--r--drivers/rtc/rtc-at32ap700x.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c
index b2752b6e7a2f..e725d51e773d 100644
--- a/drivers/rtc/rtc-at32ap700x.c
+++ b/drivers/rtc/rtc-at32ap700x.c
@@ -134,36 +134,29 @@ static int at32_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
134 return ret; 134 return ret;
135} 135}
136 136
137static int at32_rtc_ioctl(struct device *dev, unsigned int cmd, 137static int at32_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
138 unsigned long arg)
139{ 138{
140 struct rtc_at32ap700x *rtc = dev_get_drvdata(dev); 139 struct rtc_at32ap700x *rtc = dev_get_drvdata(dev);
141 int ret = 0; 140 int ret = 0;
142 141
143 spin_lock_irq(&rtc->lock); 142 spin_lock_irq(&rtc->lock);
144 143
145 switch (cmd) { 144 if(enabled) {
146 case RTC_AIE_ON:
147 if (rtc_readl(rtc, VAL) > rtc->alarm_time) { 145 if (rtc_readl(rtc, VAL) > rtc->alarm_time) {
148 ret = -EINVAL; 146 ret = -EINVAL;
149 break; 147 goto out;
150 } 148 }
151 rtc_writel(rtc, CTRL, rtc_readl(rtc, CTRL) 149 rtc_writel(rtc, CTRL, rtc_readl(rtc, CTRL)
152 | RTC_BIT(CTRL_TOPEN)); 150 | RTC_BIT(CTRL_TOPEN));
153 rtc_writel(rtc, ICR, RTC_BIT(ICR_TOPI)); 151 rtc_writel(rtc, ICR, RTC_BIT(ICR_TOPI));
154 rtc_writel(rtc, IER, RTC_BIT(IER_TOPI)); 152 rtc_writel(rtc, IER, RTC_BIT(IER_TOPI));
155 break; 153 } else {
156 case RTC_AIE_OFF:
157 rtc_writel(rtc, CTRL, rtc_readl(rtc, CTRL) 154 rtc_writel(rtc, CTRL, rtc_readl(rtc, CTRL)
158 & ~RTC_BIT(CTRL_TOPEN)); 155 & ~RTC_BIT(CTRL_TOPEN));
159 rtc_writel(rtc, IDR, RTC_BIT(IDR_TOPI)); 156 rtc_writel(rtc, IDR, RTC_BIT(IDR_TOPI));
160 rtc_writel(rtc, ICR, RTC_BIT(ICR_TOPI)); 157 rtc_writel(rtc, ICR, RTC_BIT(ICR_TOPI));
161 break;
162 default:
163 ret = -ENOIOCTLCMD;
164 break;
165 } 158 }
166 159out:
167 spin_unlock_irq(&rtc->lock); 160 spin_unlock_irq(&rtc->lock);
168 161
169 return ret; 162 return ret;
@@ -195,11 +188,11 @@ static irqreturn_t at32_rtc_interrupt(int irq, void *dev_id)
195} 188}
196 189
197static struct rtc_class_ops at32_rtc_ops = { 190static struct rtc_class_ops at32_rtc_ops = {
198 .ioctl = at32_rtc_ioctl,
199 .read_time = at32_rtc_readtime, 191 .read_time = at32_rtc_readtime,
200 .set_time = at32_rtc_settime, 192 .set_time = at32_rtc_settime,
201 .read_alarm = at32_rtc_readalarm, 193 .read_alarm = at32_rtc_readalarm,
202 .set_alarm = at32_rtc_setalarm, 194 .set_alarm = at32_rtc_setalarm,
195 .alarm_irq_enable = at32_rtc_alarm_irq_enable,
203}; 196};
204 197
205static int __init at32_rtc_probe(struct platform_device *pdev) 198static int __init at32_rtc_probe(struct platform_device *pdev)