i2c_main.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/init.h>
  4. #include <linux/cdev.h>
  5. #include <linux/fs.h>
  6. #include <linux/errno.h>
  7. #include <asm/current.h>
  8. #include <linux/sched.h>
  9. #include <linux/device.h>
  10. #include <linux/err.h>
  11. #include <asm/uaccess.h>
  12. #include <linux/delay.h>
  13. #include <linux/uaccess.h>
  14. #include <asm-generic/ioctl.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/irqreturn.h>
  17. #include <linux/wait.h>
  18. #include "stm32f4xx.h"
  19. #include "stm32f4xx_hal_gpio.h"
  20. #include "stm32_hal_legacy.h"
  21. #include "driver.h"
  22. #define I2C_MAJOR MAJOR_I2C
  23. //static int minor = 0;
  24. //static dev_t devno;
  25. //static struct cdev *i2c_cdev = NULL;
  26. //static int count = 3;
  27. //static int ret=0;
  28. #define DEVNAME "i2c"
  29. #define NUM_OF_DEVICES 3
  30. static uint8_t i2c_rcv_buf[100];
  31. static uint8_t i2c_rcv_size;
  32. static DECLARE_WAIT_QUEUE_HEAD(wq);
  33. static volatile int ev_press = 0;
  34. struct i2c_device {
  35. dev_t devno;
  36. struct cdev cdev;
  37. char name[16];
  38. IRQn_Type Event_IRQn;
  39. IRQn_Type Err_IRQn;
  40. } i2c_dev[NUM_OF_DEVICES];
  41. static int i2c_open(struct inode *inode, struct file *filep);
  42. static int i2c_close(struct inode *inode, struct file *filep);
  43. static ssize_t i2c_read(struct file *filep, char __user *buf, size_t size, loff_t *offset);
  44. static ssize_t i2c_write(struct file *filep, const char __user *buf, size_t size, loff_t *offset);
  45. static int i2c_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg);
  46. static struct file_operations i2c_ops =
  47. {
  48. .owner = THIS_MODULE,
  49. .open = i2c_open,
  50. .release = i2c_close,
  51. .ioctl = i2c_ioctl,
  52. .read = i2c_read,
  53. .write = i2c_write,
  54. };
  55. static int i2c_open(struct inode *inode, struct file *filep)
  56. {
  57. int imajor,iminor;
  58. I2C_HandleTypeDef hi2c;
  59. imajor = MAJOR(inode->i_rdev);
  60. iminor = MINOR(inode->i_rdev);
  61. if(imajor != I2C_MAJOR)
  62. {
  63. printk("Error: %s %d i2c major fail! %d\n",__FILE__,__LINE__,imajor);
  64. return -1;
  65. }
  66. switch(iminor)
  67. {
  68. case 0:
  69. HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
  70. HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
  71. hi2c.Instance = I2C1;
  72. printk("i2c1 open\n");
  73. break;
  74. case 1:
  75. HAL_NVIC_EnableIRQ(I2C2_EV_IRQn);
  76. HAL_NVIC_EnableIRQ(I2C2_ER_IRQn);
  77. hi2c.Instance = I2C2;
  78. printk("i2c2 open\n");
  79. break;
  80. case 2:
  81. HAL_NVIC_EnableIRQ(I2C3_EV_IRQn);
  82. HAL_NVIC_EnableIRQ(I2C3_ER_IRQn);
  83. hi2c.Instance = I2C3;
  84. break;
  85. default:
  86. printk("Error:%s %d Invalid minor %d",__FILE__,__LINE__,iminor);
  87. return -1;
  88. }
  89. __HAL_I2C_DISABLE(&hi2c); //clear all flags.
  90. hi2c.State = HAL_I2C_STATE_READY;
  91. __HAL_I2C_ENABLE(&hi2c);
  92. //HAL_I2C_EnableListen_IT(&hi2c);
  93. return 0;
  94. }
  95. static int i2c_close(struct inode *inode, struct file *filep)
  96. {
  97. int imajor,iminor;
  98. I2C_HandleTypeDef hi2c;
  99. imajor = MAJOR(inode->i_rdev);
  100. iminor = MINOR(inode->i_rdev);
  101. if(imajor != I2C_MAJOR)
  102. {
  103. printk("Error: %s %d i2c major fail! %d\n",__FILE__,__LINE__,imajor);
  104. return -1;
  105. }
  106. switch(iminor)
  107. {
  108. case 0:
  109. HAL_NVIC_DisableIRQ(I2C1_EV_IRQn);
  110. HAL_NVIC_DisableIRQ(I2C1_ER_IRQn);
  111. hi2c.Instance = I2C1;
  112. printk("i2c1 close\n");
  113. break;
  114. case 1:
  115. HAL_NVIC_DisableIRQ(I2C2_EV_IRQn);
  116. HAL_NVIC_DisableIRQ(I2C2_ER_IRQn);
  117. hi2c.Instance = I2C2;
  118. printk("i2c2 close\n");
  119. break;
  120. case 2:
  121. HAL_NVIC_DisableIRQ(I2C3_EV_IRQn);
  122. HAL_NVIC_DisableIRQ(I2C3_ER_IRQn);
  123. hi2c.Instance = I2C3;
  124. break;
  125. default:
  126. printk("Error:%s %d Invalid minor %d",__FILE__,__LINE__,iminor);
  127. return -1;
  128. }
  129. __HAL_I2C_DISABLE(&hi2c);
  130. return 0;
  131. }
  132. irqreturn_t i2cErrIRQHandler(int irqno, void *dev_id)
  133. {
  134. I2C_HandleTypeDef hi2c;
  135. switch(irqno)
  136. {
  137. case I2C1_EV_IRQn:
  138. hi2c.Instance = I2C1;
  139. printk("i2c1 Error, restart...\n");
  140. break;
  141. case I2C2_EV_IRQn:
  142. hi2c.Instance = I2C2;
  143. printk("i2c2 Error, restart...\n");
  144. break;
  145. case I2C3_EV_IRQn:
  146. hi2c.Instance = I2C3;
  147. printk("i2c3 Error, restart...\n");
  148. break;
  149. default:
  150. return IRQ_HANDLED;
  151. }
  152. //restart i2c
  153. hi2c.State = HAL_I2C_STATE_READY;
  154. __HAL_I2C_DISABLE(&hi2c);
  155. __HAL_I2C_ENABLE(&hi2c);
  156. return IRQ_HANDLED;
  157. }
  158. /**
  159. ** @brief This function handles I2C event interrupt request.
  160. ** @param
  161. ** @retval
  162. **/
  163. irqreturn_t i2cEvIRQHandler(int irqno, void *dev_id)
  164. {
  165. I2C_HandleTypeDef hi2c;
  166. uint32_t sr2itflags;
  167. uint32_t sr1itflags;
  168. uint32_t itsources;
  169. uint32_t CurrentMode;
  170. // memcpy(h12c, &I2cHandle, sizeof(I2C_HandleTypeDef));
  171. switch(irqno)
  172. {
  173. case I2C1_EV_IRQn:
  174. hi2c.Instance = I2C1;
  175. break;
  176. case I2C2_EV_IRQn:
  177. hi2c.Instance = I2C2;
  178. break;
  179. case I2C3_EV_IRQn:
  180. hi2c.Instance = I2C3;
  181. break;
  182. default:
  183. return IRQ_HANDLED;
  184. }
  185. hi2c.Mode = HAL_I2C_MODE_SLAVE;
  186. sr2itflags = READ_REG(hi2c.Instance->SR2);
  187. sr1itflags = READ_REG(hi2c.Instance->SR1);
  188. itsources = READ_REG(hi2c.Instance->CR2);
  189. CurrentMode = hi2c.Mode;
  190. // printk("SR1: %#x, SR2: %#x, CR2: %#x\n", sr1itflags, sr2itflags, itsources);
  191. /* Slave mode selected */
  192. /* ADDR set --------------------------------------------------------------*/
  193. if(((sr1itflags & I2C_FLAG_ADDR) != RESET) && ((itsources & I2C_IT_EVT) != RESET))
  194. {
  195. i2c_rcv_size = 0;
  196. /* Clear ADDR flag */
  197. __HAL_I2C_CLEAR_ADDRFLAG(&hi2c);
  198. }
  199. else if(((sr1itflags & I2C_FLAG_RXNE) != RESET))
  200. {
  201. i2c_rcv_buf[i2c_rcv_size++] = hi2c.Instance->DR;
  202. }
  203. /* STOPF set --------------------------------------------------------------*/
  204. else if(((sr1itflags & I2C_FLAG_STOPF) != RESET) && ((itsources & I2C_IT_EVT) != RESET))
  205. {
  206. ev_press = 1;
  207. wake_up_interruptible(&wq);
  208. /* Clear STOPF flag */
  209. __HAL_I2C_CLEAR_STOPFLAG(&hi2c);
  210. }
  211. else
  212. {
  213. //clear all flags
  214. hi2c.State = HAL_I2C_STATE_READY;
  215. __HAL_I2C_DISABLE(&hi2c);
  216. __HAL_I2C_ENABLE(&hi2c);
  217. }
  218. return IRQ_HANDLED;
  219. }
  220. static int i2c_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg)
  221. {
  222. uint32_t pclk1 = 0;
  223. I2C_HandleTypeDef I2CxHandle;
  224. i2c_arg_t i2c_arg;
  225. int imajor,iminor;
  226. HAL_StatusTypeDef retSta;
  227. IRQn_Type I2CxEvIRQn;
  228. imajor = MAJOR(inode->i_rdev);
  229. iminor = MINOR(inode->i_rdev);
  230. if(imajor != I2C_MAJOR)
  231. {
  232. printk("Error: %s %d i2c major fail! %d\n",__FILE__,__LINE__,imajor);
  233. return -EFAULT;
  234. }
  235. if ( copy_from_user(&i2c_arg, (void*)arg, sizeof(i2c_arg_t)) != 0)
  236. {
  237. printk("---> copy form user space fail!\n");
  238. return -EFAULT;
  239. }
  240. if(iminor == 0)
  241. {
  242. I2CxHandle.Instance = I2C1;
  243. I2CxEvIRQn = I2C1_EV_IRQn;
  244. }
  245. else if(iminor == 1)
  246. {
  247. I2CxHandle.Instance = I2C2;
  248. I2CxEvIRQn = I2C2_EV_IRQn;
  249. }
  250. else if(iminor == 2)
  251. {
  252. I2CxHandle.Instance = I2C3;
  253. I2CxEvIRQn = I2C3_EV_IRQn;
  254. }
  255. else
  256. {
  257. printk(KERN_ERR"Invalid minor\n");
  258. return -EFAULT;
  259. }
  260. switch(cmd)
  261. {
  262. case SET_I2C_SPEED:
  263. /* Get PCLK1 frequency */
  264. pclk1 = HAL_RCC_GetPCLK1Freq();
  265. __HAL_I2C_DISABLE(&I2CxHandle);
  266. HAL_NVIC_DisableIRQ(I2CxEvIRQn);
  267. if(i2c_arg.ClockSpeed <= 100000)
  268. I2CxHandle.Instance->CCR = I2C_SPEED_STANDARD(pclk1, i2c_arg.ClockSpeed) & 0x7fff;
  269. else
  270. I2CxHandle.Instance->CCR = I2C_SPEED_FAST(pclk1, i2c_arg.ClockSpeed, I2C_DUTYCYCLE_16_9) | 0x8000;
  271. __HAL_I2C_ENABLE(&I2CxHandle);
  272. HAL_NVIC_EnableIRQ(I2CxEvIRQn);
  273. //HAL_I2C_EnableListen_IT(&I2CxHandle);
  274. break;
  275. case GET_I2C_SPEED:
  276. pclk1 = HAL_RCC_GetPCLK1Freq();
  277. if(I2CxHandle.Instance->CCR & 0x8000) //fast mode
  278. i2c_arg.ClockSpeed = pclk1/((I2CxHandle.Instance->CCR & I2C_CCR_CCR)*25);
  279. else //slow mode
  280. i2c_arg.ClockSpeed = pclk1/((I2CxHandle.Instance->CCR & I2C_CCR_CCR)<<1);
  281. if(copy_to_user((void*)arg, &i2c_arg, sizeof(i2c_arg_t)))
  282. return -EFAULT;
  283. break;
  284. case SET_I2C_ADDR: //8bit
  285. __HAL_I2C_DISABLE(&I2CxHandle);
  286. HAL_NVIC_DisableIRQ(I2CxEvIRQn);
  287. /* Configure I2Cx: Own Address1 and addressing mode */
  288. I2CxHandle.Instance->OAR1 = (I2C_ADDRESSINGMODE_7BIT | i2c_arg.OwnAddress1)&0xff;
  289. __HAL_I2C_ENABLE(&I2CxHandle);
  290. HAL_NVIC_EnableIRQ(I2CxEvIRQn);
  291. //HAL_I2C_EnableListen_IT(&I2CxHandle);
  292. printk("OAR1: %#x\n", I2CxHandle.Instance->OAR1);
  293. break;
  294. case GET_I2C_ADDR: //8bit
  295. i2c_arg.OwnAddress1 = I2CxHandle.Instance->OAR1 & 0x0ff;
  296. if(copy_to_user((void*)arg, &i2c_arg, sizeof(i2c_arg_t)))
  297. return -EFAULT;
  298. break;
  299. case I2C_MASTER_TRANSFER:
  300. HAL_NVIC_DisableIRQ(I2CxEvIRQn);
  301. I2CxHandle.State = HAL_I2C_STATE_READY;
  302. I2CxHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  303. retSta = HAL_I2C_Master_Transmit(&I2CxHandle, (uint16_t)i2c_arg.DevAddress, i2c_arg.buf, i2c_arg.Size, 100); //timeout 1s
  304. if(retSta != HAL_OK)
  305. {
  306. printk(KERN_ERR"I2C master tansfer error, minor = %d, Err = %#x\n", iminor, retSta);
  307. }
  308. HAL_NVIC_EnableIRQ(I2CxEvIRQn);
  309. //HAL_I2C_EnableListen_IT(&I2CxHandle);
  310. break;
  311. case I2C_MASTER_RECEIVE:
  312. HAL_NVIC_DisableIRQ(I2CxEvIRQn);
  313. I2CxHandle.State = HAL_I2C_STATE_READY;
  314. I2CxHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  315. retSta = HAL_I2C_Master_Receive(&I2CxHandle, (uint16_t) i2c_arg.DevAddress, i2c_arg.buf, i2c_arg.Size, 100); //timeout 1s
  316. if(retSta != HAL_OK)
  317. {
  318. printk(KERN_ERR"I2C master recevice error!\n");
  319. }
  320. if(copy_to_user((void*)arg, &i2c_arg, sizeof(i2c_arg_t)))
  321. return -EFAULT;
  322. HAL_NVIC_EnableIRQ(I2CxEvIRQn);
  323. //HAL_I2C_EnableListen_IT(&I2CxHandle);
  324. break;
  325. case I2C_SLAVE_RECEIVE_IT:
  326. I2CxHandle.State = HAL_I2C_STATE_READY;
  327. HAL_I2C_EnableListen_IT(&I2CxHandle);
  328. wait_event_interruptible(wq, ev_press);
  329. ev_press = 0;
  330. memcpy(i2c_arg.buf, i2c_rcv_buf, i2c_rcv_size);
  331. i2c_arg.Size = i2c_rcv_size;
  332. if(copy_to_user((void*)arg, &i2c_arg, sizeof(i2c_arg_t)))
  333. return -EFAULT;
  334. break;
  335. default:
  336. printk("---> Invalid action\n");
  337. return -1;
  338. break;
  339. }
  340. return 0;
  341. }
  342. static ssize_t i2c_read(struct file *filep, char __user *buf, size_t size, loff_t *offset)
  343. {
  344. return 0;
  345. }
  346. static ssize_t i2c_write(struct file *filep, const char __user *buf, size_t size, loff_t *offset)
  347. {
  348. return 0;
  349. }
  350. void i2c_hw_init(void)
  351. {
  352. I2C_HandleTypeDef I2cHandle;
  353. GPIO_InitTypeDef GPIO_InitStruct;
  354. //enable periph clock
  355. __HAL_RCC_GPIOA_CLK_ENABLE();
  356. __HAL_RCC_GPIOB_CLK_ENABLE();
  357. __HAL_RCC_GPIOC_CLK_ENABLE();
  358. __HAL_RCC_GPIOH_CLK_ENABLE();
  359. __HAL_RCC_I2C1_CLK_ENABLE();
  360. __HAL_RCC_I2C2_CLK_ENABLE();
  361. __HAL_RCC_I2C3_CLK_ENABLE();
  362. //config gpio
  363. GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
  364. GPIO_InitStruct.Pull = GPIO_PULLUP;
  365. GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
  366. //I2C1
  367. GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_7; //SCL | SDA
  368. GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
  369. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  370. //I2C2
  371. GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5; //SCL | SDA
  372. GPIO_InitStruct.Alternate = GPIO_AF4_I2C2;
  373. HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
  374. //I2C3
  375. GPIO_InitStruct.Alternate = GPIO_AF4_I2C3;
  376. GPIO_InitStruct.Pin = GPIO_PIN_8; //SCL
  377. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  378. GPIO_InitStruct.Pin = GPIO_PIN_9; //SDA
  379. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  380. //config I2C controller
  381. I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  382. I2cHandle.Init.ClockSpeed = 100000;
  383. I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  384. I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_16_9;
  385. I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  386. I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  387. I2cHandle.Init.OwnAddress1 = 0x40; //default address
  388. I2cHandle.Init.OwnAddress2 = 0xFE;
  389. I2cHandle.State = HAL_I2C_STATE_READY;
  390. I2cHandle.Instance = I2C1;
  391. if(HAL_I2C_Init(&I2cHandle) != HAL_OK)
  392. {
  393. printk(KERN_ERR"I2C1 hw init error!\n");
  394. }
  395. HAL_NVIC_SetPriority(I2C1_EV_IRQn, 2, 0);
  396. HAL_NVIC_SetPriority(I2C1_ER_IRQn, 15, 0);
  397. //HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
  398. //HAL_I2C_EnableListen_IT(&I2cHandle);
  399. I2cHandle.Instance = I2C2;
  400. if(HAL_I2C_Init(&I2cHandle) != HAL_OK)
  401. {
  402. printk(KERN_ERR"I2C1 hw init error!\n");
  403. }
  404. HAL_NVIC_SetPriority(I2C2_EV_IRQn, 2, 0);
  405. HAL_NVIC_SetPriority(I2C2_ER_IRQn, 15, 0);
  406. //HAL_NVIC_EnableIRQ(I2C2_EV_IRQn);
  407. //HAL_I2C_EnableListen_IT(&I2cHandle);
  408. I2cHandle.Instance = I2C3;
  409. if(HAL_I2C_Init(&I2cHandle) != HAL_OK)
  410. {
  411. printk(KERN_ERR"I2C1 hw init error!\n");
  412. }
  413. HAL_NVIC_SetPriority(I2C3_EV_IRQn, 2, 0);
  414. HAL_NVIC_SetPriority(I2C3_ER_IRQn, 15, 0);
  415. //HAL_NVIC_EnableIRQ(I2C3_EV_IRQn);
  416. //HAL_I2C_EnableListen_IT(&I2cHandle);
  417. }
  418. static int __init i2c_init(void)
  419. {
  420. int ret;
  421. int i;
  422. for (i = 0; i < NUM_OF_DEVICES; i++)
  423. {
  424. printk("i2c%d module start...\n", i+1);
  425. i2c_dev[i].devno = MKDEV(MAJOR_I2C, i);
  426. sprintf(i2c_dev[i].name, "%s%d", DEVNAME, i+1);
  427. register_chrdev_region(i2c_dev[i].devno, 1, i2c_dev[i].name);
  428. cdev_add(&i2c_dev[i].cdev, i2c_dev[i].devno, 1);
  429. cdev_init(&i2c_dev[i].cdev, &i2c_ops);
  430. }
  431. i2c_hw_init();
  432. i2c_dev[0].Event_IRQn = I2C1_EV_IRQn;
  433. i2c_dev[1].Event_IRQn = I2C2_EV_IRQn;
  434. i2c_dev[2].Event_IRQn = I2C3_EV_IRQn;
  435. i2c_dev[0].Err_IRQn = I2C1_ER_IRQn;
  436. i2c_dev[1].Err_IRQn = I2C2_ER_IRQn;
  437. i2c_dev[2].Err_IRQn = I2C3_ER_IRQn;
  438. for(i=0; i<NUM_OF_DEVICES; i++)
  439. {
  440. ret = request_irq(i2c_dev[i].Event_IRQn, i2cEvIRQHandler, IRQF_SHARED, i2c_dev[i].name, &i2c_dev[i].devno);
  441. if(ret) {
  442. printk("request_irq() event fialed! %d\n", ret);
  443. goto ERR_STEP1;
  444. }
  445. ret = request_irq(i2c_dev[i].Err_IRQn, i2cErrIRQHandler, IRQF_SHARED, i2c_dev[i].name, &i2c_dev[i].devno);
  446. if(ret) {
  447. printk("request_irq() error fialed! %d\n", ret);
  448. goto ERR_STEP1;
  449. }
  450. }
  451. return 0;
  452. ERR_STEP1:
  453. for(i=0;i<NUM_OF_DEVICES;i++)
  454. unregister_chrdev_region(i2c_dev[i].devno,1);
  455. //ERR_STEP:
  456. for(i=0;i<NUM_OF_DEVICES;i++)
  457. cdev_del(&i2c_dev[i].cdev);
  458. return ret;
  459. }
  460. static void __exit i2c_exit(void)
  461. {
  462. int i;
  463. for(i=0;i<NUM_OF_DEVICES;i++)
  464. {
  465. unregister_chrdev_region(i2c_dev[i].devno, 1);
  466. cdev_del(&i2c_dev[i].cdev);
  467. }
  468. }
  469. module_init(i2c_init);
  470. module_exit(i2c_exit);
  471. MODULE_LICENSE("GPL");
  472. MODULE_AUTHOR("Jimbo");
  473. MODULE_DESCRIPTION("this is i2c module");