aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--arch/x86/kernel/hpet.c13
-rw-r--r--drivers/char/hpet.c45
-rw-r--r--include/linux/hpet.h2
3 files changed, 44 insertions, 16 deletions
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 9ec2ab793042..786aa227afdf 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -117,8 +117,7 @@ int is_hpet_enabled(void)
117static void hpet_reserve_platform_timers(unsigned long id) 117static void hpet_reserve_platform_timers(unsigned long id)
118{ 118{
119 struct hpet __iomem *hpet = hpet_virt_address; 119 struct hpet __iomem *hpet = hpet_virt_address;
120 struct hpet_timer __iomem *timer = &hpet->hpet_timers[2]; 120 unsigned int nrtimers;
121 unsigned int nrtimers, i;
122 struct hpet_data hd; 121 struct hpet_data hd;
123 122
124 nrtimers = ((id & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT) + 1; 123 nrtimers = ((id & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT) + 1;
@@ -133,16 +132,14 @@ static void hpet_reserve_platform_timers(unsigned long id)
133#ifdef CONFIG_HPET_EMULATE_RTC 132#ifdef CONFIG_HPET_EMULATE_RTC
134 hpet_reserve_timer(&hd, 1); 133 hpet_reserve_timer(&hd, 1);
135#endif 134#endif
136
137 hd.hd_irq[0] = HPET_LEGACY_8254; 135 hd.hd_irq[0] = HPET_LEGACY_8254;
138 hd.hd_irq[1] = HPET_LEGACY_RTC; 136 hd.hd_irq[1] = HPET_LEGACY_RTC;
139 137
140 for (i = 2; i < nrtimers; timer++, i++) 138 /*
141 hd.hd_irq[i] = (timer->hpet_config & Tn_INT_ROUTE_CNF_MASK) >> 139 * IRQs for the other timers are assigned dynamically
142 Tn_INT_ROUTE_CNF_SHIFT; 140 * in hpet_alloc
143 141 */
144 hpet_alloc(&hd); 142 hpet_alloc(&hd);
145
146} 143}
147#else 144#else
148static void hpet_reserve_platform_timers(unsigned long id) { } 145static void hpet_reserve_platform_timers(unsigned long id) { }
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",
diff --git a/include/linux/hpet.h b/include/linux/hpet.h
index 707f7cb9e795..e3c0b2aa944c 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_INI_ROUTE_CAP_SHIFT (32UL) 67#define Tn_INT_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)