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