2018-11-09 21:54:00 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2014-10-02 10:54:14 +08:00
|
|
|
/*
|
|
|
|
* Greybus connections
|
|
|
|
*
|
|
|
|
* Copyright 2014 Google Inc.
|
2014-12-13 02:08:42 +08:00
|
|
|
* Copyright 2014 Linaro Ltd.
|
2014-10-02 10:54:14 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CONNECTION_H
|
|
|
|
#define __CONNECTION_H
|
|
|
|
|
staging: greybus: add missing includes
Before moving greybus core out of staging and moving header files to
include/linux some greybus header files were missing the necessary
includes. This would trigger compilation faillures with some example
errors logged bellow for with CONFIG_KERNEL_HEADER_TEST=y.
So, add the necessary headers to compile clean before relocating the
header files.
./include/linux/greybus/hd.h:23:50: error: unknown type name 'u16'
int (*cport_disable)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/greybus_protocols.h:1314:2: error: unknown type name '__u8'
__u8 data[0];
^~~~
./include/linux/greybus/hd.h:24:52: error: unknown type name 'u16'
int (*cport_connected)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:25:48: error: unknown type name 'u16'
int (*cport_flush)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:26:51: error: unknown type name 'u16'
int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id, ^~~
./include/linux/greybus/hd.h:27:5: error: unknown type name 'u8'
u8 phase, unsigned int timeout);
^~
./include/linux/greybus/hd.h:28:50: error: unknown type name 'u16'
int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id, ^~~
./include/linux/greybus/hd.h:29:5: error: unknown type name 'size_t'
size_t peer_space, unsigned int timeout);
^~~~~~
./include/linux/greybus/hd.h:29:5: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
./include/linux/greybus/hd.h:1:1:
+#include <stddef.h>
/* SPDX-License-Identifier: GPL-2.0 */
./include/linux/greybus/hd.h:29:5:
size_t peer_space, unsigned int timeout);
^~~~~~
./include/linux/greybus/hd.h:30:48: error: unknown type name 'u16'
int (*cport_clear)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:32:49: error: unknown type name 'u16'
int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id, ^~~
./include/linux/greybus/hd.h:33:32: error: unknown type name 'gfp_t'
struct gb_message *message, gfp_t gfp_mask); ^~~~~
./include/linux/greybus/hd.h:35:55: error: unknown type name 'u16'
int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Gao Xiang <hsiangkao@aol.com>
Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Link: https://lore.kernel.org/r/20190827155302.25704-1-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-27 23:53:02 +08:00
|
|
|
#include <linux/bits.h>
|
2014-10-02 10:54:14 +08:00
|
|
|
#include <linux/list.h>
|
2015-08-11 20:50:51 +08:00
|
|
|
#include <linux/kfifo.h>
|
staging: greybus: add missing includes
Before moving greybus core out of staging and moving header files to
include/linux some greybus header files were missing the necessary
includes. This would trigger compilation faillures with some example
errors logged bellow for with CONFIG_KERNEL_HEADER_TEST=y.
So, add the necessary headers to compile clean before relocating the
header files.
./include/linux/greybus/hd.h:23:50: error: unknown type name 'u16'
int (*cport_disable)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/greybus_protocols.h:1314:2: error: unknown type name '__u8'
__u8 data[0];
^~~~
./include/linux/greybus/hd.h:24:52: error: unknown type name 'u16'
int (*cport_connected)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:25:48: error: unknown type name 'u16'
int (*cport_flush)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:26:51: error: unknown type name 'u16'
int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id, ^~~
./include/linux/greybus/hd.h:27:5: error: unknown type name 'u8'
u8 phase, unsigned int timeout);
^~
./include/linux/greybus/hd.h:28:50: error: unknown type name 'u16'
int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id, ^~~
./include/linux/greybus/hd.h:29:5: error: unknown type name 'size_t'
size_t peer_space, unsigned int timeout);
^~~~~~
./include/linux/greybus/hd.h:29:5: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
./include/linux/greybus/hd.h:1:1:
+#include <stddef.h>
/* SPDX-License-Identifier: GPL-2.0 */
./include/linux/greybus/hd.h:29:5:
size_t peer_space, unsigned int timeout);
^~~~~~
./include/linux/greybus/hd.h:30:48: error: unknown type name 'u16'
int (*cport_clear)(struct gb_host_device *hd, u16 cport_id); ^~~
./include/linux/greybus/hd.h:32:49: error: unknown type name 'u16'
int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id, ^~~
./include/linux/greybus/hd.h:33:32: error: unknown type name 'gfp_t'
struct gb_message *message, gfp_t gfp_mask); ^~~~~
./include/linux/greybus/hd.h:35:55: error: unknown type name 'u16'
int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Gao Xiang <hsiangkao@aol.com>
Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Link: https://lore.kernel.org/r/20190827155302.25704-1-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-27 23:53:02 +08:00
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/workqueue.h>
|
2014-10-02 10:54:14 +08:00
|
|
|
|
2016-03-03 20:34:39 +08:00
|
|
|
#define GB_CONNECTION_FLAG_CSD BIT(0)
|
2016-05-11 16:17:55 +08:00
|
|
|
#define GB_CONNECTION_FLAG_NO_FLOWCTRL BIT(1)
|
2016-05-11 16:17:56 +08:00
|
|
|
#define GB_CONNECTION_FLAG_OFFLOADED BIT(2)
|
2016-05-11 16:18:04 +08:00
|
|
|
#define GB_CONNECTION_FLAG_CDSI1 BIT(3)
|
2016-05-27 23:26:25 +08:00
|
|
|
#define GB_CONNECTION_FLAG_CONTROL BIT(4)
|
2016-06-22 17:42:04 +08:00
|
|
|
#define GB_CONNECTION_FLAG_HIGH_PRIO BIT(5)
|
2016-03-03 20:34:39 +08:00
|
|
|
|
2016-06-22 17:42:03 +08:00
|
|
|
#define GB_CONNECTION_FLAG_CORE_MASK GB_CONNECTION_FLAG_CONTROL
|
|
|
|
|
2014-10-22 15:04:30 +08:00
|
|
|
enum gb_connection_state {
|
2016-05-27 23:26:36 +08:00
|
|
|
GB_CONNECTION_STATE_DISABLED = 0,
|
|
|
|
GB_CONNECTION_STATE_ENABLED_TX = 1,
|
|
|
|
GB_CONNECTION_STATE_ENABLED = 2,
|
|
|
|
GB_CONNECTION_STATE_DISCONNECTING = 3,
|
2014-10-22 15:04:30 +08:00
|
|
|
};
|
|
|
|
|
2016-01-19 19:51:02 +08:00
|
|
|
struct gb_operation;
|
|
|
|
|
|
|
|
typedef int (*gb_request_handler_t)(struct gb_operation *);
|
|
|
|
|
2014-10-02 10:54:14 +08:00
|
|
|
struct gb_connection {
|
2015-11-04 01:03:23 +08:00
|
|
|
struct gb_host_device *hd;
|
2015-11-25 22:59:11 +08:00
|
|
|
struct gb_interface *intf;
|
2014-12-13 06:10:17 +08:00
|
|
|
struct gb_bundle *bundle;
|
2015-10-17 07:56:38 +08:00
|
|
|
struct kref kref;
|
2014-10-03 01:30:05 +08:00
|
|
|
u16 hd_cport_id;
|
2015-06-04 12:48:01 +08:00
|
|
|
u16 intf_cport_id;
|
2014-10-02 10:54:14 +08:00
|
|
|
|
2014-11-17 22:08:44 +08:00
|
|
|
struct list_head hd_links;
|
2014-12-13 06:10:17 +08:00
|
|
|
struct list_head bundle_links;
|
2014-10-29 08:36:00 +08:00
|
|
|
|
2016-01-19 19:51:02 +08:00
|
|
|
gb_request_handler_t handler;
|
2016-03-03 20:34:36 +08:00
|
|
|
unsigned long flags;
|
2016-01-19 19:51:02 +08:00
|
|
|
|
2016-01-19 19:51:06 +08:00
|
|
|
struct mutex mutex;
|
2015-07-14 21:43:30 +08:00
|
|
|
spinlock_t lock;
|
2014-10-22 15:04:30 +08:00
|
|
|
enum gb_connection_state state;
|
2015-07-14 21:43:31 +08:00
|
|
|
struct list_head operations;
|
2014-10-02 10:54:15 +08:00
|
|
|
|
2015-11-25 22:59:14 +08:00
|
|
|
char name[16];
|
2015-07-23 16:50:02 +08:00
|
|
|
struct workqueue_struct *wq;
|
|
|
|
|
2014-12-03 22:35:08 +08:00
|
|
|
atomic_t op_cycle;
|
2014-10-04 04:05:21 +08:00
|
|
|
|
|
|
|
void *private;
|
2016-05-27 23:26:40 +08:00
|
|
|
|
|
|
|
bool mode_switch;
|
2014-10-02 10:54:14 +08:00
|
|
|
};
|
|
|
|
|
2015-11-25 22:59:11 +08:00
|
|
|
struct gb_connection *gb_connection_create_static(struct gb_host_device *hd,
|
2016-01-22 00:34:21 +08:00
|
|
|
u16 hd_cport_id, gb_request_handler_t handler);
|
2016-01-22 00:34:12 +08:00
|
|
|
struct gb_connection *gb_connection_create_control(struct gb_interface *intf);
|
2016-01-22 00:34:15 +08:00
|
|
|
struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
|
2016-01-22 00:34:21 +08:00
|
|
|
u16 cport_id, gb_request_handler_t handler);
|
2016-05-11 16:17:57 +08:00
|
|
|
struct gb_connection *gb_connection_create_flags(struct gb_bundle *bundle,
|
2016-03-03 20:34:36 +08:00
|
|
|
u16 cport_id, gb_request_handler_t handler,
|
|
|
|
unsigned long flags);
|
2016-05-11 16:17:57 +08:00
|
|
|
struct gb_connection *gb_connection_create_offloaded(struct gb_bundle *bundle,
|
|
|
|
u16 cport_id, unsigned long flags);
|
2014-10-03 01:30:01 +08:00
|
|
|
void gb_connection_destroy(struct gb_connection *connection);
|
2014-10-16 19:35:35 +08:00
|
|
|
|
2015-11-25 22:59:13 +08:00
|
|
|
static inline bool gb_connection_is_static(struct gb_connection *connection)
|
|
|
|
{
|
|
|
|
return !connection->intf;
|
|
|
|
}
|
|
|
|
|
2016-01-22 00:34:21 +08:00
|
|
|
int gb_connection_enable(struct gb_connection *connection);
|
|
|
|
int gb_connection_enable_tx(struct gb_connection *connection);
|
2016-01-19 19:51:08 +08:00
|
|
|
void gb_connection_disable_rx(struct gb_connection *connection);
|
2016-01-19 19:51:00 +08:00
|
|
|
void gb_connection_disable(struct gb_connection *connection);
|
2016-05-27 23:26:22 +08:00
|
|
|
void gb_connection_disable_forced(struct gb_connection *connection);
|
2016-01-19 19:51:00 +08:00
|
|
|
|
2016-05-27 23:26:40 +08:00
|
|
|
void gb_connection_mode_switch_prepare(struct gb_connection *connection);
|
|
|
|
void gb_connection_mode_switch_complete(struct gb_connection *connection);
|
|
|
|
|
2015-11-04 01:03:23 +08:00
|
|
|
void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,
|
2019-02-26 08:32:44 +08:00
|
|
|
u8 *data, size_t length);
|
2014-10-04 04:05:22 +08:00
|
|
|
|
2015-10-15 23:10:42 +08:00
|
|
|
void gb_connection_latency_tag_enable(struct gb_connection *connection);
|
|
|
|
void gb_connection_latency_tag_disable(struct gb_connection *connection);
|
|
|
|
|
2016-03-03 20:34:39 +08:00
|
|
|
static inline bool gb_connection_e2efc_enabled(struct gb_connection *connection)
|
|
|
|
{
|
|
|
|
return !(connection->flags & GB_CONNECTION_FLAG_CSD);
|
|
|
|
}
|
|
|
|
|
2016-05-11 16:17:55 +08:00
|
|
|
static inline bool
|
|
|
|
gb_connection_flow_control_disabled(struct gb_connection *connection)
|
|
|
|
{
|
|
|
|
return connection->flags & GB_CONNECTION_FLAG_NO_FLOWCTRL;
|
|
|
|
}
|
|
|
|
|
2016-05-11 16:17:56 +08:00
|
|
|
static inline bool gb_connection_is_offloaded(struct gb_connection *connection)
|
|
|
|
{
|
|
|
|
return connection->flags & GB_CONNECTION_FLAG_OFFLOADED;
|
|
|
|
}
|
|
|
|
|
2016-05-27 23:26:25 +08:00
|
|
|
static inline bool gb_connection_is_control(struct gb_connection *connection)
|
|
|
|
{
|
|
|
|
return connection->flags & GB_CONNECTION_FLAG_CONTROL;
|
|
|
|
}
|
|
|
|
|
2016-03-23 02:30:16 +08:00
|
|
|
static inline void *gb_connection_get_data(struct gb_connection *connection)
|
|
|
|
{
|
|
|
|
return connection->private;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gb_connection_set_data(struct gb_connection *connection,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
connection->private = data;
|
|
|
|
}
|
|
|
|
|
2014-10-02 10:54:14 +08:00
|
|
|
#endif /* __CONNECTION_H */
|