coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
i2c.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _QUARK_I2C_H_
4 #define _QUARK_I2C_H_
5 
6 #include <stdint.h>
7 
8 typedef volatile struct _I2C_REGS {
9  volatile uint32_t ic_con; /* 00: Control Register */
10  volatile uint32_t ic_tar; /* 04: Master Target Address */
12  volatile uint32_t ic_data_cmd; /* 10: Data Buffer & Command */
13  uint32_t ic_ss_scl_hcnt; /* 14: Standard Speed Clock SCL High Count */
14  uint32_t ic_ss_scl_lcnt; /* 18: Standard Speed Clock SCL Low Count */
15  uint32_t ic_fs_scl_hcnt; /* 1c: Fast Speed Clock SCL High Count */
16  uint32_t ic_fs_scl_lcnt; /* 20: Fast Speed Clock SCL Low Count */
18  volatile uint32_t ic_intr_stat; /* 2c: Interrupt Status */
19  uint32_t ic_intr_mask; /* 30: Interrupt Mask */
20  uint32_t ic_raw_intr_stat; /* 34: Raw Interrupt Status */
21  uint32_t ic_rx_tl; /* 38: Receive FIFO Threshold Level */
22  uint32_t ic_tx_tl; /* 3c: Transmit FIFO Threshold Level */
23  uint32_t ic_clr_intr; /* 40: Clear Combined/Individual Interrupt */
24  uint32_t ic_clr_rx_under; /* 44: Clear RX_UNDER Interrupt */
25  uint32_t ic_clr_rx_over; /* 48: Clear RX_OVER Interrupt */
26  uint32_t ic_clr_tx_over; /* 4c: Clear TX_OVER Interrupt */
27  uint32_t ic_clr_rd_req; /* 50: Clear RD_REQ Interrupt */
28  uint32_t ic_clr_tx_abrt; /* 54: Clear TX_ABRT Interrupt */
30  uint32_t ic_clr_activity; /* 5c: Clear ACTIVITY Interrupt */
31  uint32_t ic_clr_stop_det; /* 60: Clear STOP_DET Interrupt */
32  uint32_t ic_clr_start_det; /* 64: Clear START_DET Interrupt */
34  volatile uint32_t ic_enable; /* 6c: Enable */
35  volatile uint32_t ic_status; /* 70: Status */
36  uint32_t ic_txflr; /* 74: Transmit FIFO Level */
37  uint32_t ic_rxflr; /* 78: Receive FIFO Level */
38  uint32_t ic_sda_hold; /* 7c: SDA Hold */
39  volatile uint32_t ic_tx_abrt_source; /* 80: Transmit Abort Source */
41  volatile uint32_t ic_enable_status; /* 9c: Enable Status */
42  uint32_t ic_fs_spklen; /* a0: SS and FS Spike Suppression Limit */
44 
45 #define IC_CON offsetof(I2C_REGS, ic_con)
46 #define IC_TAR offsetof(I2C_REGS, ic_tar)
47 #define IC_DATA_CMD offsetof(I2C_REGS, ic_data_cmd)
48 #define IC_SS_SCL_HCNT offsetof(I2C_REGS, ic_ss_scl_hcnt)
49 #define IC_SS_SCL_LCNT offsetof(I2C_REGS, ic_ss_scl_lcnt)
50 #define IC_FS_SCL_HCNT offsetof(I2C_REGS, ic_fs_scl_hcnt)
51 #define IC_FS_SCL_LCNT offsetof(I2C_REGS, ic_fs_scl_lcnt)
52 #define IC_INTR_STAT offsetof(I2C_REGS, ic_intr_stat)
53 #define IC_INTR_MASK offsetof(I2C_REGS, ic_intr_mask)
54 #define IC_RAW_INTR_STAT offsetof(I2C_REGS, ic_raw_intr_stat)
55 #define IC_RX_TL offsetof(I2C_REGS, ic_rx_tl)
56 #define IC_TX_TL offsetof(I2C_REGS, ic_tx_tl)
57 #define IC_CLR_INTR offsetof(I2C_REGS, ic_clr_intr)
58 #define IC_CLR_RX_UNDER offsetof(I2C_REGS, ic_clr_rx_under)
59 #define IC_CLR_RX_OVER offsetof(I2C_REGS, ic_clr_rx_over)
60 #define IC_CLR_TX_OVER offsetof(I2C_REGS, ic_clr_tx_over)
61 #define IC_CLR_RD_REQ offsetof(I2C_REGS, ic_clr_rd_req)
62 #define IC_CLR_TX_ABRT offsetof(I2C_REGS, ic_clr_tx_abrt)
63 #define IC_CLR_ACTIVITY offsetof(I2C_REGS, ic_clr_activity)
64 #define IC_CLR_STOP_DET offsetof(I2C_REGS, ic_clr_stop_det)
65 #define IC_CLR_START_DET offsetof(I2C_REGS, ic_clr_start_det)
66 #define IC_ENABLE offsetof(I2C_REGS, ic_enable)
67 #define IC_STATUS offsetof(I2C_REGS, ic_status)
68 #define IC_TXFLR offsetof(I2C_REGS, ic_txflr)
69 #define IC_RXFLR offsetof(I2C_REGS, ic_rxflr)
70 #define IC_SDA_HOLD offsetof(I2C_REGS, ic_sda_hold)
71 #define IC_TX_ABRT_SOURCE offsetof(I2C_REGS, ic_tx_abrt_source)
72 #define IC_ENABLE_STATUS offsetof(I2C_REGS, ic_enable_status)
73 #define IC_FS_SPKLEN offsetof(I2C_REGS, ic_fs_spklen)
74 
75 /* 0x00: ic_con */
76 #define IC_CON_RESTART_EN 0x00000020 /* Enable start/restart */
77 #define IC_CON_10B 0x00000010 /* 10-bit addressing */
78 #define IC_CON_7B 0 /* 7-bit addressing */
79 #define IC_CON_SPEED 0x00000006 /* I2C bus speed */
80 #define IC_CON_SPEED_400_KHz 0x00000004 /* Fast mode */
81 #define IC_CON_SPEED_100_KHz 0x00000002 /* Standard mode */
82 #define IC_CON_MASTER_MODE 0x00000001 /* Enable master mode */
83 
84 /* 0x10: ic_data_cmd */
85 #define IC_DATA_CMD_RESTART 0x00000400 /* Send restart before byte */
86 #define IC_DATA_CMD_STOP 0x00000200 /* Send stop after byte */
87 #define IC_DATA_CMD_CMD 0x00000100 /* Type of transaction */
88 #define IC_DATA_CMD_READ IC_DATA_CMD_CMD
89 #define IC_DATA_CMD_WRITE 0
90 #define IC_DATA_CMD_DATA 0x000000ff /* Data byte */
91 
92 /* 0x2c: ic_intr_stat
93  * 0x30: ic_intr_mask
94  * 0x34: ic_raw_intr_stat
95  */
96 #define IC_INTR_START_DET 0x00000400 /* Start bit detected */
97 #define IC_INTR_STOP_DET 0x00000200 /* Stop bit detected */
98 #define IC_INTR_ACTIVITY 0x00000100 /* Activity detected */
99 #define IC_INTR_TX_ABRT 0x00000040 /* Transmit abort */
100 #define IC_INTR_RD_REQ 0x00000020 /* Read request */
101 #define IC_INTR_TX_EMPTY 0x00000010 /* TX FIFO is empty */
102 #define IC_INTR_TX_OVER 0x00000008 /* TX FIFO overflow */
103 #define IC_INTR_RX_FULL 0x00000004 /* Receive FIFO is full */
104 #define IC_INTR_RX_OVER 0x00000002 /* Receive FIFO overflow */
105 #define IC_INTR_RX_UNDER 0x00000001 /* Receive FIFO underflow */
106 
107 /* 0x6c: ic_enable
108  * 0x9c: ic_enable_status
109  */
110 #define IC_ENABLE_CONTROLLER 0x00000001 /* Enable the I2C controller */
111 
112 /* 0x70: ic_status */
113 #define IC_STATUS_MST_ACTIVITY 0x00000020 /* Master FSM activity */
114 #define IC_STATUS_RFF 0x00000010 /* Receive FIFO completely full */
115 #define IC_STATUS_RFNE 0x00000008 /* Receive FIFO not empty */
116 #define IC_STATUS_TFE 0x00000004 /* Transmit FIFO completely empty */
117 #define IC_STATUS_TFNF 0x00000002 /* Transmit FIFO not full */
118 #define IC_STATUS_ACTIVITY 0x00000001 /* Activity */
119 
120 #endif /* _QUARK_I2C_H_ */
volatile struct _I2C_REGS I2C_REGS
unsigned int uint32_t
Definition: stdint.h:14
Definition: i2c.h:8
uint32_t ic_clr_start_det
Definition: i2c.h:32
volatile uint32_t ic_tar
Definition: i2c.h:10
uint32_t reserved_24[2]
Definition: i2c.h:17
volatile uint32_t ic_data_cmd
Definition: i2c.h:12
uint32_t reserved_68
Definition: i2c.h:33
uint32_t ic_fs_scl_lcnt
Definition: i2c.h:16
uint32_t ic_clr_stop_det
Definition: i2c.h:31
volatile uint32_t ic_enable_status
Definition: i2c.h:41
uint32_t ic_tx_tl
Definition: i2c.h:22
uint32_t ic_ss_scl_lcnt
Definition: i2c.h:14
volatile uint32_t ic_tx_abrt_source
Definition: i2c.h:39
volatile uint32_t ic_status
Definition: i2c.h:35
uint32_t ic_clr_tx_abrt
Definition: i2c.h:28
uint32_t ic_ss_scl_hcnt
Definition: i2c.h:13
uint32_t ic_fs_scl_hcnt
Definition: i2c.h:15
uint32_t ic_raw_intr_stat
Definition: i2c.h:20
uint32_t reserved_08[2]
Definition: i2c.h:11
uint32_t reserved_58
Definition: i2c.h:29
uint32_t ic_rx_tl
Definition: i2c.h:21
uint32_t reserved_84[6]
Definition: i2c.h:40
uint32_t ic_txflr
Definition: i2c.h:36
uint32_t ic_sda_hold
Definition: i2c.h:38
uint32_t ic_fs_spklen
Definition: i2c.h:42
volatile uint32_t ic_enable
Definition: i2c.h:34
uint32_t ic_intr_mask
Definition: i2c.h:19
uint32_t ic_clr_rx_over
Definition: i2c.h:25
volatile uint32_t ic_con
Definition: i2c.h:9
volatile uint32_t ic_intr_stat
Definition: i2c.h:18
uint32_t ic_clr_activity
Definition: i2c.h:30
uint32_t ic_clr_rd_req
Definition: i2c.h:27
uint32_t ic_clr_intr
Definition: i2c.h:23
uint32_t ic_clr_rx_under
Definition: i2c.h:24
uint32_t ic_rxflr
Definition: i2c.h:37
uint32_t ic_clr_tx_over
Definition: i2c.h:26