1*3cff842bSKuo-Jung Su /* 2*3cff842bSKuo-Jung Su * Faraday I2C Controller 3*3cff842bSKuo-Jung Su * 4*3cff842bSKuo-Jung Su * (C) Copyright 2010 Faraday Technology 5*3cff842bSKuo-Jung Su * Dante Su <dantesu@faraday-tech.com> 6*3cff842bSKuo-Jung Su * 7*3cff842bSKuo-Jung Su * This file is released under the terms of GPL v2 and any later version. 8*3cff842bSKuo-Jung Su * See the file COPYING in the root directory of the source tree for details. 9*3cff842bSKuo-Jung Su */ 10*3cff842bSKuo-Jung Su 11*3cff842bSKuo-Jung Su #ifndef __FTI2C010_H 12*3cff842bSKuo-Jung Su #define __FTI2C010_H 13*3cff842bSKuo-Jung Su 14*3cff842bSKuo-Jung Su /* 15*3cff842bSKuo-Jung Su * FTI2C010 registers 16*3cff842bSKuo-Jung Su */ 17*3cff842bSKuo-Jung Su struct fti2c010_regs { 18*3cff842bSKuo-Jung Su uint32_t cr; /* 0x00: control register */ 19*3cff842bSKuo-Jung Su uint32_t sr; /* 0x04: status register */ 20*3cff842bSKuo-Jung Su uint32_t cdr; /* 0x08: clock division register */ 21*3cff842bSKuo-Jung Su uint32_t dr; /* 0x0c: data register */ 22*3cff842bSKuo-Jung Su uint32_t sar; /* 0x10: slave address register */ 23*3cff842bSKuo-Jung Su uint32_t tgsr;/* 0x14: time & glitch suppression register */ 24*3cff842bSKuo-Jung Su uint32_t bmr; /* 0x18: bus monitor register */ 25*3cff842bSKuo-Jung Su uint32_t rsvd[5]; 26*3cff842bSKuo-Jung Su uint32_t revr;/* 0x30: revision register */ 27*3cff842bSKuo-Jung Su }; 28*3cff842bSKuo-Jung Su 29*3cff842bSKuo-Jung Su /* 30*3cff842bSKuo-Jung Su * control register 31*3cff842bSKuo-Jung Su */ 32*3cff842bSKuo-Jung Su #define CR_ALIRQ 0x2000 /* arbitration lost interrupt (master) */ 33*3cff842bSKuo-Jung Su #define CR_SAMIRQ 0x1000 /* slave address match interrupt (slave) */ 34*3cff842bSKuo-Jung Su #define CR_STOPIRQ 0x800 /* stop condition interrupt (slave) */ 35*3cff842bSKuo-Jung Su #define CR_NAKRIRQ 0x400 /* NACK response interrupt (master) */ 36*3cff842bSKuo-Jung Su #define CR_DRIRQ 0x200 /* rx interrupt (both) */ 37*3cff842bSKuo-Jung Su #define CR_DTIRQ 0x100 /* tx interrupt (both) */ 38*3cff842bSKuo-Jung Su #define CR_TBEN 0x80 /* tx enable (both) */ 39*3cff842bSKuo-Jung Su #define CR_NAK 0x40 /* NACK (both) */ 40*3cff842bSKuo-Jung Su #define CR_STOP 0x20 /* stop (master) */ 41*3cff842bSKuo-Jung Su #define CR_START 0x10 /* start (master) */ 42*3cff842bSKuo-Jung Su #define CR_GCEN 0x8 /* general call support (slave) */ 43*3cff842bSKuo-Jung Su #define CR_SCLEN 0x4 /* enable clock out (master) */ 44*3cff842bSKuo-Jung Su #define CR_I2CEN 0x2 /* enable I2C (both) */ 45*3cff842bSKuo-Jung Su #define CR_I2CRST 0x1 /* reset I2C (both) */ 46*3cff842bSKuo-Jung Su #define CR_ENABLE \ 47*3cff842bSKuo-Jung Su (CR_ALIRQ | CR_NAKRIRQ | CR_DRIRQ | CR_DTIRQ | CR_SCLEN | CR_I2CEN) 48*3cff842bSKuo-Jung Su 49*3cff842bSKuo-Jung Su /* 50*3cff842bSKuo-Jung Su * status register 51*3cff842bSKuo-Jung Su */ 52*3cff842bSKuo-Jung Su #define SR_CLRAL 0x400 /* clear arbitration lost */ 53*3cff842bSKuo-Jung Su #define SR_CLRGC 0x200 /* clear general call */ 54*3cff842bSKuo-Jung Su #define SR_CLRSAM 0x100 /* clear slave address match */ 55*3cff842bSKuo-Jung Su #define SR_CLRSTOP 0x80 /* clear stop */ 56*3cff842bSKuo-Jung Su #define SR_CLRNAKR 0x40 /* clear NACK respond */ 57*3cff842bSKuo-Jung Su #define SR_DR 0x20 /* rx ready */ 58*3cff842bSKuo-Jung Su #define SR_DT 0x10 /* tx done */ 59*3cff842bSKuo-Jung Su #define SR_BB 0x8 /* bus busy */ 60*3cff842bSKuo-Jung Su #define SR_BUSY 0x4 /* chip busy */ 61*3cff842bSKuo-Jung Su #define SR_ACK 0x2 /* ACK/NACK received */ 62*3cff842bSKuo-Jung Su #define SR_RW 0x1 /* set when master-rx or slave-tx mode */ 63*3cff842bSKuo-Jung Su 64*3cff842bSKuo-Jung Su /* 65*3cff842bSKuo-Jung Su * clock division register 66*3cff842bSKuo-Jung Su */ 67*3cff842bSKuo-Jung Su #define CDR_DIV(n) ((n) & 0x3ffff) 68*3cff842bSKuo-Jung Su 69*3cff842bSKuo-Jung Su /* 70*3cff842bSKuo-Jung Su * time & glitch suppression register 71*3cff842bSKuo-Jung Su */ 72*3cff842bSKuo-Jung Su #define TGSR_GSR(n) (((n) & 0x7) << 10) 73*3cff842bSKuo-Jung Su #define TGSR_TSR(n) ((n) & 0x3ff) 74*3cff842bSKuo-Jung Su 75*3cff842bSKuo-Jung Su /* 76*3cff842bSKuo-Jung Su * bus monitor register 77*3cff842bSKuo-Jung Su */ 78*3cff842bSKuo-Jung Su #define BMR_SCL 0x2 /* SCL is pull-up */ 79*3cff842bSKuo-Jung Su #define BMR_SDA 0x1 /* SDA is pull-up */ 80*3cff842bSKuo-Jung Su 81*3cff842bSKuo-Jung Su #endif /* __FTI2C010_H */ 82