ARM: perf: use integers for ARMv7 event indices
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / net / caif / caif_hsi.h
blobc5dedd87b4cb1048862ca47de863fc9517d4e7b7
1 /*
2 * Copyright (C) ST-Ericsson AB 2010
3 * Contact: Sjur Brendeland / sjur.brandeland@stericsson.com
4 * Author: Daniel Martensson / daniel.martensson@stericsson.com
5 * Dmitry.Tarnyagin / dmitry.tarnyagin@stericsson.com
6 * License terms: GNU General Public License (GPL) version 2
7 */
9 #ifndef CAIF_HSI_H_
10 #define CAIF_HSI_H_
12 #include <net/caif/caif_layer.h>
13 #include <net/caif/caif_device.h>
14 #include <linux/atomic.h>
17 * Maximum number of CAIF frames that can reside in the same HSI frame.
19 #define CFHSI_MAX_PKTS 15
22 * Maximum number of bytes used for the frame that can be embedded in the
23 * HSI descriptor.
25 #define CFHSI_MAX_EMB_FRM_SZ 96
28 * Decides if HSI buffers should be prefilled with 0xFF pattern for easier
29 * debugging. Both TX and RX buffers will be filled before the transfer.
31 #define CFHSI_DBG_PREFILL 0
33 /* Structure describing a HSI packet descriptor. */
34 #pragma pack(1) /* Byte alignment. */
35 struct cfhsi_desc {
36 u8 header;
37 u8 offset;
38 u16 cffrm_len[CFHSI_MAX_PKTS];
39 u8 emb_frm[CFHSI_MAX_EMB_FRM_SZ];
41 #pragma pack() /* Default alignment. */
43 /* Size of the complete HSI packet descriptor. */
44 #define CFHSI_DESC_SZ (sizeof(struct cfhsi_desc))
47 * Size of the complete HSI packet descriptor excluding the optional embedded
48 * CAIF frame.
50 #define CFHSI_DESC_SHORT_SZ (CFHSI_DESC_SZ - CFHSI_MAX_EMB_FRM_SZ)
53 * Maximum bytes transferred in one transfer.
55 /* TODO: 4096 is temporary... */
56 #define CFHSI_MAX_PAYLOAD_SZ (CFHSI_MAX_PKTS * 4096)
58 /* Size of the complete HSI TX buffer. */
59 #define CFHSI_BUF_SZ_TX (CFHSI_DESC_SZ + CFHSI_MAX_PAYLOAD_SZ)
61 /* Size of the complete HSI RX buffer. */
62 #define CFHSI_BUF_SZ_RX ((2 * CFHSI_DESC_SZ) + CFHSI_MAX_PAYLOAD_SZ)
64 /* Bitmasks for the HSI descriptor. */
65 #define CFHSI_PIGGY_DESC (0x01 << 7)
67 #define CFHSI_TX_STATE_IDLE 0
68 #define CFHSI_TX_STATE_XFER 1
70 #define CFHSI_RX_STATE_DESC 0
71 #define CFHSI_RX_STATE_PAYLOAD 1
73 /* Bitmasks for power management. */
74 #define CFHSI_WAKE_UP 0
75 #define CFHSI_WAKE_UP_ACK 1
76 #define CFHSI_WAKE_DOWN_ACK 2
77 #define CFHSI_AWAKE 3
78 #define CFHSI_PENDING_RX 4
79 #define CFHSI_SHUTDOWN 6
80 #define CFHSI_FLUSH_FIFO 7
82 #ifndef CFHSI_INACTIVITY_TOUT
83 #define CFHSI_INACTIVITY_TOUT (1 * HZ)
84 #endif /* CFHSI_INACTIVITY_TOUT */
86 #ifndef CFHSI_WAKEUP_TOUT
87 #define CFHSI_WAKEUP_TOUT (3 * HZ)
88 #endif /* CFHSI_WAKEUP_TOUT */
91 /* Structure implemented by the CAIF HSI driver. */
92 struct cfhsi_drv {
93 void (*tx_done_cb) (struct cfhsi_drv *drv);
94 void (*rx_done_cb) (struct cfhsi_drv *drv);
95 void (*wake_up_cb) (struct cfhsi_drv *drv);
96 void (*wake_down_cb) (struct cfhsi_drv *drv);
99 /* Structure implemented by HSI device. */
100 struct cfhsi_dev {
101 int (*cfhsi_up) (struct cfhsi_dev *dev);
102 int (*cfhsi_down) (struct cfhsi_dev *dev);
103 int (*cfhsi_tx) (u8 *ptr, int len, struct cfhsi_dev *dev);
104 int (*cfhsi_rx) (u8 *ptr, int len, struct cfhsi_dev *dev);
105 int (*cfhsi_wake_up) (struct cfhsi_dev *dev);
106 int (*cfhsi_wake_down) (struct cfhsi_dev *dev);
107 int (*cfhsi_fifo_occupancy)(struct cfhsi_dev *dev, size_t *occupancy);
108 int (*cfhsi_rx_cancel)(struct cfhsi_dev *dev);
109 struct cfhsi_drv *drv;
112 /* Structure implemented by CAIF HSI drivers. */
113 struct cfhsi {
114 struct caif_dev_common cfdev;
115 struct net_device *ndev;
116 struct platform_device *pdev;
117 struct sk_buff_head qhead;
118 struct cfhsi_drv drv;
119 struct cfhsi_dev *dev;
120 int tx_state;
121 int rx_state;
122 int rx_len;
123 u8 *rx_ptr;
124 u8 *tx_buf;
125 u8 *rx_buf;
126 spinlock_t lock;
127 int flow_off_sent;
128 u32 q_low_mark;
129 u32 q_high_mark;
130 struct list_head list;
131 struct work_struct wake_up_work;
132 struct work_struct wake_down_work;
133 struct work_struct rx_done_work;
134 struct work_struct tx_done_work;
135 struct workqueue_struct *wq;
136 wait_queue_head_t wake_up_wait;
137 wait_queue_head_t wake_down_wait;
138 wait_queue_head_t flush_fifo_wait;
139 struct timer_list timer;
140 unsigned long bits;
143 extern struct platform_driver cfhsi_driver;
145 #endif /* CAIF_HSI_H_ */