2019-05-27 14:55:01 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2013-09-27 14:23:25 +08:00
|
|
|
/*
|
|
|
|
* phy.h -- generic phy header file
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
|
|
|
|
*
|
|
|
|
* Author: Kishon Vijay Abraham I <kishon@ti.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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>
|
2014-07-04 17:55:45 +08:00
|
|
|
#include <linux/regulator/consumer.h>
|
2013-09-27 14:23:25 +08:00
|
|
|
|
2020-01-06 20:22:40 +08:00
|
|
|
#include <linux/phy/phy-dp.h>
|
2018-12-07 21:55:30 +08:00
|
|
|
#include <linux/phy/phy-mipi-dphy.h>
|
|
|
|
|
2013-09-27 14:23:25 +08:00
|
|
|
struct phy;
|
|
|
|
|
2016-05-10 07:39:59 +08:00
|
|
|
enum phy_mode {
|
|
|
|
PHY_MODE_INVALID,
|
|
|
|
PHY_MODE_USB_HOST,
|
2018-01-16 18:57:09 +08:00
|
|
|
PHY_MODE_USB_HOST_LS,
|
|
|
|
PHY_MODE_USB_HOST_FS,
|
|
|
|
PHY_MODE_USB_HOST_HS,
|
|
|
|
PHY_MODE_USB_HOST_SS,
|
2016-05-10 07:39:59 +08:00
|
|
|
PHY_MODE_USB_DEVICE,
|
2018-01-16 18:57:09 +08:00
|
|
|
PHY_MODE_USB_DEVICE_LS,
|
|
|
|
PHY_MODE_USB_DEVICE_FS,
|
|
|
|
PHY_MODE_USB_DEVICE_HS,
|
|
|
|
PHY_MODE_USB_DEVICE_SS,
|
2016-05-10 07:39:59 +08:00
|
|
|
PHY_MODE_USB_OTG,
|
2017-10-12 14:19:33 +08:00
|
|
|
PHY_MODE_UFS_HS_A,
|
|
|
|
PHY_MODE_UFS_HS_B,
|
2018-10-04 20:22:03 +08:00
|
|
|
PHY_MODE_PCIE,
|
2018-11-20 09:24:21 +08:00
|
|
|
PHY_MODE_ETHERNET,
|
2018-12-07 21:55:28 +08:00
|
|
|
PHY_MODE_MIPI_DPHY,
|
2019-10-24 06:38:49 +08:00
|
|
|
PHY_MODE_SATA,
|
|
|
|
PHY_MODE_LVDS,
|
2020-01-06 20:22:40 +08:00
|
|
|
PHY_MODE_DP
|
2016-05-10 07:39:59 +08:00
|
|
|
};
|
|
|
|
|
phy: Add configuration interface
The phy framework is only allowing to configure the power state of the PHY
using the init and power_on hooks, and their power_off and exit
counterparts.
While it works for most, simple, PHYs supported so far, some more advanced
PHYs need some configuration depending on runtime parameters. These PHYs
have been supported by a number of means already, often by using ad-hoc
drivers in their consumer drivers.
That doesn't work too well however, when a consumer device needs to deal
with multiple PHYs, or when multiple consumers need to deal with the same
PHY (a DSI driver and a CSI driver for example).
So we'll add a new interface, through two funtions, phy_validate and
phy_configure. The first one will allow to check that a current
configuration, for a given mode, is applicable. It will also allow the PHY
driver to tune the settings given as parameters as it sees fit.
phy_configure will actually apply that configuration in the phy itself.
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
2018-12-07 21:55:29 +08:00
|
|
|
/**
|
|
|
|
* union phy_configure_opts - Opaque generic phy configuration
|
2018-12-07 21:55:30 +08:00
|
|
|
*
|
|
|
|
* @mipi_dphy: Configuration set applicable for phys supporting
|
|
|
|
* the MIPI_DPHY phy mode.
|
2020-01-06 20:22:40 +08:00
|
|
|
* @dp: Configuration set applicable for phys supporting
|
|
|
|
* the DisplayPort protocol.
|
phy: Add configuration interface
The phy framework is only allowing to configure the power state of the PHY
using the init and power_on hooks, and their power_off and exit
counterparts.
While it works for most, simple, PHYs supported so far, some more advanced
PHYs need some configuration depending on runtime parameters. These PHYs
have been supported by a number of means already, often by using ad-hoc
drivers in their consumer drivers.
That doesn't work too well however, when a consumer device needs to deal
with multiple PHYs, or when multiple consumers need to deal with the same
PHY (a DSI driver and a CSI driver for example).
So we'll add a new interface, through two funtions, phy_validate and
phy_configure. The first one will allow to check that a current
configuration, for a given mode, is applicable. It will also allow the PHY
driver to tune the settings given as parameters as it sees fit.
phy_configure will actually apply that configuration in the phy itself.
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
2018-12-07 21:55:29 +08:00
|
|
|
*/
|
|
|
|
union phy_configure_opts {
|
2018-12-07 21:55:30 +08:00
|
|
|
struct phy_configure_opts_mipi_dphy mipi_dphy;
|
2020-01-06 20:22:40 +08:00
|
|
|
struct phy_configure_opts_dp dp;
|
phy: Add configuration interface
The phy framework is only allowing to configure the power state of the PHY
using the init and power_on hooks, and their power_off and exit
counterparts.
While it works for most, simple, PHYs supported so far, some more advanced
PHYs need some configuration depending on runtime parameters. These PHYs
have been supported by a number of means already, often by using ad-hoc
drivers in their consumer drivers.
That doesn't work too well however, when a consumer device needs to deal
with multiple PHYs, or when multiple consumers need to deal with the same
PHY (a DSI driver and a CSI driver for example).
So we'll add a new interface, through two funtions, phy_validate and
phy_configure. The first one will allow to check that a current
configuration, for a given mode, is applicable. It will also allow the PHY
driver to tune the settings given as parameters as it sees fit.
phy_configure will actually apply that configuration in the phy itself.
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
2018-12-07 21:55:29 +08:00
|
|
|
};
|
|
|
|
|
2013-09-27 14:23:25 +08:00
|
|
|
/**
|
|
|
|
* struct phy_ops - set of function pointers for performing phy operations
|
|
|
|
* @init: operation to be performed for initializing phy
|
|
|
|
* @exit: operation to be performed while exiting
|
|
|
|
* @power_on: powering on the phy
|
|
|
|
* @power_off: powering off the phy
|
2016-05-10 07:39:59 +08:00
|
|
|
* @set_mode: set the mode of the phy
|
2016-09-10 02:59:37 +08:00
|
|
|
* @reset: resetting the phy
|
2017-10-09 20:00:50 +08:00
|
|
|
* @calibrate: calibrate the phy
|
2019-04-05 19:08:30 +08:00
|
|
|
* @release: ops to be performed while the consumer relinquishes the PHY
|
2013-09-27 14:23:25 +08:00
|
|
|
* @owner: the module owner containing the ops
|
|
|
|
*/
|
|
|
|
struct phy_ops {
|
|
|
|
int (*init)(struct phy *phy);
|
|
|
|
int (*exit)(struct phy *phy);
|
|
|
|
int (*power_on)(struct phy *phy);
|
|
|
|
int (*power_off)(struct phy *phy);
|
2018-11-20 09:24:20 +08:00
|
|
|
int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
|
phy: Add configuration interface
The phy framework is only allowing to configure the power state of the PHY
using the init and power_on hooks, and their power_off and exit
counterparts.
While it works for most, simple, PHYs supported so far, some more advanced
PHYs need some configuration depending on runtime parameters. These PHYs
have been supported by a number of means already, often by using ad-hoc
drivers in their consumer drivers.
That doesn't work too well however, when a consumer device needs to deal
with multiple PHYs, or when multiple consumers need to deal with the same
PHY (a DSI driver and a CSI driver for example).
So we'll add a new interface, through two funtions, phy_validate and
phy_configure. The first one will allow to check that a current
configuration, for a given mode, is applicable. It will also allow the PHY
driver to tune the settings given as parameters as it sees fit.
phy_configure will actually apply that configuration in the phy itself.
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
2018-12-07 21:55:29 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @configure:
|
|
|
|
*
|
|
|
|
* Optional.
|
|
|
|
*
|
|
|
|
* Used to change the PHY parameters. phy_init() must have
|
|
|
|
* been called on the phy.
|
|
|
|
*
|
|
|
|
* Returns: 0 if successful, an negative error code otherwise
|
|
|
|
*/
|
|
|
|
int (*configure)(struct phy *phy, union phy_configure_opts *opts);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @validate:
|
|
|
|
*
|
|
|
|
* Optional.
|
|
|
|
*
|
|
|
|
* Used to check that the current set of parameters can be
|
|
|
|
* handled by the phy. Implementations are free to tune the
|
|
|
|
* parameters passed as arguments if needed by some
|
|
|
|
* implementation detail or constraints. It must not change
|
|
|
|
* any actual configuration of the PHY, so calling it as many
|
|
|
|
* times as deemed fit by the consumer must have no side
|
|
|
|
* effect.
|
|
|
|
*
|
|
|
|
* Returns: 0 if the configuration can be applied, an negative
|
|
|
|
* error code otherwise
|
|
|
|
*/
|
|
|
|
int (*validate)(struct phy *phy, enum phy_mode mode, int submode,
|
|
|
|
union phy_configure_opts *opts);
|
2016-09-10 02:59:37 +08:00
|
|
|
int (*reset)(struct phy *phy);
|
2017-10-09 20:00:50 +08:00
|
|
|
int (*calibrate)(struct phy *phy);
|
2019-04-05 19:08:30 +08:00
|
|
|
void (*release)(struct phy *phy);
|
2013-09-27 14:23:25 +08:00
|
|
|
struct module *owner;
|
|
|
|
};
|
|
|
|
|
2013-12-19 22:23:02 +08:00
|
|
|
/**
|
|
|
|
* struct phy_attrs - represents phy attributes
|
|
|
|
* @bus_width: Data path width implemented by PHY
|
2018-12-28 05:10:59 +08:00
|
|
|
* @mode: PHY mode
|
2013-12-19 22:23:02 +08:00
|
|
|
*/
|
|
|
|
struct phy_attrs {
|
|
|
|
u32 bus_width;
|
2018-01-16 18:57:09 +08:00
|
|
|
enum phy_mode mode;
|
2013-12-19 22:23:02 +08:00
|
|
|
};
|
|
|
|
|
2013-09-27 14:23:25 +08:00
|
|
|
/**
|
|
|
|
* struct phy - represents the phy device
|
|
|
|
* @dev: phy device
|
|
|
|
* @id: id of the phy device
|
|
|
|
* @ops: function pointers for performing phy operations
|
|
|
|
* @mutex: mutex to protect phy_ops
|
|
|
|
* @init_count: used to protect when the PHY is used by multiple consumers
|
|
|
|
* @power_count: used to protect when the PHY is used by multiple consumers
|
2018-02-03 00:34:50 +08:00
|
|
|
* @attrs: used to specify PHY specific attributes
|
|
|
|
* @pwr: power regulator associated with the phy
|
2013-09-27 14:23:25 +08:00
|
|
|
*/
|
|
|
|
struct phy {
|
|
|
|
struct device dev;
|
|
|
|
int id;
|
|
|
|
const struct phy_ops *ops;
|
|
|
|
struct mutex mutex;
|
|
|
|
int init_count;
|
|
|
|
int power_count;
|
2013-12-19 22:23:02 +08:00
|
|
|
struct phy_attrs attrs;
|
2014-07-04 17:55:45 +08:00
|
|
|
struct regulator *pwr;
|
2013-09-27 14:23:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct phy_provider - represents the phy provider
|
|
|
|
* @dev: phy provider device
|
2018-02-03 00:34:50 +08:00
|
|
|
* @children: can be used to override the default (dev->of_node) child node
|
2013-09-27 14:23:25 +08:00
|
|
|
* @owner: the module owner having of_xlate
|
|
|
|
* @list: to maintain a linked list of PHY providers
|
2018-02-03 00:34:50 +08:00
|
|
|
* @of_xlate: function pointer to obtain phy instance from phy pointer
|
2013-09-27 14:23:25 +08:00
|
|
|
*/
|
|
|
|
struct phy_provider {
|
|
|
|
struct device *dev;
|
2016-04-05 23:17:34 +08:00
|
|
|
struct device_node *children;
|
2013-09-27 14:23:25 +08:00
|
|
|
struct module *owner;
|
|
|
|
struct list_head list;
|
|
|
|
struct phy * (*of_xlate)(struct device *dev,
|
|
|
|
struct of_phandle_args *args);
|
|
|
|
};
|
|
|
|
|
2018-02-03 00:34:50 +08:00
|
|
|
/**
|
|
|
|
* struct phy_lookup - PHY association in list of phys managed by the phy driver
|
|
|
|
* @node: list node
|
|
|
|
* @dev_id: the device of the association
|
|
|
|
* @con_id: connection ID string on device
|
|
|
|
* @phy: the phy of the association
|
|
|
|
*/
|
2014-11-19 23:28:18 +08:00
|
|
|
struct phy_lookup {
|
|
|
|
struct list_head node;
|
|
|
|
const char *dev_id;
|
|
|
|
const char *con_id;
|
|
|
|
struct phy *phy;
|
|
|
|
};
|
|
|
|
|
2014-11-19 23:28:17 +08:00
|
|
|
#define to_phy(a) (container_of((a), struct phy, dev))
|
2013-09-27 14:23:25 +08:00
|
|
|
|
|
|
|
#define of_phy_provider_register(dev, xlate) \
|
2016-04-05 23:17:34 +08:00
|
|
|
__of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
|
2013-09-27 14:23:25 +08:00
|
|
|
|
|
|
|
#define devm_of_phy_provider_register(dev, xlate) \
|
2016-04-05 23:17:34 +08:00
|
|
|
__devm_of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
|
|
|
|
|
|
|
|
#define of_phy_provider_register_full(dev, children, xlate) \
|
|
|
|
__of_phy_provider_register(dev, children, THIS_MODULE, xlate)
|
|
|
|
|
|
|
|
#define devm_of_phy_provider_register_full(dev, children, xlate) \
|
|
|
|
__devm_of_phy_provider_register(dev, children, THIS_MODULE, xlate)
|
2013-09-27 14:23:25 +08:00
|
|
|
|
|
|
|
static inline void phy_set_drvdata(struct phy *phy, void *data)
|
|
|
|
{
|
|
|
|
dev_set_drvdata(&phy->dev, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *phy_get_drvdata(struct phy *phy)
|
|
|
|
{
|
|
|
|
return dev_get_drvdata(&phy->dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
#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);
|
2018-11-20 09:24:20 +08:00
|
|
|
int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
|
|
|
|
#define phy_set_mode(phy, mode) \
|
|
|
|
phy_set_mode_ext(phy, mode, 0)
|
phy: Add configuration interface
The phy framework is only allowing to configure the power state of the PHY
using the init and power_on hooks, and their power_off and exit
counterparts.
While it works for most, simple, PHYs supported so far, some more advanced
PHYs need some configuration depending on runtime parameters. These PHYs
have been supported by a number of means already, often by using ad-hoc
drivers in their consumer drivers.
That doesn't work too well however, when a consumer device needs to deal
with multiple PHYs, or when multiple consumers need to deal with the same
PHY (a DSI driver and a CSI driver for example).
So we'll add a new interface, through two funtions, phy_validate and
phy_configure. The first one will allow to check that a current
configuration, for a given mode, is applicable. It will also allow the PHY
driver to tune the settings given as parameters as it sees fit.
phy_configure will actually apply that configuration in the phy itself.
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
2018-12-07 21:55:29 +08:00
|
|
|
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);
|
2018-11-20 09:24:20 +08:00
|
|
|
|
2018-01-16 18:57:09 +08:00
|
|
|
static inline enum phy_mode phy_get_mode(struct phy *phy)
|
|
|
|
{
|
|
|
|
return phy->attrs.mode;
|
|
|
|
}
|
2016-09-10 02:59:37 +08:00
|
|
|
int phy_reset(struct phy *phy);
|
2017-10-09 20:00:50 +08:00
|
|
|
int phy_calibrate(struct phy *phy);
|
2013-12-19 22:23:02 +08:00
|
|
|
static inline int phy_get_bus_width(struct phy *phy)
|
|
|
|
{
|
|
|
|
return phy->attrs.bus_width;
|
|
|
|
}
|
|
|
|
static inline void phy_set_bus_width(struct phy *phy, int bus_width)
|
|
|
|
{
|
|
|
|
phy->attrs.bus_width = bus_width;
|
|
|
|
}
|
2013-09-27 14:23:25 +08:00
|
|
|
struct phy *phy_get(struct device *dev, const char *string);
|
2014-02-05 01:33:12 +08:00
|
|
|
struct phy *phy_optional_get(struct device *dev, const char *string);
|
2013-09-27 14:23:25 +08:00
|
|
|
struct phy *devm_phy_get(struct device *dev, const char *string);
|
2014-02-05 01:33:12 +08:00
|
|
|
struct phy *devm_phy_optional_get(struct device *dev, const char *string);
|
2014-03-06 19:16:47 +08:00
|
|
|
struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
|
|
|
|
const char *con_id);
|
2015-04-23 07:04:11 +08:00
|
|
|
struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
|
|
|
|
int index);
|
2019-11-04 22:37:13 +08:00
|
|
|
void of_phy_put(struct phy *phy);
|
|
|
|
void phy_put(struct device *dev, struct phy *phy);
|
2013-09-27 14:23:25 +08:00
|
|
|
void devm_phy_put(struct device *dev, struct phy *phy);
|
2014-03-06 19:16:46 +08:00
|
|
|
struct phy *of_phy_get(struct device_node *np, const char *con_id);
|
2013-09-27 14:23:25 +08:00
|
|
|
struct phy *of_phy_simple_xlate(struct device *dev,
|
|
|
|
struct of_phandle_args *args);
|
2014-07-14 18:25:02 +08:00
|
|
|
struct phy *phy_create(struct device *dev, struct device_node *node,
|
2014-11-19 23:28:21 +08:00
|
|
|
const struct phy_ops *ops);
|
2014-07-14 18:25:02 +08:00
|
|
|
struct phy *devm_phy_create(struct device *dev, struct device_node *node,
|
2014-11-19 23:28:21 +08:00
|
|
|
const struct phy_ops *ops);
|
2013-09-27 14:23:25 +08:00
|
|
|
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,
|
2016-04-05 23:17:34 +08:00
|
|
|
struct device_node *children, struct module *owner,
|
|
|
|
struct phy * (*of_xlate)(struct device *dev,
|
|
|
|
struct of_phandle_args *args));
|
2013-09-27 14:23:25 +08:00
|
|
|
struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
|
2016-04-05 23:17:34 +08:00
|
|
|
struct device_node *children, struct module *owner,
|
|
|
|
struct phy * (*of_xlate)(struct device *dev,
|
|
|
|
struct of_phandle_args *args));
|
2013-09-27 14:23:25 +08:00
|
|
|
void of_phy_provider_unregister(struct phy_provider *phy_provider);
|
|
|
|
void devm_of_phy_provider_unregister(struct device *dev,
|
|
|
|
struct phy_provider *phy_provider);
|
2014-11-19 23:28:18 +08:00
|
|
|
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);
|
2013-09-27 14:23:25 +08:00
|
|
|
#else
|
|
|
|
static inline int phy_pm_runtime_get(struct phy *phy)
|
|
|
|
{
|
2014-04-19 11:21:44 +08:00
|
|
|
if (!phy)
|
|
|
|
return 0;
|
2013-09-27 14:23:25 +08:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int phy_pm_runtime_get_sync(struct phy *phy)
|
|
|
|
{
|
2014-04-19 11:21:44 +08:00
|
|
|
if (!phy)
|
|
|
|
return 0;
|
2013-09-27 14:23:25 +08:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int phy_pm_runtime_put(struct phy *phy)
|
|
|
|
{
|
2014-04-19 11:21:44 +08:00
|
|
|
if (!phy)
|
|
|
|
return 0;
|
2013-09-27 14:23:25 +08:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int phy_pm_runtime_put_sync(struct phy *phy)
|
|
|
|
{
|
2014-04-19 11:21:44 +08:00
|
|
|
if (!phy)
|
|
|
|
return 0;
|
2013-09-27 14:23:25 +08:00
|
|
|
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)
|
|
|
|
{
|
2014-04-19 11:21:44 +08:00
|
|
|
if (!phy)
|
|
|
|
return 0;
|
2013-09-27 14:23:25 +08:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int phy_exit(struct phy *phy)
|
|
|
|
{
|
2014-04-19 11:21:44 +08:00
|
|
|
if (!phy)
|
|
|
|
return 0;
|
2013-09-27 14:23:25 +08:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int phy_power_on(struct phy *phy)
|
|
|
|
{
|
2014-04-19 11:21:44 +08:00
|
|
|
if (!phy)
|
|
|
|
return 0;
|
2013-09-27 14:23:25 +08:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int phy_power_off(struct phy *phy)
|
|
|
|
{
|
2014-04-19 11:21:44 +08:00
|
|
|
if (!phy)
|
|
|
|
return 0;
|
2013-09-27 14:23:25 +08:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2018-11-20 09:24:20 +08:00
|
|
|
static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
|
|
|
|
int submode)
|
2016-05-10 07:39:59 +08:00
|
|
|
{
|
|
|
|
if (!phy)
|
|
|
|
return 0;
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2018-11-20 09:24:20 +08:00
|
|
|
#define phy_set_mode(phy, mode) \
|
|
|
|
phy_set_mode_ext(phy, mode, 0)
|
|
|
|
|
2018-01-16 18:57:09 +08:00
|
|
|
static inline enum phy_mode phy_get_mode(struct phy *phy)
|
|
|
|
{
|
|
|
|
return PHY_MODE_INVALID;
|
|
|
|
}
|
|
|
|
|
2016-10-25 22:15:34 +08:00
|
|
|
static inline int phy_reset(struct phy *phy)
|
|
|
|
{
|
|
|
|
if (!phy)
|
|
|
|
return 0;
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2017-10-09 20:00:50 +08:00
|
|
|
static inline int phy_calibrate(struct phy *phy)
|
|
|
|
{
|
|
|
|
if (!phy)
|
|
|
|
return 0;
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
phy: Add configuration interface
The phy framework is only allowing to configure the power state of the PHY
using the init and power_on hooks, and their power_off and exit
counterparts.
While it works for most, simple, PHYs supported so far, some more advanced
PHYs need some configuration depending on runtime parameters. These PHYs
have been supported by a number of means already, often by using ad-hoc
drivers in their consumer drivers.
That doesn't work too well however, when a consumer device needs to deal
with multiple PHYs, or when multiple consumers need to deal with the same
PHY (a DSI driver and a CSI driver for example).
So we'll add a new interface, through two funtions, phy_validate and
phy_configure. The first one will allow to check that a current
configuration, for a given mode, is applicable. It will also allow the PHY
driver to tune the settings given as parameters as it sees fit.
phy_configure will actually apply that configuration in the phy itself.
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
2018-12-07 21:55:29 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-12-19 22:23:02 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-09-27 14:23:25 +08:00
|
|
|
static inline struct phy *phy_get(struct device *dev, const char *string)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:33:12 +08:00
|
|
|
static inline struct phy *phy_optional_get(struct device *dev,
|
|
|
|
const char *string)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
2013-09-27 14:23:25 +08:00
|
|
|
static inline struct phy *devm_phy_get(struct device *dev, const char *string)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:33:12 +08:00
|
|
|
static inline struct phy *devm_phy_optional_get(struct device *dev,
|
|
|
|
const char *string)
|
|
|
|
{
|
2017-09-04 20:53:13 +08:00
|
|
|
return NULL;
|
2014-02-05 01:33:12 +08:00
|
|
|
}
|
|
|
|
|
2014-03-06 19:16:47 +08:00
|
|
|
static inline struct phy *devm_of_phy_get(struct device *dev,
|
|
|
|
struct device_node *np,
|
|
|
|
const char *con_id)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
2015-04-23 07:04:11 +08:00
|
|
|
static inline struct phy *devm_of_phy_get_by_index(struct device *dev,
|
|
|
|
struct device_node *np,
|
|
|
|
int index)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:37:13 +08:00
|
|
|
static inline void of_phy_put(struct phy *phy)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void phy_put(struct device *dev, struct phy *phy)
|
2013-09-27 14:23:25 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void devm_phy_put(struct device *dev, struct phy *phy)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-03-06 19:16:46 +08:00
|
|
|
static inline struct phy *of_phy_get(struct device_node *np, const char *con_id)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
2013-09-27 14:23:25 +08:00
|
|
|
static inline struct phy *of_phy_simple_xlate(struct device *dev,
|
|
|
|
struct of_phandle_args *args)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct phy *phy_create(struct device *dev,
|
2014-07-14 18:25:02 +08:00
|
|
|
struct device_node *node,
|
2014-11-19 23:28:21 +08:00
|
|
|
const struct phy_ops *ops)
|
2013-09-27 14:23:25 +08:00
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct phy *devm_phy_create(struct device *dev,
|
2014-07-14 18:25:02 +08:00
|
|
|
struct device_node *node,
|
2014-11-19 23:28:21 +08:00
|
|
|
const struct phy_ops *ops)
|
2013-09-27 14:23:25 +08:00
|
|
|
{
|
|
|
|
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(
|
2016-04-05 23:17:34 +08:00
|
|
|
struct device *dev, struct device_node *children, struct module *owner,
|
|
|
|
struct phy * (*of_xlate)(struct device *dev,
|
|
|
|
struct of_phandle_args *args))
|
2013-09-27 14:23:25 +08:00
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct phy_provider *__devm_of_phy_provider_register(struct device
|
2016-04-05 23:17:34 +08:00
|
|
|
*dev, struct device_node *children, struct module *owner,
|
|
|
|
struct phy * (*of_xlate)(struct device *dev,
|
|
|
|
struct of_phandle_args *args))
|
2013-09-27 14:23:25 +08:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
2014-11-19 23:28:18 +08:00
|
|
|
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) { }
|
2013-09-27 14:23:25 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __DRIVERS_PHY_H */
|