Home | History | Annotate | Line # | Download | only in ic
hd44780var.h revision 1.5.40.2
      1  1.5.40.2      yamt /* $NetBSD: hd44780var.h,v 1.5.40.2 2009/09/16 13:37:47 yamt Exp $ */
      2       1.1      joff 
      3       1.1      joff /*
      4       1.1      joff  * Copyright (c) 2002 Dennis I. Chernoivanov
      5       1.1      joff  * All rights reserved.
      6       1.1      joff  *
      7       1.1      joff  * Redistribution and use in source and binary forms, with or without
      8       1.1      joff  * modification, are permitted provided that the following conditions
      9       1.1      joff  * are met:
     10       1.1      joff  * 1. Redistributions of source code must retain the above copyright
     11       1.1      joff  *    notice, this list of conditions and the following disclaimer.
     12       1.1      joff  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1      joff  *    notice, this list of conditions and the following disclaimer in the
     14       1.1      joff  *    documentation and/or other materials provided with the distribution.
     15       1.1      joff  * 3. The name of the author may not be used to endorse or promote products
     16       1.1      joff  *    derived from this software without specific prior written permission
     17       1.1      joff  *
     18       1.1      joff  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19       1.1      joff  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20       1.1      joff  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21       1.1      joff  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22       1.1      joff  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23       1.1      joff  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24       1.1      joff  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25       1.1      joff  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26       1.1      joff  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27       1.1      joff  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28       1.1      joff  */
     29       1.1      joff 
     30       1.1      joff #ifndef _DEV_IC_HD44780VAR_H_
     31       1.1      joff #define _DEV_IC_HD44780VAR_H_
     32       1.1      joff 
     33       1.1      joff /* IOCTL definitions */
     34       1.1      joff #define HLCD_DISPCTL		_IOW('h',   1, struct hd44780_dispctl)
     35       1.1      joff #define	HLCD_RESET		_IO('h',    2)
     36       1.1      joff #define	HLCD_CLEAR		_IO('h',    3)
     37       1.1      joff #define	HLCD_CURSOR_LEFT	_IO('h',    4)
     38       1.1      joff #define	HLCD_CURSOR_RIGHT	_IO('h',    5)
     39       1.1      joff #define	HLCD_GET_CURSOR_POS	_IOR('h',   6, struct hd44780_io)
     40       1.1      joff #define	HLCD_SET_CURSOR_POS	_IOW('h',   7, struct hd44780_io)
     41       1.1      joff #define	HLCD_GETC		_IOR('h',   8, struct hd44780_io)
     42       1.1      joff #define	HLCD_PUTC		_IOW('h',   9, struct hd44780_io)
     43       1.1      joff #define	HLCD_SHIFT_LEFT		_IO('h',   10)
     44       1.1      joff #define	HLCD_SHIFT_RIGHT	_IO('h',   11)
     45       1.1      joff #define	HLCD_HOME		_IO('h',   12)
     46       1.1      joff #define	HLCD_WRITE		_IOWR('h', 13, struct hd44780_io)
     47       1.1      joff #define	HLCD_READ		_IOWR('h', 14, struct hd44780_io)
     48       1.1      joff #define	HLCD_REDRAW		_IOW('h',  15, struct hd44780_io)
     49       1.1      joff #define	HLCD_WRITE_INST		_IOW('h',  16, struct hd44780_io)
     50       1.1      joff #define	HLCD_WRITE_DATA		_IOW('h',  17, struct hd44780_io)
     51       1.1      joff #define HLCD_GET_INFO		_IOR('h',  18, struct hd44780_info)
     52  1.5.40.2      yamt #define HLCD_GET_CHIPNO		_IOR('h',  19, uint8_t)
     53  1.5.40.2      yamt #define HLCD_SET_CHIPNO		_IOW('h',  20, uint8_t)
     54       1.1      joff 
     55       1.1      joff struct hd44780_dispctl {
     56  1.5.40.2      yamt 	uint8_t chip;
     57  1.5.40.2      yamt 	uint8_t	display_on:1,
     58       1.1      joff 		blink_on:1,
     59       1.1      joff 		cursor_on:1;
     60       1.1      joff };
     61       1.1      joff 
     62       1.1      joff struct hd44780_io {
     63  1.5.40.2      yamt 	uint8_t chip;
     64  1.5.40.2      yamt 	uint8_t dat;
     65  1.5.40.2      yamt 	uint8_t len;
     66  1.5.40.2      yamt 	uint8_t buf[HD_MAX_CHARS];
     67       1.1      joff };
     68       1.1      joff 
     69       1.1      joff struct hd44780_info {
     70  1.5.40.2      yamt 	uint8_t	lines;
     71  1.5.40.2      yamt 	uint8_t	phys_rows;
     72  1.5.40.2      yamt 	uint8_t	virt_rows;
     73       1.1      joff 
     74  1.5.40.2      yamt 	uint8_t	is_wide:1,
     75       1.1      joff 		is_bigfont:1,
     76       1.1      joff 		kp_present:1;
     77       1.1      joff };
     78       1.1      joff 
     79       1.1      joff #ifdef _KERNEL
     80       1.1      joff 
     81       1.2      joff struct  hlcd_screen {
     82       1.2      joff 	int hlcd_curon;
     83       1.2      joff 	int hlcd_curx;
     84       1.2      joff 	int hlcd_cury;
     85  1.5.40.2      yamt 	uint8_t *image;			/* characters of screen */
     86       1.2      joff 	struct hd44780_chip *hlcd_sc;
     87       1.2      joff };
     88       1.2      joff 
     89       1.1      joff /* HLCD driver structure */
     90       1.1      joff struct hd44780_chip {
     91       1.1      joff #define HD_8BIT			0x01	/* 8-bit if set, 4-bit otherwise */
     92       1.1      joff #define HD_MULTILINE		0x02	/* 2 lines if set, 1 otherwise */
     93       1.1      joff #define HD_BIGFONT		0x04	/* 5x10 if set, 5x8 otherwise */
     94       1.1      joff #define HD_KEYPAD		0x08	/* if set, keypad is connected */
     95       1.1      joff #define HD_UP			0x10	/* if set, lcd has been initialized */
     96       1.1      joff #define HD_TIMEDOUT		0x20	/* lcd has recently stopped talking */
     97       1.3      joff #define HD_MULTICHIP		0x40	/* two HD44780 controllers (4-line) */
     98  1.5.40.2      yamt 	uint8_t sc_flags;
     99       1.1      joff 
    100  1.5.40.2      yamt 	uint8_t sc_cols;		/* visible columns */
    101  1.5.40.2      yamt 	uint8_t sc_vcols;		/* virtual columns (normally 40) */
    102  1.5.40.2      yamt 	uint8_t sc_dev_ok;
    103  1.5.40.2      yamt 	uint8_t sc_curchip;
    104       1.1      joff 
    105       1.1      joff 	bus_space_tag_t sc_iot;
    106       1.1      joff 
    107       1.1      joff 	bus_space_handle_t sc_ioir;	/* instruction register */
    108       1.1      joff 	bus_space_handle_t sc_iodr;	/* data register */
    109       1.1      joff 
    110  1.5.40.1      yamt 	device_t sc_dev;		/* Pointer to parent device */
    111       1.2      joff 	struct hlcd_screen sc_screen;	/* currently displayed screen copy */
    112       1.2      joff 	struct hlcd_screen *sc_curscr;	/* active screen */
    113       1.2      joff 	struct callout redraw;		/* wsdisplay refresh/redraw timer */
    114       1.1      joff 
    115       1.1      joff 	/* Generic write/read byte entries. */
    116  1.5.40.2      yamt 	void     (* sc_writereg)(struct hd44780_chip *, uint32_t, uint32_t,
    117  1.5.40.2      yamt 	  uint8_t);
    118  1.5.40.2      yamt 	uint8_t (* sc_readreg)(struct hd44780_chip *, uint32_t, uint32_t);
    119       1.1      joff };
    120       1.1      joff 
    121       1.3      joff #define hd44780_ir_write(sc, en, dat) \
    122       1.1      joff 	do {								\
    123       1.3      joff 		hd44780_busy_wait(sc, (en));					\
    124       1.3      joff 		(sc)->sc_writereg((sc), (en), 0, (dat));		\
    125       1.1      joff 	} while(0)
    126       1.1      joff 
    127       1.3      joff #define hd44780_ir_read(sc, en) \
    128       1.3      joff 	(sc)->sc_readreg((sc), (en), 0)
    129       1.1      joff 
    130       1.3      joff #define hd44780_dr_write(sc, en, dat) \
    131       1.3      joff 	(sc)->sc_writereg((sc), (en), 1, (dat))
    132       1.1      joff 
    133       1.3      joff #define hd44780_dr_read(sc, en) \
    134       1.3      joff 	(sc)->sc_readreg((sc), (en), 1)
    135       1.1      joff 
    136       1.1      joff void hd44780_attach_subr(struct hd44780_chip *);
    137  1.5.40.2      yamt void hd44780_busy_wait(struct hd44780_chip *, uint32_t);
    138       1.1      joff int  hd44780_init(struct hd44780_chip *);
    139  1.5.40.2      yamt int  hd44780_chipinit(struct hd44780_chip *, uint32_t);
    140       1.5  christos int  hd44780_ioctl_subr(struct hd44780_chip *, u_long, void *);
    141  1.5.40.2      yamt void hd44780_ddram_redraw(struct hd44780_chip *, uint32_t, struct hd44780_io *);
    142       1.1      joff 
    143       1.1      joff #define HD_DDRAM_READ	0x0
    144       1.1      joff #define HD_DDRAM_WRITE	0x1
    145  1.5.40.2      yamt int  hd44780_ddram_io(struct hd44780_chip *, uint32_t, struct hd44780_io *,
    146  1.5.40.2      yamt     uint8_t);
    147       1.1      joff 
    148       1.1      joff #if defined(HD44780_STD_WIDE) || defined(HD44780_STD_SHORT)
    149  1.5.40.2      yamt void     hd44780_writereg(struct hd44780_chip *, uint32_t, uint32_t, uint8_t);
    150  1.5.40.2      yamt uint8_t hd44780_readreg(struct hd44780_chip *, uint32_t, uint32_t);
    151       1.1      joff #endif
    152       1.1      joff 
    153       1.1      joff #endif /* _KERNEL */
    154       1.1      joff 
    155       1.1      joff #endif /* _DEV_IC_HD44780VAR_H_ */
    156