1938717ceSSteve Sakoman /* 2938717ceSSteve Sakoman * (C) Copyright 2004-2010 3938717ceSSteve Sakoman * Texas Instruments, <www.ti.com> 4938717ceSSteve Sakoman * 5938717ceSSteve Sakoman * See file CREDITS for list of people who contributed to this 6938717ceSSteve Sakoman * project. 7938717ceSSteve Sakoman * 8938717ceSSteve Sakoman * This program is free software; you can redistribute it and/or 9938717ceSSteve Sakoman * modify it under the terms of the GNU General Public License as 10938717ceSSteve Sakoman * published by the Free Software Foundation; either version 2 of 11938717ceSSteve Sakoman * the License, or (at your option) any later version. 12938717ceSSteve Sakoman * 13938717ceSSteve Sakoman * This program is distributed in the hope that it will be useful, 14938717ceSSteve Sakoman * but WITHOUT ANY WARRANTY; without even the implied warranty of 15938717ceSSteve Sakoman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16938717ceSSteve Sakoman * GNU General Public License for more details. 17938717ceSSteve Sakoman * 18938717ceSSteve Sakoman * You should have received a copy of the GNU General Public License 19938717ceSSteve Sakoman * along with this program; if not, write to the Free Software 20938717ceSSteve Sakoman * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21938717ceSSteve Sakoman * MA 02111-1307 USA 22938717ceSSteve Sakoman */ 23*07cf5e20SNishanth Menon #ifndef _OMAP2PLUS_I2C_H_ 24*07cf5e20SNishanth Menon #define _OMAP2PLUS_I2C_H_ 25938717ceSSteve Sakoman 26938717ceSSteve Sakoman /* I2C masks */ 27938717ceSSteve Sakoman 28938717ceSSteve Sakoman /* I2C Interrupt Enable Register (I2C_IE): */ 29938717ceSSteve Sakoman #define I2C_IE_GC_IE (1 << 5) 30938717ceSSteve Sakoman #define I2C_IE_XRDY_IE (1 << 4) /* Transmit data ready interrupt enable */ 31938717ceSSteve Sakoman #define I2C_IE_RRDY_IE (1 << 3) /* Receive data ready interrupt enable */ 32938717ceSSteve Sakoman #define I2C_IE_ARDY_IE (1 << 2) /* Register access ready interrupt enable */ 33938717ceSSteve Sakoman #define I2C_IE_NACK_IE (1 << 1) /* No acknowledgment interrupt enable */ 34938717ceSSteve Sakoman #define I2C_IE_AL_IE (1 << 0) /* Arbitration lost interrupt enable */ 35938717ceSSteve Sakoman 36938717ceSSteve Sakoman /* I2C Status Register (I2C_STAT): */ 37938717ceSSteve Sakoman 38938717ceSSteve Sakoman #define I2C_STAT_SBD (1 << 15) /* Single byte data */ 39938717ceSSteve Sakoman #define I2C_STAT_BB (1 << 12) /* Bus busy */ 40938717ceSSteve Sakoman #define I2C_STAT_ROVR (1 << 11) /* Receive overrun */ 41938717ceSSteve Sakoman #define I2C_STAT_XUDF (1 << 10) /* Transmit underflow */ 42938717ceSSteve Sakoman #define I2C_STAT_AAS (1 << 9) /* Address as slave */ 43938717ceSSteve Sakoman #define I2C_STAT_GC (1 << 5) 44938717ceSSteve Sakoman #define I2C_STAT_XRDY (1 << 4) /* Transmit data ready */ 45938717ceSSteve Sakoman #define I2C_STAT_RRDY (1 << 3) /* Receive data ready */ 46938717ceSSteve Sakoman #define I2C_STAT_ARDY (1 << 2) /* Register access ready */ 47938717ceSSteve Sakoman #define I2C_STAT_NACK (1 << 1) /* No acknowledgment interrupt enable */ 48938717ceSSteve Sakoman #define I2C_STAT_AL (1 << 0) /* Arbitration lost interrupt enable */ 49938717ceSSteve Sakoman 50938717ceSSteve Sakoman /* I2C Interrupt Code Register (I2C_INTCODE): */ 51938717ceSSteve Sakoman 52938717ceSSteve Sakoman #define I2C_INTCODE_MASK 7 53938717ceSSteve Sakoman #define I2C_INTCODE_NONE 0 54938717ceSSteve Sakoman #define I2C_INTCODE_AL 1 /* Arbitration lost */ 55938717ceSSteve Sakoman #define I2C_INTCODE_NAK 2 /* No acknowledgement/general call */ 56938717ceSSteve Sakoman #define I2C_INTCODE_ARDY 3 /* Register access ready */ 57938717ceSSteve Sakoman #define I2C_INTCODE_RRDY 4 /* Rcv data ready */ 58938717ceSSteve Sakoman #define I2C_INTCODE_XRDY 5 /* Xmit data ready */ 59938717ceSSteve Sakoman 60938717ceSSteve Sakoman /* I2C Buffer Configuration Register (I2C_BUF): */ 61938717ceSSteve Sakoman 62938717ceSSteve Sakoman #define I2C_BUF_RDMA_EN (1 << 15) /* Receive DMA channel enable */ 63938717ceSSteve Sakoman #define I2C_BUF_XDMA_EN (1 << 7) /* Transmit DMA channel enable */ 64938717ceSSteve Sakoman 65938717ceSSteve Sakoman /* I2C Configuration Register (I2C_CON): */ 66938717ceSSteve Sakoman 67938717ceSSteve Sakoman #define I2C_CON_EN (1 << 15) /* I2C module enable */ 68938717ceSSteve Sakoman #define I2C_CON_BE (1 << 14) /* Big endian mode */ 69938717ceSSteve Sakoman #define I2C_CON_STB (1 << 11) /* Start byte mode (master mode only) */ 70938717ceSSteve Sakoman #define I2C_CON_MST (1 << 10) /* Master/slave mode */ 71938717ceSSteve Sakoman #define I2C_CON_TRX (1 << 9) /* Transmitter/receiver mode */ 72938717ceSSteve Sakoman /* (master mode only) */ 73938717ceSSteve Sakoman #define I2C_CON_XA (1 << 8) /* Expand address */ 74938717ceSSteve Sakoman #define I2C_CON_STP (1 << 1) /* Stop condition (master mode only) */ 75938717ceSSteve Sakoman #define I2C_CON_STT (1 << 0) /* Start condition (master mode only) */ 76938717ceSSteve Sakoman 77938717ceSSteve Sakoman /* I2C System Test Register (I2C_SYSTEST): */ 78938717ceSSteve Sakoman 79938717ceSSteve Sakoman #define I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */ 80938717ceSSteve Sakoman #define I2C_SYSTEST_FREE (1 << 14) /* Free running mode, on brkpoint) */ 81938717ceSSteve Sakoman #define I2C_SYSTEST_TMODE_MASK (3 << 12) /* Test mode select */ 82938717ceSSteve Sakoman #define I2C_SYSTEST_TMODE_SHIFT (12) /* Test mode select */ 83938717ceSSteve Sakoman #define I2C_SYSTEST_SCL_I (1 << 3) /* SCL line sense input value */ 84938717ceSSteve Sakoman #define I2C_SYSTEST_SCL_O (1 << 2) /* SCL line drive output value */ 85938717ceSSteve Sakoman #define I2C_SYSTEST_SDA_I (1 << 1) /* SDA line sense input value */ 86938717ceSSteve Sakoman #define I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive output value */ 87938717ceSSteve Sakoman 88d708395dSSteve Sakoman /* I2C System Status Register (I2C_SYSS): */ 89d708395dSSteve Sakoman 90d708395dSSteve Sakoman #define I2C_SYSS_RDONE (1 << 0) /* Internel reset monitoring */ 91d708395dSSteve Sakoman 92938717ceSSteve Sakoman #define I2C_SCLL_SCLL 0 93938717ceSSteve Sakoman #define I2C_SCLL_SCLL_M 0xFF 94938717ceSSteve Sakoman #define I2C_SCLL_HSSCLL 8 95938717ceSSteve Sakoman #define I2C_SCLH_HSSCLL_M 0xFF 96938717ceSSteve Sakoman #define I2C_SCLH_SCLH 0 97938717ceSSteve Sakoman #define I2C_SCLH_SCLH_M 0xFF 98938717ceSSteve Sakoman #define I2C_SCLH_HSSCLH 8 99938717ceSSteve Sakoman #define I2C_SCLH_HSSCLH_M 0xFF 100938717ceSSteve Sakoman 101938717ceSSteve Sakoman #define OMAP_I2C_STANDARD 100000 102938717ceSSteve Sakoman #define OMAP_I2C_FAST_MODE 400000 103938717ceSSteve Sakoman #define OMAP_I2C_HIGH_SPEED 3400000 104938717ceSSteve Sakoman 105938717ceSSteve Sakoman #define SYSTEM_CLOCK_12 12000000 106938717ceSSteve Sakoman #define SYSTEM_CLOCK_13 13000000 107938717ceSSteve Sakoman #define SYSTEM_CLOCK_192 19200000 108938717ceSSteve Sakoman #define SYSTEM_CLOCK_96 96000000 109938717ceSSteve Sakoman 110938717ceSSteve Sakoman /* Use the reference value of 96MHz if not explicitly set by the board */ 111938717ceSSteve Sakoman #ifndef I2C_IP_CLK 112938717ceSSteve Sakoman #define I2C_IP_CLK SYSTEM_CLOCK_96 113938717ceSSteve Sakoman #endif 114938717ceSSteve Sakoman 115938717ceSSteve Sakoman /* 116938717ceSSteve Sakoman * The reference minimum clock for high speed is 19.2MHz. 117938717ceSSteve Sakoman * The linux 2.6.30 kernel uses this value. 118938717ceSSteve Sakoman * The reference minimum clock for fast mode is 9.6MHz 119938717ceSSteve Sakoman * The reference minimum clock for standard mode is 4MHz 120938717ceSSteve Sakoman * In TRM, the value of 12MHz is used. 121938717ceSSteve Sakoman */ 122938717ceSSteve Sakoman #ifndef I2C_INTERNAL_SAMPLING_CLK 123938717ceSSteve Sakoman #define I2C_INTERNAL_SAMPLING_CLK 19200000 124938717ceSSteve Sakoman #endif 125938717ceSSteve Sakoman 126938717ceSSteve Sakoman /* 127938717ceSSteve Sakoman * The equation for the low and high time is 128938717ceSSteve Sakoman * tlow = scll + scll_trim = (sampling clock * tlow_duty) / speed 129938717ceSSteve Sakoman * thigh = sclh + sclh_trim = (sampling clock * (1 - tlow_duty)) / speed 130938717ceSSteve Sakoman * 131938717ceSSteve Sakoman * If the duty cycle is 50% 132938717ceSSteve Sakoman * 133938717ceSSteve Sakoman * tlow = scll + scll_trim = sampling clock / (2 * speed) 134938717ceSSteve Sakoman * thigh = sclh + sclh_trim = sampling clock / (2 * speed) 135938717ceSSteve Sakoman * 136938717ceSSteve Sakoman * In TRM 137938717ceSSteve Sakoman * scll_trim = 7 138938717ceSSteve Sakoman * sclh_trim = 5 139938717ceSSteve Sakoman * 140938717ceSSteve Sakoman * The linux 2.6.30 kernel uses 141938717ceSSteve Sakoman * scll_trim = 6 142938717ceSSteve Sakoman * sclh_trim = 6 143938717ceSSteve Sakoman * 144938717ceSSteve Sakoman * These are the trim values for standard and fast speed 145938717ceSSteve Sakoman */ 146938717ceSSteve Sakoman #ifndef I2C_FASTSPEED_SCLL_TRIM 147938717ceSSteve Sakoman #define I2C_FASTSPEED_SCLL_TRIM 6 148938717ceSSteve Sakoman #endif 149938717ceSSteve Sakoman #ifndef I2C_FASTSPEED_SCLH_TRIM 150938717ceSSteve Sakoman #define I2C_FASTSPEED_SCLH_TRIM 6 151938717ceSSteve Sakoman #endif 152938717ceSSteve Sakoman 153938717ceSSteve Sakoman /* These are the trim values for high speed */ 154938717ceSSteve Sakoman #ifndef I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM 155938717ceSSteve Sakoman #define I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM 156938717ceSSteve Sakoman #endif 157938717ceSSteve Sakoman #ifndef I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM 158938717ceSSteve Sakoman #define I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM 159938717ceSSteve Sakoman #endif 160938717ceSSteve Sakoman #ifndef I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM 161938717ceSSteve Sakoman #define I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM 162938717ceSSteve Sakoman #endif 163938717ceSSteve Sakoman #ifndef I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM 164938717ceSSteve Sakoman #define I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM 165938717ceSSteve Sakoman #endif 166938717ceSSteve Sakoman 167938717ceSSteve Sakoman #define I2C_PSC_MAX 0x0f 168938717ceSSteve Sakoman #define I2C_PSC_MIN 0x00 169938717ceSSteve Sakoman 170938717ceSSteve Sakoman #endif /* _OMAP24XX_I2C_H_ */ 171