]>
git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - include/linux/mfd/ipaq-micro.h
2 * Header file for the compaq Micro MFD
5 #ifndef _MFD_IPAQ_MICRO_H_
6 #define _MFD_IPAQ_MICRO_H_
8 #include <linux/spinlock.h>
9 #include <linux/completion.h>
10 #include <linux/list.h>
12 #define TX_BUF_SIZE 32
13 #define RX_BUF_SIZE 16
17 * These are the different messages that can be sent to the microcontroller
18 * to control various aspects.
20 #define MSG_VERSION 0x0
21 #define MSG_KEYBOARD 0x2
22 #define MSG_TOUCHSCREEN 0x3
23 #define MSG_EEPROM_READ 0x4
24 #define MSG_EEPROM_WRITE 0x5
25 #define MSG_THERMAL_SENSOR 0x6
26 #define MSG_NOTIFY_LED 0x8
27 #define MSG_BATTERY 0x9
28 #define MSG_SPI_READ 0xb
29 #define MSG_SPI_WRITE 0xc
30 #define MSG_BACKLIGHT 0xd /* H3600 only */
31 #define MSG_CODEC_CTRL 0xe /* H3100 only */
32 #define MSG_DISPLAY_CTRL 0xf /* H3100 only */
34 /* state of receiver parser */
36 STATE_SOF
= 0, /* Next byte should be start of frame */
37 STATE_ID
, /* Next byte is ID & message length */
38 STATE_DATA
, /* Next byte is a data byte */
39 STATE_CHKSUM
/* Next byte should be checksum */
43 * struct ipaq_micro_txdev - TX state
44 * @len: length of message in TX buffer
45 * @index: current index into TX buffer
48 struct ipaq_micro_txdev
{
55 * struct ipaq_micro_rxdev - RX state
56 * @state: context of RX state machine
57 * @chksum: calculated checksum
58 * @id: message ID from packet
59 * @len: RX buffer length
60 * @index: RX buffer index
63 struct ipaq_micro_rxdev
{
73 * struct ipaq_micro_msg - message to the iPAQ microcontroller
74 * @id: 4-bit ID of the message
75 * @tx_len: length of TX data
76 * @tx_data: TX data to send
77 * @rx_len: length of receieved RX data
78 * @rx_data: RX data to recieve
79 * @ack: a completion that will be completed when RX is complete
80 * @node: list node if message gets queued
82 struct ipaq_micro_msg
{
85 u8 tx_data
[TX_BUF_SIZE
];
87 u8 rx_data
[RX_BUF_SIZE
];
88 struct completion ack
;
89 struct list_head node
;
93 * struct ipaq_micro - iPAQ microcontroller state
94 * @dev: corresponding platform device
95 * @base: virtual memory base for underlying serial device
96 * @sdlc: virtual memory base for Synchronous Data Link Controller
97 * @version: version string
100 * @lock: lock for this state container
101 * @msg: current message
102 * @queue: message queue
103 * @key: callback for asynchronous key events
104 * @key_data: data to pass along with key events
105 * @ts: callback for asynchronous touchscreen events
106 * @ts_data: data to pass along with key events
113 struct ipaq_micro_txdev tx
; /* transmit ISR state */
114 struct ipaq_micro_rxdev rx
; /* receive ISR state */
116 struct ipaq_micro_msg
*msg
;
117 struct list_head queue
;
118 void (*key
) (void *data
, int len
, unsigned char *rxdata
);
120 void (*ts
) (void *data
, int len
, unsigned char *rxdata
);
125 ipaq_micro_tx_msg(struct ipaq_micro
*micro
, struct ipaq_micro_msg
*msg
);
128 ipaq_micro_tx_msg_sync(struct ipaq_micro
*micro
,
129 struct ipaq_micro_msg
*msg
)
133 init_completion(&msg
->ack
);
134 ret
= ipaq_micro_tx_msg(micro
, msg
);
135 wait_for_completion(&msg
->ack
);
141 ipaq_micro_tx_msg_async(struct ipaq_micro
*micro
,
142 struct ipaq_micro_msg
*msg
)
144 init_completion(&msg
->ack
);
145 return ipaq_micro_tx_msg(micro
, msg
);
148 #endif /* _MFD_IPAQ_MICRO_H_ */