xref: /netbsd/sys/dev/ic/spicvar.h (revision e1f25ac9)
1 /*	$NetBSD: spicvar.h,v 1.9 2022/04/10 09:50:45 andvar Exp $ */
2 
3 /*
4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Lennart Augustsson (lennart@augustsson.net) at
9  * Carlstedt Research & Technology.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*
34  * The SPIC is used on some Sony Vaios to handle the jog dial and other
35  * peripherals.
36  * The protocol used by the SPIC seems to vary wildly among the different
37  * models, and I've found no documentation.
38  * This file handles the jog dial on the SRX77 model, and perhaps nothing
39  * else.
40  *
41  * The general way of talking to the SPIC was gleaned from the Linux and
42  * FreeBSD drivers.  The hex numbers were taken from these drivers (they
43  * come from reverse engineering.)
44  *
45  * TODO:
46  *   Make it handle more models.
47  *   Figure out why the interrupt mode doesn't work.
48  */
49 #include <dev/sysmon/sysmonvar.h>
50 
51 struct spic_softc {
52 	device_t sc_dev;
53 
54 	bus_space_tag_t	sc_iot;
55 	bus_space_handle_t sc_ioh;
56 
57 	struct callout sc_poll;
58 
59 	int sc_buttons;
60 	char sc_enabled;
61 
62 	device_t sc_wsmousedev;
63 
64 #define	SPIC_PSWITCH_LID	0
65 #define	SPIC_PSWITCH_SUSPEND	1
66 #define	SPIC_PSWITCH_HIBERNATE	2
67 #define	SPIC_NPSWITCH		3
68 	struct sysmon_pswitch sc_smpsw[SPIC_NPSWITCH];
69 };
70 
71 void spic_attach(struct spic_softc *);
72 bool spic_suspend(device_t, const pmf_qual_t *);
73 bool spic_resume(device_t, const pmf_qual_t *);
74 
75 int spic_intr(void *);
76