/*
 * Copyright (c) 1996-2003 MIPS Technologies, Inc.
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 
 *      * Redistributions of source code must retain the above copyright
 *        notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above
 *      copyright
 *        notice, this list of conditions and the following disclaimer
 *        in the documentation and/or other materials provided with
 *        the distribution.
 *      * Neither the name of MIPS Technologies Inc. nor the names of its
 *        contributors may be used to endorse or promote products derived
 *        from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * CM1629 2x16 LCD
 */


#ifdef MIPSEB
#define lcdreg(x)	unsigned :32; unsigned :24; unsigned x:8;
#define LCDREG(x)	((8*(x))+7)
#endif
#ifdef MIPSEL
#define lcdreg(x)	unsigned x:8; unsigned :24; unsigned :32; 
#define LCDREG(x)	(8*(x))
#endif

#ifndef __ASSEMBLER__
typedef struct {
    lcdreg(lcd_data);		/* data register */
    lcdreg(lcd_cmd);		/* command register */
} cm1629dev;
#define lcd_stat lcd_cmd
#endif

#define LCD_DATA	LCDREG(0)
#define LCD_CMD		LCDREG(1)
#define LCD_STAT	LCD_CMD

/* status register */
#define	LCD_STAT_BUSY	0x80	/* display busy */
#define LCD_ADD_MASK	0x7f	/* current display address */

/* command register */

#define LCD_NOOP	0x00
#define LCD_CLEAR	0x01
#define LCD_HOME	0x02
#define LCD_MODE	0x04
# define LCD_MODE_INCR	  0x02
# define LCD_MODE_DECR	  0x00
# define LCD_MODE_SHIFT	  0x01
#define LCD_CTRL	0x08
# define LCD_CTRL_DISPLAY 0x04
# define LCD_CTRL_CURSOR  0x02
# define LCD_CTRL_BLINK   0x01
#define LCD_CSHIFT	0x10
#define LCD_DSHIFT	0x18
# define LCD_SHIFT_L	  0x04
# define LCD_SHIFT_R	  0x00
#define LCD_FUNC	0x20
# define LCD_FUNC_8BIT	  0x10
# define LCD_FUNC_4BIT	  0x00
# define LCD_FUNC_2LINE   0x08
# define LCD_FUNC_1LINE   0x00
# define LCD_FUNC_5x10	  0x04
# define LCD_FUNC_5x7	  0x00
#define LCD_SET_CGADDR	0x40
#define LCD_SET_DDADDR	0x80
