i2c-octeon.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /*
  2. * (C) Copyright 2009-2010
  3. * Nokia Siemens Networks, michael.lawnick.ext@nsn.com
  4. *
  5. * Portions Copyright (C) 2010 - 2016 Cavium, Inc.
  6. *
  7. * This is a driver for the i2c adapter in Cavium Networks' OCTEON processors.
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #include <linux/platform_device.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/kernel.h>
  16. #include <linux/module.h>
  17. #include <linux/delay.h>
  18. #include <linux/sched.h>
  19. #include <linux/slab.h>
  20. #include <linux/i2c.h>
  21. #include <linux/io.h>
  22. #include <linux/of.h>
  23. #include <asm/octeon/octeon.h>
  24. #define DRV_NAME "i2c-octeon"
  25. /* Register offsets */
  26. #define SW_TWSI 0x00
  27. #define TWSI_INT 0x10
  28. /* Controller command patterns */
  29. #define SW_TWSI_V BIT_ULL(63) /* Valid bit */
  30. #define SW_TWSI_R BIT_ULL(56) /* Result or read bit */
  31. /* Controller opcode word (bits 60:57) */
  32. #define SW_TWSI_OP_SHIFT 57
  33. #define SW_TWSI_OP_TWSI_CLK (4ULL << SW_TWSI_OP_SHIFT)
  34. #define SW_TWSI_OP_EOP (6ULL << SW_TWSI_OP_SHIFT) /* Extended opcode */
  35. /* Controller extended opcode word (bits 34:32) */
  36. #define SW_TWSI_EOP_SHIFT 32
  37. #define SW_TWSI_EOP_TWSI_DATA (SW_TWSI_OP_EOP | 1ULL << SW_TWSI_EOP_SHIFT)
  38. #define SW_TWSI_EOP_TWSI_CTL (SW_TWSI_OP_EOP | 2ULL << SW_TWSI_EOP_SHIFT)
  39. #define SW_TWSI_EOP_TWSI_CLKCTL (SW_TWSI_OP_EOP | 3ULL << SW_TWSI_EOP_SHIFT)
  40. #define SW_TWSI_EOP_TWSI_STAT (SW_TWSI_OP_EOP | 3ULL << SW_TWSI_EOP_SHIFT)
  41. #define SW_TWSI_EOP_TWSI_RST (SW_TWSI_OP_EOP | 7ULL << SW_TWSI_EOP_SHIFT)
  42. /* Controller command and status bits */
  43. #define TWSI_CTL_CE 0x80
  44. #define TWSI_CTL_ENAB 0x40 /* Bus enable */
  45. #define TWSI_CTL_STA 0x20 /* Master-mode start, HW clears when done */
  46. #define TWSI_CTL_STP 0x10 /* Master-mode stop, HW clears when done */
  47. #define TWSI_CTL_IFLG 0x08 /* HW event, SW writes 0 to ACK */
  48. #define TWSI_CTL_AAK 0x04 /* Assert ACK */
  49. /* Some status values */
  50. #define STAT_START 0x08
  51. #define STAT_RSTART 0x10
  52. #define STAT_TXADDR_ACK 0x18
  53. #define STAT_TXDATA_ACK 0x28
  54. #define STAT_RXADDR_ACK 0x40
  55. #define STAT_RXDATA_ACK 0x50
  56. #define STAT_IDLE 0xF8
  57. /* TWSI_INT values */
  58. #define TWSI_INT_CORE_EN BIT_ULL(6)
  59. #define TWSI_INT_SDA_OVR BIT_ULL(8)
  60. #define TWSI_INT_SCL_OVR BIT_ULL(9)
  61. struct octeon_i2c {
  62. wait_queue_head_t queue;
  63. struct i2c_adapter adap;
  64. int irq;
  65. u32 twsi_freq;
  66. int sys_freq;
  67. void __iomem *twsi_base;
  68. struct device *dev;
  69. };
  70. /**
  71. * octeon_i2c_write_sw - write an I2C core register
  72. * @i2c: The struct octeon_i2c
  73. * @eop_reg: Register selector
  74. * @data: Value to be written
  75. *
  76. * The I2C core registers are accessed indirectly via the SW_TWSI CSR.
  77. */
  78. static void octeon_i2c_write_sw(struct octeon_i2c *i2c, u64 eop_reg, u8 data)
  79. {
  80. u64 tmp;
  81. __raw_writeq(SW_TWSI_V | eop_reg | data, i2c->twsi_base + SW_TWSI);
  82. do {
  83. tmp = __raw_readq(i2c->twsi_base + SW_TWSI);
  84. } while ((tmp & SW_TWSI_V) != 0);
  85. }
  86. /**
  87. * octeon_i2c_read_sw - read lower bits of an I2C core register
  88. * @i2c: The struct octeon_i2c
  89. * @eop_reg: Register selector
  90. *
  91. * Returns the data.
  92. *
  93. * The I2C core registers are accessed indirectly via the SW_TWSI CSR.
  94. */
  95. static u8 octeon_i2c_read_sw(struct octeon_i2c *i2c, u64 eop_reg)
  96. {
  97. u64 tmp;
  98. __raw_writeq(SW_TWSI_V | eop_reg | SW_TWSI_R, i2c->twsi_base + SW_TWSI);
  99. do {
  100. tmp = __raw_readq(i2c->twsi_base + SW_TWSI);
  101. } while ((tmp & SW_TWSI_V) != 0);
  102. return tmp & 0xFF;
  103. }
  104. /**
  105. * octeon_i2c_write_int - write the TWSI_INT register
  106. * @i2c: The struct octeon_i2c
  107. * @data: Value to be written
  108. */
  109. static void octeon_i2c_write_int(struct octeon_i2c *i2c, u64 data)
  110. {
  111. __raw_writeq(data, i2c->twsi_base + TWSI_INT);
  112. __raw_readq(i2c->twsi_base + TWSI_INT);
  113. }
  114. /**
  115. * octeon_i2c_int_enable - enable the CORE interrupt
  116. * @i2c: The struct octeon_i2c
  117. *
  118. * The interrupt will be asserted when there is non-STAT_IDLE state in
  119. * the SW_TWSI_EOP_TWSI_STAT register.
  120. */
  121. static void octeon_i2c_int_enable(struct octeon_i2c *i2c)
  122. {
  123. octeon_i2c_write_int(i2c, TWSI_INT_CORE_EN);
  124. }
  125. /* disable the CORE interrupt */
  126. static void octeon_i2c_int_disable(struct octeon_i2c *i2c)
  127. {
  128. /* clear TS/ST/IFLG events */
  129. octeon_i2c_write_int(i2c, 0);
  130. }
  131. /**
  132. * octeon_i2c_unblock - unblock the bus
  133. * @i2c: The struct octeon_i2c
  134. *
  135. * If there was a reset while a device was driving 0 to bus, bus is blocked.
  136. * We toggle it free manually by some clock cycles and send a stop.
  137. */
  138. static void octeon_i2c_unblock(struct octeon_i2c *i2c)
  139. {
  140. int i;
  141. dev_dbg(i2c->dev, "%s\n", __func__);
  142. for (i = 0; i < 9; i++) {
  143. octeon_i2c_write_int(i2c, 0);
  144. udelay(5);
  145. octeon_i2c_write_int(i2c, TWSI_INT_SCL_OVR);
  146. udelay(5);
  147. }
  148. /* hand-crank a STOP */
  149. octeon_i2c_write_int(i2c, TWSI_INT_SDA_OVR | TWSI_INT_SCL_OVR);
  150. udelay(5);
  151. octeon_i2c_write_int(i2c, TWSI_INT_SDA_OVR);
  152. udelay(5);
  153. octeon_i2c_write_int(i2c, 0);
  154. }
  155. /* interrupt service routine */
  156. static irqreturn_t octeon_i2c_isr(int irq, void *dev_id)
  157. {
  158. struct octeon_i2c *i2c = dev_id;
  159. octeon_i2c_int_disable(i2c);
  160. wake_up(&i2c->queue);
  161. return IRQ_HANDLED;
  162. }
  163. static int octeon_i2c_test_iflg(struct octeon_i2c *i2c)
  164. {
  165. return (octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_CTL) & TWSI_CTL_IFLG) != 0;
  166. }
  167. /**
  168. * octeon_i2c_wait - wait for the IFLG to be set
  169. * @i2c: The struct octeon_i2c
  170. *
  171. * Returns 0 on success, otherwise a negative errno.
  172. */
  173. static int octeon_i2c_wait(struct octeon_i2c *i2c)
  174. {
  175. long time_left;
  176. octeon_i2c_int_enable(i2c);
  177. time_left = wait_event_timeout(i2c->queue, octeon_i2c_test_iflg(i2c),
  178. i2c->adap.timeout);
  179. octeon_i2c_int_disable(i2c);
  180. if (!time_left) {
  181. dev_dbg(i2c->dev, "%s: timeout\n", __func__);
  182. return -ETIMEDOUT;
  183. }
  184. return 0;
  185. }
  186. /* calculate and set clock divisors */
  187. static void octeon_i2c_set_clock(struct octeon_i2c *i2c)
  188. {
  189. int tclk, thp_base, inc, thp_idx, mdiv_idx, ndiv_idx, foscl, diff;
  190. int thp = 0x18, mdiv = 2, ndiv = 0, delta_hz = 1000000;
  191. for (ndiv_idx = 0; ndiv_idx < 8 && delta_hz != 0; ndiv_idx++) {
  192. /*
  193. * An mdiv value of less than 2 seems to not work well
  194. * with ds1337 RTCs, so we constrain it to larger values.
  195. */
  196. for (mdiv_idx = 15; mdiv_idx >= 2 && delta_hz != 0; mdiv_idx--) {
  197. /*
  198. * For given ndiv and mdiv values check the
  199. * two closest thp values.
  200. */
  201. tclk = i2c->twsi_freq * (mdiv_idx + 1) * 10;
  202. tclk *= (1 << ndiv_idx);
  203. thp_base = (i2c->sys_freq / (tclk * 2)) - 1;
  204. for (inc = 0; inc <= 1; inc++) {
  205. thp_idx = thp_base + inc;
  206. if (thp_idx < 5 || thp_idx > 0xff)
  207. continue;
  208. foscl = i2c->sys_freq / (2 * (thp_idx + 1));
  209. foscl = foscl / (1 << ndiv_idx);
  210. foscl = foscl / (mdiv_idx + 1) / 10;
  211. diff = abs(foscl - i2c->twsi_freq);
  212. if (diff < delta_hz) {
  213. delta_hz = diff;
  214. thp = thp_idx;
  215. mdiv = mdiv_idx;
  216. ndiv = ndiv_idx;
  217. }
  218. }
  219. }
  220. }
  221. octeon_i2c_write_sw(i2c, SW_TWSI_OP_TWSI_CLK, thp);
  222. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CLKCTL, (mdiv << 3) | ndiv);
  223. }
  224. static int octeon_i2c_init_lowlevel(struct octeon_i2c *i2c)
  225. {
  226. u8 status;
  227. int tries;
  228. /* disable high level controller, enable bus access */
  229. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB);
  230. /* reset controller */
  231. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_RST, 0);
  232. for (tries = 10; tries; tries--) {
  233. udelay(1);
  234. status = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT);
  235. if (status == STAT_IDLE)
  236. return 0;
  237. }
  238. dev_err(i2c->dev, "%s: TWSI_RST failed! (0x%x)\n", __func__, status);
  239. return -EIO;
  240. }
  241. /**
  242. * octeon_i2c_start - send START to the bus
  243. * @i2c: The struct octeon_i2c
  244. *
  245. * Returns 0 on success, otherwise a negative errno.
  246. */
  247. static int octeon_i2c_start(struct octeon_i2c *i2c)
  248. {
  249. int result;
  250. u8 data;
  251. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL,
  252. TWSI_CTL_ENAB | TWSI_CTL_STA);
  253. result = octeon_i2c_wait(i2c);
  254. if (result) {
  255. if (octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT) == STAT_IDLE) {
  256. /*
  257. * Controller refused to send start flag May
  258. * be a client is holding SDA low - let's try
  259. * to free it.
  260. */
  261. octeon_i2c_unblock(i2c);
  262. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL,
  263. TWSI_CTL_ENAB | TWSI_CTL_STA);
  264. result = octeon_i2c_wait(i2c);
  265. }
  266. if (result)
  267. return result;
  268. }
  269. data = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT);
  270. if ((data != STAT_START) && (data != STAT_RSTART)) {
  271. dev_err(i2c->dev, "%s: bad status (0x%x)\n", __func__, data);
  272. return -EIO;
  273. }
  274. return 0;
  275. }
  276. /* send STOP to the bus */
  277. static void octeon_i2c_stop(struct octeon_i2c *i2c)
  278. {
  279. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL,
  280. TWSI_CTL_ENAB | TWSI_CTL_STP);
  281. }
  282. /**
  283. * octeon_i2c_write - send data to the bus via low-level controller
  284. * @i2c: The struct octeon_i2c
  285. * @target: Target address
  286. * @data: Pointer to the data to be sent
  287. * @length: Length of the data
  288. *
  289. * The address is sent over the bus, then the data.
  290. *
  291. * Returns 0 on success, otherwise a negative errno.
  292. */
  293. static int octeon_i2c_write(struct octeon_i2c *i2c, int target,
  294. const u8 *data, int length)
  295. {
  296. int i, result;
  297. u8 tmp;
  298. result = octeon_i2c_start(i2c);
  299. if (result)
  300. return result;
  301. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, target << 1);
  302. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB);
  303. result = octeon_i2c_wait(i2c);
  304. if (result)
  305. return result;
  306. for (i = 0; i < length; i++) {
  307. tmp = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT);
  308. if ((tmp != STAT_TXADDR_ACK) && (tmp != STAT_TXDATA_ACK)) {
  309. dev_err(i2c->dev,
  310. "%s: bad status before write (0x%x)\n",
  311. __func__, tmp);
  312. return -EIO;
  313. }
  314. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, data[i]);
  315. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB);
  316. result = octeon_i2c_wait(i2c);
  317. if (result)
  318. return result;
  319. }
  320. return 0;
  321. }
  322. /**
  323. * octeon_i2c_read - receive data from the bus via low-level controller
  324. * @i2c: The struct octeon_i2c
  325. * @target: Target address
  326. * @data: Pointer to the location to store the data
  327. * @rlength: Length of the data
  328. * @recv_len: flag for length byte
  329. *
  330. * The address is sent over the bus, then the data is read.
  331. *
  332. * Returns 0 on success, otherwise a negative errno.
  333. */
  334. static int octeon_i2c_read(struct octeon_i2c *i2c, int target,
  335. u8 *data, u16 *rlength, bool recv_len)
  336. {
  337. int i, result, length = *rlength;
  338. u8 tmp;
  339. if (length < 1)
  340. return -EINVAL;
  341. result = octeon_i2c_start(i2c);
  342. if (result)
  343. return result;
  344. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, (target << 1) | 1);
  345. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB);
  346. result = octeon_i2c_wait(i2c);
  347. if (result)
  348. return result;
  349. for (i = 0; i < length; i++) {
  350. tmp = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT);
  351. if ((tmp != STAT_RXDATA_ACK) && (tmp != STAT_RXADDR_ACK)) {
  352. dev_err(i2c->dev,
  353. "%s: bad status before read (0x%x)\n",
  354. __func__, tmp);
  355. return -EIO;
  356. }
  357. if (i + 1 < length)
  358. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL,
  359. TWSI_CTL_ENAB | TWSI_CTL_AAK);
  360. else
  361. octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL,
  362. TWSI_CTL_ENAB);
  363. result = octeon_i2c_wait(i2c);
  364. if (result)
  365. return result;
  366. data[i] = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_DATA);
  367. if (recv_len && i == 0) {
  368. if (data[i] > I2C_SMBUS_BLOCK_MAX + 1) {
  369. dev_err(i2c->dev,
  370. "%s: read len > I2C_SMBUS_BLOCK_MAX %d\n",
  371. __func__, data[i]);
  372. return -EPROTO;
  373. }
  374. length += data[i];
  375. }
  376. }
  377. *rlength = length;
  378. return 0;
  379. }
  380. /**
  381. * octeon_i2c_xfer - The driver's master_xfer function
  382. * @adap: Pointer to the i2c_adapter structure
  383. * @msgs: Pointer to the messages to be processed
  384. * @num: Length of the MSGS array
  385. *
  386. * Returns the number of messages processed, or a negative errno on failure.
  387. */
  388. static int octeon_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
  389. int num)
  390. {
  391. struct octeon_i2c *i2c = i2c_get_adapdata(adap);
  392. int i, ret = 0;
  393. for (i = 0; ret == 0 && i < num; i++) {
  394. struct i2c_msg *pmsg = &msgs[i];
  395. dev_dbg(i2c->dev,
  396. "Doing %s %d byte(s) to/from 0x%02x - %d of %d messages\n",
  397. pmsg->flags & I2C_M_RD ? "read" : "write",
  398. pmsg->len, pmsg->addr, i + 1, num);
  399. if (pmsg->flags & I2C_M_RD)
  400. ret = octeon_i2c_read(i2c, pmsg->addr, pmsg->buf,
  401. &pmsg->len, pmsg->flags & I2C_M_RECV_LEN);
  402. else
  403. ret = octeon_i2c_write(i2c, pmsg->addr, pmsg->buf,
  404. pmsg->len);
  405. }
  406. octeon_i2c_stop(i2c);
  407. return (ret != 0) ? ret : num;
  408. }
  409. static u32 octeon_i2c_functionality(struct i2c_adapter *adap)
  410. {
  411. return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
  412. I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_SMBUS_BLOCK_PROC_CALL;
  413. }
  414. static const struct i2c_algorithm octeon_i2c_algo = {
  415. .master_xfer = octeon_i2c_xfer,
  416. .functionality = octeon_i2c_functionality,
  417. };
  418. static struct i2c_adapter octeon_i2c_ops = {
  419. .owner = THIS_MODULE,
  420. .name = "OCTEON adapter",
  421. .algo = &octeon_i2c_algo,
  422. };
  423. static int octeon_i2c_probe(struct platform_device *pdev)
  424. {
  425. struct device_node *node = pdev->dev.of_node;
  426. struct resource *res_mem;
  427. struct octeon_i2c *i2c;
  428. int irq, result = 0;
  429. /* All adaptors have an irq. */
  430. irq = platform_get_irq(pdev, 0);
  431. if (irq < 0)
  432. return irq;
  433. i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
  434. if (!i2c) {
  435. result = -ENOMEM;
  436. goto out;
  437. }
  438. i2c->dev = &pdev->dev;
  439. res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  440. i2c->twsi_base = devm_ioremap_resource(&pdev->dev, res_mem);
  441. if (IS_ERR(i2c->twsi_base)) {
  442. result = PTR_ERR(i2c->twsi_base);
  443. goto out;
  444. }
  445. /*
  446. * "clock-rate" is a legacy binding, the official binding is
  447. * "clock-frequency". Try the official one first and then
  448. * fall back if it doesn't exist.
  449. */
  450. if (of_property_read_u32(node, "clock-frequency", &i2c->twsi_freq) &&
  451. of_property_read_u32(node, "clock-rate", &i2c->twsi_freq)) {
  452. dev_err(i2c->dev,
  453. "no I2C 'clock-rate' or 'clock-frequency' property\n");
  454. result = -ENXIO;
  455. goto out;
  456. }
  457. i2c->sys_freq = octeon_get_io_clock_rate();
  458. init_waitqueue_head(&i2c->queue);
  459. i2c->irq = irq;
  460. result = devm_request_irq(&pdev->dev, i2c->irq,
  461. octeon_i2c_isr, 0, DRV_NAME, i2c);
  462. if (result < 0) {
  463. dev_err(i2c->dev, "failed to attach interrupt\n");
  464. goto out;
  465. }
  466. result = octeon_i2c_init_lowlevel(i2c);
  467. if (result) {
  468. dev_err(i2c->dev, "init low level failed\n");
  469. goto out;
  470. }
  471. octeon_i2c_set_clock(i2c);
  472. i2c->adap = octeon_i2c_ops;
  473. i2c->adap.timeout = msecs_to_jiffies(2);
  474. i2c->adap.retries = 5;
  475. i2c->adap.dev.parent = &pdev->dev;
  476. i2c->adap.dev.of_node = node;
  477. i2c_set_adapdata(&i2c->adap, i2c);
  478. platform_set_drvdata(pdev, i2c);
  479. result = i2c_add_adapter(&i2c->adap);
  480. if (result < 0) {
  481. dev_err(i2c->dev, "failed to add adapter\n");
  482. goto out;
  483. }
  484. dev_info(i2c->dev, "probed\n");
  485. return 0;
  486. out:
  487. return result;
  488. };
  489. static int octeon_i2c_remove(struct platform_device *pdev)
  490. {
  491. struct octeon_i2c *i2c = platform_get_drvdata(pdev);
  492. i2c_del_adapter(&i2c->adap);
  493. return 0;
  494. };
  495. static const struct of_device_id octeon_i2c_match[] = {
  496. { .compatible = "cavium,octeon-3860-twsi", },
  497. {},
  498. };
  499. MODULE_DEVICE_TABLE(of, octeon_i2c_match);
  500. static struct platform_driver octeon_i2c_driver = {
  501. .probe = octeon_i2c_probe,
  502. .remove = octeon_i2c_remove,
  503. .driver = {
  504. .name = DRV_NAME,
  505. .of_match_table = octeon_i2c_match,
  506. },
  507. };
  508. module_platform_driver(octeon_i2c_driver);
  509. MODULE_AUTHOR("Michael Lawnick <michael.lawnick.ext@nsn.com>");
  510. MODULE_DESCRIPTION("I2C-Bus adapter for Cavium OCTEON processors");
  511. MODULE_LICENSE("GPL");