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