diff options
-rw-r--r-- | arch/x86/kernel/hpet.c | 9 | ||||
-rw-r--r-- | drivers/char/hpet.c | 51 | ||||
-rw-r--r-- | include/linux/hpet.h | 2 |
3 files changed, 14 insertions, 48 deletions
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index 235fd6c77504..36652ea1a265 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c | |||
@@ -133,13 +133,16 @@ static void hpet_reserve_platform_timers(unsigned long id) | |||
133 | #ifdef CONFIG_HPET_EMULATE_RTC | 133 | #ifdef CONFIG_HPET_EMULATE_RTC |
134 | hpet_reserve_timer(&hd, 1); | 134 | hpet_reserve_timer(&hd, 1); |
135 | #endif | 135 | #endif |
136 | |||
136 | hd.hd_irq[0] = HPET_LEGACY_8254; | 137 | hd.hd_irq[0] = HPET_LEGACY_8254; |
137 | hd.hd_irq[1] = HPET_LEGACY_RTC; | 138 | hd.hd_irq[1] = HPET_LEGACY_RTC; |
138 | 139 | ||
139 | for (i = 2; i < nrtimers; timer++, i++) | 140 | for (i = 2; i < nrtimers; timer++, i++) |
140 | hd.hd_irq[i] = (timer->hpet_config & Tn_INT_ROUTE_CNF_MASK) >> | 141 | hd.hd_irq[i] = (timer->hpet_config & Tn_INT_ROUTE_CNF_MASK) >> |
141 | Tn_INT_ROUTE_CNF_SHIFT; | 142 | Tn_INT_ROUTE_CNF_SHIFT; |
143 | |||
142 | hpet_alloc(&hd); | 144 | hpet_alloc(&hd); |
145 | |||
143 | } | 146 | } |
144 | #else | 147 | #else |
145 | static void hpet_reserve_platform_timers(unsigned long id) { } | 148 | static void hpet_reserve_platform_timers(unsigned long id) { } |
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 465ad35ed38f..1399971be689 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c | |||
@@ -731,14 +731,14 @@ static unsigned long hpet_calibrate(struct hpets *hpetp) | |||
731 | 731 | ||
732 | int hpet_alloc(struct hpet_data *hdp) | 732 | int hpet_alloc(struct hpet_data *hdp) |
733 | { | 733 | { |
734 | u64 cap, mcfg, hpet_config; | 734 | u64 cap, mcfg; |
735 | struct hpet_dev *devp; | 735 | struct hpet_dev *devp; |
736 | u32 i, ntimer, irq; | 736 | u32 i, ntimer; |
737 | struct hpets *hpetp; | 737 | struct hpets *hpetp; |
738 | size_t siz; | 738 | size_t siz; |
739 | struct hpet __iomem *hpet; | 739 | struct hpet __iomem *hpet; |
740 | static struct hpets *last = NULL; | 740 | static struct hpets *last = NULL; |
741 | unsigned long period, irq_bitmap; | 741 | unsigned long period; |
742 | unsigned long long temp; | 742 | unsigned long long temp; |
743 | 743 | ||
744 | /* | 744 | /* |
@@ -765,47 +765,11 @@ int hpet_alloc(struct hpet_data *hdp) | |||
765 | hpetp->hp_hpet_phys = hdp->hd_phys_address; | 765 | hpetp->hp_hpet_phys = hdp->hd_phys_address; |
766 | 766 | ||
767 | hpetp->hp_ntimer = hdp->hd_nirqs; | 767 | hpetp->hp_ntimer = hdp->hd_nirqs; |
768 | hpet = hpetp->hp_hpet; | ||
769 | |||
770 | /* Assign IRQs statically for legacy devices */ | ||
771 | hpetp->hp_dev[0].hd_hdwirq = hdp->hd_irq[0]; | ||
772 | hpetp->hp_dev[1].hd_hdwirq = hdp->hd_irq[1]; | ||
773 | |||
774 | /* Assign IRQs dynamically for the others */ | ||
775 | for (i = 2, devp = &hpetp->hp_dev[2]; i < hdp->hd_nirqs; i++, devp++) { | ||
776 | struct hpet_timer __iomem *timer; | ||
777 | 768 | ||
778 | timer = &hpet->hpet_timers[devp - hpetp->hp_dev]; | 769 | for (i = 0; i < hdp->hd_nirqs; i++) |
770 | hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i]; | ||
779 | 771 | ||
780 | /* Check if there's already an IRQ assigned to the timer */ | 772 | hpet = hpetp->hp_hpet; |
781 | if (hdp->hd_irq[i]) { | ||
782 | hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i]; | ||
783 | continue; | ||
784 | } | ||
785 | |||
786 | hpet_config = readq(&timer->hpet_config); | ||
787 | irq_bitmap = (hpet_config & Tn_INT_ROUTE_CAP_MASK) | ||
788 | >> Tn_INT_ROUTE_CAP_SHIFT; | ||
789 | if (!irq_bitmap) | ||
790 | irq = 0; /* No valid IRQ Assignable */ | ||
791 | else { | ||
792 | irq = find_first_bit(&irq_bitmap, 32); | ||
793 | do { | ||
794 | hpet_config |= irq << Tn_INT_ROUTE_CNF_SHIFT; | ||
795 | writeq(hpet_config, &timer->hpet_config); | ||
796 | |||
797 | /* | ||
798 | * Verify whether we have written a valid | ||
799 | * IRQ number by reading it back again | ||
800 | */ | ||
801 | hpet_config = readq(&timer->hpet_config); | ||
802 | if (irq == (hpet_config & Tn_INT_ROUTE_CNF_MASK) | ||
803 | >> Tn_INT_ROUTE_CNF_SHIFT) | ||
804 | break; /* Success */ | ||
805 | } while ((irq = (find_next_bit(&irq_bitmap, 32, irq)))); | ||
806 | } | ||
807 | hpetp->hp_dev[i].hd_hdwirq = irq; | ||
808 | } | ||
809 | 773 | ||
810 | cap = readq(&hpet->hpet_cap); | 774 | cap = readq(&hpet->hpet_cap); |
811 | 775 | ||
@@ -836,8 +800,7 @@ int hpet_alloc(struct hpet_data *hdp) | |||
836 | hpetp->hp_which, hdp->hd_phys_address, | 800 | hpetp->hp_which, hdp->hd_phys_address, |
837 | hpetp->hp_ntimer > 1 ? "s" : ""); | 801 | hpetp->hp_ntimer > 1 ? "s" : ""); |
838 | for (i = 0; i < hpetp->hp_ntimer; i++) | 802 | for (i = 0; i < hpetp->hp_ntimer; i++) |
839 | printk("%s %d", i > 0 ? "," : "", | 803 | printk("%s %d", i > 0 ? "," : "", hdp->hd_irq[i]); |
840 | hpetp->hp_dev[i].hd_hdwirq); | ||
841 | printk("\n"); | 804 | printk("\n"); |
842 | 805 | ||
843 | printk(KERN_INFO "hpet%u: %u %d-bit timers, %Lu Hz\n", | 806 | printk(KERN_INFO "hpet%u: %u %d-bit timers, %Lu Hz\n", |
diff --git a/include/linux/hpet.h b/include/linux/hpet.h index 9cd94bfd07e5..2dc29ce6c8e4 100644 --- a/include/linux/hpet.h +++ b/include/linux/hpet.h | |||
@@ -64,7 +64,7 @@ struct hpet { | |||
64 | */ | 64 | */ |
65 | 65 | ||
66 | #define Tn_INT_ROUTE_CAP_MASK (0xffffffff00000000ULL) | 66 | #define Tn_INT_ROUTE_CAP_MASK (0xffffffff00000000ULL) |
67 | #define Tn_INT_ROUTE_CAP_SHIFT (32UL) | 67 | #define Tn_INI_ROUTE_CAP_SHIFT (32UL) |
68 | #define Tn_FSB_INT_DELCAP_MASK (0x8000UL) | 68 | #define Tn_FSB_INT_DELCAP_MASK (0x8000UL) |
69 | #define Tn_FSB_INT_DELCAP_SHIFT (15) | 69 | #define Tn_FSB_INT_DELCAP_SHIFT (15) |
70 | #define Tn_FSB_EN_CNF_MASK (0x4000UL) | 70 | #define Tn_FSB_EN_CNF_MASK (0x4000UL) |