]> Git Repo - linux.git/blob - drivers/i2c/busses/i2c-viai2c-common.h
Linux 6.14-rc3
[linux.git] / drivers / i2c / busses / i2c-viai2c-common.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef __I2C_VIAI2C_COMMON_H_
3 #define __I2C_VIAI2C_COMMON_H_
4
5 #include <linux/delay.h>
6 #include <linux/err.h>
7 #include <linux/i2c.h>
8 #include <linux/interrupt.h>
9 #include <linux/io.h>
10 #include <linux/module.h>
11 #include <linux/of_irq.h>
12 #include <linux/platform_device.h>
13
14 /* REG_CR Bit fields */
15 #define VIAI2C_REG_CR           0x00
16 #define VIAI2C_CR_ENABLE                BIT(0)
17 #define VIAI2C_CR_RX_END                BIT(1)
18 #define VIAI2C_CR_TX_END                BIT(2)
19 #define VIAI2C_CR_CPU_RDY               BIT(3)
20 #define VIAI2C_CR_END_MASK              GENMASK(2, 1)
21
22 /* REG_TCR Bit fields */
23 #define VIAI2C_REG_TCR          0x02
24 #define VIAI2C_TCR_HS_MODE              BIT(13)
25 #define VIAI2C_TCR_READ                 BIT(14)
26 #define VIAI2C_TCR_FAST                 BIT(15)
27 #define VIAI2C_TCR_ADDR_MASK            GENMASK(6, 0)
28
29 /* REG_CSR Bit fields */
30 #define VIAI2C_REG_CSR          0x04
31 #define VIAI2C_CSR_RCV_NOT_ACK          BIT(0)
32 #define VIAI2C_CSR_RCV_ACK_MASK         BIT(0)
33 #define VIAI2C_CSR_READY_MASK           BIT(1)
34
35 /* REG_ISR Bit fields */
36 #define VIAI2C_REG_ISR          0x06
37 #define VIAI2C_ISR_NACK_ADDR            BIT(0)
38 #define VIAI2C_ISR_BYTE_END             BIT(1)
39 #define VIAI2C_ISR_SCL_TIMEOUT          BIT(2)
40 #define VIAI2C_ISR_MASK_ALL             GENMASK(2, 0)
41
42 /* REG_IMR Bit fields */
43 #define VIAI2C_REG_IMR          0x08
44 #define VIAI2C_IMR_BYTE                 BIT(1)
45 #define VIAI2C_IMR_ENABLE_ALL           GENMASK(2, 0)
46
47 #define VIAI2C_REG_CDR          0x0A
48 #define VIAI2C_REG_TR           0x0C
49 #define VIAI2C_REG_MCR          0x0E
50
51 #define VIAI2C_TIMEOUT          (msecs_to_jiffies(1000))
52
53 enum {
54         VIAI2C_PLAT_WMT,
55         VIAI2C_PLAT_ZHAOXIN
56 };
57
58 enum {
59         VIAI2C_BYTE_MODE,
60         VIAI2C_FIFO_MODE
61 };
62
63 struct viai2c {
64         struct i2c_adapter      adapter;
65         struct completion       complete;
66         struct device           *dev;
67         void __iomem            *base;
68         struct clk              *clk;
69         u16                     tcr;
70         int                     irq;
71         u16                     xfered_len;
72         struct i2c_msg          *msg;
73         int                     ret;
74         bool                    last;
75         unsigned int            mode;
76         unsigned int            platform;
77         void                    *pltfm_priv;
78 };
79
80 int viai2c_wait_bus_not_busy(struct viai2c *i2c);
81 int viai2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num);
82 int viai2c_init(struct platform_device *pdev, struct viai2c **pi2c, int plat);
83 int viai2c_irq_xfer(struct viai2c *i2c);
84
85 #endif
This page took 0.03479 seconds and 4 git commands to generate.