]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/linux/mfd/ipaq-micro.h
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Header file for the compaq Micro MFD
6 #ifndef _MFD_IPAQ_MICRO_H_
7 #define _MFD_IPAQ_MICRO_H_
9 #include <linux/spinlock.h>
10 #include <linux/completion.h>
11 #include <linux/list.h>
13 #define TX_BUF_SIZE 32
14 #define RX_BUF_SIZE 16
18 * These are the different messages that can be sent to the microcontroller
19 * to control various aspects.
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 /* H3600 only */
32 #define MSG_CODEC_CTRL 0xe /* H3100 only */
33 #define MSG_DISPLAY_CTRL 0xf /* H3100 only */
35 /* state of receiver parser */
37 STATE_SOF
= 0, /* Next byte should be start of frame */
38 STATE_ID
, /* Next byte is ID & message length */
39 STATE_DATA
, /* Next byte is a data byte */
40 STATE_CHKSUM
/* Next byte should be checksum */
44 * struct ipaq_micro_txdev - TX state
45 * @len: length of message in TX buffer
46 * @index: current index into TX buffer
49 struct ipaq_micro_txdev
{
56 * struct ipaq_micro_rxdev - RX state
57 * @state: context of RX state machine
58 * @chksum: calculated checksum
59 * @id: message ID from packet
60 * @len: RX buffer length
61 * @index: RX buffer index
64 struct ipaq_micro_rxdev
{
74 * struct ipaq_micro_msg - message to the iPAQ microcontroller
75 * @id: 4-bit ID of the message
76 * @tx_len: length of TX data
77 * @tx_data: TX data to send
78 * @rx_len: length of receieved RX data
79 * @rx_data: RX data to recieve
80 * @ack: a completion that will be completed when RX is complete
81 * @node: list node if message gets queued
83 struct ipaq_micro_msg
{
86 u8 tx_data
[TX_BUF_SIZE
];
88 u8 rx_data
[RX_BUF_SIZE
];
89 struct completion ack
;
90 struct list_head node
;
94 * struct ipaq_micro - iPAQ microcontroller state
95 * @dev: corresponding platform device
96 * @base: virtual memory base for underlying serial device
97 * @sdlc: virtual memory base for Synchronous Data Link Controller
98 * @version: version string
101 * @lock: lock for this state container
102 * @msg: current message
103 * @queue: message queue
104 * @key: callback for asynchronous key events
105 * @key_data: data to pass along with key events
106 * @ts: callback for asynchronous touchscreen events
107 * @ts_data: data to pass along with key events
114 struct ipaq_micro_txdev tx
; /* transmit ISR state */
115 struct ipaq_micro_rxdev rx
; /* receive ISR state */
117 struct ipaq_micro_msg
*msg
;
118 struct list_head queue
;
119 void (*key
) (void *data
, int len
, unsigned char *rxdata
);
121 void (*ts
) (void *data
, int len
, unsigned char *rxdata
);
126 ipaq_micro_tx_msg(struct ipaq_micro
*micro
, struct ipaq_micro_msg
*msg
);
129 ipaq_micro_tx_msg_sync(struct ipaq_micro
*micro
,
130 struct ipaq_micro_msg
*msg
)
134 init_completion(&msg
->ack
);
135 ret
= ipaq_micro_tx_msg(micro
, msg
);
136 wait_for_completion(&msg
->ack
);
142 ipaq_micro_tx_msg_async(struct ipaq_micro
*micro
,
143 struct ipaq_micro_msg
*msg
)
145 init_completion(&msg
->ack
);
146 return ipaq_micro_tx_msg(micro
, msg
);
149 #endif /* _MFD_IPAQ_MICRO_H_ */