Seemanta Dutta | d759161 | 2013-05-03 17:44:00 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 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 Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 21 | struct subsys_device; |
| 22 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 23 | enum { |
Stephen Boyd | fcb52a3 | 2012-12-03 12:35:14 -0800 | [diff] [blame] | 24 | RESET_SOC = 0, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | RESET_SUBSYS_COUPLED, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 26 | RESET_LEVEL_MAX |
| 27 | }; |
| 28 | |
Stephen Boyd | 4ec9a94 | 2012-06-21 19:10:48 -0700 | [diff] [blame] | 29 | struct device; |
| 30 | struct 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 Boyd | 2e5c80d | 2012-06-25 19:33:43 -0700 | [diff] [blame] | 38 | * @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 Dutta | f9458c9 | 2013-05-08 19:53:29 -0700 | [diff] [blame] | 44 | * @is_not_loadable: Indicate if subsystem firmware is not loadable via pil |
| 45 | * framework |
Stephen Boyd | 4ec9a94 | 2012-06-21 19:10:48 -0700 | [diff] [blame] | 46 | */ |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 47 | struct subsys_desc { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 48 | const char *name; |
Stephen Boyd | 4ec9a94 | 2012-06-21 19:10:48 -0700 | [diff] [blame] | 49 | const char *depends_on; |
| 50 | struct device *dev; |
| 51 | struct module *owner; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 52 | |
Stephen Boyd | 2e5c80d | 2012-06-25 19:33:43 -0700 | [diff] [blame] | 53 | int (*start)(const struct subsys_desc *desc); |
| 54 | void (*stop)(const struct subsys_desc *desc); |
| 55 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 56 | int (*shutdown)(const struct subsys_desc *desc); |
| 57 | int (*powerup)(const struct subsys_desc *desc); |
| 58 | void (*crash_shutdown)(const struct subsys_desc *desc); |
| 59 | int (*ramdump)(int, const struct subsys_desc *desc); |
Seemanta Dutta | d32f92a | 2013-01-25 14:22:15 -0800 | [diff] [blame] | 60 | unsigned int err_ready_irq; |
Seemanta Dutta | f9458c9 | 2013-05-08 19:53:29 -0700 | [diff] [blame] | 61 | int is_not_loadable; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | #if defined(CONFIG_MSM_SUBSYSTEM_RESTART) |
| 65 | |
Stephen Boyd | fcb52a3 | 2012-12-03 12:35:14 -0800 | [diff] [blame] | 66 | extern int subsys_get_restart_level(struct subsys_device *dev); |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 67 | extern int subsystem_restart_dev(struct subsys_device *dev); |
| 68 | extern int subsystem_restart(const char *name); |
Stephen Boyd | 4057ec0 | 2012-12-12 17:38:38 -0800 | [diff] [blame] | 69 | extern int subsystem_crashed(const char *name); |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 70 | |
Stephen Boyd | 2e5c80d | 2012-06-25 19:33:43 -0700 | [diff] [blame] | 71 | extern void *subsystem_get(const char *name); |
| 72 | extern void subsystem_put(void *subsystem); |
| 73 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 74 | extern struct subsys_device *subsys_register(struct subsys_desc *desc); |
| 75 | extern void subsys_unregister(struct subsys_device *dev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 76 | |
Stephen Boyd | 43b380a | 2012-09-21 17:34:24 -0700 | [diff] [blame] | 77 | extern void subsys_default_online(struct subsys_device *dev); |
Seemanta Dutta | 0adbbf0 | 2013-03-12 17:26:17 -0700 | [diff] [blame^] | 78 | extern void subsys_set_crash_status(struct subsys_device *dev, bool crashed); |
| 79 | extern bool subsys_get_crash_status(struct subsys_device *dev); |
Stephen Boyd | 43b380a | 2012-09-21 17:34:24 -0700 | [diff] [blame] | 80 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 81 | #else |
| 82 | |
Stephen Boyd | fcb52a3 | 2012-12-03 12:35:14 -0800 | [diff] [blame] | 83 | static inline int subsys_get_restart_level(struct subsys_device *dev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 84 | { |
| 85 | return 0; |
| 86 | } |
| 87 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 88 | static inline int subsystem_restart_dev(struct subsys_device *dev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 89 | { |
| 90 | return 0; |
| 91 | } |
| 92 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 93 | static inline int subsystem_restart(const char *name) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 94 | { |
| 95 | return 0; |
| 96 | } |
| 97 | |
Stephen Boyd | 4057ec0 | 2012-12-12 17:38:38 -0800 | [diff] [blame] | 98 | static inline int subsystem_crashed(const char *name) |
| 99 | { |
| 100 | return 0; |
| 101 | } |
| 102 | |
Stephen Boyd | 2e5c80d | 2012-06-25 19:33:43 -0700 | [diff] [blame] | 103 | static inline void *subsystem_get(const char *name) |
| 104 | { |
| 105 | return NULL; |
| 106 | } |
| 107 | |
| 108 | static inline void subsystem_put(void *subsystem) { } |
| 109 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 110 | static inline |
| 111 | struct subsys_device *subsys_register(struct subsys_desc *desc) |
| 112 | { |
| 113 | return NULL; |
| 114 | } |
| 115 | |
| 116 | static inline void subsys_unregister(struct subsys_device *dev) { } |
| 117 | |
Stephen Boyd | 43b380a | 2012-09-21 17:34:24 -0700 | [diff] [blame] | 118 | static inline void subsys_default_online(struct subsys_device *dev) { } |
Seemanta Dutta | 0adbbf0 | 2013-03-12 17:26:17 -0700 | [diff] [blame^] | 119 | static inline |
| 120 | void subsys_set_crash_status(struct subsys_device *dev, bool crashed) { } |
| 121 | static inline bool subsys_get_crash_status(struct subsys_device *dev) |
| 122 | { |
| 123 | return false; |
| 124 | } |
Stephen Boyd | 43b380a | 2012-09-21 17:34:24 -0700 | [diff] [blame] | 125 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 126 | #endif /* CONFIG_MSM_SUBSYSTEM_RESTART */ |
| 127 | |
| 128 | #endif |