i2c-octeon.c 15 KB

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