diff mbox series

[1/2] phy: rockchip: set pulldown for strobe line in dts

Message ID 20201127033359.32725-1-chris.ruehl@gtsys.com.hk (mailing list archive)
State New, archived
Headers show
Series [1/2] phy: rockchip: set pulldown for strobe line in dts | expand

Commit Message

Chris Ruehl Nov. 27, 2020, 3:33 a.m. UTC
This patch add support to set the internal pulldown via dt property
and allow simplify the board design for the trace from emmc-phy to
the eMMC chipset.
Default to not set the pull-down.

This patch was inspired from the 4.4 tree of the
Rockchip SDK, where it is enabled unconditional.
The patch had been tested with our rk3399 customized board.

Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
---
 drivers/phy/rockchip/phy-rockchip-emmc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Chris Ruehl Nov. 27, 2020, 3:42 a.m. UTC | #1
Sorry,

this is a single patch not 1/2.

On 27/11/2020 11:33 am, Chris Ruehl wrote:
> This patch add support to set the internal pulldown via dt property
> and allow simplify the board design for the trace from emmc-phy to
> the eMMC chipset.
> Default to not set the pull-down.
> 
> This patch was inspired from the 4.4 tree of the
> Rockchip SDK, where it is enabled unconditional.
> The patch had been tested with our rk3399 customized board.
> 
> Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
> ---
>   drivers/phy/rockchip/phy-rockchip-emmc.c | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-emmc.c b/drivers/phy/rockchip/phy-rockchip-emmc.c
> index 2dc19ddd120f..d9bc45828f74 100644
> --- a/drivers/phy/rockchip/phy-rockchip-emmc.c
> +++ b/drivers/phy/rockchip/phy-rockchip-emmc.c
> @@ -67,6 +67,10 @@
>   #define PHYCTRL_OTAPDLYENA_SHIFT	0xb
>   #define PHYCTRL_OTAPDLYSEL_MASK		0xf
>   #define PHYCTRL_OTAPDLYSEL_SHIFT	0x7
> +#define PHYCTRL_REN_STRB_DISABLE	0x0
> +#define PHYCTRL_REN_STRB_ENABLE	0x1
> +#define PHYCTRL_REN_STRB_MASK	0x1
> +#define PHYCTRL_REN_STRB_SHIFT	0x9
>   
>   #define PHYCTRL_IS_CALDONE(x) \
>   	((((x) >> PHYCTRL_CALDONE_SHIFT) & \
> @@ -80,6 +84,7 @@ struct rockchip_emmc_phy {
>   	struct regmap	*reg_base;
>   	struct clk	*emmcclk;
>   	unsigned int drive_impedance;
> +	unsigned int enable_strobe_pulldown;
>   };
>   
>   static int rockchip_emmc_phy_power(struct phy *phy, bool on_off)
> @@ -295,6 +300,13 @@ static int rockchip_emmc_phy_power_on(struct phy *phy)
>   				   PHYCTRL_OTAPDLYSEL_MASK,
>   				   PHYCTRL_OTAPDLYSEL_SHIFT));
>   
> +	/* Internal pull-down for strobe line */
> +	regmap_write(rk_phy->reg_base,
> +			rk_phy->reg_offset + GRF_EMMCPHY_CON2,
> +			HIWORD_UPDATE(rk_phy->enable_strobe_pulldown,
> +				PHYCTRL_REN_STRB_MASK,
> +				PHYCTRL_REN_STRB_SHIFT));
> +
>   	/* Power up emmc phy analog blocks */
>   	return rockchip_emmc_phy_power(phy, PHYCTRL_PDB_PWR_ON);
>   }
> @@ -359,10 +371,14 @@ static int rockchip_emmc_phy_probe(struct platform_device *pdev)
>   	rk_phy->reg_offset = reg_offset;
>   	rk_phy->reg_base = grf;
>   	rk_phy->drive_impedance = PHYCTRL_DR_50OHM;
> +	rk_phy->enable_strobe_pulldown = PHYCTRL_REN_STRB_DISABLE;
>   
>   	if (!of_property_read_u32(dev->of_node, "drive-impedance-ohm", &val))
>   		rk_phy->drive_impedance = convert_drive_impedance_ohm(pdev, val);
>   
> +	if (of_property_read_bool(dev->of_node, "enable-strobe-pulldown"))
> +		rk_phy->enable_strobe_pulldown = PHYCTRL_REN_STRB_ENABLE;
> +
>   	generic_phy = devm_phy_create(dev, dev->of_node, &ops);
>   	if (IS_ERR(generic_phy)) {
>   		dev_err(dev, "failed to create PHY\n");
>
Johan Jonker Nov. 27, 2020, 8:47 a.m. UTC | #2
Hi Chris,

Before a new property "enable-strobe-pulldown" is introduced in the code
a change to the documents must be made in a separate patch.
(rockchip-emmc-phy.txt)

./scripts/checkpatch.pl --strict <patch1> <patch2>

On 11/27/20 4:33 AM, Chris Ruehl wrote:
> This patch add support to set the internal pulldown via dt property
> and allow simplify the board design for the trace from emmc-phy to
> the eMMC chipset.
> Default to not set the pull-down.
> 
> This patch was inspired from the 4.4 tree of the
> Rockchip SDK, where it is enabled unconditional.
> The patch had been tested with our rk3399 customized board.
> 
> Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
> ---
>  drivers/phy/rockchip/phy-rockchip-emmc.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-emmc.c b/drivers/phy/rockchip/phy-rockchip-emmc.c
> index 2dc19ddd120f..d9bc45828f74 100644
> --- a/drivers/phy/rockchip/phy-rockchip-emmc.c
> +++ b/drivers/phy/rockchip/phy-rockchip-emmc.c
> @@ -67,6 +67,10 @@
>  #define PHYCTRL_OTAPDLYENA_SHIFT	0xb
>  #define PHYCTRL_OTAPDLYSEL_MASK		0xf
>  #define PHYCTRL_OTAPDLYSEL_SHIFT	0x7
> +#define PHYCTRL_REN_STRB_DISABLE	0x0

> +#define PHYCTRL_REN_STRB_ENABLE	0x1
> +#define PHYCTRL_REN_STRB_MASK	0x1
> +#define PHYCTRL_REN_STRB_SHIFT	0x9

align with extra TAB ?
check TAB size

>  
>  #define PHYCTRL_IS_CALDONE(x) \
>  	((((x) >> PHYCTRL_CALDONE_SHIFT) & \
> @@ -80,6 +84,7 @@ struct rockchip_emmc_phy {
>  	struct regmap	*reg_base;
>  	struct clk	*emmcclk;
>  	unsigned int drive_impedance;
> +	unsigned int enable_strobe_pulldown;
>  };
>  
>  static int rockchip_emmc_phy_power(struct phy *phy, bool on_off)
> @@ -295,6 +300,13 @@ static int rockchip_emmc_phy_power_on(struct phy *phy)
>  				   PHYCTRL_OTAPDLYSEL_MASK,
>  				   PHYCTRL_OTAPDLYSEL_SHIFT));
>  
> +	/* Internal pull-down for strobe line */
> +	regmap_write(rk_phy->reg_base,

> +			rk_phy->reg_offset + GRF_EMMCPHY_CON2,

CHECK: Alignment should match open parenthesis
#49: FILE: drivers/phy/rockchip/phy-rockchip-emmc.c:305:
+	regmap_write(rk_phy->reg_base,
+			rk_phy->reg_offset + GRF_EMMCPHY_CON2,

> +			HIWORD_UPDATE(rk_phy->enable_strobe_pulldown,
> +				PHYCTRL_REN_STRB_MASK,
> +				PHYCTRL_REN_STRB_SHIFT));

CHECK: Alignment should match open parenthesis
#51: FILE: drivers/phy/rockchip/phy-rockchip-emmc.c:307:
+			HIWORD_UPDATE(rk_phy->enable_strobe_pulldown,
+				PHYCTRL_REN_STRB_MASK,

> +
>  	/* Power up emmc phy analog blocks */
>  	return rockchip_emmc_phy_power(phy, PHYCTRL_PDB_PWR_ON);
>  }
> @@ -359,10 +371,14 @@ static int rockchip_emmc_phy_probe(struct platform_device *pdev)
>  	rk_phy->reg_offset = reg_offset;
>  	rk_phy->reg_base = grf;
>  	rk_phy->drive_impedance = PHYCTRL_DR_50OHM;
> +	rk_phy->enable_strobe_pulldown = PHYCTRL_REN_STRB_DISABLE;
>  
>  	if (!of_property_read_u32(dev->of_node, "drive-impedance-ohm", &val))
>  		rk_phy->drive_impedance = convert_drive_impedance_ohm(pdev, val);
>  
> +	if (of_property_read_bool(dev->of_node, "enable-strobe-pulldown"))
> +		rk_phy->enable_strobe_pulldown = PHYCTRL_REN_STRB_ENABLE;
> +
>  	generic_phy = devm_phy_create(dev, dev->of_node, &ops);
>  	if (IS_ERR(generic_phy)) {
>  		dev_err(dev, "failed to create PHY\n");
>
diff mbox series

Patch

diff --git a/drivers/phy/rockchip/phy-rockchip-emmc.c b/drivers/phy/rockchip/phy-rockchip-emmc.c
index 2dc19ddd120f..d9bc45828f74 100644
--- a/drivers/phy/rockchip/phy-rockchip-emmc.c
+++ b/drivers/phy/rockchip/phy-rockchip-emmc.c
@@ -67,6 +67,10 @@ 
 #define PHYCTRL_OTAPDLYENA_SHIFT	0xb
 #define PHYCTRL_OTAPDLYSEL_MASK		0xf
 #define PHYCTRL_OTAPDLYSEL_SHIFT	0x7
+#define PHYCTRL_REN_STRB_DISABLE	0x0
+#define PHYCTRL_REN_STRB_ENABLE	0x1
+#define PHYCTRL_REN_STRB_MASK	0x1
+#define PHYCTRL_REN_STRB_SHIFT	0x9
 
 #define PHYCTRL_IS_CALDONE(x) \
 	((((x) >> PHYCTRL_CALDONE_SHIFT) & \
@@ -80,6 +84,7 @@  struct rockchip_emmc_phy {
 	struct regmap	*reg_base;
 	struct clk	*emmcclk;
 	unsigned int drive_impedance;
+	unsigned int enable_strobe_pulldown;
 };
 
 static int rockchip_emmc_phy_power(struct phy *phy, bool on_off)
@@ -295,6 +300,13 @@  static int rockchip_emmc_phy_power_on(struct phy *phy)
 				   PHYCTRL_OTAPDLYSEL_MASK,
 				   PHYCTRL_OTAPDLYSEL_SHIFT));
 
+	/* Internal pull-down for strobe line */
+	regmap_write(rk_phy->reg_base,
+			rk_phy->reg_offset + GRF_EMMCPHY_CON2,
+			HIWORD_UPDATE(rk_phy->enable_strobe_pulldown,
+				PHYCTRL_REN_STRB_MASK,
+				PHYCTRL_REN_STRB_SHIFT));
+
 	/* Power up emmc phy analog blocks */
 	return rockchip_emmc_phy_power(phy, PHYCTRL_PDB_PWR_ON);
 }
@@ -359,10 +371,14 @@  static int rockchip_emmc_phy_probe(struct platform_device *pdev)
 	rk_phy->reg_offset = reg_offset;
 	rk_phy->reg_base = grf;
 	rk_phy->drive_impedance = PHYCTRL_DR_50OHM;
+	rk_phy->enable_strobe_pulldown = PHYCTRL_REN_STRB_DISABLE;
 
 	if (!of_property_read_u32(dev->of_node, "drive-impedance-ohm", &val))
 		rk_phy->drive_impedance = convert_drive_impedance_ohm(pdev, val);
 
+	if (of_property_read_bool(dev->of_node, "enable-strobe-pulldown"))
+		rk_phy->enable_strobe_pulldown = PHYCTRL_REN_STRB_ENABLE;
+
 	generic_phy = devm_phy_create(dev, dev->of_node, &ops);
 	if (IS_ERR(generic_phy)) {
 		dev_err(dev, "failed to create PHY\n");