[coldfire]: switch to 2.6.38
[openwrt/svn-archive/archive.git] / target / linux / coldfire / patches / 046-Convert-rtc-drivers-to-use-the-alarm_irq_enable-meth.patch
1 From ab2284cd4730b9ea29937ee3a0ef1bcdc6b3159d Mon Sep 17 00:00:00 2001
2 From: Alison Wang <b18965@freescale.com>
3 Date: Thu, 4 Aug 2011 09:59:54 +0800
4 Subject: [PATCH 46/52] Convert rtc drivers to use the alarm_irq_enable method
5
6 Old rtc drivers use the ioctl method instead of the alarm_irq_enable
7 method for enabling alarm interupts. With the new virtualized RTC
8 rework, its important for drivers to use the alarm_irq_enable instead.
9
10 This patch converts the drivers that use the AIE ioctl method to
11 use the alarm_irq_enable method.
12
13 Signed-off-by: Alison Wang <b18965@freescale.com>
14 ---
15 drivers/rtc/rtc-m5441x.c | 22 +++++++++++-----------
16 drivers/rtc/rtc-mcf.c | 23 +++++++++++------------
17 2 files changed, 22 insertions(+), 23 deletions(-)
18
19 --- a/drivers/rtc/rtc-m5441x.c
20 +++ b/drivers/rtc/rtc-m5441x.c
21 @@ -400,17 +400,6 @@ static int mcf_rtc_ioctl(struct device *
22 writew((readw(MCF_RTC_IER) | PIE_BIT_DEF[i][1]), MCF_RTC_IER);
23 spin_unlock_irq(&rtc_lock);
24 return 0;
25 - case RTC_AIE_OFF:
26 - spin_lock_irq(&rtc_lock);
27 - writew((readw(MCF_RTC_IER) & ~MCF_RTC_ISR_ALM), MCF_RTC_IER);
28 - spin_unlock_irq(&rtc_lock);
29 - return 0;
30 -
31 - case RTC_AIE_ON:
32 - spin_lock_irq(&rtc_lock);
33 - writew((readw(MCF_RTC_IER) | MCF_RTC_ISR_ALM), MCF_RTC_IER);
34 - spin_unlock_irq(&rtc_lock);
35 - return 0;
36
37 case RTC_UIE_OFF: /* UIE is for the 1Hz interrupt */
38 spin_lock_irq(&rtc_lock);
39 @@ -427,6 +416,16 @@ static int mcf_rtc_ioctl(struct device *
40 return -ENOIOCTLCMD;
41 }
42
43 +static int mcf_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
44 +{
45 + if (enabled)
46 + writew((readw(MCF_RTC_IER) | MCF_RTC_ISR_ALM), MCF_RTC_IER);
47 + else
48 + writew((readw(MCF_RTC_IER) & ~MCF_RTC_ISR_ALM), MCF_RTC_IER);
49 +
50 + return 0;
51 +}
52 +
53 /*!
54 * This function reads the current RTC time into tm in Gregorian date.
55 *
56 @@ -534,6 +533,7 @@ static struct rtc_class_ops mcf_rtc_ops
57 .set_time = mcf_rtc_set_time,
58 .read_alarm = mcf_rtc_read_alarm,
59 .set_alarm = mcf_rtc_set_alarm,
60 + .alarm_irq_enable = mcf_rtc_alarm_irq_enable,
61 };
62
63 static int __devinit mcf_rtc_probe(struct platform_device *pdev)
64 --- a/drivers/rtc/rtc-mcf.c
65 +++ b/drivers/rtc/rtc-mcf.c
66 @@ -298,18 +298,6 @@ static int mcf_rtc_ioctl(struct device *
67 writel((readl(MCF_RTC_IER) | PIE_BIT_DEF[i][1]), MCF_RTC_IER);
68 spin_unlock_irq(&rtc_lock);
69 return 0;
70 - case RTC_AIE_OFF:
71 - spin_lock_irq(&rtc_lock);
72 - writel((readl(MCF_RTC_IER) & ~MCF_RTC_ISR_ALM), MCF_RTC_IER);
73 - spin_unlock_irq(&rtc_lock);
74 - return 0;
75 -
76 - case RTC_AIE_ON:
77 - spin_lock_irq(&rtc_lock);
78 - writel((readl(MCF_RTC_IER) | MCF_RTC_ISR_ALM), MCF_RTC_IER);
79 - spin_unlock_irq(&rtc_lock);
80 - return 0;
81 -
82 case RTC_UIE_OFF: /* UIE is for the 1Hz interrupt */
83 spin_lock_irq(&rtc_lock);
84 writel((readl(MCF_RTC_IER) & ~MCF_RTC_ISR_1HZ), MCF_RTC_IER);
85 @@ -325,6 +313,16 @@ static int mcf_rtc_ioctl(struct device *
86 return -ENOIOCTLCMD;
87 }
88
89 +static int mcf_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
90 +{
91 + if (enabled)
92 + writel((readl(MCF_RTC_IER) | MCF_RTC_ISR_ALM), MCF_RTC_IER);
93 + else
94 + writel((readl(MCF_RTC_IER) & ~MCF_RTC_ISR_ALM), MCF_RTC_IER);
95 +
96 + return 0;
97 +}
98 +
99 /*!
100 * This function reads the current RTC time into tm in Gregorian date.
101 *
102 @@ -466,6 +464,7 @@ static struct rtc_class_ops mcf_rtc_ops
103 .read_alarm = mcf_rtc_read_alarm,
104 .set_alarm = mcf_rtc_set_alarm,
105 .proc = mcf_rtc_proc,
106 + .alarm_irq_enable = mcf_rtc_alarm_irq_enable,
107 };
108
109 static int __devinit mcf_rtc_probe(struct platform_device *pdev)