1/*-
2 * Copyright (c) 2004 M. Warner Losh
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
29/*-
30 * Copyright 1992 by the University of Guelph
31 *
32 * Permission to use, copy and modify this
33 * software and its documentation for any purpose and without
34 * fee is hereby granted, provided that the above copyright
35 * notice appear in all copies and that both that copyright
36 * notice and this permission notice appear in supporting
37 * documentation.
38 * University of Guelph makes no representations about the suitability of
39 * this software for any purpose.  It is provided "as is"
40 * without express or implied warranty.
41 */
42
43/* driver configuration flags (config) */
44#define MSE_CONFIG_ACCEL	0x00f0  /* acceleration factor */
45#define MSE_CONFIG_FLAGS	(MSE_CONFIG_ACCEL)
46
47/*
48 * Software control structure for mouse. The sc_enablemouse(),
49 * sc_disablemouse() and sc_getmouse() routines must be called spl'd().
50 */
51typedef struct mse_softc {
52	int		sc_flags;
53	int		sc_mousetype;
54	struct selinfo	sc_selp;
55	struct resource	*sc_port;
56	struct resource	*sc_intr;
57	bus_space_tag_t	sc_iot;
58	bus_space_handle_t sc_ioh;
59	void		*sc_ih;
60	void		(*sc_enablemouse)(bus_space_tag_t t,
61			    bus_space_handle_t h);
62	void		(*sc_disablemouse)(bus_space_tag_t t,
63			    bus_space_handle_t h);
64	void		(*sc_getmouse)(bus_space_tag_t t, bus_space_handle_t h,
65			    int *dx, int *dy, int *but);
66	int		sc_deltax;
67	int		sc_deltay;
68	int		sc_obuttons;
69	int		sc_buttons;
70	int		sc_bytesread;
71	u_char		sc_bytes[MOUSE_SYS_PACKETSIZE];
72	struct		callout_handle sc_callout;
73	int		sc_watchdog;
74	struct cdev *sc_dev;
75	struct cdev *sc_ndev;
76	mousehw_t	hw;
77	mousemode_t	mode;
78	mousestatus_t	status;
79} mse_softc_t;
80
81/* Flags */
82#define	MSESC_OPEN	0x1
83#define	MSESC_WANT	0x2
84
85/* and Mouse Types */
86#define	MSE_NONE	0	/* don't move this! */
87
88/* pc98 bus mouse types */
89#define	MSE_98BUSMOUSE	0x1
90
91/* isa bus mouse types */
92#define	MSE_LOGITECH	0x1
93#define	MSE_ATIINPORT	0x2
94
95#define	MSE_LOGI_SIG	0xA5
96
97/* XXX msereg.h? */
98#define	MSE_PORTA	0
99#define	MSE_PORTB	1
100#define	MSE_PORTC	2
101#define	MSE_PORTD	3
102#define MSE_IOSIZE	4
103
104/*
105 * Table of mouse types.
106 * Keep the Logitech last, since I haven't figured out how to probe it
107 * properly yet. (Someday I'll have the documentation.)
108 */
109struct mse_types {
110	int	m_type;		/* Type of bus mouse */
111	int	(*m_probe)(device_t dev, mse_softc_t *sc);
112				/* Probe routine to test for it */
113	void	(*m_enable)(bus_space_tag_t t, bus_space_handle_t h);
114				/* Start routine */
115	void	(*m_disable)(bus_space_tag_t t, bus_space_handle_t h);
116				/* Disable interrupts routine */
117	void	(*m_get)(bus_space_tag_t t, bus_space_handle_t h, int *dx,
118		    int *dy, int *but);
119				/* and get mouse status */
120	mousehw_t   m_hw;	/* buttons iftype type model hwid */
121	mousemode_t m_mode;	/* proto rate res accel level size mask */
122};
123
124extern devclass_t	mse_devclass;
125int mse_common_attach(device_t);
126