isp1301.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * NXP ISP1301 USB transceiver driver
  3. *
  4. * Copyright (C) 2012 Roland Stigge
  5. *
  6. * Author: Roland Stigge <stigge@antcom.de>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/i2c.h>
  14. #define DRV_NAME "isp1301"
  15. static const struct i2c_device_id isp1301_id[] = {
  16. { "isp1301", 0 },
  17. { }
  18. };
  19. static struct i2c_client *isp1301_i2c_client;
  20. static int isp1301_probe(struct i2c_client *client,
  21. const struct i2c_device_id *i2c_id)
  22. {
  23. isp1301_i2c_client = client;
  24. return 0;
  25. }
  26. static int isp1301_remove(struct i2c_client *client)
  27. {
  28. return 0;
  29. }
  30. static struct i2c_driver isp1301_driver = {
  31. .driver = {
  32. .name = DRV_NAME,
  33. },
  34. .probe = isp1301_probe,
  35. .remove = isp1301_remove,
  36. .id_table = isp1301_id,
  37. };
  38. module_i2c_driver(isp1301_driver);
  39. static int match(struct device *dev, void *data)
  40. {
  41. struct device_node *node = (struct device_node *)data;
  42. return (dev->of_node == node) &&
  43. (dev->driver == &isp1301_driver.driver);
  44. }
  45. struct i2c_client *isp1301_get_client(struct device_node *node)
  46. {
  47. if (node) { /* reference of ISP1301 I2C node via DT */
  48. struct device *dev = bus_find_device(&i2c_bus_type, NULL,
  49. node, match);
  50. if (!dev)
  51. return NULL;
  52. return to_i2c_client(dev);
  53. } else { /* non-DT: only one ISP1301 chip supported */
  54. return isp1301_i2c_client;
  55. }
  56. }
  57. EXPORT_SYMBOL_GPL(isp1301_get_client);
  58. MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
  59. MODULE_DESCRIPTION("NXP ISP1301 USB transceiver driver");
  60. MODULE_LICENSE("GPL");