isp1301.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #define ISP1301_I2C_ADDR 0x2C
  16. static const unsigned short normal_i2c[] = {
  17. ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END
  18. };
  19. static const struct i2c_device_id isp1301_id[] = {
  20. { "isp1301", 0 },
  21. { }
  22. };
  23. static struct i2c_client *isp1301_i2c_client;
  24. static int isp1301_probe(struct i2c_client *client,
  25. const struct i2c_device_id *i2c_id)
  26. {
  27. isp1301_i2c_client = client;
  28. return 0;
  29. }
  30. static int isp1301_remove(struct i2c_client *client)
  31. {
  32. return 0;
  33. }
  34. static struct i2c_driver isp1301_driver = {
  35. .driver = {
  36. .name = DRV_NAME,
  37. },
  38. .probe = isp1301_probe,
  39. .remove = isp1301_remove,
  40. .id_table = isp1301_id,
  41. };
  42. module_i2c_driver(isp1301_driver);
  43. static int match(struct device *dev, void *data)
  44. {
  45. struct device_node *node = (struct device_node *)data;
  46. return (dev->of_node == node) &&
  47. (dev->driver == &isp1301_driver.driver);
  48. }
  49. struct i2c_client *isp1301_get_client(struct device_node *node)
  50. {
  51. if (node) { /* reference of ISP1301 I2C node via DT */
  52. struct device *dev = bus_find_device(&i2c_bus_type, NULL,
  53. node, match);
  54. if (!dev)
  55. return NULL;
  56. return to_i2c_client(dev);
  57. } else { /* non-DT: only one ISP1301 chip supported */
  58. return isp1301_i2c_client;
  59. }
  60. }
  61. EXPORT_SYMBOL_GPL(isp1301_get_client);
  62. MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
  63. MODULE_DESCRIPTION("NXP ISP1301 USB transceiver driver");
  64. MODULE_LICENSE("GPL");