blob: bccdb26dca492aa73937f8eebfd787346c57353a [file] [log] [blame]
Andres Salomondf08ef22008-09-16 12:30:34 -04001/*
2 * OLPC HGPK (XO-1) touchpad PS/2 mouse driver
3 */
4
5#ifndef _HGPK_H
6#define _HGPK_H
7
Daniel Drakeca94ec42010-11-11 22:19:57 -08008#define HGPK_GS 0xff /* The GlideSensor */
9#define HGPK_PT 0xcf /* The PenTablet */
10
Andres Salomondf08ef22008-09-16 12:30:34 -040011enum hgpk_model_t {
12 HGPK_MODEL_PREA = 0x0a, /* pre-B1s */
13 HGPK_MODEL_A = 0x14, /* found on B1s, PT disabled in hardware */
14 HGPK_MODEL_B = 0x28, /* B2s, has capacitance issues */
15 HGPK_MODEL_C = 0x3c,
16 HGPK_MODEL_D = 0x50, /* C1, mass production */
17};
18
Daniel Drakec0dc8342010-11-11 22:20:02 -080019enum hgpk_spew_flag {
20 NO_SPEW,
21 MAYBE_SPEWING,
22 SPEW_DETECTED,
23 RECALIBRATING,
24};
25
26#define SPEW_WATCH_COUNT 42 /* at 12ms/packet, this is 1/2 second */
27
Daniel Drakeca94ec42010-11-11 22:19:57 -080028enum hgpk_mode {
29 HGPK_MODE_MOUSE,
30 HGPK_MODE_GLIDESENSOR,
31 HGPK_MODE_PENTABLET,
32 HGPK_MODE_INVALID
33};
34
Andres Salomondf08ef22008-09-16 12:30:34 -040035struct hgpk_data {
36 struct psmouse *psmouse;
Daniel Drakeca94ec42010-11-11 22:19:57 -080037 enum hgpk_mode mode;
Dmitry Torokhovb7802c52009-09-09 19:13:20 -070038 bool powered;
Daniel Drakec0dc8342010-11-11 22:20:02 -080039 enum hgpk_spew_flag spew_flag;
40 int spew_count, x_tally, y_tally; /* spew detection */
Andres Salomondf08ef22008-09-16 12:30:34 -040041 unsigned long recalib_window;
42 struct delayed_work recalib_wq;
Daniel Drakeca94ec42010-11-11 22:19:57 -080043 int abs_x, abs_y;
Daniel Drakec0dc8342010-11-11 22:20:02 -080044 int dupe_count;
Andres Salomondf08ef22008-09-16 12:30:34 -040045};
46
47#define hgpk_dbg(psmouse, format, arg...) \
48 dev_dbg(&(psmouse)->ps2dev.serio->dev, format, ## arg)
49#define hgpk_err(psmouse, format, arg...) \
50 dev_err(&(psmouse)->ps2dev.serio->dev, format, ## arg)
51#define hgpk_info(psmouse, format, arg...) \
52 dev_info(&(psmouse)->ps2dev.serio->dev, format, ## arg)
53#define hgpk_warn(psmouse, format, arg...) \
54 dev_warn(&(psmouse)->ps2dev.serio->dev, format, ## arg)
55#define hgpk_notice(psmouse, format, arg...) \
56 dev_notice(&(psmouse)->ps2dev.serio->dev, format, ## arg)
57
58#ifdef CONFIG_MOUSE_PS2_OLPC
Daniel Drakeca94ec42010-11-11 22:19:57 -080059void hgpk_module_init(void);
Dmitry Torokhovb7802c52009-09-09 19:13:20 -070060int hgpk_detect(struct psmouse *psmouse, bool set_properties);
Andres Salomondf08ef22008-09-16 12:30:34 -040061int hgpk_init(struct psmouse *psmouse);
62#else
Daniel Drakeca94ec42010-11-11 22:19:57 -080063static inline void hgpk_module_init(void)
64{
65}
Dmitry Torokhovb7802c52009-09-09 19:13:20 -070066static inline int hgpk_detect(struct psmouse *psmouse, bool set_properties)
Andres Salomondf08ef22008-09-16 12:30:34 -040067{
68 return -ENODEV;
69}
70static inline int hgpk_init(struct psmouse *psmouse)
71{
72 return -ENODEV;
73}
74#endif
75
76#endif