aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2012-07-30 17:41:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 20:25:18 -0400
commitaff05ed5d103524bd69bd9d7b621c5c8a6c63198 (patch)
treee71d87d9b9f6f18ea31395382a90084ff9461829 /drivers/rtc
parent36ac1d24f1488c32b85a1718a4edfda615b2ef77 (diff)
rtc: pl031: encapsulate per-vendor ops
Move the per-vendor operations for this RTC into a encapsulating struct so we can have more per-vendor variables than just the ops. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Cc: Alessandro Zummo <a.zummo@towertech.it> 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-pl031.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index cc0533994f6e..575fbbf966db 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -68,7 +68,16 @@
68 68
69#define RTC_TIMER_FREQ 32768 69#define RTC_TIMER_FREQ 32768
70 70
71/**
72 * struct pl031_vendor_data - per-vendor variations
73 * @ops: the vendor-specific operations used on this silicon version
74 */
75struct pl031_vendor_data {
76 struct rtc_class_ops ops;
77};
78
71struct pl031_local { 79struct pl031_local {
80 struct pl031_vendor_data *vendor;
72 struct rtc_device *rtc; 81 struct rtc_device *rtc;
73 void __iomem *base; 82 void __iomem *base;
74 u8 hw_designer; 83 u8 hw_designer;
@@ -303,7 +312,8 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
303{ 312{
304 int ret; 313 int ret;
305 struct pl031_local *ldata; 314 struct pl031_local *ldata;
306 struct rtc_class_ops *ops = id->data; 315 struct pl031_vendor_data *vendor = id->data;
316 struct rtc_class_ops *ops = &vendor->ops;
307 unsigned long time; 317 unsigned long time;
308 318
309 ret = amba_request_regions(adev, NULL); 319 ret = amba_request_regions(adev, NULL);
@@ -315,6 +325,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
315 ret = -ENOMEM; 325 ret = -ENOMEM;
316 goto out; 326 goto out;
317 } 327 }
328 ldata->vendor = vendor;
318 329
319 ldata->base = ioremap(adev->res.start, resource_size(&adev->res)); 330 ldata->base = ioremap(adev->res.start, resource_size(&adev->res));
320 331
@@ -383,48 +394,54 @@ err_req:
383} 394}
384 395
385/* Operations for the original ARM version */ 396/* Operations for the original ARM version */
386static struct rtc_class_ops arm_pl031_ops = { 397static struct pl031_vendor_data arm_pl031 = {
387 .read_time = pl031_read_time, 398 .ops = {
388 .set_time = pl031_set_time, 399 .read_time = pl031_read_time,
389 .read_alarm = pl031_read_alarm, 400 .set_time = pl031_set_time,
390 .set_alarm = pl031_set_alarm, 401 .read_alarm = pl031_read_alarm,
391 .alarm_irq_enable = pl031_alarm_irq_enable, 402 .set_alarm = pl031_set_alarm,
403 .alarm_irq_enable = pl031_alarm_irq_enable,
404 },
392}; 405};
393 406
394/* The First ST derivative */ 407/* The First ST derivative */
395static struct rtc_class_ops stv1_pl031_ops = { 408static struct pl031_vendor_data stv1_pl031 = {
396 .read_time = pl031_read_time, 409 .ops = {
397 .set_time = pl031_set_time, 410 .read_time = pl031_read_time,
398 .read_alarm = pl031_read_alarm, 411 .set_time = pl031_set_time,
399 .set_alarm = pl031_set_alarm, 412 .read_alarm = pl031_read_alarm,
400 .alarm_irq_enable = pl031_alarm_irq_enable, 413 .set_alarm = pl031_set_alarm,
414 .alarm_irq_enable = pl031_alarm_irq_enable,
415 },
401}; 416};
402 417
403/* And the second ST derivative */ 418/* And the second ST derivative */
404static struct rtc_class_ops stv2_pl031_ops = { 419static struct pl031_vendor_data stv2_pl031 = {
405 .read_time = pl031_stv2_read_time, 420 .ops = {
406 .set_time = pl031_stv2_set_time, 421 .read_time = pl031_stv2_read_time,
407 .read_alarm = pl031_stv2_read_alarm, 422 .set_time = pl031_stv2_set_time,
408 .set_alarm = pl031_stv2_set_alarm, 423 .read_alarm = pl031_stv2_read_alarm,
409 .alarm_irq_enable = pl031_alarm_irq_enable, 424 .set_alarm = pl031_stv2_set_alarm,
425 .alarm_irq_enable = pl031_alarm_irq_enable,
426 },
410}; 427};
411 428
412static struct amba_id pl031_ids[] = { 429static struct amba_id pl031_ids[] = {
413 { 430 {
414 .id = 0x00041031, 431 .id = 0x00041031,
415 .mask = 0x000fffff, 432 .mask = 0x000fffff,
416 .data = &arm_pl031_ops, 433 .data = &arm_pl031,
417 }, 434 },
418 /* ST Micro variants */ 435 /* ST Micro variants */
419 { 436 {
420 .id = 0x00180031, 437 .id = 0x00180031,
421 .mask = 0x00ffffff, 438 .mask = 0x00ffffff,
422 .data = &stv1_pl031_ops, 439 .data = &stv1_pl031,
423 }, 440 },
424 { 441 {
425 .id = 0x00280031, 442 .id = 0x00280031,
426 .mask = 0x00ffffff, 443 .mask = 0x00ffffff,
427 .data = &stv2_pl031_ops, 444 .data = &stv2_pl031,
428 }, 445 },
429 {0, 0}, 446 {0, 0},
430}; 447};