#ifndef __DRIVERS_PHY_H
#define __DRIVERS_PHY_H
#include <linux/err.h>
#include <linux/of.h>
#include <linux/device.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/phy/phy-dp.h>
#include <linux/phy/phy-lvds.h>
#include <linux/phy/phy-mipi-dphy.h>
struct phy;
enum phy_mode { … };
enum phy_media { … };
phy_configure_opts;
struct phy_ops { … };
struct phy_attrs { … };
struct phy { … };
struct phy_provider { … };
struct phy_lookup { … };
#define to_phy(a) …
#define of_phy_provider_register(dev, xlate) …
#define devm_of_phy_provider_register(dev, xlate) …
#define of_phy_provider_register_full(dev, children, xlate) …
#define devm_of_phy_provider_register_full(dev, children, xlate) …
static inline void phy_set_drvdata(struct phy *phy, void *data)
{ … }
static inline void *phy_get_drvdata(struct phy *phy)
{ … }
#if IS_ENABLED(CONFIG_GENERIC_PHY)
int phy_pm_runtime_get(struct phy *phy);
int phy_pm_runtime_get_sync(struct phy *phy);
int phy_pm_runtime_put(struct phy *phy);
int phy_pm_runtime_put_sync(struct phy *phy);
void phy_pm_runtime_allow(struct phy *phy);
void phy_pm_runtime_forbid(struct phy *phy);
int phy_init(struct phy *phy);
int phy_exit(struct phy *phy);
int phy_power_on(struct phy *phy);
int phy_power_off(struct phy *phy);
int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
#define phy_set_mode(phy, mode) …
int phy_set_media(struct phy *phy, enum phy_media media);
int phy_set_speed(struct phy *phy, int speed);
int phy_configure(struct phy *phy, union phy_configure_opts *opts);
int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
union phy_configure_opts *opts);
static inline enum phy_mode phy_get_mode(struct phy *phy)
{ … }
int phy_reset(struct phy *phy);
int phy_calibrate(struct phy *phy);
int phy_notify_connect(struct phy *phy, int port);
int phy_notify_disconnect(struct phy *phy, int port);
static inline int phy_get_bus_width(struct phy *phy)
{ … }
static inline void phy_set_bus_width(struct phy *phy, int bus_width)
{ … }
struct phy *phy_get(struct device *dev, const char *string);
struct phy *devm_phy_get(struct device *dev, const char *string);
struct phy *devm_phy_optional_get(struct device *dev, const char *string);
struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
const char *con_id);
struct phy *devm_of_phy_optional_get(struct device *dev, struct device_node *np,
const char *con_id);
struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
int index);
void of_phy_put(struct phy *phy);
void phy_put(struct device *dev, struct phy *phy);
void devm_phy_put(struct device *dev, struct phy *phy);
struct phy *of_phy_get(struct device_node *np, const char *con_id);
struct phy *of_phy_simple_xlate(struct device *dev,
const struct of_phandle_args *args);
struct phy *phy_create(struct device *dev, struct device_node *node,
const struct phy_ops *ops);
struct phy *devm_phy_create(struct device *dev, struct device_node *node,
const struct phy_ops *ops);
void phy_destroy(struct phy *phy);
void devm_phy_destroy(struct device *dev, struct phy *phy);
struct phy_provider *__of_phy_provider_register(struct device *dev,
struct device_node *children, struct module *owner,
struct phy * (*of_xlate)(struct device *dev,
const struct of_phandle_args *args));
struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
struct device_node *children, struct module *owner,
struct phy * (*of_xlate)(struct device *dev,
const struct of_phandle_args *args));
void of_phy_provider_unregister(struct phy_provider *phy_provider);
void devm_of_phy_provider_unregister(struct device *dev,
struct phy_provider *phy_provider);
int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id);
#else
static inline int phy_pm_runtime_get(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_pm_runtime_get_sync(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_pm_runtime_put(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_pm_runtime_put_sync(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline void phy_pm_runtime_allow(struct phy *phy)
{
return;
}
static inline void phy_pm_runtime_forbid(struct phy *phy)
{
return;
}
static inline int phy_init(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_exit(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_power_on(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_power_off(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
int submode)
{
if (!phy)
return 0;
return -ENOSYS;
}
#define phy_set_mode …
static inline int phy_set_media(struct phy *phy, enum phy_media media)
{
if (!phy)
return 0;
return -ENODEV;
}
static inline int phy_set_speed(struct phy *phy, int speed)
{
if (!phy)
return 0;
return -ENODEV;
}
static inline enum phy_mode phy_get_mode(struct phy *phy)
{
return PHY_MODE_INVALID;
}
static inline int phy_reset(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_calibrate(struct phy *phy)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_notify_connect(struct phy *phy, int index)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_notify_disconnect(struct phy *phy, int index)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_configure(struct phy *phy,
union phy_configure_opts *opts)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
union phy_configure_opts *opts)
{
if (!phy)
return 0;
return -ENOSYS;
}
static inline int phy_get_bus_width(struct phy *phy)
{
return -ENOSYS;
}
static inline void phy_set_bus_width(struct phy *phy, int bus_width)
{
return;
}
static inline struct phy *phy_get(struct device *dev, const char *string)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *devm_phy_get(struct device *dev, const char *string)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *devm_phy_optional_get(struct device *dev,
const char *string)
{
return NULL;
}
static inline struct phy *devm_of_phy_get(struct device *dev,
struct device_node *np,
const char *con_id)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *devm_of_phy_optional_get(struct device *dev,
struct device_node *np,
const char *con_id)
{
return NULL;
}
static inline struct phy *devm_of_phy_get_by_index(struct device *dev,
struct device_node *np,
int index)
{
return ERR_PTR(-ENOSYS);
}
static inline void of_phy_put(struct phy *phy)
{
}
static inline void phy_put(struct device *dev, struct phy *phy)
{
}
static inline void devm_phy_put(struct device *dev, struct phy *phy)
{
}
static inline struct phy *of_phy_get(struct device_node *np, const char *con_id)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *of_phy_simple_xlate(struct device *dev,
const struct of_phandle_args *args)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *phy_create(struct device *dev,
struct device_node *node,
const struct phy_ops *ops)
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy *devm_phy_create(struct device *dev,
struct device_node *node,
const struct phy_ops *ops)
{
return ERR_PTR(-ENOSYS);
}
static inline void phy_destroy(struct phy *phy)
{
}
static inline void devm_phy_destroy(struct device *dev, struct phy *phy)
{
}
static inline struct phy_provider *__of_phy_provider_register(
struct device *dev, struct device_node *children, struct module *owner,
struct phy * (*of_xlate)(struct device *dev,
const struct of_phandle_args *args))
{
return ERR_PTR(-ENOSYS);
}
static inline struct phy_provider *__devm_of_phy_provider_register(struct device
*dev, struct device_node *children, struct module *owner,
struct phy * (*of_xlate)(struct device *dev,
const struct of_phandle_args *args))
{
return ERR_PTR(-ENOSYS);
}
static inline void of_phy_provider_unregister(struct phy_provider *phy_provider)
{
}
static inline void devm_of_phy_provider_unregister(struct device *dev,
struct phy_provider *phy_provider)
{
}
static inline int
phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id)
{
return 0;
}
static inline void phy_remove_lookup(struct phy *phy, const char *con_id,
const char *dev_id) { }
#endif
#endif