Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. 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 { |
| 24 | RESET_SOC = 1, |
| 25 | RESET_SUBSYS_COUPLED, |
| 26 | RESET_SUBSYS_INDEPENDENT, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 27 | RESET_LEVEL_MAX |
| 28 | }; |
| 29 | |
Stephen Boyd | 4ec9a94 | 2012-06-21 19:10:48 -0700 | [diff] [blame] | 30 | struct device; |
| 31 | struct module; |
| 32 | |
| 33 | /** |
| 34 | * struct subsys_desc - subsystem descriptor |
| 35 | * @name: name of subsystem |
| 36 | * @depends_on: subsystem this subsystem depends on to operate |
| 37 | * @dev: parent device |
| 38 | * @owner: module the descriptor belongs to |
Stephen Boyd | 2e5c80d | 2012-06-25 19:33:43 -0700 | [diff] [blame] | 39 | * @start: Start a subsystem |
| 40 | * @stop: Stop a subsystem |
| 41 | * @shutdown: Stop a subsystem |
| 42 | * @powerup: Start a subsystem |
| 43 | * @crash_shutdown: Shutdown a subsystem when the system crashes (can't sleep) |
| 44 | * @ramdump: Collect a ramdump of the subsystem |
Stephen Boyd | 4ec9a94 | 2012-06-21 19:10:48 -0700 | [diff] [blame] | 45 | */ |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 46 | struct subsys_desc { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 47 | const char *name; |
Stephen Boyd | 4ec9a94 | 2012-06-21 19:10:48 -0700 | [diff] [blame] | 48 | const char *depends_on; |
| 49 | struct device *dev; |
| 50 | struct module *owner; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 51 | |
Stephen Boyd | 2e5c80d | 2012-06-25 19:33:43 -0700 | [diff] [blame] | 52 | int (*start)(const struct subsys_desc *desc); |
| 53 | void (*stop)(const struct subsys_desc *desc); |
| 54 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 55 | 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); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | #if defined(CONFIG_MSM_SUBSYSTEM_RESTART) |
| 62 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 63 | extern int get_restart_level(void); |
| 64 | extern int subsystem_restart_dev(struct subsys_device *dev); |
| 65 | extern int subsystem_restart(const char *name); |
| 66 | |
Stephen Boyd | 2e5c80d | 2012-06-25 19:33:43 -0700 | [diff] [blame] | 67 | extern void *subsystem_get(const char *name); |
| 68 | extern void subsystem_put(void *subsystem); |
| 69 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 70 | extern struct subsys_device *subsys_register(struct subsys_desc *desc); |
| 71 | extern void subsys_unregister(struct subsys_device *dev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 72 | |
Stephen Boyd | 43b380a | 2012-09-21 17:34:24 -0700 | [diff] [blame^] | 73 | extern void subsys_default_online(struct subsys_device *dev); |
| 74 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 75 | #else |
| 76 | |
| 77 | static inline int get_restart_level(void) |
| 78 | { |
| 79 | return 0; |
| 80 | } |
| 81 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 82 | static inline int subsystem_restart_dev(struct subsys_device *dev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 83 | { |
| 84 | return 0; |
| 85 | } |
| 86 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 87 | static inline int subsystem_restart(const char *name) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 88 | { |
| 89 | return 0; |
| 90 | } |
| 91 | |
Stephen Boyd | 2e5c80d | 2012-06-25 19:33:43 -0700 | [diff] [blame] | 92 | static inline void *subsystem_get(const char *name) |
| 93 | { |
| 94 | return NULL; |
| 95 | } |
| 96 | |
| 97 | static inline void subsystem_put(void *subsystem) { } |
| 98 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 99 | static inline |
| 100 | struct subsys_device *subsys_register(struct subsys_desc *desc) |
| 101 | { |
| 102 | return NULL; |
| 103 | } |
| 104 | |
| 105 | static inline void subsys_unregister(struct subsys_device *dev) { } |
| 106 | |
Stephen Boyd | 43b380a | 2012-09-21 17:34:24 -0700 | [diff] [blame^] | 107 | static inline void subsys_default_online(struct subsys_device *dev) { } |
| 108 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 109 | #endif /* CONFIG_MSM_SUBSYSTEM_RESTART */ |
| 110 | |
| 111 | #endif |