Home | History | Annotate | Line # | Download | only in i2c
gttwsireg.h revision 1.3
      1 /* $NetBSD: gttwsireg.h,v 1.3 2014/09/11 11:14:44 jmcneill Exp $ */
      2 
      3 /*
      4  * Copyright (c) 2008 Eiji Kawauchi.
      5  * All rights reserved.
      6  *
      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  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  */
     27 #ifndef _GTTWSIREG_H_
     28 #define _GTTWSIREG_H_
     29 
     30 #include "opt_gttwsi.h"
     31 
     32 #define GTTWSI_SIZE		0x100
     33 
     34 #if defined(GTTWSI_ALLWINNER)
     35 #define TWSI_SLAVEADDR		0x00
     36 #define TWSI_EXTEND_SLAVEADDR	0x04
     37 #define TWSI_DATA		0x08
     38 #define TWSI_CONTROL		0x0c
     39 #define TWSI_STATUS		0x10
     40 #define TWSI_BAUDRATE		0x14
     41 #define TWSI_SOFTRESET		0x18
     42 #else
     43 #define	TWSI_SLAVEADDR		0x00
     44 #define	TWSI_EXTEND_SLAVEADDR	0x10
     45 #define	TWSI_DATA		0x04
     46 #define	TWSI_CONTROL		0x08
     47 #define	TWSI_STATUS		0x0c	/* for read */
     48 #define	TWSI_BAUDRATE		0x0c	/* for write */
     49 #define	TWSI_SOFTRESET		0x1c
     50 #endif
     51 
     52 #define	SLAVEADDR_GCE_MASK	0x01
     53 #define	SLAVEADDR_SADDR_MASK	0xfe
     54 
     55 #define	EXTEND_SLAVEADDR_MASK	0xff
     56 
     57 #define	DATA_MASK		0xff
     58 
     59 #define	CONTROL_ACK		(1<<2)
     60 #define	CONTROL_IFLG		(1<<3)
     61 #define	CONTROL_STOP		(1<<4)
     62 #define	CONTROL_START		(1<<5)
     63 #define	CONTROL_TWSIEN		(1<<6)
     64 #define	CONTROL_INTEN		(1<<7)
     65 
     66 #define	STAT_BE		0x00	/* Bus Error */
     67 #define	STAT_SCT	0x08	/* Start condition transmitted */
     68 #define	STAT_RSCT	0x10	/* Repeated start condition transmitted */
     69 #define	STAT_AWBT_AR	0x18	/* Address + write bit transd, ack recvd */
     70 #define	STAT_AWBT_ANR	0x20	/* Address + write bit transd, ack not recvd */
     71 #define	STAT_MTDB_AR	0x28	/* Master transd data byte, ack recvd */
     72 #define	STAT_MTDB_ANR	0x30	/* Master transd data byte, ack not recvd */
     73 #define	STAT_MLADADT	0x38	/* Master lost arbitr during addr or data tx */
     74 #define	STAT_ARBT_AR	0x40	/* Address + read bit transd, ack recvd */
     75 #define	STAT_ARBT_ANR	0x48	/* Address + read bit transd, ack not recvd */
     76 #define	STAT_MRRD_AT	0x50	/* Master received read data, ack transd */
     77 #define	STAT_MRRD_ANT	0x58	/* Master received read data, ack not transd */
     78 #define	STAT_SAWBT_AR	0xd0	/* Second addr + write bit transd, ack recvd */
     79 #define	STAT_SAWBT_ANR	0xd8	/* S addr + write bit transd, ack not recvd */
     80 #define	STAT_SARBT_AR	0xe0	/* Second addr + read bit transd, ack recvd */
     81 #define	STAT_SARBT_ANR	0xe8	/* S addr + read bit transd, ack not recvd */
     82 #define	STAT_NRS	0xf8	/* No relevant status */
     83 
     84 #define	SOFTRESET_VAL		0		/* reset value */
     85 
     86 #define TWSI_RETRY_COUNT	1000		/* retry loop count */
     87 #define TWSI_RETRY_DELAY	1		/* retry delay */
     88 #define	TWSI_STAT_DELAY		1		/* poll status delay */
     89 #define	TWSI_READ_DELAY		2		/* read delay */
     90 #define	TWSI_WRITE_DELAY	2		/* write delay */
     91 
     92 #endif	/* _GTTWSIREG_H_ */
     93