~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/mfd/ipaq-micro.h

Version: ~ [ linux-5.10-rc5 ] ~ [ linux-5.9.10 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.79 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.159 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.208 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.245 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.245 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Header file for the compaq Micro MFD
  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  * These are the different messages that can be sent to the microcontroller
 19  * to control various aspects.
 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 /* H3600 only */
 32 #define MSG_CODEC_CTRL          0xe /* H3100 only */
 33 #define MSG_DISPLAY_CTRL        0xf /* H3100 only */
 34 
 35 /* state of receiver parser */
 36 enum rx_state {
 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       */
 41 };
 42 
 43 /**
 44  * struct ipaq_micro_txdev - TX state
 45  * @len: length of message in TX buffer
 46  * @index: current index into TX buffer
 47  * @buf: TX buffer
 48  */
 49 struct ipaq_micro_txdev {
 50         u8 len;
 51         u8 index;
 52         u8 buf[TX_BUF_SIZE];
 53 };
 54 
 55 /**
 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
 62  * @buf: RX buffer
 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  * 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
 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  * 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
 99  * @tx: TX state
100  * @rx: RX state
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
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;     /* transmit ISR state */
115         struct ipaq_micro_rxdev rx;     /* receive ISR state */
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 /* _MFD_IPAQ_MICRO_H_ */
150 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp