Commit | Line | Data |
---|---|---|
8c12cde3 | 1 | /* |
1db0a5ff | 2 | * Greybus bundles |
8c12cde3 AE |
3 | * |
4 | * Copyright 2014 Google Inc. | |
a46e9671 | 5 | * Copyright 2014 Linaro Ltd. |
8c12cde3 AE |
6 | * |
7 | * Released under the GPLv2 only. | |
8 | */ | |
9 | ||
1db0a5ff GKH |
10 | #ifndef __BUNDLE_H |
11 | #define __BUNDLE_H | |
8c12cde3 AE |
12 | |
13 | #include <linux/list.h> | |
14 | ||
76639ef5 AE |
15 | #define BUNDLE_ID_NONE U8_MAX |
16 | ||
1db0a5ff GKH |
17 | /* Greybus "public" definitions" */ |
18 | struct gb_bundle { | |
f0f61b90 | 19 | struct device dev; |
4ab9b3c2 | 20 | struct gb_interface *intf; |
b807aa7a | 21 | |
63cc932b | 22 | u8 id; |
88e6d37c | 23 | u8 class; |
b807aa7a JH |
24 | u8 class_major; |
25 | u8 class_minor; | |
26 | ||
98fdf5a0 JH |
27 | size_t num_cports; |
28 | struct greybus_descriptor_cport *cport_desc; | |
29 | ||
748e1230 | 30 | struct list_head connections; |
75052a55 | 31 | u8 *state; |
8c12cde3 | 32 | |
1db0a5ff | 33 | struct list_head links; /* interface->bundles */ |
8c12cde3 | 34 | }; |
1db0a5ff | 35 | #define to_gb_bundle(d) container_of(d, struct gb_bundle, dev) |
8c12cde3 | 36 | |
1db0a5ff | 37 | /* Greybus "private" definitions" */ |
7c183f70 | 38 | struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id, |
88e6d37c | 39 | u8 class); |
a7e36d0e | 40 | int gb_bundle_add(struct gb_bundle *bundle); |
fe53b45c | 41 | void gb_bundle_destroy(struct gb_bundle *bundle); |
8c12cde3 | 42 | |
61e13db9 | 43 | /* Bundle Runtime PM wrappers */ |
948c6227 | 44 | #ifdef CONFIG_PM |
61e13db9 DL |
45 | static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle) |
46 | { | |
47 | int retval; | |
48 | ||
49 | retval = pm_runtime_get_sync(&bundle->dev); | |
50 | if (retval < 0) { | |
51 | dev_err(&bundle->dev, | |
52 | "pm_runtime_get_sync failed: %d\n", retval); | |
53 | pm_runtime_put_noidle(&bundle->dev); | |
54 | return retval; | |
55 | } | |
56 | ||
57 | return 0; | |
58 | } | |
59 | ||
60 | static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle) | |
61 | { | |
62 | int retval; | |
63 | ||
64 | pm_runtime_mark_last_busy(&bundle->dev); | |
65 | retval = pm_runtime_put_autosuspend(&bundle->dev); | |
66 | ||
67 | return retval; | |
68 | } | |
69 | ||
70 | static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) | |
71 | { | |
72 | pm_runtime_get_noresume(&bundle->dev); | |
73 | } | |
74 | ||
75 | static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) | |
76 | { | |
77 | pm_runtime_put_noidle(&bundle->dev); | |
78 | } | |
79 | ||
80 | #else | |
81 | static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle) | |
82 | { return 0; } | |
83 | static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle) | |
84 | { return 0; } | |
85 | ||
86 | static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) {} | |
87 | static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) {} | |
88 | #endif | |
89 | ||
1db0a5ff | 90 | #endif /* __BUNDLE_H */ |