0001
0002
0003
0004
0005
0006 #ifndef _MFD_IPAQ_MICRO_H_
0007 #define _MFD_IPAQ_MICRO_H_
0008
0009 #include <linux/spinlock.h>
0010 #include <linux/completion.h>
0011 #include <linux/list.h>
0012
0013 #define TX_BUF_SIZE 32
0014 #define RX_BUF_SIZE 16
0015 #define CHAR_SOF 0x02
0016
0017
0018
0019
0020
0021 #define MSG_VERSION 0x0
0022 #define MSG_KEYBOARD 0x2
0023 #define MSG_TOUCHSCREEN 0x3
0024 #define MSG_EEPROM_READ 0x4
0025 #define MSG_EEPROM_WRITE 0x5
0026 #define MSG_THERMAL_SENSOR 0x6
0027 #define MSG_NOTIFY_LED 0x8
0028 #define MSG_BATTERY 0x9
0029 #define MSG_SPI_READ 0xb
0030 #define MSG_SPI_WRITE 0xc
0031 #define MSG_BACKLIGHT 0xd
0032 #define MSG_CODEC_CTRL 0xe
0033 #define MSG_DISPLAY_CTRL 0xf
0034
0035
0036 enum rx_state {
0037 STATE_SOF = 0,
0038 STATE_ID,
0039 STATE_DATA,
0040 STATE_CHKSUM
0041 };
0042
0043
0044
0045
0046
0047
0048
0049 struct ipaq_micro_txdev {
0050 u8 len;
0051 u8 index;
0052 u8 buf[TX_BUF_SIZE];
0053 };
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 struct ipaq_micro_rxdev {
0065 enum rx_state state;
0066 unsigned char chksum;
0067 u8 id;
0068 unsigned int len;
0069 unsigned int index;
0070 u8 buf[RX_BUF_SIZE];
0071 };
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 struct ipaq_micro_msg {
0084 u8 id;
0085 u8 tx_len;
0086 u8 tx_data[TX_BUF_SIZE];
0087 u8 rx_len;
0088 u8 rx_data[RX_BUF_SIZE];
0089 struct completion ack;
0090 struct list_head node;
0091 };
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 struct ipaq_micro {
0110 struct device *dev;
0111 void __iomem *base;
0112 void __iomem *sdlc;
0113 char version[5];
0114 struct ipaq_micro_txdev tx;
0115 struct ipaq_micro_rxdev rx;
0116 spinlock_t lock;
0117 struct ipaq_micro_msg *msg;
0118 struct list_head queue;
0119 void (*key) (void *data, int len, unsigned char *rxdata);
0120 void *key_data;
0121 void (*ts) (void *data, int len, unsigned char *rxdata);
0122 void *ts_data;
0123 };
0124
0125 extern int
0126 ipaq_micro_tx_msg(struct ipaq_micro *micro, struct ipaq_micro_msg *msg);
0127
0128 static inline int
0129 ipaq_micro_tx_msg_sync(struct ipaq_micro *micro,
0130 struct ipaq_micro_msg *msg)
0131 {
0132 int ret;
0133
0134 init_completion(&msg->ack);
0135 ret = ipaq_micro_tx_msg(micro, msg);
0136 wait_for_completion(&msg->ack);
0137
0138 return ret;
0139 }
0140
0141 static inline int
0142 ipaq_micro_tx_msg_async(struct ipaq_micro *micro,
0143 struct ipaq_micro_msg *msg)
0144 {
0145 init_completion(&msg->ack);
0146 return ipaq_micro_tx_msg(micro, msg);
0147 }
0148
0149 #endif