1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc. 3*4882a593Smuzhiyun All rights reserved. 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun Redistribution and use in source and binary forms, with or without 6*4882a593Smuzhiyun modification, are permitted provided that the following conditions are met: 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun * Redistributions of source code must retain the above copyright notice, 9*4882a593Smuzhiyun this list of conditions and the following disclaimer. 10*4882a593Smuzhiyun * Redistributions in binary form must reproduce the above copyright notice, 11*4882a593Smuzhiyun this list of conditions and the following disclaimer in the documentation 12*4882a593Smuzhiyun and/or other materials provided with the distribution. 13*4882a593Smuzhiyun * Neither the name of Trident Microsystems nor Hauppauge Computer Works 14*4882a593Smuzhiyun nor the names of its contributors may be used to endorse or promote 15*4882a593Smuzhiyun products derived from this software without specific prior written 16*4882a593Smuzhiyun permission. 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19*4882a593Smuzhiyun AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*4882a593Smuzhiyun IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*4882a593Smuzhiyun ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22*4882a593Smuzhiyun LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*4882a593Smuzhiyun CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*4882a593Smuzhiyun SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*4882a593Smuzhiyun INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*4882a593Smuzhiyun CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*4882a593Smuzhiyun ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*4882a593Smuzhiyun POSSIBILITY OF SUCH DAMAGE. 29*4882a593Smuzhiyun */ 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun /******************************************************************************* 32*4882a593Smuzhiyun * FILENAME: $Id: drx_dap_fasi.h,v 1.5 2009/07/07 14:21:40 justin Exp $ 33*4882a593Smuzhiyun * 34*4882a593Smuzhiyun * DESCRIPTION: 35*4882a593Smuzhiyun * Part of DRX driver. 36*4882a593Smuzhiyun * Data access protocol: Fast Access Sequential Interface (fasi) 37*4882a593Smuzhiyun * Fast access, because of short addressing format (16 instead of 32 bits addr) 38*4882a593Smuzhiyun * Sequential, because of I2C. 39*4882a593Smuzhiyun * 40*4882a593Smuzhiyun * USAGE: 41*4882a593Smuzhiyun * Include. 42*4882a593Smuzhiyun * 43*4882a593Smuzhiyun * NOTES: 44*4882a593Smuzhiyun * 45*4882a593Smuzhiyun * 46*4882a593Smuzhiyun *******************************************************************************/ 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun /*-------- compilation control switches --------------------------------------*/ 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun #ifndef __DRX_DAP_FASI_H__ 51*4882a593Smuzhiyun #define __DRX_DAP_FASI_H__ 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun /*-------- Required includes -------------------------------------------------*/ 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun #include "drx_driver.h" 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun /*-------- Defines, configuring the API --------------------------------------*/ 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun /******************************************** 60*4882a593Smuzhiyun * Allowed address formats 61*4882a593Smuzhiyun ********************************************/ 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun /* 64*4882a593Smuzhiyun * Comments about short/long addressing format: 65*4882a593Smuzhiyun * 66*4882a593Smuzhiyun * The DAP FASI offers long address format (4 bytes) and short address format 67*4882a593Smuzhiyun * (2 bytes). The DAP can operate in 3 modes: 68*4882a593Smuzhiyun * (1) only short 69*4882a593Smuzhiyun * (2) only long 70*4882a593Smuzhiyun * (3) both long and short but short preferred and long only when necessary 71*4882a593Smuzhiyun * 72*4882a593Smuzhiyun * These modes must be selected compile time via compile switches. 73*4882a593Smuzhiyun * Compile switch settings for the different modes: 74*4882a593Smuzhiyun * (1) DRXDAPFASI_LONG_ADDR_ALLOWED=0, DRXDAPFASI_SHORT_ADDR_ALLOWED=1 75*4882a593Smuzhiyun * (2) DRXDAPFASI_LONG_ADDR_ALLOWED=1, DRXDAPFASI_SHORT_ADDR_ALLOWED=0 76*4882a593Smuzhiyun * (3) DRXDAPFASI_LONG_ADDR_ALLOWED=1, DRXDAPFASI_SHORT_ADDR_ALLOWED=1 77*4882a593Smuzhiyun * 78*4882a593Smuzhiyun * The default setting will be (3) both long and short. 79*4882a593Smuzhiyun * The default setting will need no compile switches. 80*4882a593Smuzhiyun * The default setting must be overridden if compile switches are already 81*4882a593Smuzhiyun * defined. 82*4882a593Smuzhiyun * 83*4882a593Smuzhiyun */ 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun /* set default */ 86*4882a593Smuzhiyun #if !defined(DRXDAPFASI_LONG_ADDR_ALLOWED) 87*4882a593Smuzhiyun #define DRXDAPFASI_LONG_ADDR_ALLOWED 1 88*4882a593Smuzhiyun #endif 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun /* set default */ 91*4882a593Smuzhiyun #if !defined(DRXDAPFASI_SHORT_ADDR_ALLOWED) 92*4882a593Smuzhiyun #define DRXDAPFASI_SHORT_ADDR_ALLOWED 1 93*4882a593Smuzhiyun #endif 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun /* check */ 96*4882a593Smuzhiyun #if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 0) && \ 97*4882a593Smuzhiyun (DRXDAPFASI_SHORT_ADDR_ALLOWED == 0)) 98*4882a593Smuzhiyun #error At least one of short- or long-addressing format must be allowed. 99*4882a593Smuzhiyun *; /* illegal statement to force compiler error */ 100*4882a593Smuzhiyun #endif 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun /******************************************** 103*4882a593Smuzhiyun * Single/master multi master setting 104*4882a593Smuzhiyun ********************************************/ 105*4882a593Smuzhiyun /* 106*4882a593Smuzhiyun * Comments about SINGLE MASTER/MULTI MASTER modes: 107*4882a593Smuzhiyun * 108*4882a593Smuzhiyun * Consider the two sides:1) the master and 2)the slave. 109*4882a593Smuzhiyun * 110*4882a593Smuzhiyun * Master: 111*4882a593Smuzhiyun * Single/multimaster operation set via DRXDAP_SINGLE_MASTER compile switch 112*4882a593Smuzhiyun * + single master mode means no use of repeated starts 113*4882a593Smuzhiyun * + multi master mode means use of repeated starts 114*4882a593Smuzhiyun * Default is single master. 115*4882a593Smuzhiyun * Default can be overridden by setting the compile switch DRXDAP_SINGLE_MASTER. 116*4882a593Smuzhiyun * 117*4882a593Smuzhiyun * Slave: 118*4882a593Smuzhiyun * Single/multi master selected via the flags in the FASI protocol. 119*4882a593Smuzhiyun * + single master means remember memory address between i2c packets 120*4882a593Smuzhiyun * + multimaster means flush memory address between i2c packets 121*4882a593Smuzhiyun * Default is single master, DAP FASI changes multi-master setting silently 122*4882a593Smuzhiyun * into single master setting. This cannot be overridden. 123*4882a593Smuzhiyun * 124*4882a593Smuzhiyun */ 125*4882a593Smuzhiyun /* set default */ 126*4882a593Smuzhiyun #ifndef DRXDAP_SINGLE_MASTER 127*4882a593Smuzhiyun #define DRXDAP_SINGLE_MASTER 0 128*4882a593Smuzhiyun #endif 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun /******************************************** 131*4882a593Smuzhiyun * Chunk/mode checking 132*4882a593Smuzhiyun ********************************************/ 133*4882a593Smuzhiyun /* 134*4882a593Smuzhiyun * Comments about DRXDAP_MAX_WCHUNKSIZE in single or multi master mode and 135*4882a593Smuzhiyun * in combination with short and long addressing format. All text below 136*4882a593Smuzhiyun * assumes long addressing format. The table also includes information 137*4882a593Smuzhiyun * for short ADDRessing format. 138*4882a593Smuzhiyun * 139*4882a593Smuzhiyun * In single master mode, data can be written by sending the register address 140*4882a593Smuzhiyun * first, then two or four bytes of data in the next packet. 141*4882a593Smuzhiyun * Because the device address plus a register address equals five bytes, 142*4882a593Smuzhiyun * the minimum chunk size must be five. 143*4882a593Smuzhiyun * If ten-bit I2C device addresses are used, the minimum chunk size must be six, 144*4882a593Smuzhiyun * because the I2C device address will then occupy two bytes when writing. 145*4882a593Smuzhiyun * 146*4882a593Smuzhiyun * Data in single master mode is transferred as follows: 147*4882a593Smuzhiyun * <S> <devW> a0 a1 a2 a3 <P> 148*4882a593Smuzhiyun * <S> <devW> d0 d1 [d2 d3] <P> 149*4882a593Smuzhiyun * .. 150*4882a593Smuzhiyun * or 151*4882a593Smuzhiyun * .. 152*4882a593Smuzhiyun * <S> <devW> a0 a1 a2 a3 <P> 153*4882a593Smuzhiyun * <S> <devR> --- <P> 154*4882a593Smuzhiyun * 155*4882a593Smuzhiyun * In multi-master mode, the data must immediately follow the address (an I2C 156*4882a593Smuzhiyun * stop resets the internal address), and hence the minimum chunk size is 157*4882a593Smuzhiyun * 1 <I2C address> + 4 (register address) + 2 (data to send) = 7 bytes (8 if 158*4882a593Smuzhiyun * 10-bit I2C device addresses are used). 159*4882a593Smuzhiyun * 160*4882a593Smuzhiyun * The 7-bit or 10-bit i2c address parameters is a runtime parameter. 161*4882a593Smuzhiyun * The other parameters can be limited via compile time switches. 162*4882a593Smuzhiyun * 163*4882a593Smuzhiyun *------------------------------------------------------------------------------- 164*4882a593Smuzhiyun * 165*4882a593Smuzhiyun * Minimum chunk size table (in bytes): 166*4882a593Smuzhiyun * 167*4882a593Smuzhiyun * +----------------+----------------+ 168*4882a593Smuzhiyun * | 7b i2c addr | 10b i2c addr | 169*4882a593Smuzhiyun * +----------------+----------------+ 170*4882a593Smuzhiyun * | single | multi | single | multi | 171*4882a593Smuzhiyun * ------+--------+-------+--------+-------+ 172*4882a593Smuzhiyun * short | 3 | 5 | 4 | 6 | 173*4882a593Smuzhiyun * long | 5 | 7 | 6 | 8 | 174*4882a593Smuzhiyun * ------+--------+-------+--------+-------+ 175*4882a593Smuzhiyun * 176*4882a593Smuzhiyun */ 177*4882a593Smuzhiyun 178*4882a593Smuzhiyun /* set default */ 179*4882a593Smuzhiyun #if !defined(DRXDAP_MAX_WCHUNKSIZE) 180*4882a593Smuzhiyun #define DRXDAP_MAX_WCHUNKSIZE 254 181*4882a593Smuzhiyun #endif 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun /* check */ 184*4882a593Smuzhiyun #if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 0) && (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1)) 185*4882a593Smuzhiyun #if DRXDAP_SINGLE_MASTER 186*4882a593Smuzhiyun #define DRXDAP_MAX_WCHUNKSIZE_MIN 3 187*4882a593Smuzhiyun #else 188*4882a593Smuzhiyun #define DRXDAP_MAX_WCHUNKSIZE_MIN 5 189*4882a593Smuzhiyun #endif 190*4882a593Smuzhiyun #else 191*4882a593Smuzhiyun #if DRXDAP_SINGLE_MASTER 192*4882a593Smuzhiyun #define DRXDAP_MAX_WCHUNKSIZE_MIN 5 193*4882a593Smuzhiyun #else 194*4882a593Smuzhiyun #define DRXDAP_MAX_WCHUNKSIZE_MIN 7 195*4882a593Smuzhiyun #endif 196*4882a593Smuzhiyun #endif 197*4882a593Smuzhiyun 198*4882a593Smuzhiyun #if DRXDAP_MAX_WCHUNKSIZE < DRXDAP_MAX_WCHUNKSIZE_MIN 199*4882a593Smuzhiyun #if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 0) && (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1)) 200*4882a593Smuzhiyun #if DRXDAP_SINGLE_MASTER 201*4882a593Smuzhiyun #error DRXDAP_MAX_WCHUNKSIZE must be at least 3 in single master mode 202*4882a593Smuzhiyun *; /* illegal statement to force compiler error */ 203*4882a593Smuzhiyun #else 204*4882a593Smuzhiyun #error DRXDAP_MAX_WCHUNKSIZE must be at least 5 in multi master mode 205*4882a593Smuzhiyun *; /* illegal statement to force compiler error */ 206*4882a593Smuzhiyun #endif 207*4882a593Smuzhiyun #else 208*4882a593Smuzhiyun #if DRXDAP_SINGLE_MASTER 209*4882a593Smuzhiyun #error DRXDAP_MAX_WCHUNKSIZE must be at least 5 in single master mode 210*4882a593Smuzhiyun *; /* illegal statement to force compiler error */ 211*4882a593Smuzhiyun #else 212*4882a593Smuzhiyun #error DRXDAP_MAX_WCHUNKSIZE must be at least 7 in multi master mode 213*4882a593Smuzhiyun *; /* illegal statement to force compiler error */ 214*4882a593Smuzhiyun #endif 215*4882a593Smuzhiyun #endif 216*4882a593Smuzhiyun #endif 217*4882a593Smuzhiyun 218*4882a593Smuzhiyun /* set default */ 219*4882a593Smuzhiyun #if !defined(DRXDAP_MAX_RCHUNKSIZE) 220*4882a593Smuzhiyun #define DRXDAP_MAX_RCHUNKSIZE 254 221*4882a593Smuzhiyun #endif 222*4882a593Smuzhiyun 223*4882a593Smuzhiyun /* check */ 224*4882a593Smuzhiyun #if DRXDAP_MAX_RCHUNKSIZE < 2 225*4882a593Smuzhiyun #error DRXDAP_MAX_RCHUNKSIZE must be at least 2 226*4882a593Smuzhiyun *; /* illegal statement to force compiler error */ 227*4882a593Smuzhiyun #endif 228*4882a593Smuzhiyun 229*4882a593Smuzhiyun /* check */ 230*4882a593Smuzhiyun #if DRXDAP_MAX_RCHUNKSIZE & 1 231*4882a593Smuzhiyun #error DRXDAP_MAX_RCHUNKSIZE must be even 232*4882a593Smuzhiyun *; /* illegal statement to force compiler error */ 233*4882a593Smuzhiyun #endif 234*4882a593Smuzhiyun 235*4882a593Smuzhiyun /*-------- Public API functions ----------------------------------------------*/ 236*4882a593Smuzhiyun 237*4882a593Smuzhiyun extern struct drx_access_func drx_dap_fasi_funct_g; 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun #define DRXDAP_FASI_RMW 0x10000000 240*4882a593Smuzhiyun #define DRXDAP_FASI_BROADCAST 0x20000000 241*4882a593Smuzhiyun #define DRXDAP_FASI_CLEARCRC 0x80000000 242*4882a593Smuzhiyun #define DRXDAP_FASI_SINGLE_MASTER 0xC0000000 243*4882a593Smuzhiyun #define DRXDAP_FASI_MULTI_MASTER 0x40000000 244*4882a593Smuzhiyun #define DRXDAP_FASI_SMM_SWITCH 0x40000000 /* single/multi master switch */ 245*4882a593Smuzhiyun #define DRXDAP_FASI_MODEFLAGS 0xC0000000 246*4882a593Smuzhiyun #define DRXDAP_FASI_FLAGS 0xF0000000 247*4882a593Smuzhiyun 248*4882a593Smuzhiyun #define DRXDAP_FASI_ADDR2BLOCK(addr) (((addr)>>22)&0x3F) 249*4882a593Smuzhiyun #define DRXDAP_FASI_ADDR2BANK(addr) (((addr)>>16)&0x3F) 250*4882a593Smuzhiyun #define DRXDAP_FASI_ADDR2OFFSET(addr) ((addr)&0x7FFF) 251*4882a593Smuzhiyun 252*4882a593Smuzhiyun #define DRXDAP_FASI_SHORT_FORMAT(addr) (((addr) & 0xFC30FF80) == 0) 253*4882a593Smuzhiyun #define DRXDAP_FASI_LONG_FORMAT(addr) (((addr) & 0xFC30FF80) != 0) 254*4882a593Smuzhiyun #define DRXDAP_FASI_OFFSET_TOO_LARGE(addr) (((addr) & 0x00008000) != 0) 255*4882a593Smuzhiyun 256*4882a593Smuzhiyun #endif /* __DRX_DAP_FASI_H__ */ 257