hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-tegra-bpmp.c
....@@ -1,21 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * drivers/i2c/busses/i2c-tegra-bpmp.c
34 *
45 * Copyright (c) 2016 NVIDIA Corporation. All rights reserved.
56 *
67 * Author: Shardar Shariff Md <smohammed@nvidia.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms and conditions of the GNU General Public License,
10
- * version 2, as published by the Free Software Foundation.
11
- *
12
- * This program is distributed in the hope it will be useful, but WITHOUT
13
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15
- * more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
198 */
209
2110 #include <linux/err.h>
....@@ -207,7 +196,8 @@
207196
208197 static int tegra_bpmp_i2c_msg_xfer(struct tegra_bpmp_i2c *i2c,
209198 struct mrq_i2c_request *request,
210
- struct mrq_i2c_response *response)
199
+ struct mrq_i2c_response *response,
200
+ bool atomic)
211201 {
212202 struct tegra_bpmp_message msg;
213203 int err;
....@@ -222,7 +212,7 @@
222212 msg.rx.data = response;
223213 msg.rx.size = sizeof(*response);
224214
225
- if (irqs_disabled())
215
+ if (atomic)
226216 err = tegra_bpmp_transfer_atomic(i2c->bpmp, &msg);
227217 else
228218 err = tegra_bpmp_transfer(i2c->bpmp, &msg);
....@@ -230,8 +220,9 @@
230220 return err;
231221 }
232222
233
-static int tegra_bpmp_i2c_xfer(struct i2c_adapter *adapter,
234
- struct i2c_msg *msgs, int num)
223
+static int tegra_bpmp_i2c_xfer_common(struct i2c_adapter *adapter,
224
+ struct i2c_msg *msgs, int num,
225
+ bool atomic)
235226 {
236227 struct tegra_bpmp_i2c *i2c = i2c_get_adapdata(adapter);
237228 struct mrq_i2c_response response;
....@@ -253,7 +244,7 @@
253244 return err;
254245 }
255246
256
- err = tegra_bpmp_i2c_msg_xfer(i2c, &request, &response);
247
+ err = tegra_bpmp_i2c_msg_xfer(i2c, &request, &response, atomic);
257248 if (err < 0) {
258249 dev_err(i2c->dev, "failed to transfer message: %d\n", err);
259250 return err;
....@@ -268,6 +259,18 @@
268259 return num;
269260 }
270261
262
+static int tegra_bpmp_i2c_xfer(struct i2c_adapter *adapter,
263
+ struct i2c_msg *msgs, int num)
264
+{
265
+ return tegra_bpmp_i2c_xfer_common(adapter, msgs, num, false);
266
+}
267
+
268
+static int tegra_bpmp_i2c_xfer_atomic(struct i2c_adapter *adapter,
269
+ struct i2c_msg *msgs, int num)
270
+{
271
+ return tegra_bpmp_i2c_xfer_common(adapter, msgs, num, true);
272
+}
273
+
271274 static u32 tegra_bpmp_i2c_func(struct i2c_adapter *adapter)
272275 {
273276 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |
....@@ -276,6 +279,7 @@
276279
277280 static const struct i2c_algorithm tegra_bpmp_i2c_algo = {
278281 .master_xfer = tegra_bpmp_i2c_xfer,
282
+ .master_xfer_atomic = tegra_bpmp_i2c_xfer_atomic,
279283 .functionality = tegra_bpmp_i2c_func,
280284 };
281285