blob: c232cc9c45ca1ae21d3292267291ce217c76eaaf [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>
Seemanta Dutta076d00e2013-06-17 17:58:18 -070018#include <linux/interrupt.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019
20#define SUBSYS_NAME_MAX_LENGTH 40
21
Stephen Boyd0ebf7212012-04-30 20:42:35 -070022struct subsys_device;
23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024enum {
Stephen Boydfcb52a32012-12-03 12:35:14 -080025 RESET_SOC = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026 RESET_SUBSYS_COUPLED,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070027 RESET_LEVEL_MAX
28};
29
Stephen Boyd4ec9a942012-06-21 19:10:48 -070030struct device;
31struct 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 Boyd2e5c80d2012-06-25 19:33:43 -070039 * @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
Seemanta Duttaf9458c92013-05-08 19:53:29 -070045 * @is_not_loadable: Indicate if subsystem firmware is not loadable via pil
46 * framework
Stephen Boyd4ec9a942012-06-21 19:10:48 -070047 */
Stephen Boyd0ebf7212012-04-30 20:42:35 -070048struct subsys_desc {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049 const char *name;
Stephen Boyd4ec9a942012-06-21 19:10:48 -070050 const char *depends_on;
51 struct device *dev;
52 struct module *owner;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070053
Stephen Boyd2e5c80d2012-06-25 19:33:43 -070054 int (*start)(const struct subsys_desc *desc);
55 void (*stop)(const struct subsys_desc *desc);
56
Stephen Boyd0ebf7212012-04-30 20:42:35 -070057 int (*shutdown)(const struct subsys_desc *desc);
58 int (*powerup)(const struct subsys_desc *desc);
59 void (*crash_shutdown)(const struct subsys_desc *desc);
60 int (*ramdump)(int, const struct subsys_desc *desc);
Seemanta Dutta076d00e2013-06-17 17:58:18 -070061 irqreturn_t (*err_fatal_handler) (int irq, void *dev_id);
62 irqreturn_t (*stop_ack_handler) (int irq, void *dev_id);
63 irqreturn_t (*wdog_bite_handler) (int irq, void *dev_id);
Seemanta Duttaf9458c92013-05-08 19:53:29 -070064 int is_not_loadable;
Seemanta Dutta076d00e2013-06-17 17:58:18 -070065 unsigned int err_fatal_irq;
66 unsigned int err_ready_irq;
67 unsigned int stop_ack_irq;
68 unsigned int wdog_bite_irq;
69 int force_stop_gpio;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070};
71
72#if defined(CONFIG_MSM_SUBSYSTEM_RESTART)
73
Stephen Boydfcb52a32012-12-03 12:35:14 -080074extern int subsys_get_restart_level(struct subsys_device *dev);
Stephen Boyd0ebf7212012-04-30 20:42:35 -070075extern int subsystem_restart_dev(struct subsys_device *dev);
76extern int subsystem_restart(const char *name);
Stephen Boyd4057ec02012-12-12 17:38:38 -080077extern int subsystem_crashed(const char *name);
Stephen Boyd0ebf7212012-04-30 20:42:35 -070078
Stephen Boyd2e5c80d2012-06-25 19:33:43 -070079extern void *subsystem_get(const char *name);
80extern void subsystem_put(void *subsystem);
81
Stephen Boyd0ebf7212012-04-30 20:42:35 -070082extern struct subsys_device *subsys_register(struct subsys_desc *desc);
83extern void subsys_unregister(struct subsys_device *dev);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070084
Stephen Boyd43b380a2012-09-21 17:34:24 -070085extern void subsys_default_online(struct subsys_device *dev);
Seemanta Dutta0adbbf02013-03-12 17:26:17 -070086extern void subsys_set_crash_status(struct subsys_device *dev, bool crashed);
87extern bool subsys_get_crash_status(struct subsys_device *dev);
Stephen Boyd43b380a2012-09-21 17:34:24 -070088
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089#else
90
Stephen Boydfcb52a32012-12-03 12:35:14 -080091static inline int subsys_get_restart_level(struct subsys_device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092{
93 return 0;
94}
95
Stephen Boyd0ebf7212012-04-30 20:42:35 -070096static inline int subsystem_restart_dev(struct subsys_device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097{
98 return 0;
99}
100
Stephen Boyd0ebf7212012-04-30 20:42:35 -0700101static inline int subsystem_restart(const char *name)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102{
103 return 0;
104}
105
Stephen Boyd4057ec02012-12-12 17:38:38 -0800106static inline int subsystem_crashed(const char *name)
107{
108 return 0;
109}
110
Stephen Boyd2e5c80d2012-06-25 19:33:43 -0700111static inline void *subsystem_get(const char *name)
112{
113 return NULL;
114}
115
116static inline void subsystem_put(void *subsystem) { }
117
Stephen Boyd0ebf7212012-04-30 20:42:35 -0700118static inline
119struct subsys_device *subsys_register(struct subsys_desc *desc)
120{
121 return NULL;
122}
123
124static inline void subsys_unregister(struct subsys_device *dev) { }
125
Stephen Boyd43b380a2012-09-21 17:34:24 -0700126static inline void subsys_default_online(struct subsys_device *dev) { }
Seemanta Dutta0adbbf02013-03-12 17:26:17 -0700127static inline
128void subsys_set_crash_status(struct subsys_device *dev, bool crashed) { }
129static inline bool subsys_get_crash_status(struct subsys_device *dev)
130{
131 return false;
132}
Stephen Boyd43b380a2012-09-21 17:34:24 -0700133
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700134#endif /* CONFIG_MSM_SUBSYSTEM_RESTART */
135
136#endif