1 /* $NetBSD: gxlcd.c,v 1.1 2009/08/09 07:10:13 kiyohara Exp $ */
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
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
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
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>
51 #include <sys/malloc.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
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 *);
84 static struct pxa2x0_wsscreen_descr gxlcd_std_screen
= {
87 .textops
= &pxa2x0_lcd_emulops
,
90 .capabilities
= WSSCREEN_WSCOLORS
,
92 .depth
= 16, /* bits per pixel */
95 static const struct wsscreen_descr
*gxlcd_scr_descr
[] = {
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
= {
107 pxa2x0_lcd_alloc_screen
,
108 pxa2x0_lcd_free_screen
,
115 const struct lcd_panel_geometry samsung_lte430wq_f0c
=
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 */
129 10, /* vertical sync pulse width */
134 static int gxlcd_console
;
137 CFATTACH_DECL_NEW(gxlcd
, sizeof(struct pxa2x0_lcd_softc
),
138 gxlcd_match
, gxlcd_attach
, NULL
, NULL
);
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)
149 pxa
->pxa_size
= PXA2X0_LCDC_SIZE
;
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
;
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
);
176 pxa2x0_lcd_cnattach(&gxlcd_std_screen
, &CURRENT_DISPLAY
);
183 * wsdisplay accessops overrides
186 gxlcd_ioctl(void *v
, void *vs
, u_long cmd
, void *data
, int flag
, struct lwp
*l
)
191 case WSDISPLAYIO_SVIDEO
:
192 if (*(int *)data
== WSDISPLAYIO_VIDEO_ON
)
193 pxa2x0_gpio_set_function(17, GPIO_IN
);
195 pxa2x0_gpio_set_function(17, GPIO_OUT
| GPIO_CLR
);
200 res
= pxa2x0_lcd_ioctl(v
, vs
, cmd
, data
, flag
, l
);
205 gxlcd_show_screen(void *v
, void *cookie
, int waitok
,
206 void (*cb_func
)(void *, int, int), void *cb_arg
)
210 error
= pxa2x0_lcd_show_screen(v
, cookie
, waitok
, cb_func
, cb_arg
);
215 pxa2x0_gpio_set_function(17, GPIO_IN
);