diff options
| author | Chanwoo Choi <cw00.choi@samsung.com> | 2015-04-16 15:45:15 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-17 09:04:00 -0400 |
| commit | 24e1455493dae5ce4b15f83d6ad549befd15f980 (patch) | |
| tree | 3159347dfbf7e3a8f7e202b046655c40c46c0a7a /drivers/rtc | |
| parent | aed98b9a1be6fcf1685dfd37f0a3e78e92a21f7d (diff) | |
drivers/rtc/rtc-s3c.c: delete duplicate clock control
The current functions in s3c-rtc driver execute clk_enable/disable() to
control clocks and some functions execute s3c_rtc_alarm_clk_enable()
unnecessarily. So this patch deletes the duplicate clock control and
spilts s3c_rtc_alarm_clk_enable() out as
s3c_rtc_enable_clk()/s3c_rtc_disable_clk() to improve readability.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/rtc-s3c.c | 163 |
1 files changed, 39 insertions, 124 deletions
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index f4cf6851fae9..fb0c569765c6 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
| @@ -39,7 +39,6 @@ struct s3c_rtc { | |||
| 39 | void __iomem *base; | 39 | void __iomem *base; |
| 40 | struct clk *rtc_clk; | 40 | struct clk *rtc_clk; |
| 41 | struct clk *rtc_src_clk; | 41 | struct clk *rtc_src_clk; |
| 42 | bool enabled; | ||
| 43 | 42 | ||
| 44 | struct s3c_rtc_data *data; | 43 | struct s3c_rtc_data *data; |
| 45 | 44 | ||
| @@ -67,26 +66,25 @@ struct s3c_rtc_data { | |||
| 67 | void (*disable) (struct s3c_rtc *info); | 66 | void (*disable) (struct s3c_rtc *info); |
| 68 | }; | 67 | }; |
| 69 | 68 | ||
| 70 | static void s3c_rtc_alarm_clk_enable(struct s3c_rtc *info, bool enable) | 69 | static void s3c_rtc_enable_clk(struct s3c_rtc *info) |
| 71 | { | 70 | { |
| 72 | unsigned long irq_flags; | 71 | unsigned long irq_flags; |
| 73 | 72 | ||
| 74 | spin_lock_irqsave(&info->alarm_clk_lock, irq_flags); | 73 | spin_lock_irqsave(&info->alarm_clk_lock, irq_flags); |
| 75 | if (enable) { | 74 | clk_enable(info->rtc_clk); |
| 76 | if (!info->enabled) { | 75 | if (info->data->needs_src_clk) |
| 77 | clk_enable(info->rtc_clk); | 76 | clk_enable(info->rtc_src_clk); |
| 78 | if (info->data->needs_src_clk) | 77 | spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags); |
| 79 | clk_enable(info->rtc_src_clk); | 78 | } |
| 80 | info->enabled = true; | 79 | |
| 81 | } | 80 | static void s3c_rtc_disable_clk(struct s3c_rtc *info) |
| 82 | } else { | 81 | { |
| 83 | if (info->enabled) { | 82 | unsigned long irq_flags; |
| 84 | if (info->data->needs_src_clk) | 83 | |
| 85 | clk_disable(info->rtc_src_clk); | 84 | spin_lock_irqsave(&info->alarm_clk_lock, irq_flags); |
| 86 | clk_disable(info->rtc_clk); | 85 | if (info->data->needs_src_clk) |
| 87 | info->enabled = false; | 86 | clk_disable(info->rtc_src_clk); |
| 88 | } | 87 | clk_disable(info->rtc_clk); |
| 89 | } | ||
| 90 | spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags); | 88 | spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags); |
| 91 | } | 89 | } |
| 92 | 90 | ||
| @@ -119,20 +117,16 @@ static int s3c_rtc_setaie(struct device *dev, unsigned int enabled) | |||
| 119 | 117 | ||
| 120 | dev_dbg(info->dev, "%s: aie=%d\n", __func__, enabled); | 118 | dev_dbg(info->dev, "%s: aie=%d\n", __func__, enabled); |
| 121 | 119 | ||
| 122 | clk_enable(info->rtc_clk); | 120 | s3c_rtc_enable_clk(info); |
| 123 | if (info->data->needs_src_clk) | 121 | |
| 124 | clk_enable(info->rtc_src_clk); | ||
| 125 | tmp = readb(info->base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; | 122 | tmp = readb(info->base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; |
| 126 | 123 | ||
| 127 | if (enabled) | 124 | if (enabled) |
| 128 | tmp |= S3C2410_RTCALM_ALMEN; | 125 | tmp |= S3C2410_RTCALM_ALMEN; |
| 129 | 126 | ||
| 130 | writeb(tmp, info->base + S3C2410_RTCALM); | 127 | writeb(tmp, info->base + S3C2410_RTCALM); |
| 131 | if (info->data->needs_src_clk) | ||
| 132 | clk_disable(info->rtc_src_clk); | ||
| 133 | clk_disable(info->rtc_clk); | ||
| 134 | 128 | ||
| 135 | s3c_rtc_alarm_clk_enable(info, enabled); | 129 | s3c_rtc_disable_clk(info); |
| 136 | 130 | ||
| 137 | return 0; | 131 | return 0; |
| 138 | } | 132 | } |
| @@ -143,18 +137,12 @@ static int s3c_rtc_setfreq(struct s3c_rtc *info, int freq) | |||
| 143 | if (!is_power_of_2(freq)) | 137 | if (!is_power_of_2(freq)) |
| 144 | return -EINVAL; | 138 | return -EINVAL; |
| 145 | 139 | ||
| 146 | clk_enable(info->rtc_clk); | ||
| 147 | if (info->data->needs_src_clk) | ||
| 148 | clk_enable(info->rtc_src_clk); | ||
| 149 | spin_lock_irq(&info->pie_lock); | 140 | spin_lock_irq(&info->pie_lock); |
| 150 | 141 | ||
| 151 | if (info->data->set_freq) | 142 | if (info->data->set_freq) |
| 152 | info->data->set_freq(info, freq); | 143 | info->data->set_freq(info, freq); |
| 153 | 144 | ||
| 154 | spin_unlock_irq(&info->pie_lock); | 145 | spin_unlock_irq(&info->pie_lock); |
| 155 | if (info->data->needs_src_clk) | ||
| 156 | clk_disable(info->rtc_src_clk); | ||
| 157 | clk_disable(info->rtc_clk); | ||
| 158 | 146 | ||
| 159 | return 0; | 147 | return 0; |
| 160 | } | 148 | } |
| @@ -165,9 +153,7 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
| 165 | struct s3c_rtc *info = dev_get_drvdata(dev); | 153 | struct s3c_rtc *info = dev_get_drvdata(dev); |
| 166 | unsigned int have_retried = 0; | 154 | unsigned int have_retried = 0; |
| 167 | 155 | ||
| 168 | clk_enable(info->rtc_clk); | 156 | s3c_rtc_enable_clk(info); |
| 169 | if (info->data->needs_src_clk) | ||
| 170 | clk_enable(info->rtc_src_clk); | ||
| 171 | 157 | ||
| 172 | retry_get_time: | 158 | retry_get_time: |
| 173 | rtc_tm->tm_min = readb(info->base + S3C2410_RTCMIN); | 159 | rtc_tm->tm_min = readb(info->base + S3C2410_RTCMIN); |
| @@ -194,6 +180,8 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
| 194 | rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); | 180 | rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); |
| 195 | rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); | 181 | rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); |
| 196 | 182 | ||
| 183 | s3c_rtc_disable_clk(info); | ||
| 184 | |||
| 197 | rtc_tm->tm_year += 100; | 185 | rtc_tm->tm_year += 100; |
| 198 | 186 | ||
| 199 | dev_dbg(dev, "read time %04d.%02d.%02d %02d:%02d:%02d\n", | 187 | dev_dbg(dev, "read time %04d.%02d.%02d %02d:%02d:%02d\n", |
| @@ -202,10 +190,6 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
| 202 | 190 | ||
| 203 | rtc_tm->tm_mon -= 1; | 191 | rtc_tm->tm_mon -= 1; |
| 204 | 192 | ||
| 205 | if (info->data->needs_src_clk) | ||
| 206 | clk_disable(info->rtc_src_clk); | ||
| 207 | clk_disable(info->rtc_clk); | ||
| 208 | |||
| 209 | return rtc_valid_tm(rtc_tm); | 193 | return rtc_valid_tm(rtc_tm); |
| 210 | } | 194 | } |
| 211 | 195 | ||
| @@ -225,9 +209,7 @@ static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
| 225 | return -EINVAL; | 209 | return -EINVAL; |
| 226 | } | 210 | } |
| 227 | 211 | ||
| 228 | clk_enable(info->rtc_clk); | 212 | s3c_rtc_enable_clk(info); |
| 229 | if (info->data->needs_src_clk) | ||
| 230 | clk_enable(info->rtc_src_clk); | ||
| 231 | 213 | ||
| 232 | writeb(bin2bcd(tm->tm_sec), info->base + S3C2410_RTCSEC); | 214 | writeb(bin2bcd(tm->tm_sec), info->base + S3C2410_RTCSEC); |
| 233 | writeb(bin2bcd(tm->tm_min), info->base + S3C2410_RTCMIN); | 215 | writeb(bin2bcd(tm->tm_min), info->base + S3C2410_RTCMIN); |
| @@ -236,9 +218,7 @@ static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
| 236 | writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_RTCMON); | 218 | writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_RTCMON); |
| 237 | writeb(bin2bcd(year), info->base + S3C2410_RTCYEAR); | 219 | writeb(bin2bcd(year), info->base + S3C2410_RTCYEAR); |
| 238 | 220 | ||
| 239 | if (info->data->needs_src_clk) | 221 | s3c_rtc_disable_clk(info); |
| 240 | clk_disable(info->rtc_src_clk); | ||
| 241 | clk_disable(info->rtc_clk); | ||
| 242 | 222 | ||
| 243 | return 0; | 223 | return 0; |
| 244 | } | 224 | } |
| @@ -249,9 +229,7 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 249 | struct rtc_time *alm_tm = &alrm->time; | 229 | struct rtc_time *alm_tm = &alrm->time; |
| 250 | unsigned int alm_en; | 230 | unsigned int alm_en; |
| 251 | 231 | ||
| 252 | clk_enable(info->rtc_clk); | 232 | s3c_rtc_enable_clk(info); |
| 253 | if (info->data->needs_src_clk) | ||
| 254 | clk_enable(info->rtc_src_clk); | ||
| 255 | 233 | ||
| 256 | alm_tm->tm_sec = readb(info->base + S3C2410_ALMSEC); | 234 | alm_tm->tm_sec = readb(info->base + S3C2410_ALMSEC); |
| 257 | alm_tm->tm_min = readb(info->base + S3C2410_ALMMIN); | 235 | alm_tm->tm_min = readb(info->base + S3C2410_ALMMIN); |
| @@ -262,6 +240,8 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 262 | 240 | ||
| 263 | alm_en = readb(info->base + S3C2410_RTCALM); | 241 | alm_en = readb(info->base + S3C2410_RTCALM); |
| 264 | 242 | ||
| 243 | s3c_rtc_disable_clk(info); | ||
| 244 | |||
| 265 | alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0; | 245 | alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0; |
| 266 | 246 | ||
| 267 | dev_dbg(dev, "read alarm %d, %04d.%02d.%02d %02d:%02d:%02d\n", | 247 | dev_dbg(dev, "read alarm %d, %04d.%02d.%02d %02d:%02d:%02d\n", |
| @@ -269,9 +249,7 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 269 | 1900 + alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, | 249 | 1900 + alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, |
| 270 | alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec); | 250 | alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec); |
| 271 | 251 | ||
| 272 | |||
| 273 | /* decode the alarm enable field */ | 252 | /* decode the alarm enable field */ |
| 274 | |||
| 275 | if (alm_en & S3C2410_RTCALM_SECEN) | 253 | if (alm_en & S3C2410_RTCALM_SECEN) |
| 276 | alm_tm->tm_sec = bcd2bin(alm_tm->tm_sec); | 254 | alm_tm->tm_sec = bcd2bin(alm_tm->tm_sec); |
| 277 | else | 255 | else |
| @@ -304,10 +282,6 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 304 | else | 282 | else |
| 305 | alm_tm->tm_year = -1; | 283 | alm_tm->tm_year = -1; |
| 306 | 284 | ||
| 307 | if (info->data->needs_src_clk) | ||
| 308 | clk_disable(info->rtc_src_clk); | ||
| 309 | clk_disable(info->rtc_clk); | ||
| 310 | |||
| 311 | return 0; | 285 | return 0; |
| 312 | } | 286 | } |
| 313 | 287 | ||
| @@ -317,15 +291,13 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 317 | struct rtc_time *tm = &alrm->time; | 291 | struct rtc_time *tm = &alrm->time; |
| 318 | unsigned int alrm_en; | 292 | unsigned int alrm_en; |
| 319 | 293 | ||
| 320 | clk_enable(info->rtc_clk); | ||
| 321 | if (info->data->needs_src_clk) | ||
| 322 | clk_enable(info->rtc_src_clk); | ||
| 323 | |||
| 324 | dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", | 294 | dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", |
| 325 | alrm->enabled, | 295 | alrm->enabled, |
| 326 | 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, | 296 | 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, |
| 327 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 297 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 328 | 298 | ||
| 299 | s3c_rtc_enable_clk(info); | ||
| 300 | |||
| 329 | alrm_en = readb(info->base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; | 301 | alrm_en = readb(info->base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; |
| 330 | writeb(0x00, info->base + S3C2410_RTCALM); | 302 | writeb(0x00, info->base + S3C2410_RTCALM); |
| 331 | 303 | ||
| @@ -348,11 +320,9 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 348 | 320 | ||
| 349 | writeb(alrm_en, info->base + S3C2410_RTCALM); | 321 | writeb(alrm_en, info->base + S3C2410_RTCALM); |
| 350 | 322 | ||
| 351 | s3c_rtc_setaie(dev, alrm->enabled); | 323 | s3c_rtc_disable_clk(info); |
| 352 | 324 | ||
| 353 | if (info->data->needs_src_clk) | 325 | s3c_rtc_setaie(dev, alrm->enabled); |
| 354 | clk_disable(info->rtc_src_clk); | ||
| 355 | clk_disable(info->rtc_clk); | ||
| 356 | 326 | ||
| 357 | return 0; | 327 | return 0; |
| 358 | } | 328 | } |
| @@ -361,16 +331,12 @@ static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) | |||
| 361 | { | 331 | { |
| 362 | struct s3c_rtc *info = dev_get_drvdata(dev); | 332 | struct s3c_rtc *info = dev_get_drvdata(dev); |
| 363 | 333 | ||
| 364 | clk_enable(info->rtc_clk); | 334 | s3c_rtc_enable_clk(info); |
| 365 | if (info->data->needs_src_clk) | ||
| 366 | clk_enable(info->rtc_src_clk); | ||
| 367 | 335 | ||
| 368 | if (info->data->enable_tick) | 336 | if (info->data->enable_tick) |
| 369 | info->data->enable_tick(info, seq); | 337 | info->data->enable_tick(info, seq); |
| 370 | 338 | ||
| 371 | if (info->data->needs_src_clk) | 339 | s3c_rtc_disable_clk(info); |
| 372 | clk_disable(info->rtc_src_clk); | ||
| 373 | clk_disable(info->rtc_clk); | ||
| 374 | 340 | ||
| 375 | return 0; | 341 | return 0; |
| 376 | } | 342 | } |
| @@ -388,10 +354,6 @@ static void s3c24xx_rtc_enable(struct s3c_rtc *info) | |||
| 388 | { | 354 | { |
| 389 | unsigned int con, tmp; | 355 | unsigned int con, tmp; |
| 390 | 356 | ||
| 391 | clk_enable(info->rtc_clk); | ||
| 392 | if (info->data->needs_src_clk) | ||
| 393 | clk_enable(info->rtc_src_clk); | ||
| 394 | |||
| 395 | con = readw(info->base + S3C2410_RTCCON); | 357 | con = readw(info->base + S3C2410_RTCCON); |
| 396 | /* re-enable the device, and check it is ok */ | 358 | /* re-enable the device, and check it is ok */ |
| 397 | if ((con & S3C2410_RTCCON_RTCEN) == 0) { | 359 | if ((con & S3C2410_RTCCON_RTCEN) == 0) { |
| @@ -417,20 +379,12 @@ static void s3c24xx_rtc_enable(struct s3c_rtc *info) | |||
| 417 | writew(tmp & ~S3C2410_RTCCON_CLKRST, | 379 | writew(tmp & ~S3C2410_RTCCON_CLKRST, |
| 418 | info->base + S3C2410_RTCCON); | 380 | info->base + S3C2410_RTCCON); |
| 419 | } | 381 | } |
| 420 | |||
| 421 | if (info->data->needs_src_clk) | ||
| 422 | clk_disable(info->rtc_src_clk); | ||
| 423 | clk_disable(info->rtc_clk); | ||
| 424 | } | 382 | } |
| 425 | 383 | ||
| 426 | static void s3c24xx_rtc_disable(struct s3c_rtc *info) | 384 | static void s3c24xx_rtc_disable(struct s3c_rtc *info) |
| 427 | { | 385 | { |
| 428 | unsigned int con; | 386 | unsigned int con; |
| 429 | 387 | ||
| 430 | clk_enable(info->rtc_clk); | ||
| 431 | if (info->data->needs_src_clk) | ||
| 432 | clk_enable(info->rtc_src_clk); | ||
| 433 | |||
| 434 | con = readw(info->base + S3C2410_RTCCON); | 388 | con = readw(info->base + S3C2410_RTCCON); |
| 435 | con &= ~S3C2410_RTCCON_RTCEN; | 389 | con &= ~S3C2410_RTCCON_RTCEN; |
| 436 | writew(con, info->base + S3C2410_RTCCON); | 390 | writew(con, info->base + S3C2410_RTCCON); |
| @@ -438,28 +392,16 @@ static void s3c24xx_rtc_disable(struct s3c_rtc *info) | |||
| 438 | con = readb(info->base + S3C2410_TICNT); | 392 | con = readb(info->base + S3C2410_TICNT); |
| 439 | con &= ~S3C2410_TICNT_ENABLE; | 393 | con &= ~S3C2410_TICNT_ENABLE; |
| 440 | writeb(con, info->base + S3C2410_TICNT); | 394 | writeb(con, info->base + S3C2410_TICNT); |
| 441 | |||
| 442 | if (info->data->needs_src_clk) | ||
| 443 | clk_disable(info->rtc_src_clk); | ||
| 444 | clk_disable(info->rtc_clk); | ||
| 445 | } | 395 | } |
| 446 | 396 | ||
| 447 | static void s3c6410_rtc_disable(struct s3c_rtc *info) | 397 | static void s3c6410_rtc_disable(struct s3c_rtc *info) |
| 448 | { | 398 | { |
| 449 | unsigned int con; | 399 | unsigned int con; |
| 450 | 400 | ||
| 451 | clk_enable(info->rtc_clk); | ||
| 452 | if (info->data->needs_src_clk) | ||
| 453 | clk_enable(info->rtc_src_clk); | ||
| 454 | |||
| 455 | con = readw(info->base + S3C2410_RTCCON); | 401 | con = readw(info->base + S3C2410_RTCCON); |
| 456 | con &= ~S3C64XX_RTCCON_TICEN; | 402 | con &= ~S3C64XX_RTCCON_TICEN; |
| 457 | con &= ~S3C2410_RTCCON_RTCEN; | 403 | con &= ~S3C2410_RTCCON_RTCEN; |
| 458 | writew(con, info->base + S3C2410_RTCCON); | 404 | writew(con, info->base + S3C2410_RTCCON); |
| 459 | |||
| 460 | if (info->data->needs_src_clk) | ||
| 461 | clk_disable(info->rtc_src_clk); | ||
| 462 | clk_disable(info->rtc_clk); | ||
| 463 | } | 405 | } |
| 464 | 406 | ||
| 465 | static int s3c_rtc_remove(struct platform_device *pdev) | 407 | static int s3c_rtc_remove(struct platform_device *pdev) |
| @@ -598,15 +540,16 @@ static int s3c_rtc_probe(struct platform_device *pdev) | |||
| 598 | 540 | ||
| 599 | s3c_rtc_setfreq(info, 1); | 541 | s3c_rtc_setfreq(info, 1); |
| 600 | 542 | ||
| 601 | if (info->data->needs_src_clk) | 543 | s3c_rtc_disable_clk(info); |
| 602 | clk_disable(info->rtc_src_clk); | ||
| 603 | clk_disable(info->rtc_clk); | ||
| 604 | 544 | ||
| 605 | return 0; | 545 | return 0; |
| 606 | 546 | ||
| 607 | err_nortc: | 547 | err_nortc: |
| 608 | if (info->data->disable) | 548 | if (info->data->disable) |
| 609 | info->data->disable(info); | 549 | info->data->disable(info); |
| 550 | |||
| 551 | if (info->data->needs_src_clk) | ||
| 552 | clk_disable_unprepare(info->rtc_src_clk); | ||
| 610 | clk_disable_unprepare(info->rtc_clk); | 553 | clk_disable_unprepare(info->rtc_clk); |
| 611 | 554 | ||
| 612 | return ret; | 555 | return ret; |
| @@ -618,9 +561,7 @@ static int s3c_rtc_suspend(struct device *dev) | |||
| 618 | { | 561 | { |
| 619 | struct s3c_rtc *info = dev_get_drvdata(dev); | 562 | struct s3c_rtc *info = dev_get_drvdata(dev); |
| 620 | 563 | ||
| 621 | clk_enable(info->rtc_clk); | 564 | s3c_rtc_enable_clk(info); |
| 622 | if (info->data->needs_src_clk) | ||
| 623 | clk_enable(info->rtc_src_clk); | ||
| 624 | 565 | ||
| 625 | /* save TICNT for anyone using periodic interrupts */ | 566 | /* save TICNT for anyone using periodic interrupts */ |
| 626 | if (info->data->save_tick_cnt) | 567 | if (info->data->save_tick_cnt) |
| @@ -636,10 +577,6 @@ static int s3c_rtc_suspend(struct device *dev) | |||
| 636 | dev_err(dev, "enable_irq_wake failed\n"); | 577 | dev_err(dev, "enable_irq_wake failed\n"); |
| 637 | } | 578 | } |
| 638 | 579 | ||
| 639 | if (info->data->needs_src_clk) | ||
| 640 | clk_disable(info->rtc_src_clk); | ||
| 641 | clk_disable(info->rtc_clk); | ||
| 642 | |||
| 643 | return 0; | 580 | return 0; |
| 644 | } | 581 | } |
| 645 | 582 | ||
| @@ -647,25 +584,19 @@ static int s3c_rtc_resume(struct device *dev) | |||
| 647 | { | 584 | { |
| 648 | struct s3c_rtc *info = dev_get_drvdata(dev); | 585 | struct s3c_rtc *info = dev_get_drvdata(dev); |
| 649 | 586 | ||
| 650 | clk_enable(info->rtc_clk); | ||
| 651 | if (info->data->needs_src_clk) | ||
| 652 | clk_enable(info->rtc_src_clk); | ||
| 653 | |||
| 654 | if (info->data->enable) | 587 | if (info->data->enable) |
| 655 | info->data->enable(info); | 588 | info->data->enable(info); |
| 656 | 589 | ||
| 657 | if (info->data->restore_tick_cnt) | 590 | if (info->data->restore_tick_cnt) |
| 658 | info->data->restore_tick_cnt(info); | 591 | info->data->restore_tick_cnt(info); |
| 659 | 592 | ||
| 593 | s3c_rtc_disable_clk(info); | ||
| 594 | |||
| 660 | if (device_may_wakeup(dev) && info->wake_en) { | 595 | if (device_may_wakeup(dev) && info->wake_en) { |
| 661 | disable_irq_wake(info->irq_alarm); | 596 | disable_irq_wake(info->irq_alarm); |
| 662 | info->wake_en = false; | 597 | info->wake_en = false; |
| 663 | } | 598 | } |
| 664 | 599 | ||
| 665 | if (info->data->needs_src_clk) | ||
| 666 | clk_disable(info->rtc_src_clk); | ||
| 667 | clk_disable(info->rtc_clk); | ||
| 668 | |||
| 669 | return 0; | 600 | return 0; |
| 670 | } | 601 | } |
| 671 | #endif | 602 | #endif |
| @@ -673,29 +604,13 @@ static SIMPLE_DEV_PM_OPS(s3c_rtc_pm_ops, s3c_rtc_suspend, s3c_rtc_resume); | |||
| 673 | 604 | ||
| 674 | static void s3c24xx_rtc_irq(struct s3c_rtc *info, int mask) | 605 | static void s3c24xx_rtc_irq(struct s3c_rtc *info, int mask) |
| 675 | { | 606 | { |
| 676 | clk_enable(info->rtc_clk); | ||
| 677 | if (info->data->needs_src_clk) | ||
| 678 | clk_enable(info->rtc_src_clk); | ||
| 679 | rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); | 607 | rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); |
| 680 | if (info->data->needs_src_clk) | ||
| 681 | clk_disable(info->rtc_src_clk); | ||
| 682 | clk_disable(info->rtc_clk); | ||
| 683 | |||
| 684 | s3c_rtc_alarm_clk_enable(info, false); | ||
| 685 | } | 608 | } |
| 686 | 609 | ||
| 687 | static void s3c6410_rtc_irq(struct s3c_rtc *info, int mask) | 610 | static void s3c6410_rtc_irq(struct s3c_rtc *info, int mask) |
| 688 | { | 611 | { |
| 689 | clk_enable(info->rtc_clk); | ||
| 690 | if (info->data->needs_src_clk) | ||
| 691 | clk_enable(info->rtc_src_clk); | ||
| 692 | rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); | 612 | rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); |
| 693 | writeb(mask, info->base + S3C2410_INTP); | 613 | writeb(mask, info->base + S3C2410_INTP); |
| 694 | if (info->data->needs_src_clk) | ||
| 695 | clk_disable(info->rtc_src_clk); | ||
| 696 | clk_disable(info->rtc_clk); | ||
| 697 | |||
| 698 | s3c_rtc_alarm_clk_enable(info, false); | ||
| 699 | } | 614 | } |
| 700 | 615 | ||
| 701 | static void s3c2410_rtc_setfreq(struct s3c_rtc *info, int freq) | 616 | static void s3c2410_rtc_setfreq(struct s3c_rtc *info, int freq) |
