13cff842bSKuo-Jung Su /* 23cff842bSKuo-Jung Su * Faraday I2C Controller 33cff842bSKuo-Jung Su * 43cff842bSKuo-Jung Su * (C) Copyright 2010 Faraday Technology 53cff842bSKuo-Jung Su * Dante Su <dantesu@faraday-tech.com> 63cff842bSKuo-Jung Su * 7*8dde4ca9STom Rini * SPDX-License-Identifier: GPL-2.0+ 83cff842bSKuo-Jung Su */ 93cff842bSKuo-Jung Su 103cff842bSKuo-Jung Su #ifndef __FTI2C010_H 113cff842bSKuo-Jung Su #define __FTI2C010_H 123cff842bSKuo-Jung Su 133cff842bSKuo-Jung Su /* 143cff842bSKuo-Jung Su * FTI2C010 registers 153cff842bSKuo-Jung Su */ 163cff842bSKuo-Jung Su struct fti2c010_regs { 173cff842bSKuo-Jung Su uint32_t cr; /* 0x00: control register */ 183cff842bSKuo-Jung Su uint32_t sr; /* 0x04: status register */ 193cff842bSKuo-Jung Su uint32_t cdr; /* 0x08: clock division register */ 203cff842bSKuo-Jung Su uint32_t dr; /* 0x0c: data register */ 213cff842bSKuo-Jung Su uint32_t sar; /* 0x10: slave address register */ 223cff842bSKuo-Jung Su uint32_t tgsr;/* 0x14: time & glitch suppression register */ 233cff842bSKuo-Jung Su uint32_t bmr; /* 0x18: bus monitor register */ 243cff842bSKuo-Jung Su uint32_t rsvd[5]; 253cff842bSKuo-Jung Su uint32_t revr;/* 0x30: revision register */ 263cff842bSKuo-Jung Su }; 273cff842bSKuo-Jung Su 283cff842bSKuo-Jung Su /* 293cff842bSKuo-Jung Su * control register 303cff842bSKuo-Jung Su */ 313cff842bSKuo-Jung Su #define CR_ALIRQ 0x2000 /* arbitration lost interrupt (master) */ 323cff842bSKuo-Jung Su #define CR_SAMIRQ 0x1000 /* slave address match interrupt (slave) */ 333cff842bSKuo-Jung Su #define CR_STOPIRQ 0x800 /* stop condition interrupt (slave) */ 343cff842bSKuo-Jung Su #define CR_NAKRIRQ 0x400 /* NACK response interrupt (master) */ 353cff842bSKuo-Jung Su #define CR_DRIRQ 0x200 /* rx interrupt (both) */ 363cff842bSKuo-Jung Su #define CR_DTIRQ 0x100 /* tx interrupt (both) */ 373cff842bSKuo-Jung Su #define CR_TBEN 0x80 /* tx enable (both) */ 383cff842bSKuo-Jung Su #define CR_NAK 0x40 /* NACK (both) */ 393cff842bSKuo-Jung Su #define CR_STOP 0x20 /* stop (master) */ 403cff842bSKuo-Jung Su #define CR_START 0x10 /* start (master) */ 413cff842bSKuo-Jung Su #define CR_GCEN 0x8 /* general call support (slave) */ 423cff842bSKuo-Jung Su #define CR_SCLEN 0x4 /* enable clock out (master) */ 433cff842bSKuo-Jung Su #define CR_I2CEN 0x2 /* enable I2C (both) */ 443cff842bSKuo-Jung Su #define CR_I2CRST 0x1 /* reset I2C (both) */ 453cff842bSKuo-Jung Su #define CR_ENABLE \ 463cff842bSKuo-Jung Su (CR_ALIRQ | CR_NAKRIRQ | CR_DRIRQ | CR_DTIRQ | CR_SCLEN | CR_I2CEN) 473cff842bSKuo-Jung Su 483cff842bSKuo-Jung Su /* 493cff842bSKuo-Jung Su * status register 503cff842bSKuo-Jung Su */ 513cff842bSKuo-Jung Su #define SR_CLRAL 0x400 /* clear arbitration lost */ 523cff842bSKuo-Jung Su #define SR_CLRGC 0x200 /* clear general call */ 533cff842bSKuo-Jung Su #define SR_CLRSAM 0x100 /* clear slave address match */ 543cff842bSKuo-Jung Su #define SR_CLRSTOP 0x80 /* clear stop */ 553cff842bSKuo-Jung Su #define SR_CLRNAKR 0x40 /* clear NACK respond */ 563cff842bSKuo-Jung Su #define SR_DR 0x20 /* rx ready */ 573cff842bSKuo-Jung Su #define SR_DT 0x10 /* tx done */ 583cff842bSKuo-Jung Su #define SR_BB 0x8 /* bus busy */ 593cff842bSKuo-Jung Su #define SR_BUSY 0x4 /* chip busy */ 603cff842bSKuo-Jung Su #define SR_ACK 0x2 /* ACK/NACK received */ 613cff842bSKuo-Jung Su #define SR_RW 0x1 /* set when master-rx or slave-tx mode */ 623cff842bSKuo-Jung Su 633cff842bSKuo-Jung Su /* 643cff842bSKuo-Jung Su * clock division register 653cff842bSKuo-Jung Su */ 663cff842bSKuo-Jung Su #define CDR_DIV(n) ((n) & 0x3ffff) 673cff842bSKuo-Jung Su 683cff842bSKuo-Jung Su /* 693cff842bSKuo-Jung Su * time & glitch suppression register 703cff842bSKuo-Jung Su */ 713cff842bSKuo-Jung Su #define TGSR_GSR(n) (((n) & 0x7) << 10) 723cff842bSKuo-Jung Su #define TGSR_TSR(n) ((n) & 0x3ff) 733cff842bSKuo-Jung Su 743cff842bSKuo-Jung Su /* 753cff842bSKuo-Jung Su * bus monitor register 763cff842bSKuo-Jung Su */ 773cff842bSKuo-Jung Su #define BMR_SCL 0x2 /* SCL is pull-up */ 783cff842bSKuo-Jung Su #define BMR_SDA 0x1 /* SDA is pull-up */ 793cff842bSKuo-Jung Su 803cff842bSKuo-Jung Su #endif /* __FTI2C010_H */ 81