1*938717ceSSteve Sakoman /* 2*938717ceSSteve Sakoman * (C) Copyright 2004-2010 3*938717ceSSteve Sakoman * Texas Instruments, <www.ti.com> 4*938717ceSSteve Sakoman * 5*938717ceSSteve Sakoman * See file CREDITS for list of people who contributed to this 6*938717ceSSteve Sakoman * project. 7*938717ceSSteve Sakoman * 8*938717ceSSteve Sakoman * This program is free software; you can redistribute it and/or 9*938717ceSSteve Sakoman * modify it under the terms of the GNU General Public License as 10*938717ceSSteve Sakoman * published by the Free Software Foundation; either version 2 of 11*938717ceSSteve Sakoman * the License, or (at your option) any later version. 12*938717ceSSteve Sakoman * 13*938717ceSSteve Sakoman * This program is distributed in the hope that it will be useful, 14*938717ceSSteve Sakoman * but WITHOUT ANY WARRANTY; without even the implied warranty of 15*938717ceSSteve Sakoman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*938717ceSSteve Sakoman * GNU General Public License for more details. 17*938717ceSSteve Sakoman * 18*938717ceSSteve Sakoman * You should have received a copy of the GNU General Public License 19*938717ceSSteve Sakoman * along with this program; if not, write to the Free Software 20*938717ceSSteve Sakoman * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21*938717ceSSteve Sakoman * MA 02111-1307 USA 22*938717ceSSteve Sakoman */ 23*938717ceSSteve Sakoman #ifndef _OMAP24XX_I2C_H_ 24*938717ceSSteve Sakoman #define _OMAP24XX_I2C_H_ 25*938717ceSSteve Sakoman 26*938717ceSSteve Sakoman /* I2C masks */ 27*938717ceSSteve Sakoman 28*938717ceSSteve Sakoman /* I2C Interrupt Enable Register (I2C_IE): */ 29*938717ceSSteve Sakoman #define I2C_IE_GC_IE (1 << 5) 30*938717ceSSteve Sakoman #define I2C_IE_XRDY_IE (1 << 4) /* Transmit data ready interrupt enable */ 31*938717ceSSteve Sakoman #define I2C_IE_RRDY_IE (1 << 3) /* Receive data ready interrupt enable */ 32*938717ceSSteve Sakoman #define I2C_IE_ARDY_IE (1 << 2) /* Register access ready interrupt enable */ 33*938717ceSSteve Sakoman #define I2C_IE_NACK_IE (1 << 1) /* No acknowledgment interrupt enable */ 34*938717ceSSteve Sakoman #define I2C_IE_AL_IE (1 << 0) /* Arbitration lost interrupt enable */ 35*938717ceSSteve Sakoman 36*938717ceSSteve Sakoman /* I2C Status Register (I2C_STAT): */ 37*938717ceSSteve Sakoman 38*938717ceSSteve Sakoman #define I2C_STAT_SBD (1 << 15) /* Single byte data */ 39*938717ceSSteve Sakoman #define I2C_STAT_BB (1 << 12) /* Bus busy */ 40*938717ceSSteve Sakoman #define I2C_STAT_ROVR (1 << 11) /* Receive overrun */ 41*938717ceSSteve Sakoman #define I2C_STAT_XUDF (1 << 10) /* Transmit underflow */ 42*938717ceSSteve Sakoman #define I2C_STAT_AAS (1 << 9) /* Address as slave */ 43*938717ceSSteve Sakoman #define I2C_STAT_GC (1 << 5) 44*938717ceSSteve Sakoman #define I2C_STAT_XRDY (1 << 4) /* Transmit data ready */ 45*938717ceSSteve Sakoman #define I2C_STAT_RRDY (1 << 3) /* Receive data ready */ 46*938717ceSSteve Sakoman #define I2C_STAT_ARDY (1 << 2) /* Register access ready */ 47*938717ceSSteve Sakoman #define I2C_STAT_NACK (1 << 1) /* No acknowledgment interrupt enable */ 48*938717ceSSteve Sakoman #define I2C_STAT_AL (1 << 0) /* Arbitration lost interrupt enable */ 49*938717ceSSteve Sakoman 50*938717ceSSteve Sakoman /* I2C Interrupt Code Register (I2C_INTCODE): */ 51*938717ceSSteve Sakoman 52*938717ceSSteve Sakoman #define I2C_INTCODE_MASK 7 53*938717ceSSteve Sakoman #define I2C_INTCODE_NONE 0 54*938717ceSSteve Sakoman #define I2C_INTCODE_AL 1 /* Arbitration lost */ 55*938717ceSSteve Sakoman #define I2C_INTCODE_NAK 2 /* No acknowledgement/general call */ 56*938717ceSSteve Sakoman #define I2C_INTCODE_ARDY 3 /* Register access ready */ 57*938717ceSSteve Sakoman #define I2C_INTCODE_RRDY 4 /* Rcv data ready */ 58*938717ceSSteve Sakoman #define I2C_INTCODE_XRDY 5 /* Xmit data ready */ 59*938717ceSSteve Sakoman 60*938717ceSSteve Sakoman /* I2C Buffer Configuration Register (I2C_BUF): */ 61*938717ceSSteve Sakoman 62*938717ceSSteve Sakoman #define I2C_BUF_RDMA_EN (1 << 15) /* Receive DMA channel enable */ 63*938717ceSSteve Sakoman #define I2C_BUF_XDMA_EN (1 << 7) /* Transmit DMA channel enable */ 64*938717ceSSteve Sakoman 65*938717ceSSteve Sakoman /* I2C Configuration Register (I2C_CON): */ 66*938717ceSSteve Sakoman 67*938717ceSSteve Sakoman #define I2C_CON_EN (1 << 15) /* I2C module enable */ 68*938717ceSSteve Sakoman #define I2C_CON_BE (1 << 14) /* Big endian mode */ 69*938717ceSSteve Sakoman #define I2C_CON_STB (1 << 11) /* Start byte mode (master mode only) */ 70*938717ceSSteve Sakoman #define I2C_CON_MST (1 << 10) /* Master/slave mode */ 71*938717ceSSteve Sakoman #define I2C_CON_TRX (1 << 9) /* Transmitter/receiver mode */ 72*938717ceSSteve Sakoman /* (master mode only) */ 73*938717ceSSteve Sakoman #define I2C_CON_XA (1 << 8) /* Expand address */ 74*938717ceSSteve Sakoman #define I2C_CON_STP (1 << 1) /* Stop condition (master mode only) */ 75*938717ceSSteve Sakoman #define I2C_CON_STT (1 << 0) /* Start condition (master mode only) */ 76*938717ceSSteve Sakoman 77*938717ceSSteve Sakoman /* I2C System Test Register (I2C_SYSTEST): */ 78*938717ceSSteve Sakoman 79*938717ceSSteve Sakoman #define I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */ 80*938717ceSSteve Sakoman #define I2C_SYSTEST_FREE (1 << 14) /* Free running mode, on brkpoint) */ 81*938717ceSSteve Sakoman #define I2C_SYSTEST_TMODE_MASK (3 << 12) /* Test mode select */ 82*938717ceSSteve Sakoman #define I2C_SYSTEST_TMODE_SHIFT (12) /* Test mode select */ 83*938717ceSSteve Sakoman #define I2C_SYSTEST_SCL_I (1 << 3) /* SCL line sense input value */ 84*938717ceSSteve Sakoman #define I2C_SYSTEST_SCL_O (1 << 2) /* SCL line drive output value */ 85*938717ceSSteve Sakoman #define I2C_SYSTEST_SDA_I (1 << 1) /* SDA line sense input value */ 86*938717ceSSteve Sakoman #define I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive output value */ 87*938717ceSSteve Sakoman 88*938717ceSSteve Sakoman #define I2C_SCLL_SCLL 0 89*938717ceSSteve Sakoman #define I2C_SCLL_SCLL_M 0xFF 90*938717ceSSteve Sakoman #define I2C_SCLL_HSSCLL 8 91*938717ceSSteve Sakoman #define I2C_SCLH_HSSCLL_M 0xFF 92*938717ceSSteve Sakoman #define I2C_SCLH_SCLH 0 93*938717ceSSteve Sakoman #define I2C_SCLH_SCLH_M 0xFF 94*938717ceSSteve Sakoman #define I2C_SCLH_HSSCLH 8 95*938717ceSSteve Sakoman #define I2C_SCLH_HSSCLH_M 0xFF 96*938717ceSSteve Sakoman 97*938717ceSSteve Sakoman #define OMAP_I2C_STANDARD 100000 98*938717ceSSteve Sakoman #define OMAP_I2C_FAST_MODE 400000 99*938717ceSSteve Sakoman #define OMAP_I2C_HIGH_SPEED 3400000 100*938717ceSSteve Sakoman 101*938717ceSSteve Sakoman #define SYSTEM_CLOCK_12 12000000 102*938717ceSSteve Sakoman #define SYSTEM_CLOCK_13 13000000 103*938717ceSSteve Sakoman #define SYSTEM_CLOCK_192 19200000 104*938717ceSSteve Sakoman #define SYSTEM_CLOCK_96 96000000 105*938717ceSSteve Sakoman 106*938717ceSSteve Sakoman /* Use the reference value of 96MHz if not explicitly set by the board */ 107*938717ceSSteve Sakoman #ifndef I2C_IP_CLK 108*938717ceSSteve Sakoman #define I2C_IP_CLK SYSTEM_CLOCK_96 109*938717ceSSteve Sakoman #endif 110*938717ceSSteve Sakoman 111*938717ceSSteve Sakoman /* 112*938717ceSSteve Sakoman * The reference minimum clock for high speed is 19.2MHz. 113*938717ceSSteve Sakoman * The linux 2.6.30 kernel uses this value. 114*938717ceSSteve Sakoman * The reference minimum clock for fast mode is 9.6MHz 115*938717ceSSteve Sakoman * The reference minimum clock for standard mode is 4MHz 116*938717ceSSteve Sakoman * In TRM, the value of 12MHz is used. 117*938717ceSSteve Sakoman */ 118*938717ceSSteve Sakoman #ifndef I2C_INTERNAL_SAMPLING_CLK 119*938717ceSSteve Sakoman #define I2C_INTERNAL_SAMPLING_CLK 19200000 120*938717ceSSteve Sakoman #endif 121*938717ceSSteve Sakoman 122*938717ceSSteve Sakoman /* 123*938717ceSSteve Sakoman * The equation for the low and high time is 124*938717ceSSteve Sakoman * tlow = scll + scll_trim = (sampling clock * tlow_duty) / speed 125*938717ceSSteve Sakoman * thigh = sclh + sclh_trim = (sampling clock * (1 - tlow_duty)) / speed 126*938717ceSSteve Sakoman * 127*938717ceSSteve Sakoman * If the duty cycle is 50% 128*938717ceSSteve Sakoman * 129*938717ceSSteve Sakoman * tlow = scll + scll_trim = sampling clock / (2 * speed) 130*938717ceSSteve Sakoman * thigh = sclh + sclh_trim = sampling clock / (2 * speed) 131*938717ceSSteve Sakoman * 132*938717ceSSteve Sakoman * In TRM 133*938717ceSSteve Sakoman * scll_trim = 7 134*938717ceSSteve Sakoman * sclh_trim = 5 135*938717ceSSteve Sakoman * 136*938717ceSSteve Sakoman * The linux 2.6.30 kernel uses 137*938717ceSSteve Sakoman * scll_trim = 6 138*938717ceSSteve Sakoman * sclh_trim = 6 139*938717ceSSteve Sakoman * 140*938717ceSSteve Sakoman * These are the trim values for standard and fast speed 141*938717ceSSteve Sakoman */ 142*938717ceSSteve Sakoman #ifndef I2C_FASTSPEED_SCLL_TRIM 143*938717ceSSteve Sakoman #define I2C_FASTSPEED_SCLL_TRIM 6 144*938717ceSSteve Sakoman #endif 145*938717ceSSteve Sakoman #ifndef I2C_FASTSPEED_SCLH_TRIM 146*938717ceSSteve Sakoman #define I2C_FASTSPEED_SCLH_TRIM 6 147*938717ceSSteve Sakoman #endif 148*938717ceSSteve Sakoman 149*938717ceSSteve Sakoman /* These are the trim values for high speed */ 150*938717ceSSteve Sakoman #ifndef I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM 151*938717ceSSteve Sakoman #define I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM 152*938717ceSSteve Sakoman #endif 153*938717ceSSteve Sakoman #ifndef I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM 154*938717ceSSteve Sakoman #define I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM 155*938717ceSSteve Sakoman #endif 156*938717ceSSteve Sakoman #ifndef I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM 157*938717ceSSteve Sakoman #define I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM 158*938717ceSSteve Sakoman #endif 159*938717ceSSteve Sakoman #ifndef I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM 160*938717ceSSteve Sakoman #define I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM 161*938717ceSSteve Sakoman #endif 162*938717ceSSteve Sakoman 163*938717ceSSteve Sakoman #define I2C_PSC_MAX 0x0f 164*938717ceSSteve Sakoman #define I2C_PSC_MIN 0x00 165*938717ceSSteve Sakoman 166*938717ceSSteve Sakoman #endif /* _OMAP24XX_I2C_H_ */ 167