rmi_sensor.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /**
  2. * Synaptics Register Mapped Interface (RMI4) - RMI Sensor Module.
  3. * Copyright (C) 2007 - 2011, Synaptics Incorporated
  4. *
  5. */
  6. /*
  7. * This file is licensed under the GPL2 license.
  8. *
  9. *############################################################################
  10. * GPL
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License version 2 as published
  14. * by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  19. * for more details.
  20. *
  21. *############################################################################
  22. */
  23. static const char sensorname[] = "sensor";
  24. #include <linux/kernel.h>
  25. #include <linux/gpio.h>
  26. #include <linux/list.h>
  27. #include <linux/device.h>
  28. #include <linux/hrtimer.h>
  29. #include <linux/miscdevice.h>
  30. #include <linux/fs.h>
  31. #include <linux/delay.h>
  32. #include <linux/uaccess.h>
  33. #include <linux/slab.h>
  34. #include <linux/kthread.h>
  35. #include <linux/freezer.h>
  36. #include <linux/input.h>
  37. #include <linux/interrupt.h>
  38. #include <linux/module.h>
  39. #include "rmi_drvr.h"
  40. #include "rmi_bus.h"
  41. #include "rmi_function.h"
  42. #include "rmi_sensor.h"
  43. long polltime = 25000000; /* Shared with rmi_function.c. */
  44. EXPORT_SYMBOL(polltime);
  45. module_param(polltime, long, 0644);
  46. MODULE_PARM_DESC(polltime, "How long to wait between polls (in nano seconds).");
  47. #define PDT_START_SCAN_LOCATION 0x00E9
  48. #define PDT_END_SCAN_LOCATION 0x0005
  49. #define PDT_ENTRY_SIZE 0x0006
  50. static DEFINE_MUTEX(rfi_mutex);
  51. struct rmi_functions *rmi_find_function(int functionNum);
  52. int rmi_read(struct rmi_sensor_driver *sensor, unsigned short address,
  53. char *dest)
  54. {
  55. struct rmi_phys_driver *rpd = sensor->rpd;
  56. if (!rpd)
  57. return -ENODEV;
  58. return rpd->read(rpd, address, dest);
  59. }
  60. EXPORT_SYMBOL(rmi_read);
  61. int rmi_write(struct rmi_sensor_driver *sensor, unsigned short address,
  62. unsigned char data)
  63. {
  64. struct rmi_phys_driver *rpd = sensor->rpd;
  65. if (!rpd)
  66. return -ENODEV;
  67. return rpd->write(rpd, address, data);
  68. }
  69. EXPORT_SYMBOL(rmi_write);
  70. int rmi_read_multiple(struct rmi_sensor_driver *sensor,
  71. unsigned short address, char *dest, int length)
  72. {
  73. struct rmi_phys_driver *rpd = sensor->rpd;
  74. if (!rpd)
  75. return -ENODEV;
  76. return rpd->read_multiple(rpd, address, dest, length);
  77. }
  78. EXPORT_SYMBOL(rmi_read_multiple);
  79. int rmi_write_multiple(struct rmi_sensor_driver *sensor,
  80. unsigned short address, unsigned char *data, int length)
  81. {
  82. struct rmi_phys_driver *rpd = sensor->rpd;
  83. if (!rpd)
  84. return -ENODEV;
  85. return rpd->write_multiple(rpd, address, data, length);
  86. }
  87. EXPORT_SYMBOL(rmi_write_multiple);
  88. /* Utility routine to set bits in a register. */
  89. int rmi_set_bits(struct rmi_sensor_driver *sensor, unsigned short address,
  90. unsigned char bits)
  91. {
  92. unsigned char reg_contents;
  93. int retval;
  94. retval = rmi_read(sensor, address, &reg_contents);
  95. if (retval)
  96. return retval;
  97. reg_contents = reg_contents | bits;
  98. retval = rmi_write(sensor, address, reg_contents);
  99. if (retval == 1)
  100. return 0;
  101. else if (retval == 0)
  102. return -EINVAL; /* TODO: What should this be? */
  103. else
  104. return retval;
  105. }
  106. EXPORT_SYMBOL(rmi_set_bits);
  107. /* Utility routine to clear bits in a register. */
  108. int rmi_clear_bits(struct rmi_sensor_driver *sensor,
  109. unsigned short address, unsigned char bits)
  110. {
  111. unsigned char reg_contents;
  112. int retval;
  113. retval = rmi_read(sensor, address, &reg_contents);
  114. if (retval)
  115. return retval;
  116. reg_contents = reg_contents & ~bits;
  117. retval = rmi_write(sensor, address, reg_contents);
  118. if (retval == 1)
  119. return 0;
  120. else if (retval == 0)
  121. return -EINVAL; /* TODO: What should this be? */
  122. else
  123. return retval;
  124. }
  125. EXPORT_SYMBOL(rmi_clear_bits);
  126. /* Utility routine to set the value of a bit field in a register. */
  127. int rmi_set_bit_field(struct rmi_sensor_driver *sensor,
  128. unsigned short address, unsigned char field_mask, unsigned char bits)
  129. {
  130. unsigned char reg_contents;
  131. int retval;
  132. retval = rmi_read(sensor, address, &reg_contents);
  133. if (retval)
  134. return retval;
  135. reg_contents = (reg_contents & ~field_mask) | bits;
  136. retval = rmi_write(sensor, address, reg_contents);
  137. if (retval == 1)
  138. return 0;
  139. else if (retval == 0)
  140. return -EINVAL; /* TODO: What should this be? */
  141. else
  142. return retval;
  143. }
  144. EXPORT_SYMBOL(rmi_set_bit_field);
  145. bool rmi_polling_required(struct rmi_sensor_driver *sensor)
  146. {
  147. return sensor->polling_required;
  148. }
  149. EXPORT_SYMBOL(rmi_polling_required);
  150. /** Functions can call this in order to dispatch IRQs. */
  151. void dispatchIRQs(struct rmi_sensor_driver *sensor, unsigned int irqStatus)
  152. {
  153. struct rmi_function_info *functionInfo;
  154. list_for_each_entry(functionInfo, &sensor->functions, link) {
  155. if ((functionInfo->interruptMask & irqStatus)) {
  156. if (functionInfo->function_device->
  157. rmi_funcs->inthandler) {
  158. /* Call the functions interrupt handler function. */
  159. functionInfo->function_device->rmi_funcs->
  160. inthandler(functionInfo,
  161. (functionInfo->interruptMask & irqStatus));
  162. }
  163. }
  164. }
  165. }
  166. /**
  167. * This is the function we pass to the RMI4 subsystem so we can be notified
  168. * when attention is required. It may be called in interrupt context.
  169. */
  170. static void attention(struct rmi_phys_driver *physdrvr, int instance)
  171. {
  172. /* All we have to do is schedule work. */
  173. /* TODO: It's possible that workIsReady is not really needed anymore.
  174. * Investigate this to see if the race condition between setting up
  175. * the work and enabling the interrupt still exists.
  176. */
  177. if (physdrvr->sensor->workIsReady) {
  178. schedule_work(&(physdrvr->sensor->work));
  179. } else {
  180. /* Got an interrupt but we're not ready so enable the irq
  181. * so it doesn't get hung up
  182. */
  183. printk(KERN_DEBUG "%s: Work not initialized yet -"
  184. "enabling irqs.\n", __func__);
  185. enable_irq(physdrvr->irq);
  186. }
  187. }
  188. /**
  189. * This notifies any interested functions that there
  190. * is an Attention interrupt. The interested functions should take
  191. * appropriate
  192. * actions (such as reading the interrupt status register and dispatching any
  193. * appropriate RMI4 interrupts).
  194. */
  195. void attn_notify(struct rmi_sensor_driver *sensor)
  196. {
  197. struct rmi_function_info *functionInfo;
  198. /* check each function that has data sources and if the interrupt for
  199. * that triggered then call that RMI4 functions report() function to
  200. * gather data and report it to the input subsystem
  201. */
  202. list_for_each_entry(functionInfo, &sensor->functions, link) {
  203. if (functionInfo->function_device &&
  204. functionInfo->function_device->rmi_funcs->attention)
  205. functionInfo->function_device->
  206. rmi_funcs->attention(functionInfo);
  207. }
  208. }
  209. /* This is the worker function - for now it simply has to call attn_notify.
  210. * This work should be scheduled whenever an ATTN interrupt is asserted by
  211. * the touch sensor.
  212. * We then call attn_notify to dispatch notification of the ATTN interrupt
  213. * to all
  214. * interested functions. After all the attention handling functions
  215. * have returned, it is presumed safe to re-enable the Attention interrupt.
  216. */
  217. static void sensor_work_func(struct work_struct *work)
  218. {
  219. struct rmi_sensor_driver *sensor = container_of(work,
  220. struct rmi_sensor_driver, work);
  221. attn_notify(sensor);
  222. /* we only need to enable the irq if doing interrupts */
  223. if (!rmi_polling_required(sensor))
  224. enable_irq(sensor->rpd->irq);
  225. }
  226. /* This is the timer function for polling - it simply has to schedule work
  227. * and restart the timer. */
  228. static enum hrtimer_restart sensor_poll_timer_func(struct hrtimer *timer)
  229. {
  230. struct rmi_sensor_driver *sensor = container_of(timer,
  231. struct rmi_sensor_driver, timer);
  232. schedule_work(&sensor->work);
  233. hrtimer_start(&sensor->timer, ktime_set(0, polltime),
  234. HRTIMER_MODE_REL);
  235. return HRTIMER_NORESTART;
  236. }
  237. /* This is the probe function passed to the RMI4 subsystem that gives us a
  238. * chance to recognize an RMI4 device. In this case, we're looking for
  239. * Synaptics devices that have data sources - such as touch screens, buttons,
  240. * etc.
  241. *
  242. * TODO: Well, it used to do this. I'm not sure it's required any more.
  243. */
  244. static int probe(struct rmi_sensor_driver *sensor)
  245. {
  246. struct rmi_phys_driver *rpd;
  247. rpd = sensor->rpd;
  248. if (!rpd) {
  249. printk(KERN_ERR "%s: Invalid rmi physical driver - null ptr:"
  250. "%p\n", __func__, rpd);
  251. return 0;
  252. }
  253. return 1;
  254. }
  255. static void config(struct rmi_sensor_driver *sensor)
  256. {
  257. /* For each data source we had detected print info and set up interrupts
  258. or polling. */
  259. struct rmi_function_info *functionInfo;
  260. struct rmi_phys_driver *rpd;
  261. rpd = sensor->rpd; /* get ptr to rmi_physical_driver from app */
  262. list_for_each_entry(functionInfo, &sensor->functions, link) {
  263. /* Get and print some info about the data sources... */
  264. struct rmi_functions *fn;
  265. bool found = false;
  266. /* check if function number matches - if so call that
  267. config function */
  268. fn = rmi_find_function(functionInfo->functionNum);
  269. if (fn) {
  270. found = true;
  271. if (fn->config) {
  272. fn->config(functionInfo);
  273. } else {
  274. /* the developer did not add in the
  275. pointer to the config function into
  276. rmi4_supported_data_src_functions */
  277. printk(KERN_ERR
  278. "%s: no config function for "
  279. "function 0x%x\n",
  280. __func__, functionInfo->functionNum);
  281. break;
  282. }
  283. }
  284. if (!found) {
  285. /* if no support found for this RMI4 function
  286. it means the developer did not add the
  287. appropriate function pointer list into the
  288. rmi4_supported_data_src_functions array and/or
  289. did not bump up the number of supported RMI4
  290. functions in rmi.h as required */
  291. printk(KERN_ERR "%s: could not find support "
  292. "for function 0x%x\n",
  293. __func__, functionInfo->functionNum);
  294. }
  295. }
  296. /* This will handle interrupts on the ATTN line (interrupt driven)
  297. * or will be called every poll interval (when we're not interrupt
  298. * driven).
  299. */
  300. INIT_WORK(&sensor->work, sensor_work_func);
  301. sensor->workIsReady = true;
  302. if (rmi_polling_required(sensor)) {
  303. /* We're polling driven, so set up the polling timer
  304. and timer function. */
  305. hrtimer_init(&sensor->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  306. sensor->timer.function = sensor_poll_timer_func;
  307. hrtimer_start(&sensor->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
  308. }
  309. }
  310. /** Just a stub for now.
  311. */
  312. static int rmi_sensor_suspend(struct device *dev, pm_message_t state)
  313. {
  314. printk(KERN_INFO "%s: sensor suspend called.", __func__);
  315. return 0;
  316. }
  317. /** Just a stub for now.
  318. */
  319. static int rmi_sensor_resume(struct device *dev)
  320. {
  321. printk(KERN_INFO "%s: sensor resume called.", __func__);
  322. return 0;
  323. }
  324. /*
  325. * This method is called, whenever a new sensor device is added for the rmi
  326. * bus.
  327. *
  328. * It will scan the devices PDT to determine the supported functions
  329. * and create a new function device for each of these. It will read
  330. * the query, control, command and data regsiters for the function
  331. * to be used for each newly created function device.
  332. *
  333. * The sensor device is then bound to every function it supports.
  334. *
  335. */
  336. int rmi_sensor_register_functions(struct rmi_sensor_driver *sensor)
  337. {
  338. struct rmi_function_device *function;
  339. unsigned int interruptRegisterCount;
  340. struct rmi_phys_driver *rpd;
  341. int i;
  342. unsigned char interruptCount;
  343. struct rmi_function_info *functionInfo;
  344. struct rmi_function_descriptor rmi_fd;
  345. struct rmi_functions *fn;
  346. int retval;
  347. pr_debug("%s: Registering sensor functions\n", __func__);
  348. retval = 0;
  349. /* Scan device for functions that may be supported */
  350. {
  351. pr_debug("%s: Scanning sensor for Functions:\n", __func__);
  352. interruptCount = 0;
  353. rpd = sensor->rpd;
  354. /* Read the Page Descriptor Table to determine what functions
  355. * are present */
  356. printk(KERN_DEBUG "%s: Scanning page descriptors.", __func__);
  357. for (i = PDT_START_SCAN_LOCATION;
  358. i >= PDT_END_SCAN_LOCATION;
  359. i -= PDT_ENTRY_SIZE) {
  360. printk(KERN_DEBUG "%s: Reading page descriptor 0x%02x", __func__, i);
  361. retval = rpd->read_multiple(rpd, i, (char *)&rmi_fd,
  362. sizeof(rmi_fd));
  363. if (!retval) {
  364. functionInfo = NULL;
  365. if (rmi_fd.functionNum != 0x00 && rmi_fd.functionNum != 0xff) {
  366. printk(KERN_DEBUG "%s: F%02x - queries %02x commands %02x control %02x data %02x ints %02x", __func__, rmi_fd.functionNum, rmi_fd.queryBaseAddr, rmi_fd.commandBaseAddr, rmi_fd.controlBaseAddr, rmi_fd.dataBaseAddr, rmi_fd.interruptSrcCnt);
  367. if ((rmi_fd.functionNum & 0xff) == 0x01)
  368. printk(KERN_DEBUG "%s: Fn $01 Found - RMI Device Control", __func__);
  369. /* determine if the function is supported and if so
  370. * then bind this function device to the sensor */
  371. if (rmi_fd.interruptSrcCnt) {
  372. functionInfo = kzalloc(sizeof(*functionInfo), GFP_KERNEL);
  373. if (!functionInfo) {
  374. printk(KERN_ERR "%s: could not allocate memory for function 0x%x.",
  375. __func__, rmi_fd.functionNum);
  376. retval = -ENOMEM;
  377. goto exit_fail;
  378. }
  379. functionInfo->sensor = sensor;
  380. functionInfo->functionNum = (rmi_fd.functionNum & 0xff);
  381. INIT_LIST_HEAD(&functionInfo->link);
  382. /* Get the ptr to the detect function based on
  383. * the function number */
  384. printk(KERN_DEBUG "%s: Checking for RMI function F%02x.", __func__, rmi_fd.functionNum);
  385. fn = rmi_find_function(rmi_fd.functionNum);
  386. if (fn) {
  387. retval = fn->detect(functionInfo, &rmi_fd,
  388. interruptCount);
  389. if (retval)
  390. printk(KERN_ERR "%s: Function detect for F%02x failed with %d.",
  391. __func__, rmi_fd.functionNum, retval);
  392. /* Create a function device and function driver for this Fn */
  393. function = kzalloc(sizeof(*function), GFP_KERNEL);
  394. if (!function) {
  395. printk(KERN_ERR "%s: Error allocating memory for rmi_function_device.", __func__);
  396. return -ENOMEM;
  397. }
  398. function->dev.parent = &sensor->sensor_device->dev;
  399. function->dev.bus = sensor->sensor_device->dev.bus;
  400. function->rmi_funcs = fn;
  401. function->sensor = sensor;
  402. function->rfi = functionInfo;
  403. functionInfo->function_device = function;
  404. /* Check if we have an interrupt mask of 0 and a non-NULL interrupt
  405. handler function and print a debug message since we should never
  406. have this.
  407. */
  408. if (functionInfo->interruptMask == 0 && fn->inthandler != NULL) {
  409. printk(KERN_DEBUG "%s: Can't have a zero interrupt mask for function F%02x (which requires an interrupt handler).\n",
  410. __func__, rmi_fd.functionNum);
  411. }
  412. /* Check if we have a non-zero interrupt mask and a NULL interrupt
  413. handler function and print a debug message since we should never
  414. have this.
  415. */
  416. if (functionInfo->interruptMask != 0 && fn->inthandler == NULL) {
  417. printk(KERN_DEBUG "%s: Can't have a non-zero interrupt mask %d for function F%02x with a NULL inthandler fn.\n",
  418. __func__, functionInfo->interruptMask, rmi_fd.functionNum);
  419. }
  420. /* Register the rmi function device */
  421. retval = rmi_function_register_device(function, rmi_fd.functionNum);
  422. if (retval) {
  423. printk(KERN_ERR "%s: Failed rmi_function_register_device.\n",
  424. __func__);
  425. return retval;
  426. }
  427. } else {
  428. printk(KERN_ERR "%s: could not find support for function 0x%02X.\n",
  429. __func__, rmi_fd.functionNum);
  430. }
  431. } else {
  432. printk(KERN_DEBUG "%s: Found function F%02x - Ignored.\n", __func__, rmi_fd.functionNum & 0xff);
  433. }
  434. /* bump interrupt count for next iteration */
  435. /* NOTE: The value 7 is reserved - for now, only bump up one for an interrupt count of 7 */
  436. if ((rmi_fd.interruptSrcCnt & 0x7) == 0x7) {
  437. interruptCount += 1;
  438. } else {
  439. interruptCount +=
  440. (rmi_fd.interruptSrcCnt & 0x7);
  441. }
  442. /* link this function info to the RMI module infos list
  443. of functions */
  444. if (functionInfo == NULL) {
  445. printk(KERN_DEBUG "%s: WTF? functionInfo is null here.", __func__);
  446. } else {
  447. printk(KERN_DEBUG "%s: Adding function F%02x with %d sources.\n",
  448. __func__, functionInfo->functionNum, functionInfo->numSources);
  449. mutex_lock(&rfi_mutex);
  450. list_add_tail(&functionInfo->link,
  451. &sensor->functions);
  452. mutex_unlock(&rfi_mutex);
  453. }
  454. } else {
  455. /* A zero or 0xff in the function number
  456. signals the end of the PDT */
  457. printk(KERN_DEBUG "%s: Found End of PDT\n",
  458. __func__);
  459. break;
  460. }
  461. } else {
  462. /* failed to read next PDT entry - end PDT
  463. scan - this may result in an incomplete set
  464. of recognized functions - should probably
  465. return an error but the driver may still be
  466. viable for diagnostics and debugging so let's
  467. let it continue. */
  468. printk(KERN_ERR "%s: Read Error %d when reading next PDT entry - "
  469. "ending PDT scan.\n",
  470. __func__, retval);
  471. break;
  472. }
  473. }
  474. printk(KERN_DEBUG "%s: Done scanning.", __func__);
  475. /* calculate the interrupt register count - used in the
  476. ISR to read the correct number of interrupt registers */
  477. interruptRegisterCount = (interruptCount + 7) / 8;
  478. sensor->interruptRegisterCount = interruptRegisterCount; /* TODO: Is this needed by the sensor anymore? */
  479. }
  480. return 0;
  481. exit_fail:
  482. return retval;
  483. }
  484. EXPORT_SYMBOL(rmi_sensor_register_functions);
  485. int rmi_sensor_register_device(struct rmi_sensor_device *dev, int index)
  486. {
  487. int status;
  488. printk(KERN_INFO "%s: Registering sensor device.\n", __func__);
  489. /* make name - sensor00, sensor01, etc. */
  490. dev_set_name(&dev->dev, "sensor%02d", index);
  491. status = device_register(&dev->dev);
  492. return status;
  493. }
  494. EXPORT_SYMBOL(rmi_sensor_register_device);
  495. static void rmi_sensor_unregister_device(struct rmi_sensor_device *rmisensordev)
  496. {
  497. printk(KERN_INFO "%s: Unregistering sensor device.\n", __func__);
  498. device_unregister(&rmisensordev->dev);
  499. }
  500. EXPORT_SYMBOL(rmi_sensor_unregister_device);
  501. int rmi_sensor_register_driver(struct rmi_sensor_driver *driver)
  502. {
  503. static int index;
  504. int ret;
  505. char *drvrname;
  506. driver->workIsReady = false;
  507. printk(KERN_INFO "%s: Registering sensor driver.\n", __func__);
  508. driver->dispatchIRQs = dispatchIRQs;
  509. driver->attention = attention;
  510. driver->config = config;
  511. driver->probe = probe;
  512. /* assign the bus type for this driver to be rmi bus */
  513. driver->drv.bus = &rmi_bus_type;
  514. driver->drv.suspend = rmi_sensor_suspend;
  515. driver->drv.resume = rmi_sensor_resume;
  516. /* Create a function device and function driver for this Fn */
  517. drvrname = kzalloc(sizeof(sensorname) + 4, GFP_KERNEL);
  518. if (!drvrname) {
  519. printk(KERN_ERR "%s: Error allocating memeory for rmi_sensor_driver name.\n", __func__);
  520. return -ENOMEM;
  521. }
  522. sprintf(drvrname, "sensor%02d", index++);
  523. driver->drv.name = drvrname;
  524. driver->module = driver->drv.owner;
  525. /* register the sensor driver */
  526. ret = driver_register(&driver->drv);
  527. if (ret) {
  528. printk(KERN_ERR "%s: Failed driver_register %d\n",
  529. __func__, ret);
  530. goto exit_fail;
  531. }
  532. /* register the functions on the sensor */
  533. ret = rmi_sensor_register_functions(driver);
  534. if (ret) {
  535. printk(KERN_ERR "%s: Failed rmi_sensor_register_functions %d\n",
  536. __func__, ret);
  537. }
  538. /* configure the sensor - enable interrupts for each function, init work, set polling timer or adjust report rate, etc. */
  539. config(driver);
  540. printk(KERN_DEBUG "%s: sensor driver registration completed.", __func__);
  541. exit_fail:
  542. return ret;
  543. }
  544. EXPORT_SYMBOL(rmi_sensor_register_driver);
  545. static void rmi_sensor_unregister_driver(struct rmi_sensor_driver *driver)
  546. {
  547. printk(KERN_DEBUG "%s: Unregistering sensor driver.\n", __func__);
  548. /* Stop the polling timer if doing polling */
  549. if (rmi_polling_required(driver))
  550. hrtimer_cancel(&driver->timer);
  551. flush_scheduled_work(); /* Make sure all scheduled work is stopped */
  552. driver_unregister(&driver->drv);
  553. }
  554. EXPORT_SYMBOL(rmi_sensor_unregister_driver);
  555. static int __init rmi_sensor_init(void)
  556. {
  557. printk(KERN_DEBUG "%s: RMI Sensor Init\n", __func__);
  558. return 0;
  559. }
  560. static void __exit rmi_sensor_exit(void)
  561. {
  562. printk(KERN_DEBUG "%s: RMI Sensor Driver Exit\n", __func__);
  563. flush_scheduled_work(); /* Make sure all scheduled work is stopped */
  564. }
  565. module_init(rmi_sensor_init);
  566. module_exit(rmi_sensor_exit);
  567. MODULE_AUTHOR("Synaptics, Inc.");
  568. MODULE_DESCRIPTION("RMI4 Sensor Driver");
  569. MODULE_LICENSE("GPL");