i2c.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /* Copyright (c) 2016-2018 Mellanox Technologies. All rights reserved */
  3. #include <linux/err.h>
  4. #include <linux/i2c.h>
  5. #include <linux/init.h>
  6. #include <linux/jiffies.h>
  7. #include <linux/kernel.h>
  8. #include <linux/mutex.h>
  9. #include <linux/module.h>
  10. #include <linux/mod_devicetable.h>
  11. #include <linux/slab.h>
  12. #include "cmd.h"
  13. #include "core.h"
  14. #include "i2c.h"
  15. #define MLXSW_I2C_CIR2_BASE 0x72000
  16. #define MLXSW_I2C_CIR_STATUS_OFF 0x18
  17. #define MLXSW_I2C_CIR2_OFF_STATUS (MLXSW_I2C_CIR2_BASE + \
  18. MLXSW_I2C_CIR_STATUS_OFF)
  19. #define MLXSW_I2C_OPMOD_SHIFT 12
  20. #define MLXSW_I2C_GO_BIT_SHIFT 23
  21. #define MLXSW_I2C_CIR_CTRL_STATUS_SHIFT 24
  22. #define MLXSW_I2C_GO_BIT BIT(MLXSW_I2C_GO_BIT_SHIFT)
  23. #define MLXSW_I2C_GO_OPMODE BIT(MLXSW_I2C_OPMOD_SHIFT)
  24. #define MLXSW_I2C_SET_IMM_CMD (MLXSW_I2C_GO_OPMODE | \
  25. MLXSW_CMD_OPCODE_QUERY_FW)
  26. #define MLXSW_I2C_PUSH_IMM_CMD (MLXSW_I2C_GO_BIT | \
  27. MLXSW_I2C_SET_IMM_CMD)
  28. #define MLXSW_I2C_SET_CMD (MLXSW_CMD_OPCODE_ACCESS_REG)
  29. #define MLXSW_I2C_PUSH_CMD (MLXSW_I2C_GO_BIT | MLXSW_I2C_SET_CMD)
  30. #define MLXSW_I2C_TLV_HDR_SIZE 0x10
  31. #define MLXSW_I2C_ADDR_WIDTH 4
  32. #define MLXSW_I2C_PUSH_CMD_SIZE (MLXSW_I2C_ADDR_WIDTH + 4)
  33. #define MLXSW_I2C_READ_SEMA_SIZE 4
  34. #define MLXSW_I2C_PREP_SIZE (MLXSW_I2C_ADDR_WIDTH + 28)
  35. #define MLXSW_I2C_MBOX_SIZE 20
  36. #define MLXSW_I2C_MBOX_OUT_PARAM_OFF 12
  37. #define MLXSW_I2C_MAX_BUFF_SIZE 32
  38. #define MLXSW_I2C_MBOX_OFFSET_BITS 20
  39. #define MLXSW_I2C_MBOX_SIZE_BITS 12
  40. #define MLXSW_I2C_ADDR_BUF_SIZE 4
  41. #define MLXSW_I2C_BLK_MAX 32
  42. #define MLXSW_I2C_RETRY 5
  43. #define MLXSW_I2C_TIMEOUT_MSECS 5000
  44. /**
  45. * struct mlxsw_i2c - device private data:
  46. * @cmd.mb_size_in: input mailbox size;
  47. * @cmd.mb_off_in: input mailbox offset in register space;
  48. * @cmd.mb_size_out: output mailbox size;
  49. * @cmd.mb_off_out: output mailbox offset in register space;
  50. * @cmd.lock: command execution lock;
  51. * @dev: I2C device;
  52. * @core: switch core pointer;
  53. * @bus_info: bus info block;
  54. */
  55. struct mlxsw_i2c {
  56. struct {
  57. u32 mb_size_in;
  58. u32 mb_off_in;
  59. u32 mb_size_out;
  60. u32 mb_off_out;
  61. struct mutex lock;
  62. } cmd;
  63. struct device *dev;
  64. struct mlxsw_core *core;
  65. struct mlxsw_bus_info bus_info;
  66. };
  67. #define MLXSW_I2C_READ_MSG(_client, _addr_buf, _buf, _len) { \
  68. { .addr = (_client)->addr, \
  69. .buf = (_addr_buf), \
  70. .len = MLXSW_I2C_ADDR_BUF_SIZE, \
  71. .flags = 0 }, \
  72. { .addr = (_client)->addr, \
  73. .buf = (_buf), \
  74. .len = (_len), \
  75. .flags = I2C_M_RD } }
  76. #define MLXSW_I2C_WRITE_MSG(_client, _buf, _len) \
  77. { .addr = (_client)->addr, \
  78. .buf = (u8 *)(_buf), \
  79. .len = (_len), \
  80. .flags = 0 }
  81. /* Routine converts in and out mail boxes offset and size. */
  82. static inline void
  83. mlxsw_i2c_convert_mbox(struct mlxsw_i2c *mlxsw_i2c, u8 *buf)
  84. {
  85. u32 tmp;
  86. /* Local in/out mailboxes: 20 bits for offset, 12 for size */
  87. tmp = be32_to_cpup((__be32 *) buf);
  88. mlxsw_i2c->cmd.mb_off_in = tmp &
  89. GENMASK(MLXSW_I2C_MBOX_OFFSET_BITS - 1, 0);
  90. mlxsw_i2c->cmd.mb_size_in = (tmp & GENMASK(31,
  91. MLXSW_I2C_MBOX_OFFSET_BITS)) >>
  92. MLXSW_I2C_MBOX_OFFSET_BITS;
  93. tmp = be32_to_cpup((__be32 *) (buf + MLXSW_I2C_ADDR_WIDTH));
  94. mlxsw_i2c->cmd.mb_off_out = tmp &
  95. GENMASK(MLXSW_I2C_MBOX_OFFSET_BITS - 1, 0);
  96. mlxsw_i2c->cmd.mb_size_out = (tmp & GENMASK(31,
  97. MLXSW_I2C_MBOX_OFFSET_BITS)) >>
  98. MLXSW_I2C_MBOX_OFFSET_BITS;
  99. }
  100. /* Routine obtains register size from mail box buffer. */
  101. static inline int mlxsw_i2c_get_reg_size(u8 *in_mbox)
  102. {
  103. u16 tmp = be16_to_cpup((__be16 *) (in_mbox + MLXSW_I2C_TLV_HDR_SIZE));
  104. return (tmp & 0x7ff) * 4 + MLXSW_I2C_TLV_HDR_SIZE;
  105. }
  106. /* Routine sets I2C device internal offset in the transaction buffer. */
  107. static inline void mlxsw_i2c_set_slave_addr(u8 *buf, u32 off)
  108. {
  109. __be32 *val = (__be32 *) buf;
  110. *val = htonl(off);
  111. }
  112. /* Routine waits until go bit is cleared. */
  113. static int mlxsw_i2c_wait_go_bit(struct i2c_client *client,
  114. struct mlxsw_i2c *mlxsw_i2c, u8 *p_status)
  115. {
  116. u8 addr_buf[MLXSW_I2C_ADDR_BUF_SIZE];
  117. u8 buf[MLXSW_I2C_READ_SEMA_SIZE];
  118. int len = MLXSW_I2C_READ_SEMA_SIZE;
  119. struct i2c_msg read_sema[] =
  120. MLXSW_I2C_READ_MSG(client, addr_buf, buf, len);
  121. bool wait_done = false;
  122. unsigned long end;
  123. int i = 0, err;
  124. mlxsw_i2c_set_slave_addr(addr_buf, MLXSW_I2C_CIR2_OFF_STATUS);
  125. end = jiffies + msecs_to_jiffies(MLXSW_I2C_TIMEOUT_MSECS);
  126. do {
  127. u32 ctrl;
  128. err = i2c_transfer(client->adapter, read_sema,
  129. ARRAY_SIZE(read_sema));
  130. ctrl = be32_to_cpu(*(__be32 *) buf);
  131. if (err == ARRAY_SIZE(read_sema)) {
  132. if (!(ctrl & MLXSW_I2C_GO_BIT)) {
  133. wait_done = true;
  134. *p_status = ctrl >>
  135. MLXSW_I2C_CIR_CTRL_STATUS_SHIFT;
  136. break;
  137. }
  138. }
  139. cond_resched();
  140. } while ((time_before(jiffies, end)) || (i++ < MLXSW_I2C_RETRY));
  141. if (wait_done) {
  142. if (*p_status)
  143. err = -EIO;
  144. } else {
  145. return -ETIMEDOUT;
  146. }
  147. return err > 0 ? 0 : err;
  148. }
  149. /* Routine posts a command to ASIC though mail box. */
  150. static int mlxsw_i2c_write_cmd(struct i2c_client *client,
  151. struct mlxsw_i2c *mlxsw_i2c,
  152. int immediate)
  153. {
  154. __be32 push_cmd_buf[MLXSW_I2C_PUSH_CMD_SIZE / 4] = {
  155. 0, cpu_to_be32(MLXSW_I2C_PUSH_IMM_CMD)
  156. };
  157. __be32 prep_cmd_buf[MLXSW_I2C_PREP_SIZE / 4] = {
  158. 0, 0, 0, 0, 0, 0,
  159. cpu_to_be32(client->adapter->nr & 0xffff),
  160. cpu_to_be32(MLXSW_I2C_SET_IMM_CMD)
  161. };
  162. struct i2c_msg push_cmd =
  163. MLXSW_I2C_WRITE_MSG(client, push_cmd_buf,
  164. MLXSW_I2C_PUSH_CMD_SIZE);
  165. struct i2c_msg prep_cmd =
  166. MLXSW_I2C_WRITE_MSG(client, prep_cmd_buf, MLXSW_I2C_PREP_SIZE);
  167. int err;
  168. if (!immediate) {
  169. push_cmd_buf[1] = cpu_to_be32(MLXSW_I2C_PUSH_CMD);
  170. prep_cmd_buf[7] = cpu_to_be32(MLXSW_I2C_SET_CMD);
  171. }
  172. mlxsw_i2c_set_slave_addr((u8 *)prep_cmd_buf,
  173. MLXSW_I2C_CIR2_BASE);
  174. mlxsw_i2c_set_slave_addr((u8 *)push_cmd_buf,
  175. MLXSW_I2C_CIR2_OFF_STATUS);
  176. /* Prepare Command Interface Register for transaction */
  177. err = i2c_transfer(client->adapter, &prep_cmd, 1);
  178. if (err < 0)
  179. return err;
  180. else if (err != 1)
  181. return -EIO;
  182. /* Write out Command Interface Register GO bit to push transaction */
  183. err = i2c_transfer(client->adapter, &push_cmd, 1);
  184. if (err < 0)
  185. return err;
  186. else if (err != 1)
  187. return -EIO;
  188. return 0;
  189. }
  190. /* Routine obtains mail box offsets from ASIC register space. */
  191. static int mlxsw_i2c_get_mbox(struct i2c_client *client,
  192. struct mlxsw_i2c *mlxsw_i2c)
  193. {
  194. u8 addr_buf[MLXSW_I2C_ADDR_BUF_SIZE];
  195. u8 buf[MLXSW_I2C_MBOX_SIZE];
  196. struct i2c_msg mbox_cmd[] =
  197. MLXSW_I2C_READ_MSG(client, addr_buf, buf, MLXSW_I2C_MBOX_SIZE);
  198. int err;
  199. /* Read mail boxes offsets. */
  200. mlxsw_i2c_set_slave_addr(addr_buf, MLXSW_I2C_CIR2_BASE);
  201. err = i2c_transfer(client->adapter, mbox_cmd, 2);
  202. if (err != 2) {
  203. dev_err(&client->dev, "Could not obtain mail boxes\n");
  204. if (!err)
  205. return -EIO;
  206. else
  207. return err;
  208. }
  209. /* Convert mail boxes. */
  210. mlxsw_i2c_convert_mbox(mlxsw_i2c, &buf[MLXSW_I2C_MBOX_OUT_PARAM_OFF]);
  211. return err;
  212. }
  213. /* Routine sends I2C write transaction to ASIC device. */
  214. static int
  215. mlxsw_i2c_write(struct device *dev, size_t in_mbox_size, u8 *in_mbox, int num,
  216. u8 *p_status)
  217. {
  218. struct i2c_client *client = to_i2c_client(dev);
  219. struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client);
  220. unsigned long timeout = msecs_to_jiffies(MLXSW_I2C_TIMEOUT_MSECS);
  221. u8 tran_buf[MLXSW_I2C_MAX_BUFF_SIZE + MLXSW_I2C_ADDR_BUF_SIZE];
  222. int off = mlxsw_i2c->cmd.mb_off_in, chunk_size, i, j;
  223. unsigned long end;
  224. struct i2c_msg write_tran =
  225. MLXSW_I2C_WRITE_MSG(client, tran_buf, MLXSW_I2C_PUSH_CMD_SIZE);
  226. int err;
  227. for (i = 0; i < num; i++) {
  228. chunk_size = (in_mbox_size > MLXSW_I2C_BLK_MAX) ?
  229. MLXSW_I2C_BLK_MAX : in_mbox_size;
  230. write_tran.len = MLXSW_I2C_ADDR_WIDTH + chunk_size;
  231. mlxsw_i2c_set_slave_addr(tran_buf, off);
  232. memcpy(&tran_buf[MLXSW_I2C_ADDR_BUF_SIZE], in_mbox +
  233. MLXSW_I2C_BLK_MAX * i, chunk_size);
  234. j = 0;
  235. end = jiffies + timeout;
  236. do {
  237. err = i2c_transfer(client->adapter, &write_tran, 1);
  238. if (err == 1)
  239. break;
  240. cond_resched();
  241. } while ((time_before(jiffies, end)) ||
  242. (j++ < MLXSW_I2C_RETRY));
  243. if (err != 1) {
  244. if (!err)
  245. err = -EIO;
  246. return err;
  247. }
  248. off += chunk_size;
  249. in_mbox_size -= chunk_size;
  250. }
  251. /* Prepare and write out Command Interface Register for transaction. */
  252. err = mlxsw_i2c_write_cmd(client, mlxsw_i2c, 0);
  253. if (err) {
  254. dev_err(&client->dev, "Could not start transaction");
  255. return -EIO;
  256. }
  257. /* Wait until go bit is cleared. */
  258. err = mlxsw_i2c_wait_go_bit(client, mlxsw_i2c, p_status);
  259. if (err) {
  260. dev_err(&client->dev, "HW semaphore is not released");
  261. return err;
  262. }
  263. /* Validate transaction completion status. */
  264. if (*p_status) {
  265. dev_err(&client->dev, "Bad transaction completion status %x\n",
  266. *p_status);
  267. return -EIO;
  268. }
  269. return 0;
  270. }
  271. /* Routine executes I2C command. */
  272. static int
  273. mlxsw_i2c_cmd(struct device *dev, size_t in_mbox_size, u8 *in_mbox,
  274. size_t out_mbox_size, u8 *out_mbox, u8 *status)
  275. {
  276. struct i2c_client *client = to_i2c_client(dev);
  277. struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client);
  278. unsigned long timeout = msecs_to_jiffies(MLXSW_I2C_TIMEOUT_MSECS);
  279. u8 tran_buf[MLXSW_I2C_ADDR_BUF_SIZE];
  280. int num, chunk_size, reg_size, i, j;
  281. int off = mlxsw_i2c->cmd.mb_off_out;
  282. unsigned long end;
  283. struct i2c_msg read_tran[] =
  284. MLXSW_I2C_READ_MSG(client, tran_buf, NULL, 0);
  285. int err;
  286. WARN_ON(in_mbox_size % sizeof(u32) || out_mbox_size % sizeof(u32));
  287. reg_size = mlxsw_i2c_get_reg_size(in_mbox);
  288. num = reg_size / MLXSW_I2C_BLK_MAX;
  289. if (reg_size % MLXSW_I2C_BLK_MAX)
  290. num++;
  291. if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) {
  292. dev_err(&client->dev, "Could not acquire lock");
  293. return -EINVAL;
  294. }
  295. err = mlxsw_i2c_write(dev, reg_size, in_mbox, num, status);
  296. if (err)
  297. goto cmd_fail;
  298. /* No out mailbox is case of write transaction. */
  299. if (!out_mbox) {
  300. mutex_unlock(&mlxsw_i2c->cmd.lock);
  301. return 0;
  302. }
  303. /* Send read transaction to get output mailbox content. */
  304. read_tran[1].buf = out_mbox;
  305. for (i = 0; i < num; i++) {
  306. chunk_size = (reg_size > MLXSW_I2C_BLK_MAX) ?
  307. MLXSW_I2C_BLK_MAX : reg_size;
  308. read_tran[1].len = chunk_size;
  309. mlxsw_i2c_set_slave_addr(tran_buf, off);
  310. j = 0;
  311. end = jiffies + timeout;
  312. do {
  313. err = i2c_transfer(client->adapter, read_tran,
  314. ARRAY_SIZE(read_tran));
  315. if (err == ARRAY_SIZE(read_tran))
  316. break;
  317. cond_resched();
  318. } while ((time_before(jiffies, end)) ||
  319. (j++ < MLXSW_I2C_RETRY));
  320. if (err != ARRAY_SIZE(read_tran)) {
  321. if (!err)
  322. err = -EIO;
  323. goto cmd_fail;
  324. }
  325. off += chunk_size;
  326. reg_size -= chunk_size;
  327. read_tran[1].buf += chunk_size;
  328. }
  329. mutex_unlock(&mlxsw_i2c->cmd.lock);
  330. return 0;
  331. cmd_fail:
  332. mutex_unlock(&mlxsw_i2c->cmd.lock);
  333. return err;
  334. }
  335. static int mlxsw_i2c_cmd_exec(void *bus_priv, u16 opcode, u8 opcode_mod,
  336. u32 in_mod, bool out_mbox_direct,
  337. char *in_mbox, size_t in_mbox_size,
  338. char *out_mbox, size_t out_mbox_size,
  339. u8 *status)
  340. {
  341. struct mlxsw_i2c *mlxsw_i2c = bus_priv;
  342. return mlxsw_i2c_cmd(mlxsw_i2c->dev, in_mbox_size, in_mbox,
  343. out_mbox_size, out_mbox, status);
  344. }
  345. static bool mlxsw_i2c_skb_transmit_busy(void *bus_priv,
  346. const struct mlxsw_tx_info *tx_info)
  347. {
  348. return false;
  349. }
  350. static int mlxsw_i2c_skb_transmit(void *bus_priv, struct sk_buff *skb,
  351. const struct mlxsw_tx_info *tx_info)
  352. {
  353. return 0;
  354. }
  355. static int
  356. mlxsw_i2c_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
  357. const struct mlxsw_config_profile *profile,
  358. struct mlxsw_res *resources)
  359. {
  360. struct mlxsw_i2c *mlxsw_i2c = bus_priv;
  361. mlxsw_i2c->core = mlxsw_core;
  362. return 0;
  363. }
  364. static void mlxsw_i2c_fini(void *bus_priv)
  365. {
  366. struct mlxsw_i2c *mlxsw_i2c = bus_priv;
  367. mlxsw_i2c->core = NULL;
  368. }
  369. static const struct mlxsw_bus mlxsw_i2c_bus = {
  370. .kind = "i2c",
  371. .init = mlxsw_i2c_init,
  372. .fini = mlxsw_i2c_fini,
  373. .skb_transmit_busy = mlxsw_i2c_skb_transmit_busy,
  374. .skb_transmit = mlxsw_i2c_skb_transmit,
  375. .cmd_exec = mlxsw_i2c_cmd_exec,
  376. };
  377. static int mlxsw_i2c_probe(struct i2c_client *client,
  378. const struct i2c_device_id *id)
  379. {
  380. struct mlxsw_i2c *mlxsw_i2c;
  381. u8 status;
  382. int err;
  383. mlxsw_i2c = devm_kzalloc(&client->dev, sizeof(*mlxsw_i2c), GFP_KERNEL);
  384. if (!mlxsw_i2c)
  385. return -ENOMEM;
  386. i2c_set_clientdata(client, mlxsw_i2c);
  387. mutex_init(&mlxsw_i2c->cmd.lock);
  388. /* In order to use mailboxes through the i2c, special area is reserved
  389. * on the i2c address space that can be used for input and output
  390. * mailboxes. Such mailboxes are called local mailboxes. When using a
  391. * local mailbox, software should specify 0 as the Input/Output
  392. * parameters. The location of the Local Mailbox addresses on the i2c
  393. * space can be retrieved through the QUERY_FW command.
  394. * For this purpose QUERY_FW is to be issued with opcode modifier equal
  395. * 0x01. For such command the output parameter is an immediate value.
  396. * Here QUERY_FW command is invoked for ASIC probing and for getting
  397. * local mailboxes addresses from immedate output parameters.
  398. */
  399. /* Prepare and write out Command Interface Register for transaction */
  400. err = mlxsw_i2c_write_cmd(client, mlxsw_i2c, 1);
  401. if (err) {
  402. dev_err(&client->dev, "Could not start transaction");
  403. goto errout;
  404. }
  405. /* Wait until go bit is cleared. */
  406. err = mlxsw_i2c_wait_go_bit(client, mlxsw_i2c, &status);
  407. if (err) {
  408. dev_err(&client->dev, "HW semaphore is not released");
  409. goto errout;
  410. }
  411. /* Validate transaction completion status. */
  412. if (status) {
  413. dev_err(&client->dev, "Bad transaction completion status %x\n",
  414. status);
  415. err = -EIO;
  416. goto errout;
  417. }
  418. /* Get mailbox offsets. */
  419. err = mlxsw_i2c_get_mbox(client, mlxsw_i2c);
  420. if (err < 0) {
  421. dev_err(&client->dev, "Fail to get mailboxes\n");
  422. goto errout;
  423. }
  424. dev_info(&client->dev, "%s mb size=%x off=0x%08x out mb size=%x off=0x%08x\n",
  425. id->name, mlxsw_i2c->cmd.mb_size_in,
  426. mlxsw_i2c->cmd.mb_off_in, mlxsw_i2c->cmd.mb_size_out,
  427. mlxsw_i2c->cmd.mb_off_out);
  428. /* Register device bus. */
  429. mlxsw_i2c->bus_info.device_kind = id->name;
  430. mlxsw_i2c->bus_info.device_name = client->name;
  431. mlxsw_i2c->bus_info.dev = &client->dev;
  432. mlxsw_i2c->dev = &client->dev;
  433. err = mlxsw_core_bus_device_register(&mlxsw_i2c->bus_info,
  434. &mlxsw_i2c_bus, mlxsw_i2c, false,
  435. NULL);
  436. if (err) {
  437. dev_err(&client->dev, "Fail to register core bus\n");
  438. return err;
  439. }
  440. return 0;
  441. errout:
  442. i2c_set_clientdata(client, NULL);
  443. return err;
  444. }
  445. static int mlxsw_i2c_remove(struct i2c_client *client)
  446. {
  447. struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client);
  448. mlxsw_core_bus_device_unregister(mlxsw_i2c->core, false);
  449. mutex_destroy(&mlxsw_i2c->cmd.lock);
  450. return 0;
  451. }
  452. int mlxsw_i2c_driver_register(struct i2c_driver *i2c_driver)
  453. {
  454. i2c_driver->probe = mlxsw_i2c_probe;
  455. i2c_driver->remove = mlxsw_i2c_remove;
  456. return i2c_add_driver(i2c_driver);
  457. }
  458. EXPORT_SYMBOL(mlxsw_i2c_driver_register);
  459. void mlxsw_i2c_driver_unregister(struct i2c_driver *i2c_driver)
  460. {
  461. i2c_del_driver(i2c_driver);
  462. }
  463. EXPORT_SYMBOL(mlxsw_i2c_driver_unregister);
  464. MODULE_AUTHOR("Vadim Pasternak <vadimp@mellanox.com>");
  465. MODULE_DESCRIPTION("Mellanox switch I2C interface driver");
  466. MODULE_LICENSE("Dual BSD/GPL");