aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hpet.c
diff options
context:
space:
mode:
authorBalaji Rao <balajirrao@gmail.com>2008-01-30 07:30:03 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:30:03 -0500
commite3f37a54f690d3e64995ea7ecea08c5ab3070faf (patch)
tree1d9d62d95b747ef47cdf994357bd9a41d02889a3 /drivers/char/hpet.c
parent45fe4fe19120a22f7339f5bb110447170c25fca9 (diff)
x86: assign IRQs to HPET timers
The userspace API for the HPET (see Documentation/hpet.txt) did not work. The HPET_IE_ON ioctl was failing as there was no IRQ assigned to the timer device. This patch fixes it by allocating IRQs to timer blocks in the HPET. arch/x86/kernel/hpet.c | 13 +++++-------- drivers/char/hpet.c | 45 ++++++++++++++++++++++++++++++++++++++------- include/linux/hpet.h | 2 +- 3 files changed, 44 insertions(+), 16 deletions(-) Signed-off-by: Balaji Rao <balajirrao@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/char/hpet.c')
-rw-r--r--drivers/char/hpet.c45
1 files changed, 38 insertions, 7 deletions
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 4c16778e3f84..593b32cfbc33 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -806,14 +806,14 @@ static unsigned long hpet_calibrate(struct hpets *hpetp)
806 806
807int hpet_alloc(struct hpet_data *hdp) 807int hpet_alloc(struct hpet_data *hdp)
808{ 808{
809 u64 cap, mcfg; 809 u64 cap, mcfg, hpet_config;
810 struct hpet_dev *devp; 810 struct hpet_dev *devp;
811 u32 i, ntimer; 811 u32 i, ntimer, irq;
812 struct hpets *hpetp; 812 struct hpets *hpetp;
813 size_t siz; 813 size_t siz;
814 struct hpet __iomem *hpet; 814 struct hpet __iomem *hpet;
815 static struct hpets *last = NULL; 815 static struct hpets *last = NULL;
816 unsigned long period; 816 unsigned long period, irq_bitmap;
817 unsigned long long temp; 817 unsigned long long temp;
818 818
819 /* 819 /*
@@ -840,11 +840,41 @@ int hpet_alloc(struct hpet_data *hdp)
840 hpetp->hp_hpet_phys = hdp->hd_phys_address; 840 hpetp->hp_hpet_phys = hdp->hd_phys_address;
841 841
842 hpetp->hp_ntimer = hdp->hd_nirqs; 842 hpetp->hp_ntimer = hdp->hd_nirqs;
843 hpet = hpetp->hp_hpet;
843 844
844 for (i = 0; i < hdp->hd_nirqs; i++) 845 /* Assign IRQs statically for legacy devices */
845 hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i]; 846 hpetp->hp_dev[0].hd_hdwirq = hdp->hd_irq[0];
847 hpetp->hp_dev[1].hd_hdwirq = hdp->hd_irq[1];
846 848
847 hpet = hpetp->hp_hpet; 849 /* Assign IRQs dynamically for the others */
850 for (i = 2, devp = &hpetp->hp_dev[2]; i < hdp->hd_nirqs; i++, devp++) {
851 struct hpet_timer __iomem *timer;
852
853 timer = &hpet->hpet_timers[devp - hpetp->hp_dev];
854
855 hpet_config = readq(&timer->hpet_config);
856 irq_bitmap = (hpet_config & Tn_INT_ROUTE_CAP_MASK)
857 >> Tn_INT_ROUTE_CAP_SHIFT;
858 if (!irq_bitmap)
859 irq = 0; /* No valid IRQ Assignable */
860 else {
861 irq = find_first_bit(&irq_bitmap, 32);
862 do {
863 hpet_config |= irq << Tn_INT_ROUTE_CNF_SHIFT;
864 writeq(hpet_config, &timer->hpet_config);
865
866 /*
867 * Verify whether we have written a valid
868 * IRQ number by reading it back again
869 */
870 hpet_config = readq(&timer->hpet_config);
871 if (irq == (hpet_config & Tn_INT_ROUTE_CNF_MASK)
872 >> Tn_INT_ROUTE_CNF_SHIFT)
873 break; /* Success */
874 } while ((irq = (find_next_bit(&irq_bitmap, 32, irq))));
875 }
876 hpetp->hp_dev[i].hd_hdwirq = irq;
877 }
848 878
849 cap = readq(&hpet->hpet_cap); 879 cap = readq(&hpet->hpet_cap);
850 880
@@ -875,7 +905,8 @@ int hpet_alloc(struct hpet_data *hdp)
875 hpetp->hp_which, hdp->hd_phys_address, 905 hpetp->hp_which, hdp->hd_phys_address,
876 hpetp->hp_ntimer > 1 ? "s" : ""); 906 hpetp->hp_ntimer > 1 ? "s" : "");
877 for (i = 0; i < hpetp->hp_ntimer; i++) 907 for (i = 0; i < hpetp->hp_ntimer; i++)
878 printk("%s %d", i > 0 ? "," : "", hdp->hd_irq[i]); 908 printk("%s %d", i > 0 ? "," : "",
909 hpetp->hp_dev[i].hd_hdwirq);
879 printk("\n"); 910 printk("\n");
880 911
881 printk(KERN_INFO "hpet%u: %u %d-bit timers, %Lu Hz\n", 912 printk(KERN_INFO "hpet%u: %u %d-bit timers, %Lu Hz\n",