[v4,2/3] phy: phy-mtk-hdmi: Add generic phy configure callback

Message ID 20220919-v4-2-bdc21e1307e9@baylibre.com
State New
Headers
Series Add MT8195 HDMI phy support |

Commit Message

Guillaume Ranquet Nov. 21, 2022, 2:19 p.m. UTC
  Some phys, such as mt8195, needs to have a configure callback defined.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
---
 drivers/phy/mediatek/phy-mtk-hdmi.c | 12 ++++++++++++
 drivers/phy/mediatek/phy-mtk-hdmi.h |  1 +
 2 files changed, 13 insertions(+)
  

Comments

Matthias Brugger Nov. 21, 2022, 5:36 p.m. UTC | #1
On 21/11/2022 15:19, Guillaume Ranquet wrote:
> Some phys, such as mt8195, needs to have a configure callback defined.
> 
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> ---
>   drivers/phy/mediatek/phy-mtk-hdmi.c | 12 ++++++++++++
>   drivers/phy/mediatek/phy-mtk-hdmi.h |  1 +
>   2 files changed, 13 insertions(+)
> 
> diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> index b16d437d6721..32f713301768 100644
> --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> @@ -8,10 +8,12 @@
>   
>   static int mtk_hdmi_phy_power_on(struct phy *phy);
>   static int mtk_hdmi_phy_power_off(struct phy *phy);
> +static int mtk_hdmi_phy_configure(struct phy *phy, union phy_configure_opts *opts);
>   
>   static const struct phy_ops mtk_hdmi_phy_dev_ops = {
>   	.power_on = mtk_hdmi_phy_power_on,
>   	.power_off = mtk_hdmi_phy_power_off,
> +	.configure = mtk_hdmi_phy_configure,
>   	.owner = THIS_MODULE,
>   };
>   
> @@ -43,6 +45,16 @@ static int mtk_hdmi_phy_power_off(struct phy *phy)
>   	return 0;
>   }
>   
> +static int mtk_hdmi_phy_configure(struct phy *phy, union phy_configure_opts *opts)
> +{
> +	struct mtk_hdmi_phy *hdmi_phy = phy_get_drvdata(phy);
> +
> +	if (hdmi_phy->conf->hdmi_phy_configure)
> +		return hdmi_phy->conf->hdmi_phy_configure(phy, opts);
> +
> +	return 0;
> +}
> +
>   static const struct phy_ops *
>   mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
>   {
> diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.h b/drivers/phy/mediatek/phy-mtk-hdmi.h
> index c7fa65cff989..f5aac9d352d8 100644
> --- a/drivers/phy/mediatek/phy-mtk-hdmi.h
> +++ b/drivers/phy/mediatek/phy-mtk-hdmi.h
> @@ -24,6 +24,7 @@ struct mtk_hdmi_phy_conf {
>   	const struct clk_ops *hdmi_phy_clk_ops;
>   	void (*hdmi_phy_enable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
>   	void (*hdmi_phy_disable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
> +	int (*hdmi_phy_configure)(struct phy *phy, union phy_configure_opts *opts);
>   };
>   
>   struct mtk_hdmi_phy {
>
  

Patch

diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
index b16d437d6721..32f713301768 100644
--- a/drivers/phy/mediatek/phy-mtk-hdmi.c
+++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
@@ -8,10 +8,12 @@ 
 
 static int mtk_hdmi_phy_power_on(struct phy *phy);
 static int mtk_hdmi_phy_power_off(struct phy *phy);
+static int mtk_hdmi_phy_configure(struct phy *phy, union phy_configure_opts *opts);
 
 static const struct phy_ops mtk_hdmi_phy_dev_ops = {
 	.power_on = mtk_hdmi_phy_power_on,
 	.power_off = mtk_hdmi_phy_power_off,
+	.configure = mtk_hdmi_phy_configure,
 	.owner = THIS_MODULE,
 };
 
@@ -43,6 +45,16 @@  static int mtk_hdmi_phy_power_off(struct phy *phy)
 	return 0;
 }
 
+static int mtk_hdmi_phy_configure(struct phy *phy, union phy_configure_opts *opts)
+{
+	struct mtk_hdmi_phy *hdmi_phy = phy_get_drvdata(phy);
+
+	if (hdmi_phy->conf->hdmi_phy_configure)
+		return hdmi_phy->conf->hdmi_phy_configure(phy, opts);
+
+	return 0;
+}
+
 static const struct phy_ops *
 mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
 {
diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.h b/drivers/phy/mediatek/phy-mtk-hdmi.h
index c7fa65cff989..f5aac9d352d8 100644
--- a/drivers/phy/mediatek/phy-mtk-hdmi.h
+++ b/drivers/phy/mediatek/phy-mtk-hdmi.h
@@ -24,6 +24,7 @@  struct mtk_hdmi_phy_conf {
 	const struct clk_ops *hdmi_phy_clk_ops;
 	void (*hdmi_phy_enable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
 	void (*hdmi_phy_disable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
+	int (*hdmi_phy_configure)(struct phy *phy, union phy_configure_opts *opts);
 };
 
 struct mtk_hdmi_phy {