This source file includes following definitions.
- ipaq_micro_tx_msg_sync
- ipaq_micro_tx_msg_async
1
2
3
4
5
6 #ifndef _MFD_IPAQ_MICRO_H_
7 #define _MFD_IPAQ_MICRO_H_
8
9 #include <linux/spinlock.h>
10 #include <linux/completion.h>
11 #include <linux/list.h>
12
13 #define TX_BUF_SIZE 32
14 #define RX_BUF_SIZE 16
15 #define CHAR_SOF 0x02
16
17
18
19
20
21 #define MSG_VERSION 0x0
22 #define MSG_KEYBOARD 0x2
23 #define MSG_TOUCHSCREEN 0x3
24 #define MSG_EEPROM_READ 0x4
25 #define MSG_EEPROM_WRITE 0x5
26 #define MSG_THERMAL_SENSOR 0x6
27 #define MSG_NOTIFY_LED 0x8
28 #define MSG_BATTERY 0x9
29 #define MSG_SPI_READ 0xb
30 #define MSG_SPI_WRITE 0xc
31 #define MSG_BACKLIGHT 0xd
32 #define MSG_CODEC_CTRL 0xe
33 #define MSG_DISPLAY_CTRL 0xf
34
35
36 enum rx_state {
37 STATE_SOF = 0,
38 STATE_ID,
39 STATE_DATA,
40 STATE_CHKSUM
41 };
42
43
44
45
46
47
48
49 struct ipaq_micro_txdev {
50 u8 len;
51 u8 index;
52 u8 buf[TX_BUF_SIZE];
53 };
54
55
56
57
58
59
60
61
62
63
64 struct ipaq_micro_rxdev {
65 enum rx_state state;
66 unsigned char chksum;
67 u8 id;
68 unsigned int len;
69 unsigned int index;
70 u8 buf[RX_BUF_SIZE];
71 };
72
73
74
75
76
77
78
79
80
81
82
83 struct ipaq_micro_msg {
84 u8 id;
85 u8 tx_len;
86 u8 tx_data[TX_BUF_SIZE];
87 u8 rx_len;
88 u8 rx_data[RX_BUF_SIZE];
89 struct completion ack;
90 struct list_head node;
91 };
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 struct ipaq_micro {
110 struct device *dev;
111 void __iomem *base;
112 void __iomem *sdlc;
113 char version[5];
114 struct ipaq_micro_txdev tx;
115 struct ipaq_micro_rxdev rx;
116 spinlock_t lock;
117 struct ipaq_micro_msg *msg;
118 struct list_head queue;
119 void (*key) (void *data, int len, unsigned char *rxdata);
120 void *key_data;
121 void (*ts) (void *data, int len, unsigned char *rxdata);
122 void *ts_data;
123 };
124
125 extern int
126 ipaq_micro_tx_msg(struct ipaq_micro *micro, struct ipaq_micro_msg *msg);
127
128 static inline int
129 ipaq_micro_tx_msg_sync(struct ipaq_micro *micro,
130 struct ipaq_micro_msg *msg)
131 {
132 int ret;
133
134 init_completion(&msg->ack);
135 ret = ipaq_micro_tx_msg(micro, msg);
136 wait_for_completion(&msg->ack);
137
138 return ret;
139 }
140
141 static inline int
142 ipaq_micro_tx_msg_async(struct ipaq_micro *micro,
143 struct ipaq_micro_msg *msg)
144 {
145 init_completion(&msg->ack);
146 return ipaq_micro_tx_msg(micro, msg);
147 }
148
149 #endif