^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) ST-Ericsson AB 2010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author: Sjur Brendeland
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef CFSRVL_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define CFSRVL_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/rculist.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct cfsrvl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct cflayer layer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) bool open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) bool phy_flow_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) bool modem_flow_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) bool supports_flowctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) void (*release)(struct cflayer *layer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct dev_info dev_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) void (*hold)(struct cflayer *lyr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) void (*put)(struct cflayer *lyr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int mtu_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) void cfsrvl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int phyid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) bool cfsrvl_phyid_match(struct cflayer *layer, int phyid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) void cfsrvl_init(struct cfsrvl *service,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) u8 channel_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct dev_info *dev_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) bool supports_flowctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) bool cfsrvl_ready(struct cfsrvl *service, int *err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u8 cfsrvl_getphyid(struct cflayer *layer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static inline void cfsrvl_get(struct cflayer *layr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) if (layr == NULL || layr->up == NULL || s->hold == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) s->hold(layr->up);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static inline void cfsrvl_put(struct cflayer *layr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if (layr == NULL || layr->up == NULL || s->hold == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) s->put(layr->up);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #endif /* CFSRVL_H_ */