aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc64/kernel/time.c')
-rw-r--r--arch/sparc64/kernel/time.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index 6b9a06e42542..a31a0439244f 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -680,22 +680,14 @@ static int starfire_set_time(u32 val)
680 680
681static u32 hypervisor_get_time(void) 681static u32 hypervisor_get_time(void)
682{ 682{
683 register unsigned long func asm("%o5"); 683 unsigned long ret, time;
684 register unsigned long arg0 asm("%o0");
685 register unsigned long arg1 asm("%o1");
686 int retries = 10000; 684 int retries = 10000;
687 685
688retry: 686retry:
689 func = HV_FAST_TOD_GET; 687 ret = sun4v_tod_get(&time);
690 arg0 = 0; 688 if (ret == HV_EOK)
691 arg1 = 0; 689 return time;
692 __asm__ __volatile__("ta %6" 690 if (ret == HV_EWOULDBLOCK) {
693 : "=&r" (func), "=&r" (arg0), "=&r" (arg1)
694 : "0" (func), "1" (arg0), "2" (arg1),
695 "i" (HV_FAST_TRAP));
696 if (arg0 == HV_EOK)
697 return arg1;
698 if (arg0 == HV_EWOULDBLOCK) {
699 if (--retries > 0) { 691 if (--retries > 0) {
700 udelay(100); 692 udelay(100);
701 goto retry; 693 goto retry;
@@ -709,20 +701,14 @@ retry:
709 701
710static int hypervisor_set_time(u32 secs) 702static int hypervisor_set_time(u32 secs)
711{ 703{
712 register unsigned long func asm("%o5"); 704 unsigned long ret;
713 register unsigned long arg0 asm("%o0");
714 int retries = 10000; 705 int retries = 10000;
715 706
716retry: 707retry:
717 func = HV_FAST_TOD_SET; 708 ret = sun4v_tod_set(secs);
718 arg0 = secs; 709 if (ret == HV_EOK)
719 __asm__ __volatile__("ta %4"
720 : "=&r" (func), "=&r" (arg0)
721 : "0" (func), "1" (arg0),
722 "i" (HV_FAST_TRAP));
723 if (arg0 == HV_EOK)
724 return 0; 710 return 0;
725 if (arg0 == HV_EWOULDBLOCK) { 711 if (ret == HV_EWOULDBLOCK) {
726 if (--retries > 0) { 712 if (--retries > 0) {
727 udelay(100); 713 udelay(100);
728 goto retry; 714 goto retry;
@@ -862,7 +848,6 @@ fs_initcall(clock_init);
862static unsigned long sparc64_init_timers(void) 848static unsigned long sparc64_init_timers(void)
863{ 849{
864 struct device_node *dp; 850 struct device_node *dp;
865 struct property *prop;
866 unsigned long clock; 851 unsigned long clock;
867#ifdef CONFIG_SMP 852#ifdef CONFIG_SMP
868 extern void smp_tick_init(void); 853 extern void smp_tick_init(void);
@@ -879,17 +864,15 @@ static unsigned long sparc64_init_timers(void)
879 if (manuf == 0x17 && impl == 0x13) { 864 if (manuf == 0x17 && impl == 0x13) {
880 /* Hummingbird, aka Ultra-IIe */ 865 /* Hummingbird, aka Ultra-IIe */
881 tick_ops = &hbtick_operations; 866 tick_ops = &hbtick_operations;
882 prop = of_find_property(dp, "stick-frequency", NULL); 867 clock = of_getintprop_default(dp, "stick-frequency", 0);
883 } else { 868 } else {
884 tick_ops = &tick_operations; 869 tick_ops = &tick_operations;
885 cpu_find_by_instance(0, &dp, NULL); 870 clock = local_cpu_data().clock_tick;
886 prop = of_find_property(dp, "clock-frequency", NULL);
887 } 871 }
888 } else { 872 } else {
889 tick_ops = &stick_operations; 873 tick_ops = &stick_operations;
890 prop = of_find_property(dp, "stick-frequency", NULL); 874 clock = of_getintprop_default(dp, "stick-frequency", 0);
891 } 875 }
892 clock = *(unsigned int *) prop->value;
893 876
894#ifdef CONFIG_SMP 877#ifdef CONFIG_SMP
895 smp_tick_init(); 878 smp_tick_init();
@@ -1030,7 +1013,7 @@ void __devinit setup_sparc64_timer(void)
1030 clockevents_register_device(sevt); 1013 clockevents_register_device(sevt);
1031} 1014}
1032 1015
1033#define SPARC64_NSEC_PER_CYC_SHIFT 32UL 1016#define SPARC64_NSEC_PER_CYC_SHIFT 10UL
1034 1017
1035static struct clocksource clocksource_tick = { 1018static struct clocksource clocksource_tick = {
1036 .rating = 100, 1019 .rating = 100,
@@ -1365,6 +1348,7 @@ static int hypervisor_set_rtc_time(struct rtc_time *time)
1365 return hypervisor_set_time(seconds); 1348 return hypervisor_set_time(seconds);
1366} 1349}
1367 1350
1351#ifdef CONFIG_PCI
1368static void bq4802_get_rtc_time(struct rtc_time *time) 1352static void bq4802_get_rtc_time(struct rtc_time *time)
1369{ 1353{
1370 unsigned char val = readb(bq4802_regs + 0x0e); 1354 unsigned char val = readb(bq4802_regs + 0x0e);
@@ -1436,6 +1420,7 @@ static int bq4802_set_rtc_time(struct rtc_time *time)
1436 1420
1437 return 0; 1421 return 0;
1438} 1422}
1423#endif /* CONFIG_PCI */
1439 1424
1440struct mini_rtc_ops { 1425struct mini_rtc_ops {
1441 void (*get_rtc_time)(struct rtc_time *); 1426 void (*get_rtc_time)(struct rtc_time *);
@@ -1452,10 +1437,12 @@ static struct mini_rtc_ops hypervisor_rtc_ops = {
1452 .set_rtc_time = hypervisor_set_rtc_time, 1437 .set_rtc_time = hypervisor_set_rtc_time,
1453}; 1438};
1454 1439
1440#ifdef CONFIG_PCI
1455static struct mini_rtc_ops bq4802_rtc_ops = { 1441static struct mini_rtc_ops bq4802_rtc_ops = {
1456 .get_rtc_time = bq4802_get_rtc_time, 1442 .get_rtc_time = bq4802_get_rtc_time,
1457 .set_rtc_time = bq4802_set_rtc_time, 1443 .set_rtc_time = bq4802_set_rtc_time,
1458}; 1444};
1445#endif /* CONFIG_PCI */
1459 1446
1460static struct mini_rtc_ops *mini_rtc_ops; 1447static struct mini_rtc_ops *mini_rtc_ops;
1461 1448
@@ -1579,8 +1566,10 @@ static int __init rtc_mini_init(void)
1579 mini_rtc_ops = &hypervisor_rtc_ops; 1566 mini_rtc_ops = &hypervisor_rtc_ops;
1580 else if (this_is_starfire) 1567 else if (this_is_starfire)
1581 mini_rtc_ops = &starfire_rtc_ops; 1568 mini_rtc_ops = &starfire_rtc_ops;
1569#ifdef CONFIG_PCI
1582 else if (bq4802_regs) 1570 else if (bq4802_regs)
1583 mini_rtc_ops = &bq4802_rtc_ops; 1571 mini_rtc_ops = &bq4802_rtc_ops;
1572#endif /* CONFIG_PCI */
1584 else 1573 else
1585 return -ENODEV; 1574 return -ENODEV;
1586 1575