This source file includes following definitions.
- amd_mp2_pm_runtime_get
- amd_mp2_pm_runtime_put
1
2
3
4
5
6
7
8
9 #ifndef I2C_AMD_PCI_MP2_H
10 #define I2C_AMD_PCI_MP2_H
11
12 #include <linux/i2c.h>
13 #include <linux/pci.h>
14 #include <linux/pm_runtime.h>
15
16 #define PCI_DEVICE_ID_AMD_MP2 0x15E6
17
18 struct amd_i2c_common;
19 struct amd_mp2_dev;
20
21 enum {
22
23 AMD_C2P_MSG0 = 0x10500,
24 AMD_C2P_MSG1 = 0x10504,
25 AMD_C2P_MSG2 = 0x10508,
26 AMD_C2P_MSG3 = 0x1050c,
27 AMD_C2P_MSG4 = 0x10510,
28 AMD_C2P_MSG5 = 0x10514,
29 AMD_C2P_MSG6 = 0x10518,
30 AMD_C2P_MSG7 = 0x1051c,
31 AMD_C2P_MSG8 = 0x10520,
32 AMD_C2P_MSG9 = 0x10524,
33
34
35 AMD_P2C_MSG0 = 0x10680,
36 AMD_P2C_MSG1 = 0x10684,
37 AMD_P2C_MSG2 = 0x10688,
38 AMD_P2C_MSG3 = 0x1068C,
39 AMD_P2C_MSG_INTEN = 0x10690,
40 AMD_P2C_MSG_INTSTS = 0x10694,
41 };
42
43
44
45 #define i2c_none (-1)
46 enum i2c_cmd {
47 i2c_read = 0,
48 i2c_write,
49 i2c_enable,
50 i2c_disable,
51 number_of_sensor_discovered,
52 is_mp2_active,
53 invalid_cmd = 0xF,
54 };
55
56 enum speed_enum {
57 speed100k = 0,
58 speed400k = 1,
59 speed1000k = 2,
60 speed1400k = 3,
61 speed3400k = 4
62 };
63
64 enum mem_type {
65 use_dram = 0,
66 use_c2pmsg = 1,
67 };
68
69
70
71
72
73
74
75
76
77
78 union i2c_cmd_base {
79 u32 ul;
80 struct {
81 enum i2c_cmd i2c_cmd : 4;
82 u8 bus_id : 4;
83 u32 slave_addr : 8;
84 u32 length : 12;
85 enum speed_enum i2c_speed : 3;
86 enum mem_type mem_type : 1;
87 } s;
88 };
89
90 enum response_type {
91 invalid_response = 0,
92 command_success = 1,
93 command_failed = 2,
94 };
95
96 enum status_type {
97 i2c_readcomplete_event = 0,
98 i2c_readfail_event = 1,
99 i2c_writecomplete_event = 2,
100 i2c_writefail_event = 3,
101 i2c_busenable_complete = 4,
102 i2c_busenable_failed = 5,
103 i2c_busdisable_complete = 6,
104 i2c_busdisable_failed = 7,
105 invalid_data_length = 8,
106 invalid_slave_address = 9,
107 invalid_i2cbus_id = 10,
108 invalid_dram_addr = 11,
109 invalid_command = 12,
110 mp2_active = 13,
111 numberof_sensors_discovered_resp = 14,
112 i2c_bus_notinitialized
113 };
114
115
116
117
118
119
120
121
122
123
124 union i2c_event {
125 u32 ul;
126 struct {
127 enum response_type response : 2;
128 enum status_type status : 5;
129 enum mem_type mem_type : 1;
130 u8 bus_id : 4;
131 u32 length : 12;
132 u32 slave_addr : 8;
133 } r;
134 };
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152 struct amd_i2c_common {
153 union i2c_event eventval;
154 struct amd_mp2_dev *mp2_dev;
155 struct i2c_msg *msg;
156 void (*cmd_completion)(struct amd_i2c_common *i2c_common);
157 enum i2c_cmd reqcmd;
158 u8 cmd_success;
159 u8 bus_id;
160 enum speed_enum i2c_speed;
161 u8 *dma_buf;
162 dma_addr_t dma_addr;
163 #ifdef CONFIG_PM
164 int (*suspend)(struct amd_i2c_common *i2c_common);
165 int (*resume)(struct amd_i2c_common *i2c_common);
166 #endif
167 };
168
169
170
171
172
173
174
175
176
177
178
179 struct amd_mp2_dev {
180 struct pci_dev *pci_dev;
181 struct amd_i2c_common *busses[2];
182 void __iomem *mmio;
183 struct mutex c2p_lock;
184 u8 c2p_lock_busid;
185 unsigned int probed;
186 };
187
188 #define ndev_pdev(ndev) ((ndev)->pci_dev)
189 #define ndev_name(ndev) pci_name(ndev_pdev(ndev))
190 #define ndev_dev(ndev) (&ndev_pdev(ndev)->dev)
191 #define work_amd_i2c_common(__work) \
192 container_of(__work, struct amd_i2c_common, work.work)
193
194
195
196 int amd_mp2_rw(struct amd_i2c_common *i2c_common, enum i2c_cmd reqcmd);
197 int amd_mp2_bus_enable_set(struct amd_i2c_common *i2c_common, bool enable);
198
199 void amd_mp2_process_event(struct amd_i2c_common *i2c_common);
200
201 void amd_mp2_rw_timeout(struct amd_i2c_common *i2c_common);
202
203 int amd_mp2_register_cb(struct amd_i2c_common *i2c_common);
204 int amd_mp2_unregister_cb(struct amd_i2c_common *i2c_common);
205
206 struct amd_mp2_dev *amd_mp2_find_device(void);
207
208 static inline void amd_mp2_pm_runtime_get(struct amd_mp2_dev *mp2_dev)
209 {
210 pm_runtime_get_sync(&mp2_dev->pci_dev->dev);
211 }
212
213 static inline void amd_mp2_pm_runtime_put(struct amd_mp2_dev *mp2_dev)
214 {
215 pm_runtime_mark_last_busy(&mp2_dev->pci_dev->dev);
216 pm_runtime_put_autosuspend(&mp2_dev->pci_dev->dev);
217 }
218
219 #endif