diff options
| author | Tang Yuantian <yuantian.tang@freescale.com> | 2014-05-07 22:04:26 -0400 |
|---|---|---|
| committer | Wim Van Sebroeck <wim@iguana.be> | 2014-06-10 15:47:26 -0400 |
| commit | d2deebabaeedccf7cee943c1f7f6fdb44afd4e3d (patch) | |
| tree | 608c9d7e57401f6782f84f3d068b8388cc7374e9 | |
| parent | ec2e32ca661e7f2fe6c23efe202013f6ab5bf021 (diff) | |
booke/watchdog: refine and clean up the codes
Basically, this patch does the following:
1. Move the codes of parsing boot parameters from setup-common.c
to driver. In this way, code reader can know directly that
there are boot parameters that can change the timeout.
2. Make boot parameter 'booke_wdt_period' effective.
currently, when driver is loaded, default timeout is always
being used in stead of booke_wdt_period.
3. Wrap up the watchdog timeout in device struct and clean up
unnecessary codes.
Signed-off-by: Tang Yuantian <yuantian.tang@freescale.com>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Li Yang <leoli@freescale.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
| -rw-r--r-- | arch/powerpc/kernel/setup-common.c | 27 | ||||
| -rw-r--r-- | drivers/watchdog/booke_wdt.c | 51 |
2 files changed, 33 insertions, 45 deletions
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 79b7612ac6fa..fb87e4ac9e86 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c | |||
| @@ -718,33 +718,6 @@ static int powerpc_debugfs_init(void) | |||
| 718 | arch_initcall(powerpc_debugfs_init); | 718 | arch_initcall(powerpc_debugfs_init); |
| 719 | #endif | 719 | #endif |
| 720 | 720 | ||
| 721 | #ifdef CONFIG_BOOKE_WDT | ||
| 722 | extern u32 booke_wdt_enabled; | ||
| 723 | extern u32 booke_wdt_period; | ||
| 724 | |||
| 725 | /* Checks wdt=x and wdt_period=xx command-line option */ | ||
| 726 | notrace int __init early_parse_wdt(char *p) | ||
| 727 | { | ||
| 728 | if (p && strncmp(p, "0", 1) != 0) | ||
| 729 | booke_wdt_enabled = 1; | ||
| 730 | |||
| 731 | return 0; | ||
| 732 | } | ||
| 733 | early_param("wdt", early_parse_wdt); | ||
| 734 | |||
| 735 | int __init early_parse_wdt_period(char *p) | ||
| 736 | { | ||
| 737 | unsigned long ret; | ||
| 738 | if (p) { | ||
| 739 | if (!kstrtol(p, 0, &ret)) | ||
| 740 | booke_wdt_period = ret; | ||
| 741 | } | ||
| 742 | |||
| 743 | return 0; | ||
| 744 | } | ||
| 745 | early_param("wdt_period", early_parse_wdt_period); | ||
| 746 | #endif /* CONFIG_BOOKE_WDT */ | ||
| 747 | |||
| 748 | void ppc_printk_progress(char *s, unsigned short hex) | 721 | void ppc_printk_progress(char *s, unsigned short hex) |
| 749 | { | 722 | { |
| 750 | pr_info("%s\n", s); | 723 | pr_info("%s\n", s); |
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c index a8dbceb32914..08a785398eac 100644 --- a/drivers/watchdog/booke_wdt.c +++ b/drivers/watchdog/booke_wdt.c | |||
| @@ -41,6 +41,28 @@ u32 booke_wdt_period = CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT; | |||
| 41 | #define WDTP_MASK (TCR_WP_MASK) | 41 | #define WDTP_MASK (TCR_WP_MASK) |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | /* Checks wdt=x and wdt_period=xx command-line option */ | ||
| 45 | notrace int __init early_parse_wdt(char *p) | ||
| 46 | { | ||
| 47 | if (p && strncmp(p, "0", 1) != 0) | ||
| 48 | booke_wdt_enabled = 1; | ||
| 49 | |||
| 50 | return 0; | ||
| 51 | } | ||
| 52 | early_param("wdt", early_parse_wdt); | ||
| 53 | |||
| 54 | int __init early_parse_wdt_period(char *p) | ||
| 55 | { | ||
| 56 | unsigned long ret; | ||
| 57 | if (p) { | ||
| 58 | if (!kstrtol(p, 0, &ret)) | ||
| 59 | booke_wdt_period = ret; | ||
| 60 | } | ||
| 61 | |||
| 62 | return 0; | ||
| 63 | } | ||
| 64 | early_param("wdt_period", early_parse_wdt_period); | ||
| 65 | |||
| 44 | #ifdef CONFIG_PPC_FSL_BOOK3E | 66 | #ifdef CONFIG_PPC_FSL_BOOK3E |
| 45 | 67 | ||
| 46 | /* For the specified period, determine the number of seconds | 68 | /* For the specified period, determine the number of seconds |
| @@ -103,17 +125,18 @@ static unsigned int sec_to_period(unsigned int secs) | |||
| 103 | static void __booke_wdt_set(void *data) | 125 | static void __booke_wdt_set(void *data) |
| 104 | { | 126 | { |
| 105 | u32 val; | 127 | u32 val; |
| 128 | struct watchdog_device *wdog = data; | ||
| 106 | 129 | ||
| 107 | val = mfspr(SPRN_TCR); | 130 | val = mfspr(SPRN_TCR); |
| 108 | val &= ~WDTP_MASK; | 131 | val &= ~WDTP_MASK; |
| 109 | val |= WDTP(booke_wdt_period); | 132 | val |= WDTP(sec_to_period(wdog->timeout)); |
| 110 | 133 | ||
| 111 | mtspr(SPRN_TCR, val); | 134 | mtspr(SPRN_TCR, val); |
| 112 | } | 135 | } |
| 113 | 136 | ||
| 114 | static void booke_wdt_set(void) | 137 | static void booke_wdt_set(void *data) |
| 115 | { | 138 | { |
| 116 | on_each_cpu(__booke_wdt_set, NULL, 0); | 139 | on_each_cpu(__booke_wdt_set, data, 0); |
| 117 | } | 140 | } |
| 118 | 141 | ||
| 119 | static void __booke_wdt_ping(void *data) | 142 | static void __booke_wdt_ping(void *data) |
| @@ -131,12 +154,13 @@ static int booke_wdt_ping(struct watchdog_device *wdog) | |||
| 131 | static void __booke_wdt_enable(void *data) | 154 | static void __booke_wdt_enable(void *data) |
| 132 | { | 155 | { |
| 133 | u32 val; | 156 | u32 val; |
| 157 | struct watchdog_device *wdog = data; | ||
| 134 | 158 | ||
| 135 | /* clear status before enabling watchdog */ | 159 | /* clear status before enabling watchdog */ |
| 136 | __booke_wdt_ping(NULL); | 160 | __booke_wdt_ping(NULL); |
| 137 | val = mfspr(SPRN_TCR); | 161 | val = mfspr(SPRN_TCR); |
| 138 | val &= ~WDTP_MASK; | 162 | val &= ~WDTP_MASK; |
| 139 | val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period)); | 163 | val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(sec_to_period(wdog->timeout))); |
| 140 | 164 | ||
| 141 | mtspr(SPRN_TCR, val); | 165 | mtspr(SPRN_TCR, val); |
| 142 | } | 166 | } |
| @@ -162,25 +186,17 @@ static void __booke_wdt_disable(void *data) | |||
| 162 | 186 | ||
| 163 | } | 187 | } |
| 164 | 188 | ||
| 165 | static void __booke_wdt_start(struct watchdog_device *wdog) | 189 | static int booke_wdt_start(struct watchdog_device *wdog) |
| 166 | { | 190 | { |
| 167 | on_each_cpu(__booke_wdt_enable, NULL, 0); | 191 | on_each_cpu(__booke_wdt_enable, wdog, 0); |
| 168 | pr_debug("watchdog enabled (timeout = %u sec)\n", wdog->timeout); | 192 | pr_debug("watchdog enabled (timeout = %u sec)\n", wdog->timeout); |
| 169 | } | ||
| 170 | 193 | ||
| 171 | static int booke_wdt_start(struct watchdog_device *wdog) | ||
| 172 | { | ||
| 173 | if (booke_wdt_enabled == 0) { | ||
| 174 | booke_wdt_enabled = 1; | ||
| 175 | __booke_wdt_start(wdog); | ||
| 176 | } | ||
| 177 | return 0; | 194 | return 0; |
| 178 | } | 195 | } |
| 179 | 196 | ||
| 180 | static int booke_wdt_stop(struct watchdog_device *wdog) | 197 | static int booke_wdt_stop(struct watchdog_device *wdog) |
| 181 | { | 198 | { |
| 182 | on_each_cpu(__booke_wdt_disable, NULL, 0); | 199 | on_each_cpu(__booke_wdt_disable, NULL, 0); |
| 183 | booke_wdt_enabled = 0; | ||
| 184 | pr_debug("watchdog disabled\n"); | 200 | pr_debug("watchdog disabled\n"); |
| 185 | 201 | ||
| 186 | return 0; | 202 | return 0; |
| @@ -191,9 +207,8 @@ static int booke_wdt_set_timeout(struct watchdog_device *wdt_dev, | |||
| 191 | { | 207 | { |
| 192 | if (timeout > MAX_WDT_TIMEOUT) | 208 | if (timeout > MAX_WDT_TIMEOUT) |
| 193 | return -EINVAL; | 209 | return -EINVAL; |
| 194 | booke_wdt_period = sec_to_period(timeout); | ||
| 195 | wdt_dev->timeout = timeout; | 210 | wdt_dev->timeout = timeout; |
| 196 | booke_wdt_set(); | 211 | booke_wdt_set(wdt_dev); |
| 197 | 212 | ||
| 198 | return 0; | 213 | return 0; |
| 199 | } | 214 | } |
| @@ -231,10 +246,10 @@ static int __init booke_wdt_init(void) | |||
| 231 | pr_info("powerpc book-e watchdog driver loaded\n"); | 246 | pr_info("powerpc book-e watchdog driver loaded\n"); |
| 232 | booke_wdt_info.firmware_version = cur_cpu_spec->pvr_value; | 247 | booke_wdt_info.firmware_version = cur_cpu_spec->pvr_value; |
| 233 | booke_wdt_set_timeout(&booke_wdt_dev, | 248 | booke_wdt_set_timeout(&booke_wdt_dev, |
| 234 | period_to_sec(CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT)); | 249 | period_to_sec(booke_wdt_period)); |
| 235 | watchdog_set_nowayout(&booke_wdt_dev, nowayout); | 250 | watchdog_set_nowayout(&booke_wdt_dev, nowayout); |
| 236 | if (booke_wdt_enabled) | 251 | if (booke_wdt_enabled) |
| 237 | __booke_wdt_start(&booke_wdt_dev); | 252 | booke_wdt_start(&booke_wdt_dev); |
| 238 | 253 | ||
| 239 | ret = watchdog_register_device(&booke_wdt_dev); | 254 | ret = watchdog_register_device(&booke_wdt_dev); |
| 240 | 255 | ||
