diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-07-27 17:40:27 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-30 03:27:32 -0400 |
commit | a0afaa6ab12cf696d170c22a8fdfd88c3e33555c (patch) | |
tree | 2c0c6cafa7ae8d95e8828d7f9bda0034b2e4452c /arch | |
parent | 3961bae0ac030a70ae2e0578270203889021f1a1 (diff) |
[SPARC64]: Handle mostek clock type in mini_rtc driver.
Now that drivers/sbus/char/rtc.c is sparc32 only, we need this.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc64/kernel/time.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 49063ca2efcd..69cad1b653c1 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c | |||
@@ -1460,6 +1460,74 @@ static int cmos_set_rtc_time(struct rtc_time *rtc_tm) | |||
1460 | } | 1460 | } |
1461 | #endif /* CONFIG_PCI */ | 1461 | #endif /* CONFIG_PCI */ |
1462 | 1462 | ||
1463 | static void mostek_get_rtc_time(struct rtc_time *rtc_tm) | ||
1464 | { | ||
1465 | void __iomem *regs = mstk48t02_regs; | ||
1466 | u8 tmp; | ||
1467 | |||
1468 | spin_lock_irq(&mostek_lock); | ||
1469 | |||
1470 | tmp = mostek_read(regs + MOSTEK_CREG); | ||
1471 | tmp |= MSTK_CREG_READ; | ||
1472 | mostek_write(regs + MOSTEK_CREG, tmp); | ||
1473 | |||
1474 | rtc_tm->tm_sec = MSTK_REG_SEC(regs); | ||
1475 | rtc_tm->tm_min = MSTK_REG_MIN(regs); | ||
1476 | rtc_tm->tm_hour = MSTK_REG_HOUR(regs); | ||
1477 | rtc_tm->tm_mday = MSTK_REG_DOM(regs); | ||
1478 | rtc_tm->tm_mon = MSTK_REG_MONTH(regs); | ||
1479 | rtc_tm->tm_year = MSTK_CVT_YEAR( MSTK_REG_YEAR(regs) ); | ||
1480 | rtc_tm->tm_wday = MSTK_REG_DOW(regs); | ||
1481 | |||
1482 | tmp = mostek_read(regs + MOSTEK_CREG); | ||
1483 | tmp &= ~MSTK_CREG_READ; | ||
1484 | mostek_write(regs + MOSTEK_CREG, tmp); | ||
1485 | |||
1486 | spin_unlock_irq(&mostek_lock); | ||
1487 | |||
1488 | rtc_tm->tm_mon--; | ||
1489 | rtc_tm->tm_wday--; | ||
1490 | rtc_tm->tm_year -= 1900; | ||
1491 | } | ||
1492 | |||
1493 | static int mostek_set_rtc_time(struct rtc_time *rtc_tm) | ||
1494 | { | ||
1495 | unsigned char mon, day, hrs, min, sec, wday; | ||
1496 | void __iomem *regs = mstk48t02_regs; | ||
1497 | unsigned int yrs; | ||
1498 | u8 tmp; | ||
1499 | |||
1500 | yrs = rtc_tm->tm_year + 1900; | ||
1501 | mon = rtc_tm->tm_mon + 1; | ||
1502 | day = rtc_tm->tm_mday; | ||
1503 | wday = rtc_tm->tm_wday + 1; | ||
1504 | hrs = rtc_tm->tm_hour; | ||
1505 | min = rtc_tm->tm_min; | ||
1506 | sec = rtc_tm->tm_sec; | ||
1507 | |||
1508 | spin_lock_irq(&mostek_lock); | ||
1509 | |||
1510 | tmp = mostek_read(regs + MOSTEK_CREG); | ||
1511 | tmp |= MSTK_CREG_WRITE; | ||
1512 | mostek_write(regs + MOSTEK_CREG, tmp); | ||
1513 | |||
1514 | MSTK_SET_REG_SEC(regs, sec); | ||
1515 | MSTK_SET_REG_MIN(regs, min); | ||
1516 | MSTK_SET_REG_HOUR(regs, hrs); | ||
1517 | MSTK_SET_REG_DOW(regs, wday); | ||
1518 | MSTK_SET_REG_DOM(regs, day); | ||
1519 | MSTK_SET_REG_MONTH(regs, mon); | ||
1520 | MSTK_SET_REG_YEAR(regs, yrs - MSTK_YEAR_ZERO); | ||
1521 | |||
1522 | tmp = mostek_read(regs + MOSTEK_CREG); | ||
1523 | tmp &= ~MSTK_CREG_WRITE; | ||
1524 | mostek_write(regs + MOSTEK_CREG, tmp); | ||
1525 | |||
1526 | spin_unlock_irq(&mostek_lock); | ||
1527 | |||
1528 | return 0; | ||
1529 | } | ||
1530 | |||
1463 | struct mini_rtc_ops { | 1531 | struct mini_rtc_ops { |
1464 | void (*get_rtc_time)(struct rtc_time *); | 1532 | void (*get_rtc_time)(struct rtc_time *); |
1465 | int (*set_rtc_time)(struct rtc_time *); | 1533 | int (*set_rtc_time)(struct rtc_time *); |
@@ -1487,6 +1555,11 @@ static struct mini_rtc_ops cmos_rtc_ops = { | |||
1487 | }; | 1555 | }; |
1488 | #endif /* CONFIG_PCI */ | 1556 | #endif /* CONFIG_PCI */ |
1489 | 1557 | ||
1558 | static struct mini_rtc_ops mostek_rtc_ops = { | ||
1559 | .get_rtc_time = mostek_get_rtc_time, | ||
1560 | .set_rtc_time = mostek_set_rtc_time, | ||
1561 | }; | ||
1562 | |||
1490 | static struct mini_rtc_ops *mini_rtc_ops; | 1563 | static struct mini_rtc_ops *mini_rtc_ops; |
1491 | 1564 | ||
1492 | static inline void mini_get_rtc_time(struct rtc_time *time) | 1565 | static inline void mini_get_rtc_time(struct rtc_time *time) |
@@ -1615,6 +1688,8 @@ static int __init rtc_mini_init(void) | |||
1615 | else if (ds1287_regs) | 1688 | else if (ds1287_regs) |
1616 | mini_rtc_ops = &cmos_rtc_ops; | 1689 | mini_rtc_ops = &cmos_rtc_ops; |
1617 | #endif /* CONFIG_PCI */ | 1690 | #endif /* CONFIG_PCI */ |
1691 | else if (mstk48t02_regs) | ||
1692 | mini_rtc_ops = &mostek_rtc_ops; | ||
1618 | else | 1693 | else |
1619 | return -ENODEV; | 1694 | return -ENODEV; |
1620 | 1695 | ||