j720ssp.c revision 1.2.8.5 1 1.2.8.5 nathanw /* $NetBSD: j720ssp.c,v 1.2.8.5 2002/08/01 02:41:44 nathanw Exp $ */
2 1.2.8.2 nathanw
3 1.2.8.2 nathanw /*-
4 1.2.8.2 nathanw * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
5 1.2.8.2 nathanw * All rights reserved.
6 1.2.8.2 nathanw *
7 1.2.8.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.2.8.2 nathanw * by Charles M. Hannum.
9 1.2.8.2 nathanw *
10 1.2.8.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.2.8.2 nathanw * modification, are permitted provided that the following conditions
12 1.2.8.2 nathanw * are met:
13 1.2.8.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.2.8.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.2.8.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.2.8.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.2.8.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.2.8.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.2.8.2 nathanw * must display the following acknowledgement:
20 1.2.8.2 nathanw * This product includes software developed by the NetBSD
21 1.2.8.2 nathanw * Foundation, Inc. and its contributors.
22 1.2.8.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.2.8.2 nathanw * contributors may be used to endorse or promote products derived
24 1.2.8.2 nathanw * from this software without specific prior written permission.
25 1.2.8.2 nathanw *
26 1.2.8.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.2.8.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.2.8.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.2.8.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.2.8.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.2.8.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.2.8.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.2.8.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.2.8.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.2.8.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.2.8.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.2.8.2 nathanw */
38 1.2.8.2 nathanw
39 1.2.8.2 nathanw /*-
40 1.2.8.2 nathanw * Copyright (c) 1990 The Regents of the University of California.
41 1.2.8.2 nathanw * All rights reserved.
42 1.2.8.2 nathanw *
43 1.2.8.2 nathanw * This code is derived from software contributed to Berkeley by
44 1.2.8.2 nathanw * William Jolitz and Don Ahn.
45 1.2.8.2 nathanw *
46 1.2.8.2 nathanw * Redistribution and use in source and binary forms, with or without
47 1.2.8.2 nathanw * modification, are permitted provided that the following conditions
48 1.2.8.2 nathanw * are met:
49 1.2.8.2 nathanw * 1. Redistributions of source code must retain the above copyright
50 1.2.8.2 nathanw * notice, this list of conditions and the following disclaimer.
51 1.2.8.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
52 1.2.8.2 nathanw * notice, this list of conditions and the following disclaimer in the
53 1.2.8.2 nathanw * documentation and/or other materials provided with the distribution.
54 1.2.8.2 nathanw * 3. All advertising materials mentioning features or use of this software
55 1.2.8.2 nathanw * must display the following acknowledgement:
56 1.2.8.2 nathanw * This product includes software developed by the University of
57 1.2.8.2 nathanw * California, Berkeley and its contributors.
58 1.2.8.2 nathanw * 4. Neither the name of the University nor the names of its contributors
59 1.2.8.2 nathanw * may be used to endorse or promote products derived from this software
60 1.2.8.2 nathanw * without specific prior written permission.
61 1.2.8.2 nathanw *
62 1.2.8.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 1.2.8.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 1.2.8.2 nathanw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 1.2.8.2 nathanw * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 1.2.8.2 nathanw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 1.2.8.2 nathanw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 1.2.8.2 nathanw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 1.2.8.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 1.2.8.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 1.2.8.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 1.2.8.2 nathanw * SUCH DAMAGE.
73 1.2.8.2 nathanw *
74 1.2.8.2 nathanw * @(#)pccons.c 5.11 (Berkeley) 5/21/91
75 1.2.8.2 nathanw */
76 1.2.8.2 nathanw
77 1.2.8.2 nathanw #include <sys/param.h>
78 1.2.8.2 nathanw #include <sys/systm.h>
79 1.2.8.2 nathanw #include <sys/device.h>
80 1.2.8.5 nathanw #include <sys/callout.h>
81 1.2.8.2 nathanw #include <sys/kernel.h>
82 1.2.8.2 nathanw #include <sys/malloc.h>
83 1.2.8.2 nathanw #include <sys/ioctl.h>
84 1.2.8.2 nathanw
85 1.2.8.2 nathanw #include <machine/bus.h>
86 1.2.8.2 nathanw #include <machine/config_hook.h>
87 1.2.8.3 nathanw #include <machine/bootinfo.h>
88 1.2.8.2 nathanw
89 1.2.8.2 nathanw #include <hpcarm/dev/sed1356var.h>
90 1.2.8.5 nathanw
91 1.2.8.5 nathanw #include <arm/sa11x0/sa11x0_var.h>
92 1.2.8.5 nathanw #include <arm/sa11x0/sa11x0_gpioreg.h>
93 1.2.8.5 nathanw #include <arm/sa11x0/sa11x0_ppcreg.h>
94 1.2.8.5 nathanw #include <arm/sa11x0/sa11x0_sspreg.h>
95 1.2.8.2 nathanw
96 1.2.8.2 nathanw #include <dev/wscons/wsconsio.h>
97 1.2.8.2 nathanw #include <dev/wscons/wskbdvar.h>
98 1.2.8.2 nathanw #include <dev/wscons/wsksymdef.h>
99 1.2.8.2 nathanw #include <dev/wscons/wsksymvar.h>
100 1.2.8.5 nathanw #include <dev/wscons/wsmousevar.h>
101 1.2.8.5 nathanw #include <dev/hpc/tpcalibvar.h>
102 1.2.8.2 nathanw
103 1.2.8.2 nathanw extern const struct wscons_keydesc j720kbd_keydesctab[];
104 1.2.8.2 nathanw
105 1.2.8.2 nathanw struct j720ssp_softc {
106 1.2.8.2 nathanw struct device sc_dev;
107 1.2.8.2 nathanw
108 1.2.8.2 nathanw bus_space_tag_t sc_iot;
109 1.2.8.2 nathanw bus_space_handle_t sc_gpioh;
110 1.2.8.2 nathanw bus_space_handle_t sc_ssph;
111 1.2.8.2 nathanw
112 1.2.8.2 nathanw struct device *sc_wskbddev;
113 1.2.8.5 nathanw struct device *sc_wsmousedev;
114 1.2.8.5 nathanw struct tpcalib_softc sc_tpcalib;
115 1.2.8.2 nathanw
116 1.2.8.5 nathanw void *sc_kbdsi;
117 1.2.8.5 nathanw void *sc_tpsi;
118 1.2.8.5 nathanw struct callout sc_tptimeout;
119 1.2.8.2 nathanw int sc_enabled;
120 1.2.8.2 nathanw };
121 1.2.8.2 nathanw
122 1.2.8.2 nathanw int j720kbd_intr(void *);
123 1.2.8.5 nathanw int j720tp_intr(void *);
124 1.2.8.2 nathanw void j720kbdsoft(void *);
125 1.2.8.5 nathanw void j720tpsoft(void *);
126 1.2.8.5 nathanw void j720tp_timeout(void *);
127 1.2.8.2 nathanw int j720lcdparam(void *, int, long, void *);
128 1.2.8.2 nathanw static void j720kbd_read(struct j720ssp_softc *, char *);
129 1.2.8.2 nathanw static int j720ssp_readwrite(struct j720ssp_softc *, int, int, int *);
130 1.2.8.2 nathanw
131 1.2.8.2 nathanw int j720sspprobe(struct device *, struct cfdata *, void *);
132 1.2.8.2 nathanw void j720sspattach(struct device *, struct device *, void *);
133 1.2.8.2 nathanw
134 1.2.8.5 nathanw int j720kbd_submatch(struct device *, struct cfdata *, void *);
135 1.2.8.5 nathanw int j720tp_submatch(struct device *, struct cfdata *, void *);
136 1.2.8.5 nathanw
137 1.2.8.2 nathanw int j720kbd_enable(void *, int);
138 1.2.8.2 nathanw void j720kbd_set_leds(void *, int);
139 1.2.8.2 nathanw int j720kbd_ioctl(void *, u_long, caddr_t, int, struct proc *);
140 1.2.8.2 nathanw
141 1.2.8.2 nathanw struct cfattach j720ssp_ca = {
142 1.2.8.2 nathanw sizeof(struct j720ssp_softc), j720sspprobe, j720sspattach,
143 1.2.8.2 nathanw };
144 1.2.8.2 nathanw
145 1.2.8.2 nathanw const struct wskbd_accessops j720kbd_accessops = {
146 1.2.8.2 nathanw j720kbd_enable,
147 1.2.8.2 nathanw j720kbd_set_leds,
148 1.2.8.2 nathanw j720kbd_ioctl,
149 1.2.8.2 nathanw };
150 1.2.8.2 nathanw
151 1.2.8.2 nathanw void j720kbd_cngetc(void *, u_int *, int *);
152 1.2.8.2 nathanw void j720kbd_cnpollc(void *, int);
153 1.2.8.2 nathanw void j720kbd_cnbell(void *, u_int, u_int, u_int);
154 1.2.8.2 nathanw
155 1.2.8.2 nathanw const struct wskbd_consops j720kbd_consops = {
156 1.2.8.2 nathanw j720kbd_cngetc,
157 1.2.8.2 nathanw j720kbd_cnpollc,
158 1.2.8.2 nathanw j720kbd_cnbell,
159 1.2.8.2 nathanw };
160 1.2.8.2 nathanw
161 1.2.8.2 nathanw const struct wskbd_mapdata j720kbd_keymapdata = {
162 1.2.8.2 nathanw j720kbd_keydesctab,
163 1.2.8.2 nathanw #ifdef J720KBD_LAYOUT
164 1.2.8.2 nathanw J720KBD_LAYOUT,
165 1.2.8.2 nathanw #else
166 1.2.8.2 nathanw KB_US,
167 1.2.8.2 nathanw #endif
168 1.2.8.2 nathanw };
169 1.2.8.2 nathanw
170 1.2.8.5 nathanw static int j720tp_enable(void *);
171 1.2.8.5 nathanw static int j720tp_ioctl(void *, u_long, caddr_t, int, struct proc *);
172 1.2.8.5 nathanw static void j720tp_disable(void *);
173 1.2.8.5 nathanw
174 1.2.8.5 nathanw const struct wsmouse_accessops j720tp_accessops = {
175 1.2.8.5 nathanw j720tp_enable,
176 1.2.8.5 nathanw j720tp_ioctl,
177 1.2.8.5 nathanw j720tp_disable,
178 1.2.8.5 nathanw };
179 1.2.8.5 nathanw
180 1.2.8.2 nathanw static int j720ssp_powerstate = 1;
181 1.2.8.2 nathanw
182 1.2.8.2 nathanw static struct j720ssp_softc j720kbdcons_sc;
183 1.2.8.2 nathanw static int j720kbdcons_initstate = 0;
184 1.2.8.2 nathanw
185 1.2.8.2 nathanw #define DEBUG
186 1.2.8.2 nathanw #ifdef DEBUG
187 1.2.8.2 nathanw int j720sspwaitcnt;
188 1.2.8.2 nathanw int j720sspwaittime;
189 1.2.8.2 nathanw extern int gettick();
190 1.2.8.2 nathanw #endif
191 1.2.8.2 nathanw
192 1.2.8.2 nathanw #define BIT_INVERT(x) do { \
193 1.2.8.2 nathanw (x) = ((((x) & 0xf0) >> 4) | (((x) & 0x0f) << 4)); \
194 1.2.8.2 nathanw (x) = ((((x) & 0xcc) >> 2) | (((x) & 0x33) << 2)); \
195 1.2.8.2 nathanw (x) = ((((x) & 0xaa) >> 1) | (((x) & 0x55) << 1)); \
196 1.2.8.2 nathanw } while(0)
197 1.2.8.2 nathanw
198 1.2.8.2 nathanw int
199 1.2.8.2 nathanw j720sspprobe(struct device *parent, struct cfdata *cf, void *aux)
200 1.2.8.2 nathanw {
201 1.2.8.2 nathanw return (1);
202 1.2.8.2 nathanw }
203 1.2.8.2 nathanw
204 1.2.8.2 nathanw void
205 1.2.8.2 nathanw j720sspattach(struct device *parent, struct device *self, void *aux)
206 1.2.8.2 nathanw {
207 1.2.8.2 nathanw struct j720ssp_softc *sc = (void *)self;
208 1.2.8.2 nathanw struct sa11x0_softc *psc = (void *)parent;
209 1.2.8.2 nathanw struct sa11x0_attach_args *sa = aux;
210 1.2.8.2 nathanw struct wskbddev_attach_args a;
211 1.2.8.5 nathanw struct wsmousedev_attach_args ma;
212 1.2.8.2 nathanw
213 1.2.8.2 nathanw printf("\n");
214 1.2.8.2 nathanw
215 1.2.8.2 nathanw sc->sc_iot = psc->sc_iot;
216 1.2.8.2 nathanw sc->sc_gpioh = psc->sc_gpioh;
217 1.2.8.2 nathanw if (bus_space_map(sc->sc_iot, sa->sa_addr, sa->sa_size, 0,
218 1.2.8.2 nathanw &sc->sc_ssph)) {
219 1.2.8.2 nathanw printf("%s: unable to map SSP registers\n",
220 1.2.8.2 nathanw sc->sc_dev.dv_xname);
221 1.2.8.2 nathanw return;
222 1.2.8.2 nathanw }
223 1.2.8.2 nathanw
224 1.2.8.5 nathanw sc->sc_kbdsi = softintr_establish(IPL_SOFTCLOCK, j720kbdsoft, sc);
225 1.2.8.2 nathanw
226 1.2.8.2 nathanw sc->sc_enabled = 0;
227 1.2.8.2 nathanw
228 1.2.8.2 nathanw a.console = 0;
229 1.2.8.2 nathanw
230 1.2.8.2 nathanw a.keymap = &j720kbd_keymapdata;
231 1.2.8.2 nathanw
232 1.2.8.2 nathanw a.accessops = &j720kbd_accessops;
233 1.2.8.2 nathanw a.accesscookie = sc;
234 1.2.8.2 nathanw
235 1.2.8.2 nathanw /* Do console initialization */
236 1.2.8.2 nathanw if (! (bootinfo->bi_cnuse & BI_CNUSE_SERIAL)) {
237 1.2.8.2 nathanw j720kbdcons_sc = *sc;
238 1.2.8.2 nathanw a.console = 1;
239 1.2.8.2 nathanw
240 1.2.8.2 nathanw wskbd_cnattach(&j720kbd_consops, NULL, &j720kbd_keymapdata);
241 1.2.8.2 nathanw j720kbdcons_initstate = 1;
242 1.2.8.2 nathanw }
243 1.2.8.2 nathanw
244 1.2.8.2 nathanw /*
245 1.2.8.2 nathanw * Attach the wskbd, saving a handle to it.
246 1.2.8.2 nathanw * XXX XXX XXX
247 1.2.8.2 nathanw */
248 1.2.8.5 nathanw sc->sc_wskbddev = config_found_sm(self, &a, wskbddevprint,
249 1.2.8.5 nathanw j720kbd_submatch);
250 1.2.8.2 nathanw
251 1.2.8.2 nathanw #ifdef DEBUG
252 1.2.8.2 nathanw /* Zero the stat counters */
253 1.2.8.2 nathanw j720sspwaitcnt = 0;
254 1.2.8.2 nathanw j720sspwaittime = 0;
255 1.2.8.2 nathanw #endif
256 1.2.8.2 nathanw
257 1.2.8.2 nathanw if (j720kbdcons_initstate == 1)
258 1.2.8.2 nathanw j720kbd_enable(sc, 1);
259 1.2.8.2 nathanw
260 1.2.8.5 nathanw ma.accessops = &j720tp_accessops;
261 1.2.8.5 nathanw ma.accesscookie = sc;
262 1.2.8.5 nathanw
263 1.2.8.5 nathanw sc->sc_wsmousedev = config_found_sm(self, &ma, wsmousedevprint,
264 1.2.8.5 nathanw j720tp_submatch);
265 1.2.8.5 nathanw tpcalib_init(&sc->sc_tpcalib);
266 1.2.8.5 nathanw
267 1.2.8.5 nathanw /* XXX fill in "default" calibrate param */
268 1.2.8.5 nathanw {
269 1.2.8.5 nathanw static const struct wsmouse_calibcoords j720_default_calib = {
270 1.2.8.5 nathanw 0, 0, 639, 239,
271 1.2.8.5 nathanw 4,
272 1.2.8.5 nathanw { { 988, 80, 0, 0 },
273 1.2.8.5 nathanw { 88, 84, 639, 0 },
274 1.2.8.5 nathanw { 988, 927, 0, 239 },
275 1.2.8.5 nathanw { 88, 940, 639, 239 } } };
276 1.2.8.5 nathanw tpcalib_ioctl(&sc->sc_tpcalib, WSMOUSEIO_SCALIBCOORDS,
277 1.2.8.5 nathanw (caddr_t)&j720_default_calib, 0, 0);
278 1.2.8.5 nathanw }
279 1.2.8.5 nathanw
280 1.2.8.5 nathanw j720tp_disable(sc);
281 1.2.8.5 nathanw callout_init(&sc->sc_tptimeout);
282 1.2.8.5 nathanw
283 1.2.8.5 nathanw /* Setup touchpad interrupt */
284 1.2.8.5 nathanw sc->sc_tpsi = softintr_establish(IPL_SOFTCLOCK, j720tpsoft, sc);
285 1.2.8.5 nathanw sa11x0_intr_establish(0, 9, 1, IPL_BIO, j720tp_intr, sc);
286 1.2.8.5 nathanw
287 1.2.8.2 nathanw /* LCD control is on the same bus */
288 1.2.8.2 nathanw config_hook(CONFIG_HOOK_SET, CONFIG_HOOK_BRIGHTNESS,
289 1.2.8.2 nathanw CONFIG_HOOK_SHARE, j720lcdparam, sc);
290 1.2.8.2 nathanw config_hook(CONFIG_HOOK_GET, CONFIG_HOOK_BRIGHTNESS,
291 1.2.8.2 nathanw CONFIG_HOOK_SHARE, j720lcdparam, sc);
292 1.2.8.2 nathanw config_hook(CONFIG_HOOK_GET, CONFIG_HOOK_BRIGHTNESS_MAX,
293 1.2.8.2 nathanw CONFIG_HOOK_SHARE, j720lcdparam, sc);
294 1.2.8.2 nathanw
295 1.2.8.2 nathanw config_hook(CONFIG_HOOK_SET, CONFIG_HOOK_CONTRAST,
296 1.2.8.2 nathanw CONFIG_HOOK_SHARE, j720lcdparam, sc);
297 1.2.8.2 nathanw config_hook(CONFIG_HOOK_GET, CONFIG_HOOK_CONTRAST,
298 1.2.8.2 nathanw CONFIG_HOOK_SHARE, j720lcdparam, sc);
299 1.2.8.2 nathanw config_hook(CONFIG_HOOK_GET, CONFIG_HOOK_CONTRAST_MAX,
300 1.2.8.2 nathanw CONFIG_HOOK_SHARE, j720lcdparam, sc);
301 1.2.8.2 nathanw }
302 1.2.8.2 nathanw
303 1.2.8.2 nathanw int
304 1.2.8.5 nathanw j720kbd_submatch(struct device *parant, struct cfdata *cf, void *aux) {
305 1.2.8.5 nathanw
306 1.2.8.5 nathanw if (strcmp(cf->cf_driver->cd_name, "wskbd") == 0)
307 1.2.8.5 nathanw return (1);
308 1.2.8.5 nathanw return (0);
309 1.2.8.5 nathanw }
310 1.2.8.5 nathanw
311 1.2.8.5 nathanw int
312 1.2.8.5 nathanw j720tp_submatch(struct device *parant, struct cfdata *cf, void *aux) {
313 1.2.8.5 nathanw
314 1.2.8.5 nathanw if (strcmp(cf->cf_driver->cd_name, "wsmouse") == 0)
315 1.2.8.5 nathanw return (1);
316 1.2.8.5 nathanw return (0);
317 1.2.8.5 nathanw }
318 1.2.8.5 nathanw
319 1.2.8.5 nathanw int
320 1.2.8.2 nathanw j720kbd_enable(void *v, int on)
321 1.2.8.2 nathanw {
322 1.2.8.2 nathanw struct j720ssp_softc *sc = v;
323 1.2.8.2 nathanw
324 1.2.8.2 nathanw if (! sc->sc_enabled) {
325 1.2.8.2 nathanw sc->sc_enabled = 1;
326 1.2.8.2 nathanw
327 1.2.8.2 nathanw sa11x0_intr_establish(0, 0, 1, IPL_BIO, j720kbd_intr, sc);
328 1.2.8.2 nathanw }
329 1.2.8.2 nathanw /* XXX */
330 1.2.8.2 nathanw return (0);
331 1.2.8.2 nathanw }
332 1.2.8.2 nathanw
333 1.2.8.2 nathanw void
334 1.2.8.2 nathanw j720kbd_set_leds(void *v, int on)
335 1.2.8.2 nathanw {
336 1.2.8.2 nathanw /* XXX */
337 1.2.8.2 nathanw return;
338 1.2.8.2 nathanw }
339 1.2.8.2 nathanw
340 1.2.8.2 nathanw int
341 1.2.8.5 nathanw j720kbd_ioctl(v, cmd, data, flag, p)
342 1.2.8.5 nathanw void *v;
343 1.2.8.5 nathanw u_long cmd;
344 1.2.8.5 nathanw caddr_t data;
345 1.2.8.5 nathanw int flag;
346 1.2.8.5 nathanw struct proc *p;
347 1.2.8.5 nathanw {
348 1.2.8.5 nathanw switch (cmd) {
349 1.2.8.5 nathanw case WSKBDIO_GTYPE:
350 1.2.8.5 nathanw *(int *)data = WSKBD_TYPE_HPC_KBD;
351 1.2.8.5 nathanw return 0;
352 1.2.8.5 nathanw }
353 1.2.8.5 nathanw
354 1.2.8.4 nathanw return (EPASSTHROUGH);
355 1.2.8.2 nathanw }
356 1.2.8.2 nathanw
357 1.2.8.2 nathanw int
358 1.2.8.2 nathanw j720kbd_intr(void *arg)
359 1.2.8.2 nathanw {
360 1.2.8.2 nathanw struct j720ssp_softc *sc = arg;
361 1.2.8.2 nathanw
362 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_EDR, 1);
363 1.2.8.2 nathanw
364 1.2.8.2 nathanw /*
365 1.2.8.2 nathanw * Schedule a soft interrupt to process at lower priority,
366 1.2.8.2 nathanw * as reading keycodes takes time.
367 1.2.8.2 nathanw *
368 1.2.8.2 nathanw * Interrupts are generated every 25-33ms as long as there
369 1.2.8.2 nathanw * are unprocessed key events. So it is not a good idea to
370 1.2.8.2 nathanw * use callout to call j720kbdsoft after some delay in hope
371 1.2.8.2 nathanw * of reducing interrupts.
372 1.2.8.2 nathanw */
373 1.2.8.5 nathanw softintr_schedule(sc->sc_kbdsi);
374 1.2.8.5 nathanw
375 1.2.8.5 nathanw return (1);
376 1.2.8.5 nathanw }
377 1.2.8.5 nathanw
378 1.2.8.5 nathanw int
379 1.2.8.5 nathanw j720tp_intr(void *arg)
380 1.2.8.5 nathanw {
381 1.2.8.5 nathanw struct j720ssp_softc *sc = arg;
382 1.2.8.5 nathanw
383 1.2.8.5 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_EDR, 1 << 9);
384 1.2.8.5 nathanw
385 1.2.8.5 nathanw softintr_schedule(sc->sc_tpsi);
386 1.2.8.2 nathanw
387 1.2.8.2 nathanw return (1);
388 1.2.8.2 nathanw }
389 1.2.8.2 nathanw
390 1.2.8.2 nathanw void
391 1.2.8.2 nathanw j720kbdsoft(void *arg)
392 1.2.8.2 nathanw {
393 1.2.8.2 nathanw struct j720ssp_softc *sc = arg;
394 1.2.8.2 nathanw int s, type, value;
395 1.2.8.2 nathanw char buf[9], *p;
396 1.2.8.2 nathanw
397 1.2.8.2 nathanw j720kbd_read(sc, buf);
398 1.2.8.2 nathanw
399 1.2.8.2 nathanw for(p = buf; *p; p++) {
400 1.2.8.2 nathanw type = *p & 0x80 ? WSCONS_EVENT_KEY_UP :
401 1.2.8.2 nathanw WSCONS_EVENT_KEY_DOWN;
402 1.2.8.2 nathanw value = *p & 0x7f;
403 1.2.8.2 nathanw s = spltty();
404 1.2.8.2 nathanw wskbd_input(sc->sc_wskbddev, type, value);
405 1.2.8.2 nathanw splx(s);
406 1.2.8.2 nathanw if (type == WSCONS_EVENT_KEY_DOWN &&
407 1.2.8.2 nathanw value == 0x7f) {
408 1.2.8.2 nathanw j720ssp_powerstate = ! j720ssp_powerstate;
409 1.2.8.2 nathanw config_hook_call(CONFIG_HOOK_POWERCONTROL,
410 1.2.8.2 nathanw CONFIG_HOOK_POWERCONTROL_LCDLIGHT,
411 1.2.8.2 nathanw (void *)j720ssp_powerstate);
412 1.2.8.2 nathanw }
413 1.2.8.2 nathanw }
414 1.2.8.2 nathanw
415 1.2.8.2 nathanw return;
416 1.2.8.2 nathanw }
417 1.2.8.2 nathanw
418 1.2.8.2 nathanw void
419 1.2.8.2 nathanw j720kbd_read(struct j720ssp_softc *sc, char *buf)
420 1.2.8.2 nathanw {
421 1.2.8.2 nathanw int data, count;
422 1.2.8.2 nathanw #ifdef DEBUG
423 1.2.8.2 nathanw u_int32_t oscr;
424 1.2.8.2 nathanw
425 1.2.8.2 nathanw oscr = gettick();
426 1.2.8.2 nathanw #endif
427 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PCR, 0x2000000);
428 1.2.8.2 nathanw
429 1.2.8.2 nathanw /* send scan keycode command */
430 1.2.8.2 nathanw if (j720ssp_readwrite(sc, 1, 0x900, &data) < 0 ||
431 1.2.8.2 nathanw data != 0x88)
432 1.2.8.2 nathanw goto out;
433 1.2.8.2 nathanw
434 1.2.8.2 nathanw /* read numbers of scancode available */
435 1.2.8.2 nathanw if (j720ssp_readwrite(sc, 0, 0x8800, &data) < 0)
436 1.2.8.2 nathanw goto out;
437 1.2.8.2 nathanw BIT_INVERT(data);
438 1.2.8.2 nathanw count = data;
439 1.2.8.2 nathanw
440 1.2.8.2 nathanw for(; count; count--) {
441 1.2.8.2 nathanw if (j720ssp_readwrite(sc, 0, 0x8800, &data) < 0)
442 1.2.8.2 nathanw goto out;
443 1.2.8.2 nathanw BIT_INVERT(data);
444 1.2.8.2 nathanw *buf++ = data;
445 1.2.8.2 nathanw }
446 1.2.8.2 nathanw *buf = 0;
447 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PSR, 0x2000000);
448 1.2.8.2 nathanw
449 1.2.8.2 nathanw #ifdef DEBUG
450 1.2.8.2 nathanw oscr = (u_int32_t)gettick() - oscr;
451 1.2.8.2 nathanw j720sspwaitcnt++;
452 1.2.8.2 nathanw j720sspwaittime += oscr;
453 1.2.8.2 nathanw #endif
454 1.2.8.2 nathanw
455 1.2.8.2 nathanw return;
456 1.2.8.2 nathanw
457 1.2.8.2 nathanw out:
458 1.2.8.2 nathanw *buf = 0;
459 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PSR, 0x2000000);
460 1.2.8.2 nathanw
461 1.2.8.2 nathanw /* reset SSP */
462 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ssph, SASSP_CR0, 0x307);
463 1.2.8.2 nathanw delay(100);
464 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ssph, SASSP_CR0, 0x387);
465 1.2.8.2 nathanw printf("j720kbd_read: error %x\n", data);
466 1.2.8.2 nathanw }
467 1.2.8.2 nathanw
468 1.2.8.5 nathanw void
469 1.2.8.5 nathanw j720tpsoft(void *arg)
470 1.2.8.5 nathanw {
471 1.2.8.5 nathanw struct j720ssp_softc *sc = arg;
472 1.2.8.5 nathanw int buf[8], data, i, x, y;
473 1.2.8.5 nathanw
474 1.2.8.5 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PCR, 0x2000000);
475 1.2.8.5 nathanw
476 1.2.8.5 nathanw /* send read touchpanel command */
477 1.2.8.5 nathanw if (j720ssp_readwrite(sc, 1, 0x500, &data) < 0 ||
478 1.2.8.5 nathanw data != 0x88)
479 1.2.8.5 nathanw goto out;
480 1.2.8.5 nathanw
481 1.2.8.5 nathanw for(i = 0; i < 8; i++) {
482 1.2.8.5 nathanw if (j720ssp_readwrite(sc, 0, 0x8800, &data) < 0)
483 1.2.8.5 nathanw goto out;
484 1.2.8.5 nathanw BIT_INVERT(data);
485 1.2.8.5 nathanw buf[i] = data;
486 1.2.8.5 nathanw }
487 1.2.8.5 nathanw
488 1.2.8.5 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PSR, 0x2000000);
489 1.2.8.5 nathanw
490 1.2.8.5 nathanw buf[6] <<= 8;
491 1.2.8.5 nathanw buf[7] <<= 8;
492 1.2.8.5 nathanw for(i = 0; i < 3; i++) {
493 1.2.8.5 nathanw buf[i] |= buf[6] & 0x300;
494 1.2.8.5 nathanw buf[6] >>= 2;
495 1.2.8.5 nathanw buf[i + 3] |= buf[7] & 0x300;
496 1.2.8.5 nathanw buf[7] >>= 2;
497 1.2.8.5 nathanw }
498 1.2.8.5 nathanw #if 0
499 1.2.8.5 nathanw printf("j720tpsoft: %d %d %d %d %d %d\n", buf[0], buf[1], buf[2],
500 1.2.8.5 nathanw buf[3], buf[4], buf[5]);
501 1.2.8.5 nathanw #endif
502 1.2.8.5 nathanw
503 1.2.8.5 nathanw /* XXX buf[1], buf[2], ... should also be used */
504 1.2.8.5 nathanw tpcalib_trans(&sc->sc_tpcalib, buf[1], buf[4], &x, &y);
505 1.2.8.5 nathanw wsmouse_input(sc->sc_wsmousedev, 1, x, y, 0,
506 1.2.8.5 nathanw WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
507 1.2.8.5 nathanw
508 1.2.8.5 nathanw callout_reset(&sc->sc_tptimeout, hz / 10, j720tp_timeout, sc);
509 1.2.8.5 nathanw
510 1.2.8.5 nathanw return;
511 1.2.8.5 nathanw
512 1.2.8.5 nathanw out:
513 1.2.8.5 nathanw *buf = 0;
514 1.2.8.5 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PSR, 0x2000000);
515 1.2.8.5 nathanw
516 1.2.8.5 nathanw /* reset SSP */
517 1.2.8.5 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ssph, SASSP_CR0, 0x307);
518 1.2.8.5 nathanw delay(100);
519 1.2.8.5 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ssph, SASSP_CR0, 0x387);
520 1.2.8.5 nathanw printf("j720tpsoft: error %x\n", data);
521 1.2.8.5 nathanw }
522 1.2.8.5 nathanw
523 1.2.8.5 nathanw void
524 1.2.8.5 nathanw j720tp_timeout(void *arg)
525 1.2.8.5 nathanw {
526 1.2.8.5 nathanw struct j720ssp_softc *sc = arg;
527 1.2.8.5 nathanw
528 1.2.8.5 nathanw #if 0
529 1.2.8.5 nathanw /* XXX I don't this this is necessary (untested) */
530 1.2.8.5 nathanw if (bus_space_read_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PLR) &
531 1.2.8.5 nathanw (1 << 9)) {
532 1.2.8.5 nathanw /* Touchpad is still pressed */
533 1.2.8.5 nathanw callout_reset(&sc->sc_tptimeout, hz / 10, j720tp_timeout, sc);
534 1.2.8.5 nathanw return;
535 1.2.8.5 nathanw }
536 1.2.8.5 nathanw #endif
537 1.2.8.5 nathanw
538 1.2.8.5 nathanw wsmouse_input(sc->sc_wsmousedev, 0, 0, 0, 0, 0);
539 1.2.8.5 nathanw }
540 1.2.8.5 nathanw
541 1.2.8.5 nathanw static int
542 1.2.8.5 nathanw j720tp_enable(void *arg) {
543 1.2.8.5 nathanw struct j720ssp_softc *sc = arg;
544 1.2.8.5 nathanw int er, s;
545 1.2.8.5 nathanw
546 1.2.8.5 nathanw s = splhigh();
547 1.2.8.5 nathanw er = bus_space_read_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_FER);
548 1.2.8.5 nathanw er |= 1 << 9;
549 1.2.8.5 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_FER, er);
550 1.2.8.5 nathanw splx(s);
551 1.2.8.5 nathanw
552 1.2.8.5 nathanw return (0);
553 1.2.8.5 nathanw }
554 1.2.8.5 nathanw
555 1.2.8.5 nathanw static void
556 1.2.8.5 nathanw j720tp_disable(void *arg) {
557 1.2.8.5 nathanw struct j720ssp_softc *sc = arg;
558 1.2.8.5 nathanw int er, s;
559 1.2.8.5 nathanw
560 1.2.8.5 nathanw s = splhigh();
561 1.2.8.5 nathanw er = bus_space_read_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_FER);
562 1.2.8.5 nathanw er &= ~(1 << 9);
563 1.2.8.5 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_FER, er);
564 1.2.8.5 nathanw splx(s);
565 1.2.8.5 nathanw }
566 1.2.8.5 nathanw
567 1.2.8.5 nathanw static int
568 1.2.8.5 nathanw j720tp_ioctl(void *arg, u_long cmd, caddr_t data, int flag, struct proc *p) {
569 1.2.8.5 nathanw struct j720ssp_softc *sc = arg;
570 1.2.8.5 nathanw
571 1.2.8.5 nathanw switch (cmd) {
572 1.2.8.5 nathanw case WSMOUSEIO_GTYPE:
573 1.2.8.5 nathanw *(u_int *)data = WSMOUSE_TYPE_TPANEL;
574 1.2.8.5 nathanw return (0);
575 1.2.8.5 nathanw
576 1.2.8.5 nathanw case WSMOUSEIO_SCALIBCOORDS:
577 1.2.8.5 nathanw case WSMOUSEIO_GCALIBCOORDS:
578 1.2.8.5 nathanw return tpcalib_ioctl(&sc->sc_tpcalib, cmd, data, flag, p);
579 1.2.8.5 nathanw
580 1.2.8.5 nathanw default:
581 1.2.8.5 nathanw return (EPASSTHROUGH);
582 1.2.8.5 nathanw }
583 1.2.8.5 nathanw }
584 1.2.8.5 nathanw
585 1.2.8.2 nathanw int
586 1.2.8.2 nathanw j720lcdparam(void *ctx, int type, long id, void *msg)
587 1.2.8.2 nathanw {
588 1.2.8.2 nathanw struct j720ssp_softc *sc = ctx;
589 1.2.8.2 nathanw int i, s;
590 1.2.8.2 nathanw u_int32_t data[2], len;
591 1.2.8.2 nathanw
592 1.2.8.2 nathanw switch (type) {
593 1.2.8.2 nathanw case CONFIG_HOOK_GET:
594 1.2.8.2 nathanw switch (id) {
595 1.2.8.2 nathanw case CONFIG_HOOK_BRIGHTNESS_MAX:
596 1.2.8.2 nathanw case CONFIG_HOOK_CONTRAST_MAX:
597 1.2.8.2 nathanw *(int *)msg = 255;
598 1.2.8.2 nathanw return 1;
599 1.2.8.2 nathanw case CONFIG_HOOK_BRIGHTNESS:
600 1.2.8.2 nathanw data[0] = 0x6b00;
601 1.2.8.2 nathanw data[1] = 0x8800;
602 1.2.8.2 nathanw len = 2;
603 1.2.8.2 nathanw break;
604 1.2.8.2 nathanw case CONFIG_HOOK_CONTRAST:
605 1.2.8.2 nathanw data[0] = 0x2b00;
606 1.2.8.2 nathanw data[1] = 0x8800;
607 1.2.8.2 nathanw len = 2;
608 1.2.8.2 nathanw break;
609 1.2.8.2 nathanw default:
610 1.2.8.2 nathanw return 0;
611 1.2.8.2 nathanw }
612 1.2.8.2 nathanw break;
613 1.2.8.2 nathanw
614 1.2.8.2 nathanw case CONFIG_HOOK_SET:
615 1.2.8.2 nathanw switch (id) {
616 1.2.8.2 nathanw case CONFIG_HOOK_BRIGHTNESS:
617 1.2.8.2 nathanw if (*(int *)msg >= 0) {
618 1.2.8.2 nathanw data[0] = 0xcb00;
619 1.2.8.2 nathanw data[1] = *(int *)msg;
620 1.2.8.2 nathanw BIT_INVERT(data[1]);
621 1.2.8.2 nathanw data[1] <<= 8;
622 1.2.8.2 nathanw len = 2;
623 1.2.8.2 nathanw } else {
624 1.2.8.2 nathanw /* XXX hack */
625 1.2.8.2 nathanw data[0] = 0xfb00;
626 1.2.8.2 nathanw len = 1;
627 1.2.8.2 nathanw }
628 1.2.8.2 nathanw break;
629 1.2.8.2 nathanw case CONFIG_HOOK_CONTRAST:
630 1.2.8.2 nathanw data[0] = 0x8b00;
631 1.2.8.2 nathanw data[1] = *(int *)msg;
632 1.2.8.2 nathanw BIT_INVERT(data[1]);
633 1.2.8.2 nathanw data[1] <<= 8;
634 1.2.8.2 nathanw len = 2;
635 1.2.8.2 nathanw break;
636 1.2.8.2 nathanw default:
637 1.2.8.2 nathanw return 0;
638 1.2.8.2 nathanw }
639 1.2.8.2 nathanw }
640 1.2.8.2 nathanw
641 1.2.8.2 nathanw s = splbio();
642 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PCR, 0x2000000);
643 1.2.8.2 nathanw
644 1.2.8.2 nathanw for (i = 0; i < len; i++) {
645 1.2.8.2 nathanw if (j720ssp_readwrite(sc, 1, data[i], &data[i]) < 0)
646 1.2.8.2 nathanw goto out;
647 1.2.8.2 nathanw }
648 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PSR, 0x2000000);
649 1.2.8.2 nathanw splx(s);
650 1.2.8.2 nathanw
651 1.2.8.2 nathanw if (type == CONFIG_HOOK_SET)
652 1.2.8.2 nathanw return 1;
653 1.2.8.2 nathanw
654 1.2.8.2 nathanw BIT_INVERT(data[1]);
655 1.2.8.2 nathanw *(int *)msg = data[1];
656 1.2.8.2 nathanw
657 1.2.8.2 nathanw return 1;
658 1.2.8.2 nathanw
659 1.2.8.2 nathanw out:
660 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PSR, 0x2000000);
661 1.2.8.2 nathanw
662 1.2.8.2 nathanw /* reset SSP */
663 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ssph, SASSP_CR0, 0x307);
664 1.2.8.2 nathanw delay(100);
665 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ssph, SASSP_CR0, 0x387);
666 1.2.8.2 nathanw splx(s);
667 1.2.8.2 nathanw return 0;
668 1.2.8.2 nathanw }
669 1.2.8.2 nathanw
670 1.2.8.2 nathanw static int
671 1.2.8.2 nathanw j720ssp_readwrite(struct j720ssp_softc *sc, int drainfifo, int in, int *out)
672 1.2.8.2 nathanw {
673 1.2.8.2 nathanw int timo;
674 1.2.8.2 nathanw
675 1.2.8.2 nathanw timo = 100000;
676 1.2.8.2 nathanw while(bus_space_read_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_PLR) & 0x400)
677 1.2.8.2 nathanw if (--timo == 0) {
678 1.2.8.2 nathanw printf("timo0\n");
679 1.2.8.2 nathanw return -1;
680 1.2.8.2 nathanw }
681 1.2.8.2 nathanw if (drainfifo) {
682 1.2.8.2 nathanw while(bus_space_read_4(sc->sc_iot, sc->sc_ssph, SASSP_SR) &
683 1.2.8.2 nathanw SR_RNE)
684 1.2.8.2 nathanw bus_space_read_4(sc->sc_iot, sc->sc_ssph, SASSP_DR);
685 1.2.8.2 nathanw #if 1
686 1.2.8.2 nathanw delay(5000);
687 1.2.8.2 nathanw #endif
688 1.2.8.2 nathanw }
689 1.2.8.2 nathanw
690 1.2.8.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ssph, SASSP_DR, in);
691 1.2.8.2 nathanw
692 1.2.8.2 nathanw delay(5000);
693 1.2.8.2 nathanw timo = 100000;
694 1.2.8.2 nathanw while(! (bus_space_read_4(sc->sc_iot, sc->sc_ssph, SASSP_SR) & SR_RNE))
695 1.2.8.2 nathanw if (--timo == 0) {
696 1.2.8.2 nathanw printf("timo1\n");
697 1.2.8.2 nathanw return -1;
698 1.2.8.2 nathanw }
699 1.2.8.2 nathanw
700 1.2.8.2 nathanw *out = bus_space_read_4(sc->sc_iot, sc->sc_ssph, SASSP_DR);
701 1.2.8.2 nathanw
702 1.2.8.2 nathanw return 0;
703 1.2.8.2 nathanw }
704 1.2.8.2 nathanw
705 1.2.8.2 nathanw #if 0
706 1.2.8.2 nathanw int
707 1.2.8.2 nathanw j720kbd_cnattach()
708 1.2.8.2 nathanw {
709 1.2.8.2 nathanw /* XXX defer initialization till j720sspattach */
710 1.2.8.2 nathanw
711 1.2.8.2 nathanw return (0);
712 1.2.8.2 nathanw }
713 1.2.8.2 nathanw #endif
714 1.2.8.2 nathanw
715 1.2.8.2 nathanw /* ARGSUSED */
716 1.2.8.2 nathanw void
717 1.2.8.2 nathanw j720kbd_cngetc(void *v, u_int *type, int *data)
718 1.2.8.2 nathanw {
719 1.2.8.2 nathanw char buf[9];
720 1.2.8.2 nathanw
721 1.2.8.2 nathanw if (j720kbdcons_initstate < 1)
722 1.2.8.2 nathanw return;
723 1.2.8.2 nathanw
724 1.2.8.2 nathanw for (;;) {
725 1.2.8.2 nathanw j720kbd_read(&j720kbdcons_sc, buf);
726 1.2.8.2 nathanw
727 1.2.8.2 nathanw if (buf[0] != 0) {
728 1.2.8.2 nathanw /* XXX we are discarding buffer contents */
729 1.2.8.2 nathanw *type = buf[0] & 0x80 ? WSCONS_EVENT_KEY_UP :
730 1.2.8.2 nathanw WSCONS_EVENT_KEY_DOWN;
731 1.2.8.2 nathanw *data = buf[0] & 0x7f;
732 1.2.8.2 nathanw return;
733 1.2.8.2 nathanw }
734 1.2.8.2 nathanw }
735 1.2.8.2 nathanw }
736 1.2.8.2 nathanw
737 1.2.8.2 nathanw void
738 1.2.8.2 nathanw j720kbd_cnpollc(void *v, int on)
739 1.2.8.2 nathanw {
740 1.2.8.2 nathanw #if 0
741 1.2.8.2 nathanw /* XXX */
742 1.2.8.2 nathanw struct j720kbd_internal *t = v;
743 1.2.8.2 nathanw
744 1.2.8.2 nathanw pckbc_set_poll(t->t_kbctag, t->t_kbcslot, on);
745 1.2.8.2 nathanw #endif
746 1.2.8.2 nathanw }
747 1.2.8.2 nathanw
748 1.2.8.2 nathanw void
749 1.2.8.2 nathanw j720kbd_cnbell(void *v, u_int pitch, u_int period, u_int volume)
750 1.2.8.2 nathanw {
751 1.2.8.2 nathanw }
752 1.2.8.2 nathanw
753 1.2.8.2 nathanw int
754 1.2.8.2 nathanw j720lcdpower(void *ctx, int type, long id, void *msg)
755 1.2.8.2 nathanw {
756 1.2.8.2 nathanw struct sed1356_softc *sc = ctx;
757 1.2.8.2 nathanw struct sa11x0_softc *psc = sc->sc_parent;
758 1.2.8.2 nathanw int val;
759 1.2.8.2 nathanw u_int32_t reg;
760 1.2.8.2 nathanw
761 1.2.8.2 nathanw if (type != CONFIG_HOOK_POWERCONTROL ||
762 1.2.8.2 nathanw id != CONFIG_HOOK_POWERCONTROL_LCDLIGHT)
763 1.2.8.2 nathanw return 0;
764 1.2.8.2 nathanw
765 1.2.8.2 nathanw sed1356_init_brightness(sc, 0);
766 1.2.8.2 nathanw sed1356_init_contrast(sc, 0);
767 1.2.8.2 nathanw
768 1.2.8.2 nathanw if (msg) {
769 1.2.8.2 nathanw bus_space_write_1(sc->sc_iot, sc->sc_regh, 0x1f0, 0);
770 1.2.8.2 nathanw
771 1.2.8.2 nathanw reg = bus_space_read_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR);
772 1.2.8.2 nathanw reg |= 0x1;
773 1.2.8.2 nathanw bus_space_write_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR, reg);
774 1.2.8.2 nathanw delay(50000);
775 1.2.8.2 nathanw
776 1.2.8.2 nathanw val = sc->sc_contrast;
777 1.2.8.2 nathanw config_hook_call(CONFIG_HOOK_SET, CONFIG_HOOK_CONTRAST, &val);
778 1.2.8.2 nathanw delay(100000);
779 1.2.8.2 nathanw
780 1.2.8.2 nathanw reg = bus_space_read_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR);
781 1.2.8.2 nathanw reg |= 0x4;
782 1.2.8.2 nathanw bus_space_write_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR, reg);
783 1.2.8.2 nathanw
784 1.2.8.2 nathanw val = sc->sc_brightness;
785 1.2.8.2 nathanw config_hook_call(CONFIG_HOOK_SET, CONFIG_HOOK_BRIGHTNESS, &val);
786 1.2.8.2 nathanw
787 1.2.8.2 nathanw reg = bus_space_read_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR);
788 1.2.8.2 nathanw reg |= 0x2;
789 1.2.8.2 nathanw bus_space_write_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR, reg);
790 1.2.8.2 nathanw } else {
791 1.2.8.2 nathanw reg = bus_space_read_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR);
792 1.2.8.2 nathanw reg &= ~0x2;
793 1.2.8.2 nathanw bus_space_write_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR, reg);
794 1.2.8.2 nathanw reg &= ~0x4;
795 1.2.8.2 nathanw bus_space_write_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR, reg);
796 1.2.8.2 nathanw delay(100000);
797 1.2.8.2 nathanw
798 1.2.8.2 nathanw val = -2;
799 1.2.8.2 nathanw config_hook_call(CONFIG_HOOK_SET, CONFIG_HOOK_BRIGHTNESS, &val);
800 1.2.8.2 nathanw
801 1.2.8.2 nathanw bus_space_write_1(sc->sc_iot, sc->sc_regh, 0x1f0, 1);
802 1.2.8.2 nathanw
803 1.2.8.2 nathanw delay(100000);
804 1.2.8.2 nathanw reg = bus_space_read_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR);
805 1.2.8.2 nathanw reg &= ~0x1;
806 1.2.8.2 nathanw bus_space_write_4(psc->sc_iot, psc->sc_ppch, SAPPC_PSR, reg);
807 1.2.8.2 nathanw }
808 1.2.8.2 nathanw return 1;
809 1.2.8.2 nathanw }
810