diff options
author | Paul Walmsley <paul@pwsan.com> | 2012-10-29 22:49:44 -0400 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2012-10-29 22:49:44 -0400 |
commit | 37c67d03989eca60b28d67398d9388f653454c5d (patch) | |
tree | cd23dc86d705b85aad3983122b32b78d0b01b3cd | |
parent | 508c0d47736023fdcb491fd55ad64f7e08f6f32f (diff) |
ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
The OMAP watchdog timer driver directly calls a function exported by
code in arch/arm/mach-omap2. This is not good; it tightly couples
this driver to the mach-omap2 integration code. Instead, add a
temporary platform_data function pointer to abstract this function
call. A subsequent patch will convert the watchdog driver to use this
function pointer.
This patch also moves the device creation code out of
arch/arm/mach-omap2/devices.c and into arch/arm/mach-omap2/wd_timer.c.
This is another step towards the removal of
arch/arm/mach-omap2/devices.c.
Cc: Wim Van Sebroeck <wim@iguana.be>
Acked-by: Wim Van Sebroeck <wim@iguana.be>
[paul@pwsan.com: skip wd_timer device creation when DT blob is present]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
-rw-r--r-- | arch/arm/mach-omap1/devices.c | 21 | ||||
-rw-r--r-- | arch/arm/mach-omap2/devices.c | 26 | ||||
-rw-r--r-- | arch/arm/mach-omap2/wd_timer.c | 35 | ||||
-rw-r--r-- | include/linux/platform_data/omap-wd-timer.h | 38 |
4 files changed, 90 insertions, 30 deletions
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c index 645668e2b1d5..745031870ce4 100644 --- a/arch/arm/mach-omap1/devices.c +++ b/arch/arm/mach-omap1/devices.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/spi/spi.h> | 18 | #include <linux/spi/spi.h> |
19 | 19 | ||
20 | #include <linux/platform_data/omap-wd-timer.h> | ||
21 | |||
20 | #include <asm/mach/map.h> | 22 | #include <asm/mach/map.h> |
21 | 23 | ||
22 | #include <mach/tc.h> | 24 | #include <mach/tc.h> |
@@ -448,18 +450,31 @@ static struct resource wdt_resources[] = { | |||
448 | }; | 450 | }; |
449 | 451 | ||
450 | static struct platform_device omap_wdt_device = { | 452 | static struct platform_device omap_wdt_device = { |
451 | .name = "omap_wdt", | 453 | .name = "omap_wdt", |
452 | .id = -1, | 454 | .id = -1, |
453 | .num_resources = ARRAY_SIZE(wdt_resources), | 455 | .num_resources = ARRAY_SIZE(wdt_resources), |
454 | .resource = wdt_resources, | 456 | .resource = wdt_resources, |
455 | }; | 457 | }; |
456 | 458 | ||
457 | static int __init omap_init_wdt(void) | 459 | static int __init omap_init_wdt(void) |
458 | { | 460 | { |
461 | struct omap_wd_timer_platform_data pdata; | ||
462 | int ret; | ||
463 | |||
459 | if (!cpu_is_omap16xx()) | 464 | if (!cpu_is_omap16xx()) |
460 | return -ENODEV; | 465 | return -ENODEV; |
461 | 466 | ||
462 | return platform_device_register(&omap_wdt_device); | 467 | pdata.read_reset_sources = omap1_get_reset_sources; |
468 | |||
469 | ret = platform_device_register(&omap_wdt_device); | ||
470 | if (!ret) { | ||
471 | ret = platform_device_add_data(&omap_wdt_device, &pdata, | ||
472 | sizeof(pdata)); | ||
473 | if (ret) | ||
474 | platform_device_del(&omap_wdt_device); | ||
475 | } | ||
476 | |||
477 | return ret; | ||
463 | } | 478 | } |
464 | subsys_initcall(omap_init_wdt); | 479 | subsys_initcall(omap_init_wdt); |
465 | #endif | 480 | #endif |
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index 2ad491d6910b..cf365c387c06 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c | |||
@@ -646,29 +646,3 @@ static int __init omap2_init_devices(void) | |||
646 | return 0; | 646 | return 0; |
647 | } | 647 | } |
648 | arch_initcall(omap2_init_devices); | 648 | arch_initcall(omap2_init_devices); |
649 | |||
650 | #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE) | ||
651 | static int __init omap_init_wdt(void) | ||
652 | { | ||
653 | int id = -1; | ||
654 | struct platform_device *pdev; | ||
655 | struct omap_hwmod *oh; | ||
656 | char *oh_name = "wd_timer2"; | ||
657 | char *dev_name = "omap_wdt"; | ||
658 | |||
659 | if (!cpu_class_is_omap2() || of_have_populated_dt()) | ||
660 | return 0; | ||
661 | |||
662 | oh = omap_hwmod_lookup(oh_name); | ||
663 | if (!oh) { | ||
664 | pr_err("Could not look up wd_timer%d hwmod\n", id); | ||
665 | return -EINVAL; | ||
666 | } | ||
667 | |||
668 | pdev = omap_device_build(dev_name, id, oh, NULL, 0, NULL, 0, 0); | ||
669 | WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n", | ||
670 | dev_name, oh->name); | ||
671 | return 0; | ||
672 | } | ||
673 | subsys_initcall(omap_init_wdt); | ||
674 | #endif | ||
diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c index f6b6c37ac3f4..5a8629ff0ab0 100644 --- a/arch/arm/mach-omap2/wd_timer.c +++ b/arch/arm/mach-omap2/wd_timer.c | |||
@@ -11,10 +11,14 @@ | |||
11 | #include <linux/io.h> | 11 | #include <linux/io.h> |
12 | #include <linux/err.h> | 12 | #include <linux/err.h> |
13 | 13 | ||
14 | #include "omap_hwmod.h" | 14 | #include <linux/platform_data/omap-wd-timer.h> |
15 | 15 | ||
16 | #include "omap_hwmod.h" | ||
17 | #include "omap_device.h" | ||
16 | #include "wd_timer.h" | 18 | #include "wd_timer.h" |
17 | #include "common.h" | 19 | #include "common.h" |
20 | #include "prm.h" | ||
21 | #include "soc.h" | ||
18 | 22 | ||
19 | /* | 23 | /* |
20 | * In order to avoid any assumptions from bootloader regarding WDT | 24 | * In order to avoid any assumptions from bootloader regarding WDT |
@@ -99,3 +103,32 @@ int omap2_wd_timer_reset(struct omap_hwmod *oh) | |||
99 | return (c == MAX_MODULE_SOFTRESET_WAIT) ? -ETIMEDOUT : | 103 | return (c == MAX_MODULE_SOFTRESET_WAIT) ? -ETIMEDOUT : |
100 | omap2_wd_timer_disable(oh); | 104 | omap2_wd_timer_disable(oh); |
101 | } | 105 | } |
106 | |||
107 | static int __init omap_init_wdt(void) | ||
108 | { | ||
109 | int id = -1; | ||
110 | struct platform_device *pdev; | ||
111 | struct omap_hwmod *oh; | ||
112 | char *oh_name = "wd_timer2"; | ||
113 | char *dev_name = "omap_wdt"; | ||
114 | struct omap_wd_timer_platform_data pdata; | ||
115 | |||
116 | if (!cpu_class_is_omap2() || of_have_populated_dt()) | ||
117 | return 0; | ||
118 | |||
119 | oh = omap_hwmod_lookup(oh_name); | ||
120 | if (!oh) { | ||
121 | pr_err("Could not look up wd_timer%d hwmod\n", id); | ||
122 | return -EINVAL; | ||
123 | } | ||
124 | |||
125 | pdata.read_reset_sources = prm_read_reset_sources; | ||
126 | |||
127 | pdev = omap_device_build(dev_name, id, oh, &pdata, | ||
128 | sizeof(struct omap_wd_timer_platform_data), | ||
129 | NULL, 0, 0); | ||
130 | WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n", | ||
131 | dev_name, oh->name); | ||
132 | return 0; | ||
133 | } | ||
134 | subsys_initcall(omap_init_wdt); | ||
diff --git a/include/linux/platform_data/omap-wd-timer.h b/include/linux/platform_data/omap-wd-timer.h new file mode 100644 index 000000000000..d75f5f802d98 --- /dev/null +++ b/include/linux/platform_data/omap-wd-timer.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * OMAP2+ WDTIMER-specific function prototypes | ||
3 | * | ||
4 | * Copyright (C) 2012 Texas Instruments, Inc. | ||
5 | * Paul Walmsley | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #ifndef __LINUX_PLATFORM_DATA_OMAP_WD_TIMER_H | ||
14 | #define __LINUX_PLATFORM_DATA_OMAP_WD_TIMER_H | ||
15 | |||
16 | #include <linux/types.h> | ||
17 | |||
18 | /* | ||
19 | * Standardized OMAP reset source bits | ||
20 | * | ||
21 | * This is a subset of the ones listed in arch/arm/mach-omap2/prm.h | ||
22 | * and are the only ones needed in the watchdog driver. | ||
23 | */ | ||
24 | #define OMAP_MPU_WD_RST_SRC_ID_SHIFT 3 | ||
25 | |||
26 | /** | ||
27 | * struct omap_wd_timer_platform_data - WDTIMER integration to the host SoC | ||
28 | * @read_reset_sources - fn ptr for the SoC to indicate the last reset cause | ||
29 | * | ||
30 | * The function pointed to by @read_reset_sources must return its data | ||
31 | * in a standard format - search for RST_SRC_ID_SHIFT in | ||
32 | * arch/arm/mach-omap2 | ||
33 | */ | ||
34 | struct omap_wd_timer_platform_data { | ||
35 | u32 (*read_reset_sources)(void); | ||
36 | }; | ||
37 | |||
38 | #endif | ||