2018-11-09 13:54:00 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2014-10-01 21:54:12 -05:00
|
|
|
/*
|
2014-12-12 17:10:17 -05:00
|
|
|
* Greybus bundles
|
2014-10-01 21:54:12 -05:00
|
|
|
*
|
|
|
|
|
* Copyright 2014 Google Inc.
|
2014-12-12 12:08:42 -06:00
|
|
|
* Copyright 2014 Linaro Ltd.
|
2014-10-01 21:54:12 -05:00
|
|
|
*/
|
|
|
|
|
|
2014-12-12 17:10:17 -05:00
|
|
|
#ifndef __BUNDLE_H
|
|
|
|
|
#define __BUNDLE_H
|
2014-10-01 21:54:12 -05:00
|
|
|
|
2019-08-27 16:53:02 +01:00
|
|
|
#include <linux/types.h>
|
2014-10-01 21:54:12 -05:00
|
|
|
#include <linux/list.h>
|
2019-08-27 16:53:02 +01:00
|
|
|
#include <linux/pm_runtime.h>
|
|
|
|
|
#include <linux/device.h>
|
2014-10-01 21:54:12 -05:00
|
|
|
|
2016-06-03 15:55:30 -05:00
|
|
|
#define BUNDLE_ID_NONE U8_MAX
|
|
|
|
|
|
2014-12-12 17:10:17 -05:00
|
|
|
/* Greybus "public" definitions" */
|
|
|
|
|
struct gb_bundle {
|
2014-10-24 17:34:46 +08:00
|
|
|
struct device dev;
|
2014-12-19 14:56:31 -08:00
|
|
|
struct gb_interface *intf;
|
2016-01-19 12:51:21 +01:00
|
|
|
|
2014-10-02 12:30:02 -05:00
|
|
|
u8 id;
|
2015-04-06 15:49:36 +05:30
|
|
|
u8 class;
|
2016-01-19 12:51:21 +01:00
|
|
|
u8 class_major;
|
|
|
|
|
u8 class_minor;
|
|
|
|
|
|
2016-01-21 17:34:09 +01:00
|
|
|
size_t num_cports;
|
|
|
|
|
struct greybus_descriptor_cport *cport_desc;
|
|
|
|
|
|
2014-10-03 14:14:22 -05:00
|
|
|
struct list_head connections;
|
2015-04-13 19:48:37 +02:00
|
|
|
u8 *state;
|
2014-10-01 21:54:12 -05:00
|
|
|
|
2014-12-12 17:10:17 -05:00
|
|
|
struct list_head links; /* interface->bundles */
|
2014-10-01 21:54:12 -05:00
|
|
|
};
|
2014-12-12 17:10:17 -05:00
|
|
|
#define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
|
2014-10-01 21:54:12 -05:00
|
|
|
|
2014-12-12 17:10:17 -05:00
|
|
|
/* Greybus "private" definitions" */
|
2015-04-01 20:32:00 +05:30
|
|
|
struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
|
2015-04-06 15:49:36 +05:30
|
|
|
u8 class);
|
2015-12-07 15:05:43 +01:00
|
|
|
int gb_bundle_add(struct gb_bundle *bundle);
|
2015-06-12 10:21:11 -05:00
|
|
|
void gb_bundle_destroy(struct gb_bundle *bundle);
|
2014-10-01 21:54:12 -05:00
|
|
|
|
2016-07-14 15:13:00 -05:00
|
|
|
/* Bundle Runtime PM wrappers */
|
2016-09-09 09:47:01 +02:00
|
|
|
#ifdef CONFIG_PM
|
2016-07-14 15:13:00 -05:00
|
|
|
static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
|
|
|
|
|
{
|
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
|
|
retval = pm_runtime_get_sync(&bundle->dev);
|
|
|
|
|
if (retval < 0) {
|
|
|
|
|
dev_err(&bundle->dev,
|
|
|
|
|
"pm_runtime_get_sync failed: %d\n", retval);
|
|
|
|
|
pm_runtime_put_noidle(&bundle->dev);
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
|
|
|
|
|
{
|
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
|
|
pm_runtime_mark_last_busy(&bundle->dev);
|
|
|
|
|
retval = pm_runtime_put_autosuspend(&bundle->dev);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle)
|
|
|
|
|
{
|
|
|
|
|
pm_runtime_get_noresume(&bundle->dev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle)
|
|
|
|
|
{
|
|
|
|
|
pm_runtime_put_noidle(&bundle->dev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
|
|
|
|
|
{ return 0; }
|
|
|
|
|
static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
|
|
|
|
|
{ return 0; }
|
|
|
|
|
|
|
|
|
|
static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) {}
|
|
|
|
|
static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) {}
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-12 17:10:17 -05:00
|
|
|
#endif /* __BUNDLE_H */
|