blob: a7af21a5524805b47718ef8001eea20e83860647 [file] [log] [blame]
Heikki Krogerus289fcff2015-05-13 15:26:42 +03001#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
8struct 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 */
16struct ulpi {
17 struct ulpi_device_id id;
Tal Shorerb9454f92016-08-16 19:04:52 +030018 const struct ulpi_ops *ops;
Heikki Krogerus289fcff2015-05-13 15:26:42 +030019 struct device dev;
20};
21
22#define to_ulpi_dev(d) container_of(d, struct ulpi, dev)
23
24static inline void ulpi_set_drvdata(struct ulpi *ulpi, void *data)
25{
26 dev_set_drvdata(&ulpi->dev, data);
27}
28
29static 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 */
41struct 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
Stephen Boyd1ebe88d2016-06-25 22:38:21 -070050/*
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)
54int __ulpi_register_driver(struct ulpi_driver *drv, struct module *module);
Heikki Krogerus289fcff2015-05-13 15:26:42 +030055void 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
61int ulpi_read(struct ulpi *ulpi, u8 addr);
62int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val);
63
64#endif /* __LINUX_ULPI_DRIVER_H */