aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/arm_arch_timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clocksource/arm_arch_timer.c')
-rw-r--r--drivers/clocksource/arm_arch_timer.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 467ee6197c3f..38bddb9a2076 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -55,8 +55,8 @@
55#define CNTV_TVAL 0x38 55#define CNTV_TVAL 0x38
56#define CNTV_CTL 0x3c 56#define CNTV_CTL 0x3c
57 57
58#define ARCH_CP15_TIMER BIT(0) 58#define ARCH_TIMER_TYPE_CP15 BIT(0)
59#define ARCH_MEM_TIMER BIT(1) 59#define ARCH_TIMER_TYPE_MEM BIT(1)
60static unsigned arch_timers_present __initdata; 60static unsigned arch_timers_present __initdata;
61 61
62static void __iomem *arch_counter_base; 62static void __iomem *arch_counter_base;
@@ -686,7 +686,7 @@ static void __arch_timer_setup(unsigned type,
686{ 686{
687 clk->features = CLOCK_EVT_FEAT_ONESHOT; 687 clk->features = CLOCK_EVT_FEAT_ONESHOT;
688 688
689 if (type == ARCH_CP15_TIMER) { 689 if (type == ARCH_TIMER_TYPE_CP15) {
690 if (arch_timer_c3stop) 690 if (arch_timer_c3stop)
691 clk->features |= CLOCK_EVT_FEAT_C3STOP; 691 clk->features |= CLOCK_EVT_FEAT_C3STOP;
692 clk->name = "arch_sys_timer"; 692 clk->name = "arch_sys_timer";
@@ -811,7 +811,7 @@ static int arch_timer_starting_cpu(unsigned int cpu)
811 struct clock_event_device *clk = this_cpu_ptr(arch_timer_evt); 811 struct clock_event_device *clk = this_cpu_ptr(arch_timer_evt);
812 u32 flags; 812 u32 flags;
813 813
814 __arch_timer_setup(ARCH_CP15_TIMER, clk); 814 __arch_timer_setup(ARCH_TIMER_TYPE_CP15, clk);
815 815
816 flags = check_ppi_trigger(arch_timer_ppi[arch_timer_uses_ppi]); 816 flags = check_ppi_trigger(arch_timer_ppi[arch_timer_uses_ppi]);
817 enable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], flags); 817 enable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], flags);
@@ -855,16 +855,17 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)
855static void arch_timer_banner(unsigned type) 855static void arch_timer_banner(unsigned type)
856{ 856{
857 pr_info("%s%s%s timer(s) running at %lu.%02luMHz (%s%s%s).\n", 857 pr_info("%s%s%s timer(s) running at %lu.%02luMHz (%s%s%s).\n",
858 type & ARCH_CP15_TIMER ? "cp15" : "", 858 type & ARCH_TIMER_TYPE_CP15 ? "cp15" : "",
859 type == (ARCH_CP15_TIMER | ARCH_MEM_TIMER) ? " and " : "", 859 type == (ARCH_TIMER_TYPE_CP15 | ARCH_TIMER_TYPE_MEM) ?
860 type & ARCH_MEM_TIMER ? "mmio" : "", 860 " and " : "",
861 type & ARCH_TIMER_TYPE_MEM ? "mmio" : "",
861 (unsigned long)arch_timer_rate / 1000000, 862 (unsigned long)arch_timer_rate / 1000000,
862 (unsigned long)(arch_timer_rate / 10000) % 100, 863 (unsigned long)(arch_timer_rate / 10000) % 100,
863 type & ARCH_CP15_TIMER ? 864 type & ARCH_TIMER_TYPE_CP15 ?
864 (arch_timer_uses_ppi == VIRT_PPI) ? "virt" : "phys" : 865 (arch_timer_uses_ppi == VIRT_PPI) ? "virt" : "phys" :
865 "", 866 "",
866 type == (ARCH_CP15_TIMER | ARCH_MEM_TIMER) ? "/" : "", 867 type == (ARCH_TIMER_TYPE_CP15 | ARCH_TIMER_TYPE_MEM) ? "/" : "",
867 type & ARCH_MEM_TIMER ? 868 type & ARCH_TIMER_TYPE_MEM ?
868 arch_timer_mem_use_virtual ? "virt" : "phys" : 869 arch_timer_mem_use_virtual ? "virt" : "phys" :
869 ""); 870 "");
870} 871}
@@ -899,7 +900,7 @@ static void __init arch_counter_register(unsigned type)
899 u64 start_count; 900 u64 start_count;
900 901
901 /* Register the CP15 based counter if we have one */ 902 /* Register the CP15 based counter if we have one */
902 if (type & ARCH_CP15_TIMER) { 903 if (type & ARCH_TIMER_TYPE_CP15) {
903 if (IS_ENABLED(CONFIG_ARM64) || arch_timer_uses_ppi == VIRT_PPI) 904 if (IS_ENABLED(CONFIG_ARM64) || arch_timer_uses_ppi == VIRT_PPI)
904 arch_timer_read_counter = arch_counter_get_cntvct; 905 arch_timer_read_counter = arch_counter_get_cntvct;
905 else 906 else
@@ -1062,7 +1063,7 @@ static int __init arch_timer_mem_register(void __iomem *base, unsigned int irq)
1062 1063
1063 t->base = base; 1064 t->base = base;
1064 t->evt.irq = irq; 1065 t->evt.irq = irq;
1065 __arch_timer_setup(ARCH_MEM_TIMER, &t->evt); 1066 __arch_timer_setup(ARCH_TIMER_TYPE_MEM, &t->evt);
1066 1067
1067 if (arch_timer_mem_use_virtual) 1068 if (arch_timer_mem_use_virtual)
1068 func = arch_timer_handler_virt_mem; 1069 func = arch_timer_handler_virt_mem;
@@ -1105,13 +1106,15 @@ arch_timer_needs_probing(int type, const struct of_device_id *matches)
1105 1106
1106static int __init arch_timer_common_init(void) 1107static int __init arch_timer_common_init(void)
1107{ 1108{
1108 unsigned mask = ARCH_CP15_TIMER | ARCH_MEM_TIMER; 1109 unsigned mask = ARCH_TIMER_TYPE_CP15 | ARCH_TIMER_TYPE_MEM;
1109 1110
1110 /* Wait until both nodes are probed if we have two timers */ 1111 /* Wait until both nodes are probed if we have two timers */
1111 if ((arch_timers_present & mask) != mask) { 1112 if ((arch_timers_present & mask) != mask) {
1112 if (arch_timer_needs_probing(ARCH_MEM_TIMER, arch_timer_mem_of_match)) 1113 if (arch_timer_needs_probing(ARCH_TIMER_TYPE_MEM,
1114 arch_timer_mem_of_match))
1113 return 0; 1115 return 0;
1114 if (arch_timer_needs_probing(ARCH_CP15_TIMER, arch_timer_of_match)) 1116 if (arch_timer_needs_probing(ARCH_TIMER_TYPE_CP15,
1117 arch_timer_of_match))
1115 return 0; 1118 return 0;
1116 } 1119 }
1117 1120
@@ -1171,12 +1174,12 @@ static int __init arch_timer_of_init(struct device_node *np)
1171{ 1174{
1172 int i; 1175 int i;
1173 1176
1174 if (arch_timers_present & ARCH_CP15_TIMER) { 1177 if (arch_timers_present & ARCH_TIMER_TYPE_CP15) {
1175 pr_warn("multiple nodes in dt, skipping\n"); 1178 pr_warn("multiple nodes in dt, skipping\n");
1176 return 0; 1179 return 0;
1177 } 1180 }
1178 1181
1179 arch_timers_present |= ARCH_CP15_TIMER; 1182 arch_timers_present |= ARCH_TIMER_TYPE_CP15;
1180 for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++) 1183 for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
1181 arch_timer_ppi[i] = irq_of_parse_and_map(np, i); 1184 arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
1182 1185
@@ -1211,7 +1214,7 @@ static int __init arch_timer_mem_init(struct device_node *np)
1211 unsigned int irq, ret = -EINVAL; 1214 unsigned int irq, ret = -EINVAL;
1212 u32 cnttidr; 1215 u32 cnttidr;
1213 1216
1214 arch_timers_present |= ARCH_MEM_TIMER; 1217 arch_timers_present |= ARCH_TIMER_TYPE_MEM;
1215 cntctlbase = of_iomap(np, 0); 1218 cntctlbase = of_iomap(np, 0);
1216 if (!cntctlbase) { 1219 if (!cntctlbase) {
1217 pr_err("Can't find CNTCTLBase\n"); 1220 pr_err("Can't find CNTCTLBase\n");
@@ -1311,14 +1314,14 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table)
1311{ 1314{
1312 struct acpi_table_gtdt *gtdt; 1315 struct acpi_table_gtdt *gtdt;
1313 1316
1314 if (arch_timers_present & ARCH_CP15_TIMER) { 1317 if (arch_timers_present & ARCH_TIMER_TYPE_CP15) {
1315 pr_warn("already initialized, skipping\n"); 1318 pr_warn("already initialized, skipping\n");
1316 return -EINVAL; 1319 return -EINVAL;
1317 } 1320 }
1318 1321
1319 gtdt = container_of(table, struct acpi_table_gtdt, header); 1322 gtdt = container_of(table, struct acpi_table_gtdt, header);
1320 1323
1321 arch_timers_present |= ARCH_CP15_TIMER; 1324 arch_timers_present |= ARCH_TIMER_TYPE_CP15;
1322 1325
1323 arch_timer_ppi[PHYS_SECURE_PPI] = 1326 arch_timer_ppi[PHYS_SECURE_PPI] =
1324 map_generic_timer_interrupt(gtdt->secure_el1_interrupt, 1327 map_generic_timer_interrupt(gtdt->secure_el1_interrupt,