Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / evbarm / gumstix / gxlcd.c
bloba75e27e2f109679a86b4a1bdb7ceae70b2a88949
1 /* $NetBSD: gxlcd.c,v 1.1 2009/08/09 07:10:13 kiyohara Exp $ */
3 /*
4 * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved.
5 * Written by Hiroyuki Bessho for Genetec Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of Genetec Corporation may not be used to endorse or
16 * promote products derived from this software without specific prior
17 * written permission.
19 * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * LCD driver for Gumstix consoleLCD-vx and compatible.
34 * (based on the Intel Lubbock driver).
36 * Controlling LCD is almost completely done through PXA2X0's
37 * integrated LCD controller. Codes for it is arm/xscale/pxa2x0_lcd.c.
39 * Codes in this file provide platform specific things including:
40 * LCD on/off switch and backlight
41 * LCD panel geometry
44 #include <sys/cdefs.h>
45 __KERNEL_RCSID(0, "$NetBSD: gxlcd.c,v 1.1 2009/08/09 07:10:13 kiyohara Exp $");
47 #include <sys/param.h>
48 #include <sys/systm.h>
49 #include <sys/conf.h>
50 #include <sys/uio.h>
51 #include <sys/malloc.h>
53 #include <dev/cons.h>
54 #include <dev/wscons/wsconsio.h>
55 #include <dev/wscons/wsdisplayvar.h>
56 #include <dev/wscons/wscons_callbacks.h>
58 #include <machine/bus.h>
60 #include <arm/xscale/pxa2x0var.h>
61 #include <arm/xscale/pxa2x0reg.h>
62 #include <arm/xscale/pxa2x0_lcd.h>
63 #include <arm/xscale/pxa2x0_gpio.h>
66 #ifndef CURRENT_DISPLAY
67 #define CURRENT_DISPLAY samsung_lte430wq_f0c
68 #endif
71 static int gxlcd_match(device_t, cfdata_t, void *);
72 static void gxlcd_attach(device_t, device_t, void *);
74 void gxlcd_cnattach(void);
76 static int gxlcd_ioctl(void *, void *, u_long, void *, int, struct lwp *);
77 static int gxlcd_show_screen(void *, void *, int,
78 void (*)(void *, int, int), void *);
82 * wsdisplay glue
84 static struct pxa2x0_wsscreen_descr gxlcd_std_screen = {
85 .c = {
86 .name = "std",
87 .textops = &pxa2x0_lcd_emulops,
88 .fontwidth = 8,
89 .fontheight = 16,
90 .capabilities = WSSCREEN_WSCOLORS,
92 .depth = 16, /* bits per pixel */
95 static const struct wsscreen_descr *gxlcd_scr_descr[] = {
96 &gxlcd_std_screen.c
99 static const struct wsscreen_list gxlcd_screen_list = {
100 .nscreens = __arraycount(gxlcd_scr_descr),
101 .screens = gxlcd_scr_descr,
104 struct wsdisplay_accessops gxlcd_accessops = {
105 gxlcd_ioctl,
106 pxa2x0_lcd_mmap,
107 pxa2x0_lcd_alloc_screen,
108 pxa2x0_lcd_free_screen,
109 gxlcd_show_screen,
110 NULL,
111 NULL,
112 NULL,
115 const struct lcd_panel_geometry samsung_lte430wq_f0c =
117 480, /* Width */
118 272, /* Height */
119 0, /* No extra lines */
121 LCDPANEL_ACTIVE | LCDPANEL_PCP,
122 1, /* clock divider */
123 0, /* AC bias pin freq */
125 41, /* horizontal sync pulse width */
126 4, /* BLW */
127 8, /* ELW */
129 10, /* vertical sync pulse width */
130 2, /* BFW */
131 4, /* EFW */
134 static int gxlcd_console;
137 CFATTACH_DECL_NEW(gxlcd, sizeof(struct pxa2x0_lcd_softc),
138 gxlcd_match, gxlcd_attach, NULL, NULL);
141 static int
142 gxlcd_match(device_t parent, cfdata_t match, void *aux)
144 struct pxaip_attach_args *pxa = aux;
146 if (strcmp(pxa->pxa_name, match->cf_name) != 0)
147 return 0;
149 pxa->pxa_size = PXA2X0_LCDC_SIZE;
150 return 1;
153 static void
154 gxlcd_attach(device_t parent, device_t self, void *aux)
156 struct pxa2x0_lcd_softc *sc = device_private(self);
157 struct wsemuldisplaydev_attach_args aa;
159 sc->dev = self;
160 pxa2x0_lcd_attach_sub(sc, aux, &CURRENT_DISPLAY);
162 aa.console = gxlcd_console;
163 aa.scrdata = &gxlcd_screen_list;
164 aa.accessops = &gxlcd_accessops;
165 aa.accesscookie = sc;
167 pxa2x0_lcd_setup_wsscreen(&gxlcd_std_screen, &CURRENT_DISPLAY, NULL);
169 (void) config_found(self, &aa, wsemuldisplaydevprint);
172 void
173 gxlcd_cnattach(void)
176 pxa2x0_lcd_cnattach(&gxlcd_std_screen, &CURRENT_DISPLAY);
178 gxlcd_console = 1;
183 * wsdisplay accessops overrides
185 static int
186 gxlcd_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
188 int res = EINVAL;
190 switch (cmd) {
191 case WSDISPLAYIO_SVIDEO:
192 if (*(int *)data == WSDISPLAYIO_VIDEO_ON)
193 pxa2x0_gpio_set_function(17, GPIO_IN);
194 else
195 pxa2x0_gpio_set_function(17, GPIO_OUT | GPIO_CLR);
196 break;
199 if (res == EINVAL)
200 res = pxa2x0_lcd_ioctl(v, vs, cmd, data, flag, l);
201 return res;
204 static int
205 gxlcd_show_screen(void *v, void *cookie, int waitok,
206 void (*cb_func)(void *, int, int), void *cb_arg)
208 int error;
210 error = pxa2x0_lcd_show_screen(v, cookie, waitok, cb_func, cb_arg);
211 if (error)
212 return (error);
214 /* Turn on LCD */
215 pxa2x0_gpio_set_function(17, GPIO_IN);
217 return 0;