aboutsummaryrefslogtreecommitdiff
path: root/include/generic-phy.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/generic-phy.h')
-rw-r--r--include/generic-phy.h190
1 files changed, 136 insertions, 54 deletions
diff --git a/include/generic-phy.h b/include/generic-phy.h
index f8eddeff67..bee4de8a0b 100644
--- a/include/generic-phy.h
+++ b/include/generic-phy.h
@@ -11,6 +11,29 @@
struct ofnode_phandle_args;
+enum phy_mode {
+ PHY_MODE_INVALID,
+ PHY_MODE_USB_HOST,
+ PHY_MODE_USB_HOST_LS,
+ PHY_MODE_USB_HOST_FS,
+ PHY_MODE_USB_HOST_HS,
+ PHY_MODE_USB_HOST_SS,
+ PHY_MODE_USB_DEVICE,
+ PHY_MODE_USB_DEVICE_LS,
+ PHY_MODE_USB_DEVICE_FS,
+ PHY_MODE_USB_DEVICE_HS,
+ PHY_MODE_USB_DEVICE_SS,
+ PHY_MODE_USB_OTG,
+ PHY_MODE_UFS_HS_A,
+ PHY_MODE_UFS_HS_B,
+ PHY_MODE_PCIE,
+ PHY_MODE_ETHERNET,
+ PHY_MODE_MIPI_DPHY,
+ PHY_MODE_SATA,
+ PHY_MODE_LVDS,
+ PHY_MODE_DP
+};
+
/**
* struct phy - A handle to (allowing control of) a single phy port.
*
@@ -69,73 +92,99 @@ struct phy_ops {
int (*init)(struct phy *phy);
/**
- * exit - de-initialize the PHY device
- *
- * Hardware de-intialization should be done here. Every step done in
- * init() should be undone here.
- * This could be used to suspend the phy to reduce power consumption or
- * to put the phy in a known condition before booting the OS (though it
- * is NOT called automatically before booting the OS)
- * If power_off() is not implemented, it must power down the phy.
- *
- * @phy: PHY port to be de-initialized
- * Return: 0 if OK, or a negative error code
- */
+ * exit - de-initialize the PHY device
+ *
+ * Hardware de-intialization should be done here. Every step done in
+ * init() should be undone here.
+ * This could be used to suspend the phy to reduce power consumption or
+ * to put the phy in a known condition before booting the OS (though it
+ * is NOT called automatically before booting the OS)
+ * If power_off() is not implemented, it must power down the phy.
+ *
+ * @phy: PHY port to be de-initialized
+ * Return: 0 if OK, or a negative error code
+ */
int (*exit)(struct phy *phy);
/**
- * reset - resets a PHY device without shutting down
- *
- * @phy: PHY port to be reset
- *
- * During runtime, the PHY may need to be reset in order to
- * re-establish connection etc without being shut down or exit.
- *
- * Return: 0 if OK, or a negative error code
- */
+ * reset - resets a PHY device without shutting down
+ *
+ * @phy: PHY port to be reset
+ *
+ * During runtime, the PHY may need to be reset in order to
+ * re-establish connection etc without being shut down or exit.
+ *
+ * Return: 0 if OK, or a negative error code
+ */
int (*reset)(struct phy *phy);
/**
- * power_on - power on a PHY device
- *
- * @phy: PHY port to be powered on
- *
- * During runtime, the PHY may need to be powered on or off several
- * times. This function is used to power on the PHY. It relies on the
- * setup done in init(). If init() is not implemented, it must take care
- * of setting up the context (PLLs, ...)
- *
- * Return: 0 if OK, or a negative error code
- */
+ * power_on - power on a PHY device
+ *
+ * @phy: PHY port to be powered on
+ *
+ * During runtime, the PHY may need to be powered on or off several
+ * times. This function is used to power on the PHY. It relies on the
+ * setup done in init(). If init() is not implemented, it must take care
+ * of setting up the context (PLLs, ...)
+ *
+ * Return: 0 if OK, or a negative error code
+ */
int (*power_on)(struct phy *phy);
/**
- * power_off - power off a PHY device
- *
- * @phy: PHY port to be powered off
- *
- * During runtime, the PHY may need to be powered on or off several
- * times. This function is used to power off the PHY. Except if
- * init()/deinit() are not implemented, it must not de-initialize
- * everything.
- *
- * Return: 0 if OK, or a negative error code
- */
+ * power_off - power off a PHY device
+ *
+ * @phy: PHY port to be powered off
+ *
+ * During runtime, the PHY may need to be powered on or off several
+ * times. This function is used to power off the PHY. Except if
+ * init()/deinit() are not implemented, it must not de-initialize
+ * everything.
+ *
+ * Return: 0 if OK, or a negative error code
+ */
int (*power_off)(struct phy *phy);
/**
- * configure - configure a PHY device
- *
- * @phy: PHY port to be configured
- * @params: PHY Parameters, underlying data is specific to the PHY function
- *
- * During runtime, the PHY may need to be configured for it's main function.
- * This function configures the PHY for it's main function following
- * power_on/off() after beeing initialized.
- *
- * Return: 0 if OK, or a negative error code
- */
+ * configure - configure a PHY device
+ *
+ * @phy: PHY port to be configured
+ * @params: PHY Parameters, underlying data is specific to the PHY function
+ *
+ * During runtime, the PHY may need to be configured for it's main function.
+ * This function configures the PHY for it's main function following
+ * power_on/off() after being initialized.
+ *
+ * Return: 0 if OK, or a negative error code
+ */
int (*configure)(struct phy *phy, void *params);
+
+ /**
+ * set_mode - set PHY device mode
+ *
+ * @phy: PHY port to be configured
+ * @mode: PHY mode
+ * @submode: PHY submode
+ *
+ * Configure PHY mode (e.g. USB, Ethernet, ...) and submode
+ * (e.g. for Ethernet this can be RGMII).
+ *
+ * Return: 0 if OK, or a negative error code
+ */
+ int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
+
+ /**
+ * set_speed - set PHY device speed
+ *
+ * @phy: PHY port to be configured
+ * @speed: PHY speed
+ *
+ * Configure PHY speed (e.g. for Ethernet, this could be 10 or 100 ...).
+ *
+ * Return: 0 if OK, or a negative error code
+ */
+ int (*set_speed)(struct phy *phy, int speed);
};
/**
@@ -206,6 +255,24 @@ int generic_phy_power_off(struct phy *phy);
*/
int generic_phy_configure(struct phy *phy, void *params);
+/**
+ * generic_phy_set_mode() - set PHY device mode
+ *
+ * @phy: PHY port to be configured
+ * @mode: PHY mode
+ * @submode: PHY submode
+ * Return: 0 if OK, or a negative error code
+ */
+int generic_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode);
+
+/**
+ * generic_phy_set_speed() - set PHY device speed
+ *
+ * @phy: PHY port to be configured
+ * @speed: PHY speed
+ * Return: 0 if OK, or a negative error code
+ */
+int generic_phy_set_speed(struct phy *phy, int speed);
/**
* generic_phy_get_by_index() - Get a PHY device by integer index.
@@ -389,6 +456,21 @@ static inline int generic_phy_power_off(struct phy *phy)
return 0;
}
+static inline int generic_phy_configure(struct phy *phy, void *params)
+{
+ return 0;
+}
+
+static inline int generic_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+ return 0;
+}
+
+static inline int generic_phy_set_speed(struct phy *phy, int speed)
+{
+ return 0;
+}
+
static inline int generic_phy_get_by_index(struct udevice *user, int index,
struct phy *phy)
{