aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/timer.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2017-05-31 18:51:30 -0400
committerTony Lindgren <tony@atomide.com>2017-06-06 03:02:36 -0400
commit8d39ff3d1696f7c6122500e21016f6837984ad8b (patch)
treea46c73f7d4eef970a38caa26e710d574c81ffd72 /arch/arm/mach-omap2/timer.c
parent2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff)
ARM: OMAP2+: Remove unused legacy code for timer
We are now booting all mach-omap2 in device tree only mode. Any code that is only called in legacy boot mode where of_have_populated_dt() is not set is safe to remove now. Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/timer.c')
-rw-r--r--arch/arm/mach-omap2/timer.c169
1 files changed, 19 insertions, 150 deletions
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 07dd692c4737..e4be76016939 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -232,37 +232,27 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
232 const char **timer_name, 232 const char **timer_name,
233 int posted) 233 int posted)
234{ 234{
235 char name[10]; /* 10 = sizeof("gptXX_Xck0") */
236 const char *oh_name = NULL; 235 const char *oh_name = NULL;
237 struct device_node *np; 236 struct device_node *np;
238 struct omap_hwmod *oh; 237 struct omap_hwmod *oh;
239 struct resource irq, mem;
240 struct clk *src; 238 struct clk *src;
241 int r = 0; 239 int r = 0;
242 240
243 if (of_have_populated_dt()) { 241 np = omap_get_timer_dt(omap_timer_match, property);
244 np = omap_get_timer_dt(omap_timer_match, property); 242 if (!np)
245 if (!np) 243 return -ENODEV;
246 return -ENODEV;
247 244
248 of_property_read_string_index(np, "ti,hwmods", 0, &oh_name); 245 of_property_read_string_index(np, "ti,hwmods", 0, &oh_name);
249 if (!oh_name) 246 if (!oh_name)
250 return -ENODEV; 247 return -ENODEV;
251 248
252 timer->irq = irq_of_parse_and_map(np, 0); 249 timer->irq = irq_of_parse_and_map(np, 0);
253 if (!timer->irq) 250 if (!timer->irq)
254 return -ENXIO; 251 return -ENXIO;
255 252
256 timer->io_base = of_iomap(np, 0); 253 timer->io_base = of_iomap(np, 0);
257 254
258 of_node_put(np); 255 of_node_put(np);
259 } else {
260 if (omap_dm_timer_reserve_systimer(timer->id))
261 return -ENODEV;
262
263 sprintf(name, "timer%d", timer->id);
264 oh_name = name;
265 }
266 256
267 oh = omap_hwmod_lookup(oh_name); 257 oh = omap_hwmod_lookup(oh_name);
268 if (!oh) 258 if (!oh)
@@ -270,22 +260,6 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
270 260
271 *timer_name = oh->name; 261 *timer_name = oh->name;
272 262
273 if (!of_have_populated_dt()) {
274 r = omap_hwmod_get_resource_byname(oh, IORESOURCE_IRQ, NULL,
275 &irq);
276 if (r)
277 return -ENXIO;
278 timer->irq = irq.start;
279
280 r = omap_hwmod_get_resource_byname(oh, IORESOURCE_MEM, NULL,
281 &mem);
282 if (r)
283 return -ENXIO;
284
285 /* Static mapping, never released */
286 timer->io_base = ioremap(mem.start, mem.end - mem.start);
287 }
288
289 if (!timer->io_base) 263 if (!timer->io_base)
290 return -ENXIO; 264 return -ENXIO;
291 265
@@ -405,18 +379,15 @@ static int __init __maybe_unused omap2_sync32k_clocksource_init(void)
405 const char *oh_name = "counter_32k"; 379 const char *oh_name = "counter_32k";
406 380
407 /* 381 /*
408 * If device-tree is present, then search the DT blob 382 * See if the 32kHz counter is supported.
409 * to see if the 32kHz counter is supported.
410 */ 383 */
411 if (of_have_populated_dt()) { 384 np = omap_get_timer_dt(omap_counter_match, NULL);
412 np = omap_get_timer_dt(omap_counter_match, NULL); 385 if (!np)
413 if (!np) 386 return -ENODEV;
414 return -ENODEV; 387
415 388 of_property_read_string_index(np, "ti,hwmods", 0, &oh_name);
416 of_property_read_string_index(np, "ti,hwmods", 0, &oh_name); 389 if (!oh_name)
417 if (!oh_name) 390 return -ENODEV;
418 return -ENODEV;
419 }
420 391
421 /* 392 /*
422 * First check hwmod data is available for sync32k counter 393 * First check hwmod data is available for sync32k counter
@@ -434,18 +405,6 @@ static int __init __maybe_unused omap2_sync32k_clocksource_init(void)
434 return ret; 405 return ret;
435 } 406 }
436 407
437 if (!of_have_populated_dt()) {
438 void __iomem *vbase;
439
440 vbase = omap_hwmod_get_mpu_rt_va(oh);
441
442 ret = omap_init_clocksource_32k(vbase);
443 if (ret) {
444 pr_warn("%s: failed to initialize counter_32k as a clocksource (%d)\n",
445 __func__, ret);
446 omap_hwmod_idle(oh);
447 }
448 }
449 return ret; 408 return ret;
450} 409}
451 410
@@ -661,96 +620,6 @@ void __init omap5_realtime_timer_init(void)
661#endif /* CONFIG_SOC_OMAP5 || CONFIG_SOC_DRA7XX */ 620#endif /* CONFIG_SOC_OMAP5 || CONFIG_SOC_DRA7XX */
662 621
663/** 622/**
664 * omap_timer_init - build and register timer device with an
665 * associated timer hwmod
666 * @oh: timer hwmod pointer to be used to build timer device
667 * @user: parameter that can be passed from calling hwmod API
668 *
669 * Called by omap_hwmod_for_each_by_class to register each of the timer
670 * devices present in the system. The number of timer devices is known
671 * by parsing through the hwmod database for a given class name. At the
672 * end of function call memory is allocated for timer device and it is
673 * registered to the framework ready to be proved by the driver.
674 */
675static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
676{
677 int id;
678 int ret = 0;
679 char *name = "omap_timer";
680 struct dmtimer_platform_data *pdata;
681 struct platform_device *pdev;
682 struct omap_timer_capability_dev_attr *timer_dev_attr;
683
684 pr_debug("%s: %s\n", __func__, oh->name);
685
686 /* on secure device, do not register secure timer */
687 timer_dev_attr = oh->dev_attr;
688 if (omap_type() != OMAP2_DEVICE_TYPE_GP && timer_dev_attr)
689 if (timer_dev_attr->timer_capability == OMAP_TIMER_SECURE)
690 return ret;
691
692 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
693 if (!pdata) {
694 pr_err("%s: No memory for [%s]\n", __func__, oh->name);
695 return -ENOMEM;
696 }
697
698 /*
699 * Extract the IDs from name field in hwmod database
700 * and use the same for constructing ids' for the
701 * timer devices. In a way, we are avoiding usage of
702 * static variable witin the function to do the same.
703 * CAUTION: We have to be careful and make sure the
704 * name in hwmod database does not change in which case
705 * we might either make corresponding change here or
706 * switch back static variable mechanism.
707 */
708 sscanf(oh->name, "timer%2d", &id);
709
710 if (timer_dev_attr)
711 pdata->timer_capability = timer_dev_attr->timer_capability;
712
713 pdata->timer_errata = omap_dm_timer_get_errata();
714 pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count;
715
716 pdev = omap_device_build(name, id, oh, pdata, sizeof(*pdata));
717
718 if (IS_ERR(pdev)) {
719 pr_err("%s: Can't build omap_device for %s: %s.\n",
720 __func__, name, oh->name);
721 ret = -EINVAL;
722 }
723
724 kfree(pdata);
725
726 return ret;
727}
728
729/**
730 * omap2_dm_timer_init - top level regular device initialization
731 *
732 * Uses dedicated hwmod api to parse through hwmod database for
733 * given class name and then build and register the timer device.
734 */
735static int __init omap2_dm_timer_init(void)
736{
737 int ret;
738
739 /* If dtb is there, the devices will be created dynamically */
740 if (of_have_populated_dt())
741 return -ENODEV;
742
743 ret = omap_hwmod_for_each_by_class("timer", omap_timer_init, NULL);
744 if (unlikely(ret)) {
745 pr_err("%s: device registration failed.\n", __func__);
746 return -EINVAL;
747 }
748
749 return 0;
750}
751omap_arch_initcall(omap2_dm_timer_init);
752
753/**
754 * omap2_override_clocksource - clocksource override with user configuration 623 * omap2_override_clocksource - clocksource override with user configuration
755 * 624 *
756 * Allows user to override default clocksource, using kernel parameter 625 * Allows user to override default clocksource, using kernel parameter