18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * drivers/i2c/busses/i2c-ibm_iic.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Support for the IIC peripheral on IBM PPC 4xx 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (c) 2003 Zultys Technologies. 88c2ecf20Sopenharmony_ci * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Based on original work by 118c2ecf20Sopenharmony_ci * Ian DaSilva <idasilva@mvista.com> 128c2ecf20Sopenharmony_ci * Armin Kuster <akuster@mvista.com> 138c2ecf20Sopenharmony_ci * Matt Porter <mporter@mvista.com> 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * Copyright 2000-2003 MontaVista Software Inc. 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci#ifndef __I2C_IBM_IIC_H_ 188c2ecf20Sopenharmony_ci#define __I2C_IBM_IIC_H_ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include <linux/i2c.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistruct iic_regs { 238c2ecf20Sopenharmony_ci u16 mdbuf; 248c2ecf20Sopenharmony_ci u16 sbbuf; 258c2ecf20Sopenharmony_ci u8 lmadr; 268c2ecf20Sopenharmony_ci u8 hmadr; 278c2ecf20Sopenharmony_ci u8 cntl; 288c2ecf20Sopenharmony_ci u8 mdcntl; 298c2ecf20Sopenharmony_ci u8 sts; 308c2ecf20Sopenharmony_ci u8 extsts; 318c2ecf20Sopenharmony_ci u8 lsadr; 328c2ecf20Sopenharmony_ci u8 hsadr; 338c2ecf20Sopenharmony_ci u8 clkdiv; 348c2ecf20Sopenharmony_ci u8 intmsk; 358c2ecf20Sopenharmony_ci u8 xfrcnt; 368c2ecf20Sopenharmony_ci u8 xtcntlss; 378c2ecf20Sopenharmony_ci u8 directcntl; 388c2ecf20Sopenharmony_ci}; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct ibm_iic_private { 418c2ecf20Sopenharmony_ci struct i2c_adapter adap; 428c2ecf20Sopenharmony_ci volatile struct iic_regs __iomem *vaddr; 438c2ecf20Sopenharmony_ci wait_queue_head_t wq; 448c2ecf20Sopenharmony_ci int idx; 458c2ecf20Sopenharmony_ci int irq; 468c2ecf20Sopenharmony_ci int fast_mode; 478c2ecf20Sopenharmony_ci u8 clckdiv; 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* IICx_CNTL register */ 518c2ecf20Sopenharmony_ci#define CNTL_HMT 0x80 528c2ecf20Sopenharmony_ci#define CNTL_AMD 0x40 538c2ecf20Sopenharmony_ci#define CNTL_TCT_MASK 0x30 548c2ecf20Sopenharmony_ci#define CNTL_TCT_SHIFT 4 558c2ecf20Sopenharmony_ci#define CNTL_RPST 0x08 568c2ecf20Sopenharmony_ci#define CNTL_CHT 0x04 578c2ecf20Sopenharmony_ci#define CNTL_RW 0x02 588c2ecf20Sopenharmony_ci#define CNTL_PT 0x01 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* IICx_MDCNTL register */ 618c2ecf20Sopenharmony_ci#define MDCNTL_FSDB 0x80 628c2ecf20Sopenharmony_ci#define MDCNTL_FMDB 0x40 638c2ecf20Sopenharmony_ci#define MDCNTL_EGC 0x20 648c2ecf20Sopenharmony_ci#define MDCNTL_FSM 0x10 658c2ecf20Sopenharmony_ci#define MDCNTL_ESM 0x08 668c2ecf20Sopenharmony_ci#define MDCNTL_EINT 0x04 678c2ecf20Sopenharmony_ci#define MDCNTL_EUBS 0x02 688c2ecf20Sopenharmony_ci#define MDCNTL_HSCL 0x01 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* IICx_STS register */ 718c2ecf20Sopenharmony_ci#define STS_SSS 0x80 728c2ecf20Sopenharmony_ci#define STS_SLPR 0x40 738c2ecf20Sopenharmony_ci#define STS_MDBS 0x20 748c2ecf20Sopenharmony_ci#define STS_MDBF 0x10 758c2ecf20Sopenharmony_ci#define STS_SCMP 0x08 768c2ecf20Sopenharmony_ci#define STS_ERR 0x04 778c2ecf20Sopenharmony_ci#define STS_IRQA 0x02 788c2ecf20Sopenharmony_ci#define STS_PT 0x01 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci/* IICx_EXTSTS register */ 818c2ecf20Sopenharmony_ci#define EXTSTS_IRQP 0x80 828c2ecf20Sopenharmony_ci#define EXTSTS_BCS_MASK 0x70 838c2ecf20Sopenharmony_ci#define EXTSTS_BCS_FREE 0x40 848c2ecf20Sopenharmony_ci#define EXTSTS_IRQD 0x08 858c2ecf20Sopenharmony_ci#define EXTSTS_LA 0x04 868c2ecf20Sopenharmony_ci#define EXTSTS_ICT 0x02 878c2ecf20Sopenharmony_ci#define EXTSTS_XFRA 0x01 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/* IICx_INTRMSK register */ 908c2ecf20Sopenharmony_ci#define INTRMSK_EIRC 0x80 918c2ecf20Sopenharmony_ci#define INTRMSK_EIRS 0x40 928c2ecf20Sopenharmony_ci#define INTRMSK_EIWC 0x20 938c2ecf20Sopenharmony_ci#define INTRMSK_EIWS 0x10 948c2ecf20Sopenharmony_ci#define INTRMSK_EIHE 0x08 958c2ecf20Sopenharmony_ci#define INTRMSK_EIIC 0x04 968c2ecf20Sopenharmony_ci#define INTRMSK_EITA 0x02 978c2ecf20Sopenharmony_ci#define INTRMSK_EIMTC 0x01 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* IICx_XFRCNT register */ 1008c2ecf20Sopenharmony_ci#define XFRCNT_MTC_MASK 0x07 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci/* IICx_XTCNTLSS register */ 1038c2ecf20Sopenharmony_ci#define XTCNTLSS_SRC 0x80 1048c2ecf20Sopenharmony_ci#define XTCNTLSS_SRS 0x40 1058c2ecf20Sopenharmony_ci#define XTCNTLSS_SWC 0x20 1068c2ecf20Sopenharmony_ci#define XTCNTLSS_SWS 0x10 1078c2ecf20Sopenharmony_ci#define XTCNTLSS_SRST 0x01 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* IICx_DIRECTCNTL register */ 1108c2ecf20Sopenharmony_ci#define DIRCNTL_SDAC 0x08 1118c2ecf20Sopenharmony_ci#define DIRCNTL_SCC 0x04 1128c2ecf20Sopenharmony_ci#define DIRCNTL_MSDA 0x02 1138c2ecf20Sopenharmony_ci#define DIRCNTL_MSC 0x01 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* Check if we really control the I2C bus and bus is free */ 1168c2ecf20Sopenharmony_ci#define DIRCTNL_FREE(v) (((v) & 0x0f) == 0x0f) 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci#endif /* __I2C_IBM_IIC_H_ */ 119