diff options
Diffstat (limited to 'include/net/caif')
-rw-r--r-- | include/net/caif/caif_dev.h | 8 | ||||
-rw-r--r-- | include/net/caif/caif_layer.h | 6 | ||||
-rw-r--r-- | include/net/caif/caif_spi.h | 153 | ||||
-rw-r--r-- | include/net/caif/cfcnfg.h | 16 | ||||
-rw-r--r-- | include/net/caif/cfsrvl.h | 15 |
5 files changed, 182 insertions, 16 deletions
diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h index 318ab9478a44..6da573c75d54 100644 --- a/include/net/caif/caif_dev.h +++ b/include/net/caif/caif_dev.h | |||
@@ -50,6 +50,9 @@ struct caif_connect_request { | |||
50 | * @client_layer: User implementation of client layer. This layer | 50 | * @client_layer: User implementation of client layer. This layer |
51 | * MUST have receive and control callback functions | 51 | * MUST have receive and control callback functions |
52 | * implemented. | 52 | * implemented. |
53 | * @ifindex: Link layer interface index used for this connection. | ||
54 | * @headroom: Head room needed by CAIF protocol. | ||
55 | * @tailroom: Tail room needed by CAIF protocol. | ||
53 | * | 56 | * |
54 | * This function connects a CAIF channel. The Client must implement | 57 | * This function connects a CAIF channel. The Client must implement |
55 | * the struct cflayer. This layer represents the Client layer and holds | 58 | * the struct cflayer. This layer represents the Client layer and holds |
@@ -59,8 +62,9 @@ struct caif_connect_request { | |||
59 | * E.g. CAIF Socket will call this function for each socket it connects | 62 | * E.g. CAIF Socket will call this function for each socket it connects |
60 | * and have one client_layer instance for each socket. | 63 | * and have one client_layer instance for each socket. |
61 | */ | 64 | */ |
62 | int caif_connect_client(struct caif_connect_request *config, | 65 | int caif_connect_client(struct caif_connect_request *conn_req, |
63 | struct cflayer *client_layer); | 66 | struct cflayer *client_layer, int *ifindex, |
67 | int *headroom, int *tailroom); | ||
64 | 68 | ||
65 | /** | 69 | /** |
66 | * caif_disconnect_client - Disconnects a client from the CAIF stack. | 70 | * caif_disconnect_client - Disconnects a client from the CAIF stack. |
diff --git a/include/net/caif/caif_layer.h b/include/net/caif/caif_layer.h index 25c472f0e5b8..c8b07a904e78 100644 --- a/include/net/caif/caif_layer.h +++ b/include/net/caif/caif_layer.h | |||
@@ -15,14 +15,8 @@ struct cfpktq; | |||
15 | struct caif_payload_info; | 15 | struct caif_payload_info; |
16 | struct caif_packet_funcs; | 16 | struct caif_packet_funcs; |
17 | 17 | ||
18 | #define CAIF_MAX_FRAMESIZE 4096 | ||
19 | #define CAIF_MAX_PAYLOAD_SIZE (4096 - 64) | ||
20 | #define CAIF_NEEDED_HEADROOM (10) | ||
21 | #define CAIF_NEEDED_TAILROOM (2) | ||
22 | 18 | ||
23 | #define CAIF_LAYER_NAME_SZ 16 | 19 | #define CAIF_LAYER_NAME_SZ 16 |
24 | #define CAIF_SUCCESS 1 | ||
25 | #define CAIF_FAILURE 0 | ||
26 | 20 | ||
27 | /** | 21 | /** |
28 | * caif_assert() - Assert function for CAIF. | 22 | * caif_assert() - Assert function for CAIF. |
diff --git a/include/net/caif/caif_spi.h b/include/net/caif/caif_spi.h new file mode 100644 index 000000000000..ce4570dff020 --- /dev/null +++ b/include/net/caif/caif_spi.h | |||
@@ -0,0 +1,153 @@ | |||
1 | /* | ||
2 | * Copyright (C) ST-Ericsson AB 2010 | ||
3 | * Author: Daniel Martensson / Daniel.Martensson@stericsson.com | ||
4 | * License terms: GNU General Public License (GPL) version 2 | ||
5 | */ | ||
6 | |||
7 | #ifndef CAIF_SPI_H_ | ||
8 | #define CAIF_SPI_H_ | ||
9 | |||
10 | #include <net/caif/caif_device.h> | ||
11 | |||
12 | #define SPI_CMD_WR 0x00 | ||
13 | #define SPI_CMD_RD 0x01 | ||
14 | #define SPI_CMD_EOT 0x02 | ||
15 | #define SPI_CMD_IND 0x04 | ||
16 | |||
17 | #define SPI_DMA_BUF_LEN 8192 | ||
18 | |||
19 | #define WL_SZ 2 /* 16 bits. */ | ||
20 | #define SPI_CMD_SZ 4 /* 32 bits. */ | ||
21 | #define SPI_IND_SZ 4 /* 32 bits. */ | ||
22 | |||
23 | #define SPI_XFER 0 | ||
24 | #define SPI_SS_ON 1 | ||
25 | #define SPI_SS_OFF 2 | ||
26 | #define SPI_TERMINATE 3 | ||
27 | |||
28 | /* Minimum time between different levels is 50 microseconds. */ | ||
29 | #define MIN_TRANSITION_TIME_USEC 50 | ||
30 | |||
31 | /* Defines for calculating duration of SPI transfers for a particular | ||
32 | * number of bytes. | ||
33 | */ | ||
34 | #define SPI_MASTER_CLK_MHZ 13 | ||
35 | #define SPI_XFER_TIME_USEC(bytes, clk) (((bytes) * 8) / clk) | ||
36 | |||
37 | /* Normally this should be aligned on the modem in order to benefit from full | ||
38 | * duplex transfers. However a size of 8188 provokes errors when running with | ||
39 | * the modem. These errors occur when packet sizes approaches 4 kB of data. | ||
40 | */ | ||
41 | #define CAIF_MAX_SPI_FRAME 4092 | ||
42 | |||
43 | /* Maximum number of uplink CAIF frames that can reside in the same SPI frame. | ||
44 | * This number should correspond with the modem setting. The application side | ||
45 | * CAIF accepts any number of embedded downlink CAIF frames. | ||
46 | */ | ||
47 | #define CAIF_MAX_SPI_PKTS 9 | ||
48 | |||
49 | /* Decides if SPI buffers should be prefilled with 0xFF pattern for easier | ||
50 | * debugging. Both TX and RX buffers will be filled before the transfer. | ||
51 | */ | ||
52 | #define CFSPI_DBG_PREFILL 0 | ||
53 | |||
54 | /* Structure describing a SPI transfer. */ | ||
55 | struct cfspi_xfer { | ||
56 | u16 tx_dma_len; | ||
57 | u16 rx_dma_len; | ||
58 | void *va_tx; | ||
59 | dma_addr_t pa_tx; | ||
60 | void *va_rx; | ||
61 | dma_addr_t pa_rx; | ||
62 | }; | ||
63 | |||
64 | /* Structure implemented by the SPI interface. */ | ||
65 | struct cfspi_ifc { | ||
66 | void (*ss_cb) (bool assert, struct cfspi_ifc *ifc); | ||
67 | void (*xfer_done_cb) (struct cfspi_ifc *ifc); | ||
68 | void *priv; | ||
69 | }; | ||
70 | |||
71 | /* Structure implemented by SPI clients. */ | ||
72 | struct cfspi_dev { | ||
73 | int (*init_xfer) (struct cfspi_xfer *xfer, struct cfspi_dev *dev); | ||
74 | void (*sig_xfer) (bool xfer, struct cfspi_dev *dev); | ||
75 | struct cfspi_ifc *ifc; | ||
76 | char *name; | ||
77 | u32 clk_mhz; | ||
78 | void *priv; | ||
79 | }; | ||
80 | |||
81 | /* Enumeration describing the CAIF SPI state. */ | ||
82 | enum cfspi_state { | ||
83 | CFSPI_STATE_WAITING = 0, | ||
84 | CFSPI_STATE_AWAKE, | ||
85 | CFSPI_STATE_FETCH_PKT, | ||
86 | CFSPI_STATE_GET_NEXT, | ||
87 | CFSPI_STATE_INIT_XFER, | ||
88 | CFSPI_STATE_WAIT_ACTIVE, | ||
89 | CFSPI_STATE_SIG_ACTIVE, | ||
90 | CFSPI_STATE_WAIT_XFER_DONE, | ||
91 | CFSPI_STATE_XFER_DONE, | ||
92 | CFSPI_STATE_WAIT_INACTIVE, | ||
93 | CFSPI_STATE_SIG_INACTIVE, | ||
94 | CFSPI_STATE_DELIVER_PKT, | ||
95 | CFSPI_STATE_MAX, | ||
96 | }; | ||
97 | |||
98 | /* Structure implemented by SPI physical interfaces. */ | ||
99 | struct cfspi { | ||
100 | struct caif_dev_common cfdev; | ||
101 | struct net_device *ndev; | ||
102 | struct platform_device *pdev; | ||
103 | struct sk_buff_head qhead; | ||
104 | struct sk_buff_head chead; | ||
105 | u16 cmd; | ||
106 | u16 tx_cpck_len; | ||
107 | u16 tx_npck_len; | ||
108 | u16 rx_cpck_len; | ||
109 | u16 rx_npck_len; | ||
110 | struct cfspi_ifc ifc; | ||
111 | struct cfspi_xfer xfer; | ||
112 | struct cfspi_dev *dev; | ||
113 | unsigned long state; | ||
114 | struct work_struct work; | ||
115 | struct workqueue_struct *wq; | ||
116 | struct list_head list; | ||
117 | int flow_off_sent; | ||
118 | u32 qd_low_mark; | ||
119 | u32 qd_high_mark; | ||
120 | struct completion comp; | ||
121 | wait_queue_head_t wait; | ||
122 | spinlock_t lock; | ||
123 | bool flow_stop; | ||
124 | #ifdef CONFIG_DEBUG_FS | ||
125 | enum cfspi_state dbg_state; | ||
126 | u16 pcmd; | ||
127 | u16 tx_ppck_len; | ||
128 | u16 rx_ppck_len; | ||
129 | struct dentry *dbgfs_dir; | ||
130 | struct dentry *dbgfs_state; | ||
131 | struct dentry *dbgfs_frame; | ||
132 | #endif /* CONFIG_DEBUG_FS */ | ||
133 | }; | ||
134 | |||
135 | extern int spi_frm_align; | ||
136 | extern int spi_up_head_align; | ||
137 | extern int spi_up_tail_align; | ||
138 | extern int spi_down_head_align; | ||
139 | extern int spi_down_tail_align; | ||
140 | extern struct platform_driver cfspi_spi_driver; | ||
141 | |||
142 | void cfspi_dbg_state(struct cfspi *cfspi, int state); | ||
143 | int cfspi_xmitfrm(struct cfspi *cfspi, u8 *buf, size_t len); | ||
144 | int cfspi_xmitlen(struct cfspi *cfspi); | ||
145 | int cfspi_rxfrm(struct cfspi *cfspi, u8 *buf, size_t len); | ||
146 | int cfspi_spi_remove(struct platform_device *pdev); | ||
147 | int cfspi_spi_probe(struct platform_device *pdev); | ||
148 | int cfspi_xmitfrm(struct cfspi *cfspi, u8 *buf, size_t len); | ||
149 | int cfspi_xmitlen(struct cfspi *cfspi); | ||
150 | int cfspi_rxfrm(struct cfspi *cfspi, u8 *buf, size_t len); | ||
151 | void cfspi_xfer(struct work_struct *work); | ||
152 | |||
153 | #endif /* CAIF_SPI_H_ */ | ||
diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h index 9fc2fc20b884..bd646faffa47 100644 --- a/include/net/caif/cfcnfg.h +++ b/include/net/caif/cfcnfg.h | |||
@@ -7,6 +7,7 @@ | |||
7 | #ifndef CFCNFG_H_ | 7 | #ifndef CFCNFG_H_ |
8 | #define CFCNFG_H_ | 8 | #define CFCNFG_H_ |
9 | #include <linux/spinlock.h> | 9 | #include <linux/spinlock.h> |
10 | #include <linux/netdevice.h> | ||
10 | #include <net/caif/caif_layer.h> | 11 | #include <net/caif/caif_layer.h> |
11 | #include <net/caif/cfctrl.h> | 12 | #include <net/caif/cfctrl.h> |
12 | 13 | ||
@@ -73,8 +74,8 @@ void cfcnfg_remove(struct cfcnfg *cfg); | |||
73 | 74 | ||
74 | void | 75 | void |
75 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, | 76 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, |
76 | void *dev, struct cflayer *phy_layer, u16 *phyid, | 77 | struct net_device *dev, struct cflayer *phy_layer, |
77 | enum cfcnfg_phy_preference pref, | 78 | u16 *phyid, enum cfcnfg_phy_preference pref, |
78 | bool fcs, bool stx); | 79 | bool fcs, bool stx); |
79 | 80 | ||
80 | /** | 81 | /** |
@@ -114,11 +115,18 @@ void cfcnfg_release_adap_layer(struct cflayer *adap_layer); | |||
114 | * @param: Link setup parameters. | 115 | * @param: Link setup parameters. |
115 | * @adap_layer: Specify the adaptation layer; the receive and | 116 | * @adap_layer: Specify the adaptation layer; the receive and |
116 | * flow-control functions MUST be set in the structure. | 117 | * flow-control functions MUST be set in the structure. |
117 | * | 118 | * @ifindex: Link layer interface index used for this connection. |
119 | * @proto_head: Protocol head-space needed by CAIF protocol, | ||
120 | * excluding link layer. | ||
121 | * @proto_tail: Protocol tail-space needed by CAIF protocol, | ||
122 | * excluding link layer. | ||
118 | */ | 123 | */ |
119 | int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, | 124 | int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, |
120 | struct cfctrl_link_param *param, | 125 | struct cfctrl_link_param *param, |
121 | struct cflayer *adap_layer); | 126 | struct cflayer *adap_layer, |
127 | int *ifindex, | ||
128 | int *proto_head, | ||
129 | int *proto_tail); | ||
122 | 130 | ||
123 | /** | 131 | /** |
124 | * cfcnfg_get_phyid() - Get physical ID, given type. | 132 | * cfcnfg_get_phyid() - Get physical ID, given type. |
diff --git a/include/net/caif/cfsrvl.h b/include/net/caif/cfsrvl.h index 2dc9eb193ecf..b1fa87ee0992 100644 --- a/include/net/caif/cfsrvl.h +++ b/include/net/caif/cfsrvl.h | |||
@@ -16,6 +16,8 @@ struct cfsrvl { | |||
16 | bool open; | 16 | bool open; |
17 | bool phy_flow_on; | 17 | bool phy_flow_on; |
18 | bool modem_flow_on; | 18 | bool modem_flow_on; |
19 | bool supports_flowctrl; | ||
20 | void (*release)(struct kref *); | ||
19 | struct dev_info dev_info; | 21 | struct dev_info dev_info; |
20 | struct kref ref; | 22 | struct kref ref; |
21 | }; | 23 | }; |
@@ -25,13 +27,15 @@ struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); | |||
25 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); | 27 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); |
26 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); | 28 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); |
27 | struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info); | 29 | struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info); |
28 | struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info); | 30 | struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, |
31 | int mtu_size); | ||
29 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); | 32 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); |
30 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); | 33 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); |
31 | void cfservl_destroy(struct cflayer *layer); | 34 | void cfservl_destroy(struct cflayer *layer); |
32 | void cfsrvl_init(struct cfsrvl *service, | 35 | void cfsrvl_init(struct cfsrvl *service, |
33 | u8 channel_id, | 36 | u8 channel_id, |
34 | struct dev_info *dev_info); | 37 | struct dev_info *dev_info, |
38 | bool supports_flowctrl); | ||
35 | bool cfsrvl_ready(struct cfsrvl *service, int *err); | 39 | bool cfsrvl_ready(struct cfsrvl *service, int *err); |
36 | u8 cfsrvl_getphyid(struct cflayer *layer); | 40 | u8 cfsrvl_getphyid(struct cflayer *layer); |
37 | 41 | ||
@@ -50,7 +54,10 @@ static inline void cfsrvl_put(struct cflayer *layr) | |||
50 | if (layr == NULL) | 54 | if (layr == NULL) |
51 | return; | 55 | return; |
52 | s = container_of(layr, struct cfsrvl, layer); | 56 | s = container_of(layr, struct cfsrvl, layer); |
53 | kref_put(&s->ref, cfsrvl_release); | 57 | |
58 | WARN_ON(!s->release); | ||
59 | if (s->release) | ||
60 | kref_put(&s->ref, s->release); | ||
54 | } | 61 | } |
55 | 62 | ||
56 | #endif /* CFSRVL_H_ */ | 63 | #endif /* CFSRVL_H_ */ |