summaryrefslogtreecommitdiffstats
path: root/arch/blackfin
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-09 17:18:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-09 17:18:40 -0400
commitd2d8f51e28fec278e9632cdd029facf813f579a3 (patch)
treea4580c900fe86d0db506c2ec78c247a32b0b689c /arch/blackfin
parentad9a19d003703ae06a6e8efc64cf26a939d9e84d (diff)
parent8ce906c13c32cfd3de71063ca4b8c3b774e4ca08 (diff)
Merge branch 'i2c/for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang: - new drivers for Spreadtrum I2C, Intel Cherry Trail Whiskey Cove SMBUS - quite some driver updates - cleanups for the i2c-mux subsystem - some subsystem-wide constification - further cleanup of include/linux/i2c * 'i2c/for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (50 commits) i2c: sprd: Fix undefined reference errors i2c: nomadik: constify amba_id i2c: versatile: Make i2c_algo_bit_data const i2c: busses: make i2c_adapter_quirks const i2c: busses: make i2c_adapter const i2c: busses: make i2c_algorithm const i2c: Add Spreadtrum I2C controller driver dt-bindings: i2c: Add Spreadtrum I2C controller documentation i2c-cht-wc: make cht_wc_i2c_adap_driver static MAINTAINERS: Add entry for drivers/i2c/busses/i2c-cht-wc.c i2c: aspeed: Retain delay/setup/hold values when configuring bus frequency dt-bindings: i2c: eeprom: Document vendor to be used and deprecated ones i2c: i801: Restore the presence state of P2SB PCI device after reading BAR MAINTAINERS: drop entry for Blackfin I2C and Sonic's email blackfin: merge the two TWI header files i2c: davinci: Preserve return value of devm_clk_get i2c: mediatek: Add i2c compatible for MediaTek MT7622 dt-bindings: i2c: Add MediaTek MT7622 i2c binding dt-bindings: i2c: modify information formats i2c: mux: i2c-arb-gpio-challenge: allow compiling w/o OF support ...
Diffstat (limited to 'arch/blackfin')
-rw-r--r--arch/blackfin/include/asm/bfin_twi.h134
-rw-r--r--arch/blackfin/kernel/debug-mmrs.c1
2 files changed, 133 insertions, 2 deletions
diff --git a/arch/blackfin/include/asm/bfin_twi.h b/arch/blackfin/include/asm/bfin_twi.h
index aaa0834d34aa..211e9c78f6fb 100644
--- a/arch/blackfin/include/asm/bfin_twi.h
+++ b/arch/blackfin/include/asm/bfin_twi.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * bfin_twi.h - interface to Blackfin TWIs 2 * bfin_twi.h - interface to Blackfin TWIs
3 * 3 *
4 * Copyright 2005-2010 Analog Devices Inc. 4 * Copyright 2005-2014 Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
@@ -10,6 +10,138 @@
10#define __ASM_BFIN_TWI_H__ 10#define __ASM_BFIN_TWI_H__
11 11
12#include <asm/blackfin.h> 12#include <asm/blackfin.h>
13#include <linux/types.h>
14#include <linux/i2c.h>
15
16/*
17 * ADI twi registers layout
18 */
19struct bfin_twi_regs {
20 u16 clkdiv;
21 u16 dummy1;
22 u16 control;
23 u16 dummy2;
24 u16 slave_ctl;
25 u16 dummy3;
26 u16 slave_stat;
27 u16 dummy4;
28 u16 slave_addr;
29 u16 dummy5;
30 u16 master_ctl;
31 u16 dummy6;
32 u16 master_stat;
33 u16 dummy7;
34 u16 master_addr;
35 u16 dummy8;
36 u16 int_stat;
37 u16 dummy9;
38 u16 int_mask;
39 u16 dummy10;
40 u16 fifo_ctl;
41 u16 dummy11;
42 u16 fifo_stat;
43 u16 dummy12;
44 u32 __pad[20];
45 u16 xmt_data8;
46 u16 dummy13;
47 u16 xmt_data16;
48 u16 dummy14;
49 u16 rcv_data8;
50 u16 dummy15;
51 u16 rcv_data16;
52 u16 dummy16;
53};
54
55struct bfin_twi_iface {
56 int irq;
57 spinlock_t lock;
58 char read_write;
59 u8 command;
60 u8 *transPtr;
61 int readNum;
62 int writeNum;
63 int cur_mode;
64 int manual_stop;
65 int result;
66 struct i2c_adapter adap;
67 struct completion complete;
68 struct i2c_msg *pmsg;
69 int msg_num;
70 int cur_msg;
71 u16 saved_clkdiv;
72 u16 saved_control;
73 struct bfin_twi_regs __iomem *regs_base;
74};
75
76/* ******************** TWO-WIRE INTERFACE (TWI) MASKS ********************/
77/* TWI_CLKDIV Macros (Use: *pTWI_CLKDIV = CLKLOW(x)|CLKHI(y); ) */
78#define CLKLOW(x) ((x) & 0xFF) /* Periods Clock Is Held Low */
79#define CLKHI(y) (((y)&0xFF)<<0x8) /* Periods Before New Clock Low */
80
81/* TWI_PRESCALE Masks */
82#define PRESCALE 0x007F /* SCLKs Per Internal Time Reference (10MHz) */
83#define TWI_ENA 0x0080 /* TWI Enable */
84#define SCCB 0x0200 /* SCCB Compatibility Enable */
85
86/* TWI_SLAVE_CTL Masks */
87#define SEN 0x0001 /* Slave Enable */
88#define SADD_LEN 0x0002 /* Slave Address Length */
89#define STDVAL 0x0004 /* Slave Transmit Data Valid */
90#define NAK 0x0008 /* NAK Generated At Conclusion Of Transfer */
91#define GEN 0x0010 /* General Call Address Matching Enabled */
92
93/* TWI_SLAVE_STAT Masks */
94#define SDIR 0x0001 /* Slave Transfer Direction (RX/TX*) */
95#define GCALL 0x0002 /* General Call Indicator */
96
97/* TWI_MASTER_CTL Masks */
98#define MEN 0x0001 /* Master Mode Enable */
99#define MADD_LEN 0x0002 /* Master Address Length */
100#define MDIR 0x0004 /* Master Transmit Direction (RX/TX*) */
101#define FAST 0x0008 /* Use Fast Mode Timing Specs */
102#define STOP 0x0010 /* Issue Stop Condition */
103#define RSTART 0x0020 /* Repeat Start or Stop* At End Of Transfer */
104#define DCNT 0x3FC0 /* Data Bytes To Transfer */
105#define SDAOVR 0x4000 /* Serial Data Override */
106#define SCLOVR 0x8000 /* Serial Clock Override */
107
108/* TWI_MASTER_STAT Masks */
109#define MPROG 0x0001 /* Master Transfer In Progress */
110#define LOSTARB 0x0002 /* Lost Arbitration Indicator (Xfer Aborted) */
111#define ANAK 0x0004 /* Address Not Acknowledged */
112#define DNAK 0x0008 /* Data Not Acknowledged */
113#define BUFRDERR 0x0010 /* Buffer Read Error */
114#define BUFWRERR 0x0020 /* Buffer Write Error */
115#define SDASEN 0x0040 /* Serial Data Sense */
116#define SCLSEN 0x0080 /* Serial Clock Sense */
117#define BUSBUSY 0x0100 /* Bus Busy Indicator */
118
119/* TWI_INT_SRC and TWI_INT_ENABLE Masks */
120#define SINIT 0x0001 /* Slave Transfer Initiated */
121#define SCOMP 0x0002 /* Slave Transfer Complete */
122#define SERR 0x0004 /* Slave Transfer Error */
123#define SOVF 0x0008 /* Slave Overflow */
124#define MCOMP 0x0010 /* Master Transfer Complete */
125#define MERR 0x0020 /* Master Transfer Error */
126#define XMTSERV 0x0040 /* Transmit FIFO Service */
127#define RCVSERV 0x0080 /* Receive FIFO Service */
128
129/* TWI_FIFO_CTRL Masks */
130#define XMTFLUSH 0x0001 /* Transmit Buffer Flush */
131#define RCVFLUSH 0x0002 /* Receive Buffer Flush */
132#define XMTINTLEN 0x0004 /* Transmit Buffer Interrupt Length */
133#define RCVINTLEN 0x0008 /* Receive Buffer Interrupt Length */
134
135/* TWI_FIFO_STAT Masks */
136#define XMTSTAT 0x0003 /* Transmit FIFO Status */
137#define XMT_EMPTY 0x0000 /* Transmit FIFO Empty */
138#define XMT_HALF 0x0001 /* Transmit FIFO Has 1 Byte To Write */
139#define XMT_FULL 0x0003 /* Transmit FIFO Full (2 Bytes To Write) */
140
141#define RCVSTAT 0x000C /* Receive FIFO Status */
142#define RCV_EMPTY 0x0000 /* Receive FIFO Empty */
143#define RCV_HALF 0x0004 /* Receive FIFO Has 1 Byte To Read */
144#define RCV_FULL 0x000C /* Receive FIFO Full (2 Bytes To Read) */
13 145
14#define DEFINE_TWI_REG(reg_name, reg) \ 146#define DEFINE_TWI_REG(reg_name, reg) \
15static inline u16 read_##reg_name(struct bfin_twi_iface *iface) \ 147static inline u16 read_##reg_name(struct bfin_twi_iface *iface) \
diff --git a/arch/blackfin/kernel/debug-mmrs.c b/arch/blackfin/kernel/debug-mmrs.c
index e272bca93c64..f31ace221392 100644
--- a/arch/blackfin/kernel/debug-mmrs.c
+++ b/arch/blackfin/kernel/debug-mmrs.c
@@ -10,7 +10,6 @@
10#include <linux/fs.h> 10#include <linux/fs.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/i2c/bfin_twi.h>
14#include <linux/gpio.h> 13#include <linux/gpio.h>
15 14
16#include <asm/blackfin.h> 15#include <asm/blackfin.h>