ark-nop-ts.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Touchscreen driver for WM831x PMICs
  3. *
  4. * Copyright 2011 Wolfson Microelectronics plc.
  5. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/moduleparam.h>
  14. #include <linux/kernel.h>
  15. #include <linux/string.h>
  16. #include <linux/pm.h>
  17. #include <linux/input.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/io.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/slab.h>
  22. #include <linux/types.h>
  23. struct ark_nop_ts {
  24. struct input_dev *input_dev;
  25. };
  26. static int ark_nop_ts_probe(struct platform_device *pdev)
  27. {
  28. int ret = -1;
  29. s8 phys[32];
  30. s8 *name = "ark_nop touchscreen";
  31. struct input_dev *input_dev = NULL;
  32. struct ark_nop_ts *ts = devm_kzalloc(&pdev->dev, sizeof(struct ark_nop_ts), GFP_KERNEL);
  33. if(!ts) {
  34. printk(KERN_ERR "%s devm_kazlloc failed\n", __FUNCTION__);
  35. ret = -ENOMEM;
  36. goto err_alloc;
  37. }
  38. input_dev = devm_input_allocate_device(&pdev->dev);
  39. if (!input_dev) {
  40. ret = -ENOMEM;
  41. goto err_alloc;
  42. }
  43. ts->input_dev = input_dev;
  44. /* set up touch configuration */
  45. sprintf(phys, "input/ts");
  46. input_dev->name = name;
  47. input_dev->phys = phys;
  48. ts->input_dev->id.bustype = BUS_HOST;
  49. __set_bit(EV_ABS, input_dev->evbit);
  50. __set_bit(EV_KEY, input_dev->evbit);
  51. __set_bit(BTN_TOUCH, input_dev->keybit);
  52. input_set_abs_params(input_dev, ABS_X, 0, 4095, 5, 0);
  53. input_set_abs_params(input_dev, ABS_Y, 0, 4095, 5, 0);
  54. input_set_abs_params(input_dev, ABS_PRESSURE, 0, 4095, 5, 0);
  55. input_set_drvdata(input_dev, ts);
  56. input_dev->dev.parent = &pdev->dev;
  57. ret = input_register_device(input_dev);
  58. if (ret)
  59. goto err_input_register_device;
  60. platform_set_drvdata(pdev, ts);
  61. printk("%s success\n", __FUNCTION__);
  62. return 0;
  63. err_input_register_device:
  64. err_alloc:
  65. printk(KERN_ERR "%s failed\n", __FUNCTION__);
  66. return ret;
  67. }
  68. static int ark_nop_ts_remove(struct platform_device *pdev)
  69. {
  70. struct ark_nop_ts *ts = platform_get_drvdata(pdev);
  71. if(ts)
  72. {
  73. if(ts->input_dev)
  74. input_unregister_device(ts->input_dev);
  75. }
  76. return 0;
  77. }
  78. static const struct of_device_id ark_nop_ts_match[] = {
  79. {
  80. .compatible = "arkmicro,ark-nop-ts",
  81. },
  82. {},
  83. };
  84. MODULE_DEVICE_TABLE(of, ark_nop_ts_match);
  85. static struct platform_driver ark_nop_ts_driver = {
  86. .probe = ark_nop_ts_probe,
  87. .remove = ark_nop_ts_remove,
  88. .driver = {
  89. .name = "ark_nop_ts",
  90. .owner = THIS_MODULE,
  91. .of_match_table = ark_nop_ts_match,
  92. },
  93. };
  94. module_platform_driver(ark_nop_ts_driver);
  95. /* Module information */
  96. MODULE_AUTHOR("Arkmicro>");
  97. MODULE_DESCRIPTION("Ark Nop touchscreen driver");
  98. MODULE_LICENSE("GPL");