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