driver.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __LINUX_ULPI_DRIVER_H
  2. #define __LINUX_ULPI_DRIVER_H
  3. #include <linux/mod_devicetable.h>
  4. #include <linux/device.h>
  5. struct ulpi_ops;
  6. /**
  7. * struct ulpi - describes ULPI PHY device
  8. * @id: vendor and product ids for ULPI device
  9. * @ops: I/O access
  10. * @dev: device interface
  11. */
  12. struct ulpi {
  13. struct ulpi_device_id id;
  14. struct ulpi_ops *ops;
  15. struct device dev;
  16. };
  17. #define to_ulpi_dev(d) container_of(d, struct ulpi, dev)
  18. static inline void ulpi_set_drvdata(struct ulpi *ulpi, void *data)
  19. {
  20. dev_set_drvdata(&ulpi->dev, data);
  21. }
  22. static inline void *ulpi_get_drvdata(struct ulpi *ulpi)
  23. {
  24. return dev_get_drvdata(&ulpi->dev);
  25. }
  26. /**
  27. * struct ulpi_driver - describes a ULPI PHY driver
  28. * @id_table: array of device identifiers supported by this driver
  29. * @probe: binds this driver to ULPI device
  30. * @remove: unbinds this driver from ULPI device
  31. * @driver: the name and owner members must be initialized by the drivers
  32. */
  33. struct ulpi_driver {
  34. const struct ulpi_device_id *id_table;
  35. int (*probe)(struct ulpi *ulpi);
  36. void (*remove)(struct ulpi *ulpi);
  37. struct device_driver driver;
  38. };
  39. #define to_ulpi_driver(d) container_of(d, struct ulpi_driver, driver)
  40. int ulpi_register_driver(struct ulpi_driver *drv);
  41. void ulpi_unregister_driver(struct ulpi_driver *drv);
  42. #define module_ulpi_driver(__ulpi_driver) \
  43. module_driver(__ulpi_driver, ulpi_register_driver, \
  44. ulpi_unregister_driver)
  45. int ulpi_read(struct ulpi *ulpi, u8 addr);
  46. int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val);
  47. #endif /* __LINUX_ULPI_DRIVER_H */