blob: 893db0b919c38e70206022219f6b71c9e67224a3 [file] [log] [blame]
Seemanta Duttad7591612013-05-03 17:44:00 -07001/* Copyright (c) 2011-2013, The Linux Foundation. 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 */
13
14#ifndef __SUBSYS_RESTART_H
15#define __SUBSYS_RESTART_H
16
17#include <linux/spinlock.h>
18
19#define SUBSYS_NAME_MAX_LENGTH 40
20
Stephen Boyd0ebf7212012-04-30 20:42:35 -070021struct subsys_device;
22
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023enum {
Stephen Boydfcb52a32012-12-03 12:35:14 -080024 RESET_SOC = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025 RESET_SUBSYS_COUPLED,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026 RESET_LEVEL_MAX
27};
28
Stephen Boyd4ec9a942012-06-21 19:10:48 -070029struct device;
30struct module;
31
32/**
33 * struct subsys_desc - subsystem descriptor
34 * @name: name of subsystem
35 * @depends_on: subsystem this subsystem depends on to operate
36 * @dev: parent device
37 * @owner: module the descriptor belongs to
Stephen Boyd2e5c80d2012-06-25 19:33:43 -070038 * @start: Start a subsystem
39 * @stop: Stop a subsystem
40 * @shutdown: Stop a subsystem
41 * @powerup: Start a subsystem
42 * @crash_shutdown: Shutdown a subsystem when the system crashes (can't sleep)
43 * @ramdump: Collect a ramdump of the subsystem
Seemanta Duttad7591612013-05-03 17:44:00 -070044 * @is_loadable: Indicate if subsystem firmware is loadable via pil framework
Stephen Boyd4ec9a942012-06-21 19:10:48 -070045 */
Stephen Boyd0ebf7212012-04-30 20:42:35 -070046struct subsys_desc {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047 const char *name;
Stephen Boyd4ec9a942012-06-21 19:10:48 -070048 const char *depends_on;
49 struct device *dev;
50 struct module *owner;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051
Stephen Boyd2e5c80d2012-06-25 19:33:43 -070052 int (*start)(const struct subsys_desc *desc);
53 void (*stop)(const struct subsys_desc *desc);
54
Stephen Boyd0ebf7212012-04-30 20:42:35 -070055 int (*shutdown)(const struct subsys_desc *desc);
56 int (*powerup)(const struct subsys_desc *desc);
57 void (*crash_shutdown)(const struct subsys_desc *desc);
58 int (*ramdump)(int, const struct subsys_desc *desc);
Seemanta Duttad32f92a2013-01-25 14:22:15 -080059 unsigned int err_ready_irq;
Seemanta Duttad7591612013-05-03 17:44:00 -070060 int is_loadable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061};
62
63#if defined(CONFIG_MSM_SUBSYSTEM_RESTART)
64
Stephen Boydfcb52a32012-12-03 12:35:14 -080065extern int subsys_get_restart_level(struct subsys_device *dev);
Stephen Boyd0ebf7212012-04-30 20:42:35 -070066extern int subsystem_restart_dev(struct subsys_device *dev);
67extern int subsystem_restart(const char *name);
Stephen Boyd4057ec02012-12-12 17:38:38 -080068extern int subsystem_crashed(const char *name);
Stephen Boyd0ebf7212012-04-30 20:42:35 -070069
Stephen Boyd2e5c80d2012-06-25 19:33:43 -070070extern void *subsystem_get(const char *name);
71extern void subsystem_put(void *subsystem);
72
Stephen Boyd0ebf7212012-04-30 20:42:35 -070073extern struct subsys_device *subsys_register(struct subsys_desc *desc);
74extern void subsys_unregister(struct subsys_device *dev);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070075
Stephen Boyd43b380a2012-09-21 17:34:24 -070076extern void subsys_default_online(struct subsys_device *dev);
77
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078#else
79
Stephen Boydfcb52a32012-12-03 12:35:14 -080080static inline int subsys_get_restart_level(struct subsys_device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070081{
82 return 0;
83}
84
Stephen Boyd0ebf7212012-04-30 20:42:35 -070085static inline int subsystem_restart_dev(struct subsys_device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070086{
87 return 0;
88}
89
Stephen Boyd0ebf7212012-04-30 20:42:35 -070090static inline int subsystem_restart(const char *name)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091{
92 return 0;
93}
94
Stephen Boyd4057ec02012-12-12 17:38:38 -080095static inline int subsystem_crashed(const char *name)
96{
97 return 0;
98}
99
Stephen Boyd2e5c80d2012-06-25 19:33:43 -0700100static inline void *subsystem_get(const char *name)
101{
102 return NULL;
103}
104
105static inline void subsystem_put(void *subsystem) { }
106
Stephen Boyd0ebf7212012-04-30 20:42:35 -0700107static inline
108struct subsys_device *subsys_register(struct subsys_desc *desc)
109{
110 return NULL;
111}
112
113static inline void subsys_unregister(struct subsys_device *dev) { }
114
Stephen Boyd43b380a2012-09-21 17:34:24 -0700115static inline void subsys_default_online(struct subsys_device *dev) { }
116
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700117#endif /* CONFIG_MSM_SUBSYSTEM_RESTART */
118
119#endif