summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorSivaram Nair <sivaramn@nvidia.com>2016-12-06 15:20:07 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2016-12-20 18:15:34 -0500
commit92b6bc1597aec785e5586be19c2f573879b18cc9 (patch)
tree047c04ed1ba3be6e36eab6e6d569c12a876ffcab /drivers/i2c
parentafd02ff40634a282f8b36f8a228263b7060d2179 (diff)
i2c: tegra: use bpmp defines from ABI header
Bug 200257382 Change-Id: I0083b29bbcbeba9b8c51c84374ada6fc6b44044f Signed-off-by: Sivaram Nair <sivaramn@nvidia.com> Reviewed-on: http://git-master/r/1268042 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Timo Alho <talho@nvidia.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-bpmp-tegra.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/drivers/i2c/busses/i2c-bpmp-tegra.c b/drivers/i2c/busses/i2c-bpmp-tegra.c
index a2d84a398..eb4028830 100644
--- a/drivers/i2c/busses/i2c-bpmp-tegra.c
+++ b/drivers/i2c/busses/i2c-bpmp-tegra.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * drivers/i2c/busses/i2c-bpmp-tegra.c 2 * Copyright (C) 2015-2016 NVIDIA Corporation. All rights reserved.
3 *
4 * Copyright (C) 2015 NVIDIA Corporation. All rights reserved.
5 * 3 *
6 * This software is licensed under the terms of the GNU General Public 4 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and 5 * License version 2, as published by the Free Software Foundation, and
@@ -38,22 +36,12 @@
38#include <linux/pinctrl/consumer.h> 36#include <linux/pinctrl/consumer.h>
39#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
40#include <soc/tegra/tegra_bpmp.h> 38#include <soc/tegra/tegra_bpmp.h>
39#include <soc/tegra/bpmp_abi.h>
41#include <linux/i2c-bpmp-tegra.h> 40#include <linux/i2c-bpmp-tegra.h>
42#include <linux/bpmp_mrq_i2c.h>
43
44#include <asm/unaligned.h> 41#include <asm/unaligned.h>
45 42
46#define TEGRA_I2C_TIMEOUT (msecs_to_jiffies(1000)) 43#define TEGRA_I2C_TIMEOUT (msecs_to_jiffies(1000))
47 44
48#define SERIALI2C_TEN 0x0010
49#define SERIALI2C_RD 0x0001
50#define SERIALI2C_STOP 0x8000
51#define SERIALI2C_NOSTART 0x4000
52#define SERIALI2C_REV_DIR_ADDR 0x2000
53#define SERIALI2C_IGNORE_NAK 0x1000
54#define SERIALI2C_NO_RD_ACK 0x0800
55#define SERIALI2C_RECV_LEN 0x0400
56
57static int seriali2c_xlate_flags(u16 *xlated_flags, u16 linux_flags) 45static int seriali2c_xlate_flags(u16 *xlated_flags, u16 linux_flags)
58{ 46{
59 u16 ret = 0; 47 u16 ret = 0;
@@ -199,10 +187,9 @@ struct tegra_bpmp_i2c_dev {
199 u32 bpmp_adapter_id; 187 u32 bpmp_adapter_id;
200}; 188};
201 189
202 190static int tegra_bpmp_i2c(struct mrq_i2c_request *in,
203static int tegra_bpmp_i2c(struct mrq_i2c_data_in *in, 191 struct mrq_i2c_response *out,
204 struct mrq_i2c_data_out *out, 192 struct tegra_bpmp_i2c_dev *i2c_dev)
205 struct tegra_bpmp_i2c_dev *i2c_dev)
206{ 193{
207 unsigned long flags; 194 unsigned long flags;
208 int ret; 195 int ret;
@@ -223,22 +210,22 @@ static int tegra_bpmp_i2c(struct mrq_i2c_data_in *in,
223 in, sizeof(*in), out, sizeof(*out)); 210 in, sizeof(*in), out, sizeof(*out));
224} 211}
225 212
226static int tegra_bpmp_i2c_req(u32 adapter, struct mrq_i2c_data_in *in, 213static int tegra_bpmp_i2c_req(u32 adapter, struct mrq_i2c_request *in,
227 int data_in_size, struct mrq_i2c_data_out *out, 214 int data_in_size, struct mrq_i2c_response *out,
228 struct tegra_bpmp_i2c_dev *i2c_dev) 215 struct tegra_bpmp_i2c_dev *i2c_dev)
229{ 216{
230 int r; 217 int r;
231 218
232 in->req = MRQ_I2C_DATA_IN_REQ_I2C_REQ; 219 in->cmd = CMD_I2C_XFER;
233 in->data.i2c_req.adapter = adapter; 220 in->xfer.bus_id = adapter;
234 in->data.i2c_req.data_in_size = data_in_size; 221 in->xfer.data_size = data_in_size;
235 r = tegra_bpmp_i2c(in, out, i2c_dev); 222 r = tegra_bpmp_i2c(in, out, i2c_dev);
236 if (r) { 223 if (r) {
237 WARN_ON(r > 0); 224 WARN_ON(r > 0);
238 return r; 225 return r;
239 } 226 }
240 227
241 return (int)out->data.i2c_req.data_size; 228 return (int)out->xfer.data_size;
242} 229}
243 230
244struct tegra_bpmp_i2c_chipdata { 231struct tegra_bpmp_i2c_chipdata {
@@ -296,8 +283,8 @@ static int tegra_bpmp_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
296 int num) 283 int num)
297{ 284{
298 struct tegra_bpmp_i2c_dev *i2c_dev = i2c_get_adapdata(adap); 285 struct tegra_bpmp_i2c_dev *i2c_dev = i2c_get_adapdata(adap);
299 struct mrq_i2c_data_in in; 286 struct mrq_i2c_request in;
300 struct mrq_i2c_data_out out; 287 struct mrq_i2c_response out;
301 int ret = 0; 288 int ret = 0;
302 int size; 289 int size;
303 290
@@ -308,7 +295,7 @@ static int tegra_bpmp_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
308 return -EINVAL; 295 return -EINVAL;
309 } 296 }
310 297
311 size = serialize_i2c(in.data.i2c_req.data_in_buf, 298 size = serialize_i2c(in.xfer.data_buf,
312 TEGRA_I2C_IPC_MAX_IN_BUF_SIZE, 299 TEGRA_I2C_IPC_MAX_IN_BUF_SIZE,
313 msgs, num); 300 msgs, num);
314 if (size < 0) { 301 if (size < 0) {
@@ -326,7 +313,7 @@ static int tegra_bpmp_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
326 return ret; 313 return ret;
327 } 314 }
328 315
329 ret = deserialize_i2c(out.data.i2c_req.data_out_buf, ret, msgs, num); 316 ret = deserialize_i2c(out.xfer.data_buf, ret, msgs, num);
330 if (ret < 0) { 317 if (ret < 0) {
331 dev_err(&i2c_dev->adapter.dev, "deserialize_i2c ret %d\n", 318 dev_err(&i2c_dev->adapter.dev, "deserialize_i2c ret %d\n",
332 ret); 319 ret);