blob: 027aa5b9c801ae54482aac2666bf017b574391c1 [file] [log] [blame]
Rohit Vaswanid0fb4182012-03-19 18:07:59 -07001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -070013#define pr_fmt(fmt) "subsys-restart: %s(): " fmt, __func__
14
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070015#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/uaccess.h>
18#include <linux/module.h>
19#include <linux/fs.h>
20#include <linux/proc_fs.h>
21#include <linux/delay.h>
22#include <linux/list.h>
23#include <linux/io.h>
24#include <linux/kthread.h>
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -070025#include <linux/time.h>
Vikram Mulukutlaf6349ae2012-02-24 12:21:15 -080026#include <linux/wakelock.h>
27#include <linux/suspend.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028
29#include <asm/current.h>
30
31#include <mach/peripheral-loader.h>
32#include <mach/scm.h>
33#include <mach/socinfo.h>
34#include <mach/subsystem_notif.h>
35#include <mach/subsystem_restart.h>
36
37#include "smd_private.h"
38
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070039struct subsys_soc_restart_order {
40 const char * const *subsystem_list;
41 int count;
42
43 struct mutex shutdown_lock;
44 struct mutex powerup_lock;
45 struct subsys_data *subsys_ptrs[];
46};
47
Vikram Mulukutla69177e12012-03-21 20:51:43 -070048struct restart_wq_data {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049 struct subsys_data *subsys;
Vikram Mulukutlaf6349ae2012-02-24 12:21:15 -080050 struct wake_lock ssr_wake_lock;
Vikram Mulukutla922a4f12012-04-13 14:36:50 -070051 char wlname[64];
52 int use_restart_order;
Vikram Mulukutla69177e12012-03-21 20:51:43 -070053 struct work_struct work;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054};
55
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -070056struct restart_log {
57 struct timeval time;
58 struct subsys_data *subsys;
59 struct list_head list;
60};
61
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062static int restart_level;
63static int enable_ramdumps;
Vikram Mulukutla69177e12012-03-21 20:51:43 -070064struct workqueue_struct *ssr_wq;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -070066static LIST_HEAD(restart_log_list);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070067static LIST_HEAD(subsystem_list);
68static DEFINE_MUTEX(subsystem_list_lock);
69static DEFINE_MUTEX(soc_order_reg_lock);
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -070070static DEFINE_MUTEX(restart_log_mutex);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071
72/* SOC specific restart orders go here */
73
74#define DEFINE_SINGLE_RESTART_ORDER(name, order) \
75 static struct subsys_soc_restart_order __##name = { \
76 .subsystem_list = order, \
77 .count = ARRAY_SIZE(order), \
78 .subsys_ptrs = {[ARRAY_SIZE(order)] = NULL} \
79 }; \
80 static struct subsys_soc_restart_order *name[] = { \
81 &__##name, \
82 }
83
84/* MSM 8x60 restart ordering info */
85static const char * const _order_8x60_all[] = {
86 "external_modem", "modem", "lpass"
87};
88DEFINE_SINGLE_RESTART_ORDER(orders_8x60_all, _order_8x60_all);
89
90static const char * const _order_8x60_modems[] = {"external_modem", "modem"};
91DEFINE_SINGLE_RESTART_ORDER(orders_8x60_modems, _order_8x60_modems);
92
93/* MSM 8960 restart ordering info */
94static const char * const order_8960[] = {"modem", "lpass"};
95
96static struct subsys_soc_restart_order restart_orders_8960_one = {
97 .subsystem_list = order_8960,
98 .count = ARRAY_SIZE(order_8960),
99 .subsys_ptrs = {[ARRAY_SIZE(order_8960)] = NULL}
100 };
101
102static struct subsys_soc_restart_order *restart_orders_8960[] = {
103 &restart_orders_8960_one,
104};
105
106/* These will be assigned to one of the sets above after
107 * runtime SoC identification.
108 */
109static struct subsys_soc_restart_order **restart_orders;
110static int n_restart_orders;
111
112module_param(enable_ramdumps, int, S_IRUGO | S_IWUSR);
113
114static struct subsys_soc_restart_order *_update_restart_order(
115 struct subsys_data *subsys);
116
117int get_restart_level()
118{
119 return restart_level;
120}
121EXPORT_SYMBOL(get_restart_level);
122
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700123static int restart_level_set(const char *val, struct kernel_param *kp)
124{
125 int ret;
126 int old_val = restart_level;
127
Rohit Vaswani56dd22a2011-11-11 16:21:28 -0800128 if (cpu_is_msm9615()) {
129 pr_err("Only Phase 1 subsystem restart is supported\n");
130 return -EINVAL;
131 }
132
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700133 ret = param_set_int(val, kp);
134 if (ret)
135 return ret;
136
137 switch (restart_level) {
138
139 case RESET_SOC:
140 case RESET_SUBSYS_COUPLED:
141 case RESET_SUBSYS_INDEPENDENT:
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700142 pr_info("Phase %d behavior activated.\n", restart_level);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700143 break;
144
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700145 default:
146 restart_level = old_val;
147 return -EINVAL;
148 break;
149
150 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700151 return 0;
152}
153
154module_param_call(restart_level, restart_level_set, param_get_int,
155 &restart_level, 0644);
156
157static struct subsys_data *_find_subsystem(const char *subsys_name)
158{
159 struct subsys_data *subsys;
160
161 mutex_lock(&subsystem_list_lock);
162 list_for_each_entry(subsys, &subsystem_list, list)
163 if (!strncmp(subsys->name, subsys_name,
164 SUBSYS_NAME_MAX_LENGTH)) {
165 mutex_unlock(&subsystem_list_lock);
166 return subsys;
167 }
168 mutex_unlock(&subsystem_list_lock);
169
170 return NULL;
171}
172
173static struct subsys_soc_restart_order *_update_restart_order(
174 struct subsys_data *subsys)
175{
176 int i, j;
177
178 if (!subsys)
179 return NULL;
180
181 if (!subsys->name)
182 return NULL;
183
184 mutex_lock(&soc_order_reg_lock);
185 for (j = 0; j < n_restart_orders; j++) {
186 for (i = 0; i < restart_orders[j]->count; i++)
187 if (!strncmp(restart_orders[j]->subsystem_list[i],
188 subsys->name, SUBSYS_NAME_MAX_LENGTH)) {
189
190 restart_orders[j]->subsys_ptrs[i] =
191 subsys;
192 mutex_unlock(&soc_order_reg_lock);
193 return restart_orders[j];
194 }
195 }
196
197 mutex_unlock(&soc_order_reg_lock);
198
199 return NULL;
200}
201
202static void _send_notification_to_order(struct subsys_data
203 **restart_list, int count,
204 enum subsys_notif_type notif_type)
205{
206 int i;
207
208 for (i = 0; i < count; i++)
209 if (restart_list[i])
210 subsys_notif_queue_notification(
211 restart_list[i]->notif_handle, notif_type);
212}
213
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -0700214static int max_restarts;
215module_param(max_restarts, int, 0644);
216
217static long max_history_time = 3600;
218module_param(max_history_time, long, 0644);
219
220static void do_epoch_check(struct subsys_data *subsys)
221{
222 int n = 0;
Jordan Crouse75a25ca2011-09-09 12:49:57 -0600223 struct timeval *time_first = NULL, *curr_time;
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -0700224 struct restart_log *r_log, *temp;
225 static int max_restarts_check;
226 static long max_history_time_check;
227
228 mutex_lock(&restart_log_mutex);
229
230 max_restarts_check = max_restarts;
231 max_history_time_check = max_history_time;
232
233 /* Check if epoch checking is enabled */
234 if (!max_restarts_check)
Vikram Mulukutla7a289092011-09-14 10:08:36 -0700235 goto out;
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -0700236
237 r_log = kmalloc(sizeof(struct restart_log), GFP_KERNEL);
Matt Wagantalleecca342011-11-10 20:12:05 -0800238 if (!r_log)
239 goto out;
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -0700240 r_log->subsys = subsys;
241 do_gettimeofday(&r_log->time);
242 curr_time = &r_log->time;
243 INIT_LIST_HEAD(&r_log->list);
244
245 list_add_tail(&r_log->list, &restart_log_list);
246
247 list_for_each_entry_safe(r_log, temp, &restart_log_list, list) {
248
249 if ((curr_time->tv_sec - r_log->time.tv_sec) >
250 max_history_time_check) {
251
252 pr_debug("Deleted node with restart_time = %ld\n",
253 r_log->time.tv_sec);
254 list_del(&r_log->list);
255 kfree(r_log);
256 continue;
257 }
258 if (!n) {
259 time_first = &r_log->time;
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700260 pr_debug("Time_first: %ld\n", time_first->tv_sec);
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -0700261 }
262 n++;
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700263 pr_debug("Restart_time: %ld\n", r_log->time.tv_sec);
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -0700264 }
265
Jordan Crouse75a25ca2011-09-09 12:49:57 -0600266 if (time_first && n >= max_restarts_check) {
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -0700267 if ((curr_time->tv_sec - time_first->tv_sec) <
268 max_history_time_check)
269 panic("Subsystems have crashed %d times in less than "
270 "%ld seconds!", max_restarts_check,
271 max_history_time_check);
272 }
273
Vikram Mulukutla7a289092011-09-14 10:08:36 -0700274out:
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -0700275 mutex_unlock(&restart_log_mutex);
276}
277
Vikram Mulukutla69177e12012-03-21 20:51:43 -0700278static void subsystem_restart_wq_func(struct work_struct *work)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700279{
Vikram Mulukutla69177e12012-03-21 20:51:43 -0700280 struct restart_wq_data *r_work = container_of(work,
281 struct restart_wq_data, work);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282 struct subsys_data **restart_list;
283 struct subsys_data *subsys = r_work->subsys;
284 struct subsys_soc_restart_order *soc_restart_order = NULL;
285
286 struct mutex *powerup_lock;
287 struct mutex *shutdown_lock;
288
289 int i;
290 int restart_list_count = 0;
291
Vikram Mulukutla922a4f12012-04-13 14:36:50 -0700292 if (r_work->use_restart_order)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700293 soc_restart_order = subsys->restart_order;
294
295 /* It's OK to not take the registration lock at this point.
296 * This is because the subsystem list inside the relevant
297 * restart order is not being traversed.
298 */
299 if (!soc_restart_order) {
300 restart_list = subsys->single_restart_list;
301 restart_list_count = 1;
302 powerup_lock = &subsys->powerup_lock;
303 shutdown_lock = &subsys->shutdown_lock;
304 } else {
305 restart_list = soc_restart_order->subsys_ptrs;
306 restart_list_count = soc_restart_order->count;
307 powerup_lock = &soc_restart_order->powerup_lock;
308 shutdown_lock = &soc_restart_order->shutdown_lock;
309 }
310
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700311 pr_debug("[%p]: Attempting to get shutdown lock!\n", current);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700312
313 /* Try to acquire shutdown_lock. If this fails, these subsystems are
314 * already being restarted - return.
315 */
Vikram Mulukutlaf6349ae2012-02-24 12:21:15 -0800316 if (!mutex_trylock(shutdown_lock))
317 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700318
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700319 pr_debug("[%p]: Attempting to get powerup lock!\n", current);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700320
321 /* Now that we've acquired the shutdown lock, either we're the first to
322 * restart these subsystems or some other thread is doing the powerup
323 * sequence for these subsystems. In the latter case, panic and bail
324 * out, since a subsystem died in its powerup sequence.
325 */
326 if (!mutex_trylock(powerup_lock))
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700327 panic("%s[%p]: Subsystem died during powerup!",
328 __func__, current);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700329
Vikram Mulukutla96aecfc2011-07-28 18:18:42 -0700330 do_epoch_check(subsys);
331
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332 /* Now it is necessary to take the registration lock. This is because
333 * the subsystem list in the SoC restart order will be traversed
334 * and it shouldn't be changed until _this_ restart sequence completes.
335 */
336 mutex_lock(&soc_order_reg_lock);
337
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700338 pr_debug("[%p]: Starting restart sequence for %s\n", current,
339 r_work->subsys->name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700340
341 _send_notification_to_order(restart_list,
342 restart_list_count,
343 SUBSYS_BEFORE_SHUTDOWN);
344
345 for (i = 0; i < restart_list_count; i++) {
346
347 if (!restart_list[i])
348 continue;
349
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700350 pr_info("[%p]: Shutting down %s\n", current,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700351 restart_list[i]->name);
352
353 if (restart_list[i]->shutdown(subsys) < 0)
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700354 panic("subsys-restart: %s[%p]: Failed to shutdown %s!",
355 __func__, current, restart_list[i]->name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700356 }
357
358 _send_notification_to_order(restart_list, restart_list_count,
359 SUBSYS_AFTER_SHUTDOWN);
360
361 /* Now that we've finished shutting down these subsystems, release the
362 * shutdown lock. If a subsystem restart request comes in for a
363 * subsystem in _this_ restart order after the unlock below, and
364 * before the powerup lock is released, panic and bail out.
365 */
366 mutex_unlock(shutdown_lock);
367
368 /* Collect ram dumps for all subsystems in order here */
369 for (i = 0; i < restart_list_count; i++) {
370 if (!restart_list[i])
371 continue;
372
373 if (restart_list[i]->ramdump)
374 if (restart_list[i]->ramdump(enable_ramdumps,
375 subsys) < 0)
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700376 pr_warn("%s[%p]: Ramdump failed.\n",
377 restart_list[i]->name, current);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700378 }
379
380 _send_notification_to_order(restart_list,
381 restart_list_count,
382 SUBSYS_BEFORE_POWERUP);
383
384 for (i = restart_list_count - 1; i >= 0; i--) {
385
386 if (!restart_list[i])
387 continue;
388
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700389 pr_info("[%p]: Powering up %s\n", current,
390 restart_list[i]->name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700391
392 if (restart_list[i]->powerup(subsys) < 0)
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700393 panic("%s[%p]: Failed to powerup %s!", __func__,
394 current, restart_list[i]->name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700395 }
396
397 _send_notification_to_order(restart_list,
398 restart_list_count,
399 SUBSYS_AFTER_POWERUP);
400
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700401 pr_info("[%p]: Restart sequence for %s completed.\n",
402 current, r_work->subsys->name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700403
404 mutex_unlock(powerup_lock);
405
406 mutex_unlock(&soc_order_reg_lock);
407
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700408 pr_debug("[%p]: Released powerup lock!\n", current);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700409
Vikram Mulukutlaf6349ae2012-02-24 12:21:15 -0800410out:
411 wake_unlock(&r_work->ssr_wake_lock);
412 wake_lock_destroy(&r_work->ssr_wake_lock);
Vikram Mulukutla69177e12012-03-21 20:51:43 -0700413 kfree(r_work);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700414}
415
Vikram Mulukutla922a4f12012-04-13 14:36:50 -0700416static void __subsystem_restart(struct subsys_data *subsys)
417{
418 struct restart_wq_data *data = NULL;
419 int rc;
420
421 pr_debug("Restarting %s [level=%d]!\n", subsys->name,
422 restart_level);
423
424 data = kzalloc(sizeof(struct restart_wq_data), GFP_ATOMIC);
425 if (!data)
426 panic("%s: Unable to allocate memory to restart %s.",
427 __func__, subsys->name);
428
429 data->subsys = subsys;
430
431 if (restart_level != RESET_SUBSYS_INDEPENDENT)
432 data->use_restart_order = 1;
433
434 snprintf(data->wlname, sizeof(data->wlname), "ssr(%s)", subsys->name);
435 wake_lock_init(&data->ssr_wake_lock, WAKE_LOCK_SUSPEND, data->wlname);
436 wake_lock(&data->ssr_wake_lock);
437
438 INIT_WORK(&data->work, subsystem_restart_wq_func);
439 rc = queue_work(ssr_wq, &data->work);
440 if (rc < 0)
441 panic("%s: Unable to schedule work to restart %s (%d).",
442 __func__, subsys->name, rc);
443}
444
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700445int subsystem_restart(const char *subsys_name)
446{
447 struct subsys_data *subsys;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700448
449 if (!subsys_name) {
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700450 pr_err("Invalid subsystem name.\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700451 return -EINVAL;
452 }
453
Vikram Mulukutla3b24c8c2011-12-02 15:12:53 -0800454 pr_info("Restart sequence requested for %s, restart_level = %d.\n",
455 subsys_name, restart_level);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700456
457 /* List of subsystems is protected by a lock. New subsystems can
458 * still come in.
459 */
460 subsys = _find_subsystem(subsys_name);
461
462 if (!subsys) {
Vikram Mulukutlaa5dd6112011-09-14 14:12:33 -0700463 pr_warn("Unregistered subsystem %s!\n", subsys_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700464 return -EINVAL;
465 }
466
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700467 switch (restart_level) {
468
469 case RESET_SUBSYS_COUPLED:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700470 case RESET_SUBSYS_INDEPENDENT:
Vikram Mulukutla922a4f12012-04-13 14:36:50 -0700471 __subsystem_restart(subsys);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700472 break;
473
474 case RESET_SOC:
Vikram Mulukutla3b24c8c2011-12-02 15:12:53 -0800475 panic("subsys-restart: Resetting the SoC - %s crashed.",
476 subsys->name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700477 break;
478
479 default:
480 panic("subsys-restart: Unknown restart level!\n");
481 break;
482
483 }
484
485 return 0;
486}
487EXPORT_SYMBOL(subsystem_restart);
488
489int ssr_register_subsystem(struct subsys_data *subsys)
490{
491 if (!subsys)
492 goto err;
493
494 if (!subsys->name)
495 goto err;
496
497 if (!subsys->powerup || !subsys->shutdown)
498 goto err;
499
500 subsys->notif_handle = subsys_notif_add_subsys(subsys->name);
501 subsys->restart_order = _update_restart_order(subsys);
502 subsys->single_restart_list[0] = subsys;
503
504 mutex_init(&subsys->shutdown_lock);
505 mutex_init(&subsys->powerup_lock);
506
507 mutex_lock(&subsystem_list_lock);
508 list_add(&subsys->list, &subsystem_list);
509 mutex_unlock(&subsystem_list_lock);
510
511 return 0;
512
513err:
514 return -EINVAL;
515}
516EXPORT_SYMBOL(ssr_register_subsystem);
517
Vikram Mulukutla2a7ea7e2011-09-06 11:38:47 -0700518static int ssr_panic_handler(struct notifier_block *this,
519 unsigned long event, void *ptr)
520{
521 struct subsys_data *subsys;
522
523 list_for_each_entry(subsys, &subsystem_list, list)
524 if (subsys->crash_shutdown)
525 subsys->crash_shutdown(subsys);
526 return NOTIFY_DONE;
527}
528
529static struct notifier_block panic_nb = {
530 .notifier_call = ssr_panic_handler,
531};
532
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700533static int __init ssr_init_soc_restart_orders(void)
534{
535 int i;
536
Vikram Mulukutla2a7ea7e2011-09-06 11:38:47 -0700537 atomic_notifier_chain_register(&panic_notifier_list,
538 &panic_nb);
539
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700540 if (cpu_is_msm8x60()) {
541 for (i = 0; i < ARRAY_SIZE(orders_8x60_all); i++) {
542 mutex_init(&orders_8x60_all[i]->powerup_lock);
543 mutex_init(&orders_8x60_all[i]->shutdown_lock);
544 }
545
546 for (i = 0; i < ARRAY_SIZE(orders_8x60_modems); i++) {
547 mutex_init(&orders_8x60_modems[i]->powerup_lock);
548 mutex_init(&orders_8x60_modems[i]->shutdown_lock);
549 }
550
551 restart_orders = orders_8x60_all;
552 n_restart_orders = ARRAY_SIZE(orders_8x60_all);
553 }
554
Rohit Vaswanid0fb4182012-03-19 18:07:59 -0700555 if (cpu_is_msm8960() || cpu_is_msm8930() || cpu_is_msm9615() ||
556 cpu_is_apq8064()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700557 restart_orders = restart_orders_8960;
558 n_restart_orders = ARRAY_SIZE(restart_orders_8960);
559 }
560
561 if (restart_orders == NULL || n_restart_orders < 1) {
562 WARN_ON(1);
563 return -EINVAL;
564 }
565
566 return 0;
567}
568
569static int __init subsys_restart_init(void)
570{
571 int ret = 0;
572
573 restart_level = RESET_SOC;
574
Vikram Mulukutla69177e12012-03-21 20:51:43 -0700575 ssr_wq = alloc_workqueue("ssr_wq", 0, 0);
576
577 if (!ssr_wq)
578 panic("Couldn't allocate workqueue for subsystem restart.\n");
579
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700580 ret = ssr_init_soc_restart_orders();
581
582 return ret;
583}
584
585arch_initcall(subsys_restart_init);
586
587MODULE_DESCRIPTION("Subsystem Restart Driver");
588MODULE_LICENSE("GPL v2");