diff mbox series

[2/4] phy: samsung: ufs: support secondary ufs phy

Message ID 20220531121913.48722-3-chanho61.park@samsung.com (mailing list archive)
State New, archived
Headers show
Series support secondary ufs for Exynos Auto v9 SoC | expand

Commit Message

Chanho Park May 31, 2022, 12:19 p.m. UTC
To support secondary ufs phy device, we need to get an offset for phy
isolation from the syscon DT node. If the first index argument of the
node is existing, we can read the offset value and set it as isol->offset.
To allow this, we should drop the const qualifier of struct pmu_isol.

Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/phy/samsung/phy-samsung-ufs.c | 7 ++++++-
 drivers/phy/samsung/phy-samsung-ufs.h | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Krzysztof Kozlowski May 31, 2022, 1:19 p.m. UTC | #1
On 31/05/2022 14:19, Chanho Park wrote:
> To support secondary ufs phy device, we need to get an offset for phy
> isolation from the syscon DT node. If the first index argument of the
> node is existing, we can read the offset value and set it as isol->offset.
> To allow this, we should drop the const qualifier of struct pmu_isol.
> 
> Signed-off-by: Chanho Park <chanho61.park@samsung.com>
> ---
>  drivers/phy/samsung/phy-samsung-ufs.c | 7 ++++++-
>  drivers/phy/samsung/phy-samsung-ufs.h | 2 +-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/samsung/phy-samsung-ufs.c b/drivers/phy/samsung/phy-samsung-ufs.c
> index 602ddef259eb..bb0f8e481a4b 100644
> --- a/drivers/phy/samsung/phy-samsung-ufs.c
> +++ b/drivers/phy/samsung/phy-samsung-ufs.c
> @@ -288,6 +288,7 @@ static int samsung_ufs_phy_probe(struct platform_device *pdev)
>  	struct phy *gen_phy;
>  	struct phy_provider *phy_provider;
>  	const struct samsung_ufs_phy_drvdata *drvdata;
> +	u32 isol_offset;
>  	int err = 0;
>  
>  	match = of_match_node(samsung_ufs_phy_match, dev->of_node);
> @@ -328,7 +329,11 @@ static int samsung_ufs_phy_probe(struct platform_device *pdev)
>  	phy->dev = dev;
>  	phy->drvdata = drvdata;
>  	phy->cfg = (struct samsung_ufs_phy_cfg **)drvdata->cfg;
> -	phy->isol = &drvdata->isol;
> +	phy->isol = (struct pmu_isol *)&drvdata->isol;

No casts are needed for proper code. If you need it - code is not proper.

> +	if (!of_property_read_u32_index(dev->of_node, "samsung,pmu-syscon", 1,
> +					&isol_offset))
> +		phy->isol->offset = isol_offset;

drvdata is const.

> +
>  	phy->lane_cnt = PHY_DEF_LANE_CNT;
>  
>  	phy_set_drvdata(gen_phy, phy);
> diff --git a/drivers/phy/samsung/phy-samsung-ufs.h b/drivers/phy/samsung/phy-samsung-ufs.h
> index 91a0e9f94f98..75dc533273f9 100644
> --- a/drivers/phy/samsung/phy-samsung-ufs.h
> +++ b/drivers/phy/samsung/phy-samsung-ufs.h
> @@ -122,7 +122,7 @@ struct samsung_ufs_phy {
>  	struct clk *rx1_symbol_clk;
>  	const struct samsung_ufs_phy_drvdata *drvdata;
>  	struct samsung_ufs_phy_cfg **cfg;
> -	const struct pmu_isol *isol;
> +	struct pmu_isol *isol;
>  	u8 lane_cnt;
>  	int ufs_phy_state;
>  	enum phy_mode mode;


Best regards,
Krzysztof
Chanho Park June 2, 2022, 2:26 a.m. UTC | #2
> > +	u32 isol_offset;
> >  	int err = 0;
> >
> >  	match = of_match_node(samsung_ufs_phy_match, dev->of_node); @@
> > -328,7 +329,11 @@ static int samsung_ufs_phy_probe(struct
> platform_device *pdev)
> >  	phy->dev = dev;
> >  	phy->drvdata = drvdata;
> >  	phy->cfg = (struct samsung_ufs_phy_cfg **)drvdata->cfg;
> > -	phy->isol = &drvdata->isol;
> > +	phy->isol = (struct pmu_isol *)&drvdata->isol;
> 
> No casts are needed for proper code. If you need it - code is not proper.

To change a value of phy->isol, I need to allocate its own isol data and copying whole data from drvdata instead of using drvdata->isol pointer.

Best Regards,
Chanho Park
diff mbox series

Patch

diff --git a/drivers/phy/samsung/phy-samsung-ufs.c b/drivers/phy/samsung/phy-samsung-ufs.c
index 602ddef259eb..bb0f8e481a4b 100644
--- a/drivers/phy/samsung/phy-samsung-ufs.c
+++ b/drivers/phy/samsung/phy-samsung-ufs.c
@@ -288,6 +288,7 @@  static int samsung_ufs_phy_probe(struct platform_device *pdev)
 	struct phy *gen_phy;
 	struct phy_provider *phy_provider;
 	const struct samsung_ufs_phy_drvdata *drvdata;
+	u32 isol_offset;
 	int err = 0;
 
 	match = of_match_node(samsung_ufs_phy_match, dev->of_node);
@@ -328,7 +329,11 @@  static int samsung_ufs_phy_probe(struct platform_device *pdev)
 	phy->dev = dev;
 	phy->drvdata = drvdata;
 	phy->cfg = (struct samsung_ufs_phy_cfg **)drvdata->cfg;
-	phy->isol = &drvdata->isol;
+	phy->isol = (struct pmu_isol *)&drvdata->isol;
+	if (!of_property_read_u32_index(dev->of_node, "samsung,pmu-syscon", 1,
+					&isol_offset))
+		phy->isol->offset = isol_offset;
+
 	phy->lane_cnt = PHY_DEF_LANE_CNT;
 
 	phy_set_drvdata(gen_phy, phy);
diff --git a/drivers/phy/samsung/phy-samsung-ufs.h b/drivers/phy/samsung/phy-samsung-ufs.h
index 91a0e9f94f98..75dc533273f9 100644
--- a/drivers/phy/samsung/phy-samsung-ufs.h
+++ b/drivers/phy/samsung/phy-samsung-ufs.h
@@ -122,7 +122,7 @@  struct samsung_ufs_phy {
 	struct clk *rx1_symbol_clk;
 	const struct samsung_ufs_phy_drvdata *drvdata;
 	struct samsung_ufs_phy_cfg **cfg;
-	const struct pmu_isol *isol;
+	struct pmu_isol *isol;
 	u8 lane_cnt;
 	int ufs_phy_state;
 	enum phy_mode mode;