3 * Driver for iPAQ H3xxx/h5xxx Extension Packs
5 * Copyright 2000 Compaq Computer Corporation.
7 * Use consistent with the GNU GPL is permitted,
8 * provided that this copyright notice is
9 * preserved in its entirety in all copies and derived works.
11 * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
12 * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
13 * FITNESS FOR ANY PARTICULAR PURPOSE.
15 * Author: Jamey Hicks.
18 #ifndef _INCLUDE_IPAQ_SLEEVE_H_
19 #define _INCLUDE_IPAQ_SLEEVE_H_
21 #include <linux/device.h>
22 #include <asm/arch-sa1100/h3600.h> /* !!! */
24 enum sleeve_vendor_id
{
26 COMPAQ_VENDOR_ID
= 0x1125,
27 TALON_VENDOR
= 0x0100,
28 BIOCENTRIC_SOLUTIONS
= 0x0101,
29 HANVIT_INFO_TECH
= 0x0102,
30 SYMBOL_VENDOR
= 0x0103,
31 OMRON_CORPORATION
= 0x0104,
32 HAGIWARA_SYSCOM_CO
= 0x0105,
33 TACTEL_SLEEVE_VENDOR
= 0x0107,
34 NEXIAN_VENDOR
= 0x010a,
35 PITECH_VENDOR
= 0x0111,
36 LIFEVIEW_VENDOR
= 0x0601,
40 enum sleeve_device_id
{
43 /* COMPAQ_VENDOR_ID sleeve devices */
44 SINGLE_COMPACTFLASH_SLEEVE
= 0xCF11,
45 SINGLE_PCMCIA_SLEEVE
= 0xD7C3,
46 DUAL_PCMCIA_SLEEVE
= 0x0001,
47 EXTENDED_BATTERY_SLEEVE
= 0x0002,
48 SINGLE_CF_PLUS_SLEEVE
= 0x0003,
49 SINGLE_PCMCIA_PLUS_SLEEVE
= 0x0004,
50 GPRS_EXPANSION_PACK
= 0x0010,
51 BLUETOOTH_EXPANSION_PACK
= 0x0011,
52 MERCURY_BACKPAQ
= 0x0100,
54 /* TALON_VENDOR sleeve devices */
55 NAVMAN_GPS_SLEEVE
= 0x0001,
56 NAVMAN_GPS_SLEEVE_ALT
= 0x0010,
58 /* Nexian sleeve devices */
59 NEXIAN_DUAL_CF_SLEEVE
= 0x0001,
60 NEXIAN_CAMERA_CF_SLEEVE
= 0x0003,
62 /* Symbol sleeve devices */
63 SYMBOL_WLAN_SCANNER_SLEEVE
= 0x0011,
65 /* Lifeview sleeve devices */
66 LIFEVIEW_FLYJACKET_SLEEVE
= 0x8a10,
68 /* PiTech sleeve devices */
69 MEMPLUG_SLEEVE
= 0x0001,
70 MEMPLUG_SLEEVE3
= 0x0003,
73 TACTEL_BLUETOOTH_CF_SLEEVE
= 0xbcbc
77 #define IPAQ_SLEEVE_ID(vendor,device) ((vendor)<<16 | (device))
79 struct ipaq_sleeve_driver
;
83 * @driver: which driver allocated this device
84 * @procent: device entry in /proc/bus/sleeve
85 * @vendor: vendor id copied from eeprom
86 * @device: device id copied from eeprom
87 * @driver_data: private data for the driver
90 struct ipaq_sleeve_device
{
92 struct proc_dir_entry
*procent
; /* device entry in /proc/bus/sleeve */
93 unsigned short vendor
; /* Copied from EEPROM */
94 unsigned short device
;
96 #define to_ipaq_sleeve_device(obj) container_of(obj, struct ipaq_sleeve_device, dev)
98 struct ipaq_sleeve_device_id
{
99 unsigned int vendor
, device
; /* Vendor and device ID or SLEEVE_ANY_ID */
102 #define SLEEVE_HAS_CF_MASK 0x00000003 /* 0 to 3 */
103 #define SLEEVE_HAS_CF(x) (x)
104 #define SLEEVE_GET_CF(x) ((x)&SLEEVE_HAS_CF_MASK)
105 #define SLEEVE_HAS_PCMCIA_MASK 0x0000000c
106 #define SLEEVE_HAS_PCMCIA(x) ((x)<<2)
107 #define SLEEVE_GET_PCMCIA(x) (((x)&SLEEVE_HAS_PCMCIA_MASK)>>2)
109 #define SLEEVE_HAS_BLUETOOTH 0x00000010
110 #define SLEEVE_HAS_GPS 0x00000020
111 #define SLEEVE_HAS_GPRS 0x00000040
112 #define SLEEVE_HAS_CAMERA 0x00000080
113 #define SLEEVE_HAS_ACCELEROMETER 0x00000100
114 #define SLEEVE_HAS_FLASH 0x00000200
115 #define SLEEVE_HAS_BARCODE_READER 0x00000400
116 #define SLEEVE_HAS_802_11B 0x00000800
117 #define SLEEVE_HAS_EBAT 0x00001000
118 #define SLEEVE_HAS_VGA_OUT 0x00002000
119 #define SLEEVE_HAS_VIDEO_OUT 0x00004000
120 #define SLEEVE_HAS_VIDEO_IN 0x00008000
121 #define SLEEVE_HAS_IRDA 0x00010000
122 #define SLEEVE_HAS_AUDIO 0x00020000
124 #define SLEEVE_HAS_FIXED_BATTERY 0x10000000
125 #define SLEEVE_HAS_REMOVABLE_BATTERY 0x20000000
127 struct h3600_battery
;
130 * struct ipaq_sleeve_driver: driver for iPAQ extension pack
131 * @name: name of device type
132 * @id_table: table of &struct_sleeve_device_id identifying matching sleeves by vendor,device
133 * @features: SLEEVE_HAS flags
134 * @driver: used by driverfs
135 * @probe: called when new sleeve inserted
136 * @remove: called when sleeve removed
137 * @suspend: called before suspending iPAQ
138 * @resume: called while resuming iPAQ
141 struct ipaq_sleeve_driver
{
142 struct device_driver driver
;
143 const struct ipaq_sleeve_device_id
*id_table
; /* NULL if wants all devices */
144 unsigned int features
; /* SLEEVE_HAS flags */
147 #define to_ipaq_sleeve_driver(obj) container_of(obj, struct ipaq_sleeve_driver, driver)
150 * struct ipaq_sleeve_controller_driver: driver for the controller for iPAQ expansion sleeves
152 struct ipaq_sleeve_controller_driver
{
153 /* called to indicate that sleeve has been inserted or removed */
154 int (*sleeve_detect
)(struct ipaq_sleeve_device
*dev
, int present
);
155 struct device_driver
*driver
;
158 extern struct bus_type ipaq_sleeve_bus_type
;
160 extern int ipaq_current_sleeve( void ); /* returns IPAQ_SLEEVE_ID(vendor,dev) */
163 * ipaq_sleeve_driver_register: Registers a driver for an iPAQ extension pack.
164 * @drv: the sleeve driver
166 extern int ipaq_sleeve_driver_register(struct ipaq_sleeve_driver
*drv
);
169 * ipaq_sleeve_driver_unregister: Unregisters a driver for an iPAQ extension pack.
170 * @drv: the sleeve driver
172 extern void ipaq_sleeve_driver_unregister(struct ipaq_sleeve_driver
*drv
);
174 extern int ipaq_sleeve_egpio_irq(int egpio
);
176 #define ipaq_sleeve_clear_egpio(n) \
177 ipaq_sleeve_write_egpio(n, 0)
178 #define ipaq_sleeve_set_egpio(n) \
179 ipaq_sleeve_write_egpio(n, 1)
181 extern void ipaq_sleeve_write_egpio(int nr
, int state
);
182 extern int ipaq_sleeve_read_egpio(int nr
);
183 extern int ipaq_sleeve_egpio_irq(int nr
);
185 #ifdef CONFIG_SLEEVE_DEBUG
186 #ifndef CONFIG_SLEEVE_DEBUG_VERBOSE
187 #define CONFIG_SLEEVE_DEBUG_VERBOSE 3
189 extern int g_sleeve_debug
;
190 #define SLEEVE_DEBUG(n, args...) \
191 if (n <= g_sleeve_debug) { \
192 printk(KERN_DEBUG "%s: ", __FUNCTION__); printk(args); \
195 #define SLEEVE_DEBUG(n, args...)
196 #endif /* CONFIG_SLEEVE_DEBUG */
198 struct ipaq_sleeve_version
{
202 /* Functions provided to generic ipaq-sleeve code by board support */
203 struct ipaq_sleeve_ops
{
204 int (*spi_read
)(void *dev
, unsigned short address
, unsigned char *data
, unsigned short len
);
205 int (*spi_write
)(void *dev
, unsigned short address
, unsigned char *data
, unsigned short len
);
206 int (*get_option_detect
)(void *dev
, int *result
);
207 int (*get_version
)(void *dev
, struct ipaq_sleeve_version
*);
208 int (*set_ebat
)(void *dev
);
209 int (*control_egpio
)(void *dev
, int egpio
, int state
);
210 int (*read_egpio
)(void *dev
, int egpio
);
211 int (*egpio_irq
)(void *dev
, int egpio
);
212 int (*read_battery
)(void *dev
, unsigned char *chem
, unsigned char *percent
, unsigned char *flag
);
215 extern int ipaq_sleeve_register(struct ipaq_sleeve_ops
*ops
, void *dev
);
216 extern int ipaq_sleeve_unregister(void);
217 extern irqreturn_t
ipaq_sleeve_presence_interrupt (int irq
, void *dev_id
, struct pt_regs
*regs
);
219 #endif /* _INCLUDE_IPAQ_SLEEVE_H_ */