1 /* $NetBSD: lubbock_lcd.c,v 1.9 2009/01/29 12:28:15 nonaka 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 Intel Lubbock.
35 * Controlling LCD is almost completely done through PXA2X0's
36 * integrated LCD controller. Codes for it is arm/xscale/pxa2x0_lcd.c.
38 * Codes in this file provide platform specific things including:
39 * LCD on/off switch in on-board PLD register.
42 #include <sys/cdefs.h>
43 __KERNEL_RCSID(0, "$NetBSD: lubbock_lcd.c,v 1.9 2009/01/29 12:28:15 nonaka Exp $");
45 #include <sys/param.h>
46 #include <sys/systm.h>
49 #include <sys/malloc.h>
52 #include <dev/wscons/wsconsio.h>
53 #include <dev/wscons/wsdisplayvar.h>
54 #include <dev/wscons/wscons_callbacks.h>
56 #include <machine/bus.h>
57 #include <arm/xscale/pxa2x0var.h>
58 #include <arm/xscale/pxa2x0reg.h>
59 #include <arm/xscale/pxa2x0_lcd.h>
61 #include <arch/evbarm/lubbock/lubbock_reg.h>
62 #include <arch/evbarm/lubbock/lubbock_var.h>
64 #include "wsdisplay.h"
66 int lcd_match(device_t
, cfdata_t
, void *);
67 void lcd_attach(device_t
, device_t
, void *);
75 struct pxa2x0_wsscreen_descr lcd_bpp16_screen
= {
82 16 /* bits per pixel */
83 }, lcd_bpp8_screen
= {
90 8 /* bits per pixel */
91 }, lcd_bpp4_screen
= {
98 4 /* bits per pixel */
102 static const struct wsscreen_descr
*lcd_scr_descr
[] = {
104 /* bpp4 needs a patch to rasops4 */
111 const struct wsscreen_list lcd_screen_list
= {
112 sizeof lcd_scr_descr
/ sizeof lcd_scr_descr
[0],
116 int lcd_ioctl(void *, void *, u_long
, void *, int, struct lwp
*);
118 int lcd_show_screen(void *, void *, int,
119 void (*)(void *, int, int), void *);
121 const struct wsdisplay_accessops lcd_accessops
= {
124 pxa2x0_lcd_alloc_screen
,
125 pxa2x0_lcd_free_screen
,
127 NULL
, /* load_font */
132 * Interface to LCD framebuffer without wscons
134 dev_type_open(lcdopen
);
135 dev_type_close(lcdclose
);
136 dev_type_ioctl(lcdioctl
);
137 dev_type_mmap(lcdmmap
);
138 const struct cdevsw lcd_cdevsw
= {
139 lcdopen
, lcdclose
, noread
, nowrite
,
140 lcdioctl
, nostop
, notty
, nopoll
, lcdmmap
, D_TTY
145 CFATTACH_DECL_NEW(lcd_obio
, sizeof (struct pxa2x0_lcd_softc
), lcd_match
,
146 lcd_attach
, NULL
, NULL
);
149 lcd_match( device_t parent
, cfdata_t cf
, void *aux
)
154 static const struct lcd_panel_geometry sharp_LM8V31
=
158 0, /* No extra lines */
160 LCDPANEL_DUAL
|LCDPANEL_PASSIVE
|LCDPANEL_PCP
,
161 10, /* clock divider */
162 0xff, /* AC bias pin freq */
164 2, /* horizontal sync pulse width */
168 1, /* vertical sync pulse width */
174 void lcd_attach( device_t parent
, device_t self
, void *aux
)
176 struct pxa2x0_lcd_softc
*sc
= device_private(self
);
180 pxa2x0_lcd_attach_sub(sc
, aux
, &sharp_LM8V31
);
186 struct wsemuldisplaydev_attach_args aa
;
188 /* make wsdisplay screen list */
189 pxa2x0_lcd_setup_wsscreen( &lcd_bpp16_screen
, &sharp_LM8V31
, NULL
);
190 pxa2x0_lcd_setup_wsscreen( &lcd_bpp8_screen
, &sharp_LM8V31
, NULL
);
191 pxa2x0_lcd_setup_wsscreen( &lcd_bpp4_screen
, &sharp_LM8V31
, NULL
);
194 aa
.scrdata
= &lcd_screen_list
;
195 aa
.accessops
= &lcd_accessops
;
196 aa
.accesscookie
= sc
;
200 (void) config_found(self
, &aa
, wsemuldisplaydevprint
);
204 struct pxa2x0_lcd_screen
*screen
;
207 error
= pxa2x0_lcd_new_screen( sc
, 8, &screen
);
210 pxa2x0_lcd_start_dma( sc
, screen
);
222 lcd_ioctl(void *v
, void *vs
, u_long cmd
, void *data
, int flag
, struct lwp
*l
)
224 struct pxa2x0_lcd_softc
*sc
= (struct pxa2x0_lcd_softc
*) v
;
225 struct obio_softc
*osc
= device_private(device_parent(sc
->dev
));
229 case WSDISPLAYIO_SVIDEO
:
230 reg
= bus_space_read_2( osc
->sc_iot
, osc
->sc_obioreg_ioh
,
232 if( *(int *)data
== WSDISPLAYIO_VIDEO_ON
)
233 reg
|= MISCWR_LCDDISP
;
235 reg
&= ~MISCWR_LCDDISP
;
236 bus_space_write_2( osc
->sc_iot
, osc
->sc_obioreg_ioh
,
237 LUBBOCK_MISCWR
, reg
);
238 break; /* turn on/off LCD controller */
241 return pxa2x0_lcd_ioctl( v
, vs
, cmd
, data
, flag
, l
);
245 lcd_show_screen(void *v
, void *cookie
, int waitok
,
246 void (*cb
)(void *, int, int), void *cbarg
)
248 struct pxa2x0_lcd_softc
*sc
= (struct pxa2x0_lcd_softc
*) v
;
249 struct obio_softc
*osc
= device_private(device_parent(sc
->dev
));
251 pxa2x0_lcd_show_screen(v
,cookie
,waitok
,cb
,cbarg
);
254 bus_space_write_4( osc
->sc_iot
, osc
->sc_obioreg_ioh
, LUBBOCK_MISCWR
,
256 bus_space_read_4( osc
->sc_iot
, osc
->sc_obioreg_ioh
, LUBBOCK_MISCWR
) );
263 #else /* NWSDISPLAY==0 */
266 lcdopen( dev_t dev
, int oflags
, int devtype
, struct lwp
*l
)
272 lcdclose( dev_t dev
, int fflag
, int devtype
, struct lwp
*l
)
278 lcdmmap( dev_t dev
, off_t offset
, int size
)
280 struct pxa2x0_lcd_softc
*sc
=
281 device_lookup_private(&lcd_cd
, minor(dev
));
282 struct pxa2x0_lcd_screen
*scr
= sc
->active
;
284 return bus_dmamem_mmap( &pxa2x0_bus_dma_tag
, scr
->segs
, scr
->nsegs
,
285 offset
, 0, BUS_DMA_WAITOK
|BUS_DMA_COHERENT
);
289 lcdioctl( dev_t dev
, u_long cmd
, void *data
,
290 int fflag
, struct lwp
*l
)
295 #endif /* NWSDISPLAY>0 */