diff mbox series

[v4,1/2] pinctrl: qcom: Add support for i2c specific pull feature

Message ID 20230209074510.4153294-1-abel.vesa@linaro.org (mailing list archive)
State Not Applicable
Headers show
Series [v4,1/2] pinctrl: qcom: Add support for i2c specific pull feature | expand

Commit Message

Abel Vesa Feb. 9, 2023, 7:45 a.m. UTC
Add support for the new i2c_pull property introduced for SM8550 setting
a I2C specific pull mode on I2C able pins. Add the bit to the SM8550
specific driver while at it.

Co-developed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---

The v3 of this specific patch is here:
https://lore.kernel.org/all/20230208081836.984673-1-abel.vesa@linaro.org/

Changes since v3:
 * changed the condition in msm_config_group_set to "arg == MSM_I2C_STRONG_PULL_UP"
   as Bjorn suggested

Changes since v2:
 * This time, this patch is sent separate w.r.t. SM8550 pinctrl driver
 * The qcom,i2c-pull is dropped, bias-pull-up with value is used instead
 * Default value for i2c pull up is 2.2kOhms and since SM8550 is the
   first one to use it, we hard code it for now
 * changed the authorship as the implementation looks entirely different now

 drivers/pinctrl/qcom/pinctrl-msm.c    | 7 +++++++
 drivers/pinctrl/qcom/pinctrl-msm.h    | 1 +
 drivers/pinctrl/qcom/pinctrl-sm8550.c | 1 +
 3 files changed, 9 insertions(+)

Comments

Bjorn Andersson Feb. 10, 2023, 4:04 a.m. UTC | #1
On Thu, Feb 09, 2023 at 09:45:09AM +0200, Abel Vesa wrote:
> Add support for the new i2c_pull property introduced for SM8550 setting
> a I2C specific pull mode on I2C able pins. Add the bit to the SM8550
> specific driver while at it.
> 
> Co-developed-by: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Abel Vesa <abel.vesa@linaro.org>

Reviewed-by: Bjorn Andersson <andersson@kernel.org>

> ---
> 
> The v3 of this specific patch is here:
> https://lore.kernel.org/all/20230208081836.984673-1-abel.vesa@linaro.org/
> 
> Changes since v3:
>  * changed the condition in msm_config_group_set to "arg == MSM_I2C_STRONG_PULL_UP"
>    as Bjorn suggested
> 
> Changes since v2:
>  * This time, this patch is sent separate w.r.t. SM8550 pinctrl driver
>  * The qcom,i2c-pull is dropped, bias-pull-up with value is used instead
>  * Default value for i2c pull up is 2.2kOhms and since SM8550 is the
>    first one to use it, we hard code it for now
>  * changed the authorship as the implementation looks entirely different now
> 
>  drivers/pinctrl/qcom/pinctrl-msm.c    | 7 +++++++
>  drivers/pinctrl/qcom/pinctrl-msm.h    | 1 +
>  drivers/pinctrl/qcom/pinctrl-sm8550.c | 1 +
>  3 files changed, 9 insertions(+)
> 
> diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
> index 5142c363480a..a69f93e74435 100644
> --- a/drivers/pinctrl/qcom/pinctrl-msm.c
> +++ b/drivers/pinctrl/qcom/pinctrl-msm.c
> @@ -310,6 +310,8 @@ static int msm_config_reg(struct msm_pinctrl *pctrl,
>  	case PIN_CONFIG_BIAS_PULL_UP:
>  		*bit = g->pull_bit;
>  		*mask = 3;
> +		if (g->i2c_pull_bit)
> +			*mask |= BIT(g->i2c_pull_bit) >> *bit;
>  		break;
>  	case PIN_CONFIG_DRIVE_OPEN_DRAIN:
>  		*bit = g->od_bit;
> @@ -336,6 +338,7 @@ static int msm_config_reg(struct msm_pinctrl *pctrl,
>  #define MSM_KEEPER		2
>  #define MSM_PULL_UP_NO_KEEPER	2
>  #define MSM_PULL_UP		3
> +#define MSM_I2C_STRONG_PULL_UP	2200
>  
>  static unsigned msm_regval_to_drive(u32 val)
>  {
> @@ -387,6 +390,8 @@ static int msm_config_group_get(struct pinctrl_dev *pctldev,
>  	case PIN_CONFIG_BIAS_PULL_UP:
>  		if (pctrl->soc->pull_no_keeper)
>  			arg = arg == MSM_PULL_UP_NO_KEEPER;
> +		else if (arg & BIT(g->i2c_pull_bit))
> +			arg = MSM_I2C_STRONG_PULL_UP;
>  		else
>  			arg = arg == MSM_PULL_UP;
>  		if (!arg)
> @@ -467,6 +472,8 @@ static int msm_config_group_set(struct pinctrl_dev *pctldev,
>  		case PIN_CONFIG_BIAS_PULL_UP:
>  			if (pctrl->soc->pull_no_keeper)
>  				arg = MSM_PULL_UP_NO_KEEPER;
> +			else if (g->i2c_pull_bit && arg == MSM_I2C_STRONG_PULL_UP)
> +				arg = BIT(g->i2c_pull_bit) | MSM_PULL_UP;
>  			else
>  				arg = MSM_PULL_UP;
>  			break;
> diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h
> index 05a1209bf9ae..985eceda2517 100644
> --- a/drivers/pinctrl/qcom/pinctrl-msm.h
> +++ b/drivers/pinctrl/qcom/pinctrl-msm.h
> @@ -80,6 +80,7 @@ struct msm_pingroup {
>  
>  	unsigned pull_bit:5;
>  	unsigned drv_bit:5;
> +	unsigned i2c_pull_bit:5;
>  
>  	unsigned od_bit:5;
>  	unsigned egpio_enable:5;
> diff --git a/drivers/pinctrl/qcom/pinctrl-sm8550.c b/drivers/pinctrl/qcom/pinctrl-sm8550.c
> index 0b7db7d4054a..c9d038098f2c 100644
> --- a/drivers/pinctrl/qcom/pinctrl-sm8550.c
> +++ b/drivers/pinctrl/qcom/pinctrl-sm8550.c
> @@ -47,6 +47,7 @@
>  		.mux_bit = 2,			\
>  		.pull_bit = 0,			\
>  		.drv_bit = 6,			\
> +		.i2c_pull_bit = 13,		\
>  		.egpio_enable = 12,		\
>  		.egpio_present = 11,		\
>  		.oe_bit = 9,			\
> -- 
> 2.34.1
>
Linus Walleij Feb. 10, 2023, 10:48 p.m. UTC | #2
On Thu, Feb 9, 2023 at 8:45 AM Abel Vesa <abel.vesa@linaro.org> wrote:

> Add support for the new i2c_pull property introduced for SM8550 setting
> a I2C specific pull mode on I2C able pins. Add the bit to the SM8550
> specific driver while at it.
>
> Co-developed-by: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Abel Vesa <abel.vesa@linaro.org>

Applied to the pin control tree for v6.3, I expect that Bjorn will apply
patch 2/2 to the qcom tree!

Yours,
Linus Walleij
Bjorn Andersson March 7, 2023, 4:20 a.m. UTC | #3
On Thu, 9 Feb 2023 09:45:09 +0200, Abel Vesa wrote:
> Add support for the new i2c_pull property introduced for SM8550 setting
> a I2C specific pull mode on I2C able pins. Add the bit to the SM8550
> specific driver while at it.
> 
> 

Applied, thanks!

[2/2] arm64: dts: qcom: sm8550: Add bias pull up value to tlmm i2c data clk states
      commit: 4059297ed0a5adf8e5fd0bd734d702a24202c02e

Best regards,
diff mbox series

Patch

diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 5142c363480a..a69f93e74435 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -310,6 +310,8 @@  static int msm_config_reg(struct msm_pinctrl *pctrl,
 	case PIN_CONFIG_BIAS_PULL_UP:
 		*bit = g->pull_bit;
 		*mask = 3;
+		if (g->i2c_pull_bit)
+			*mask |= BIT(g->i2c_pull_bit) >> *bit;
 		break;
 	case PIN_CONFIG_DRIVE_OPEN_DRAIN:
 		*bit = g->od_bit;
@@ -336,6 +338,7 @@  static int msm_config_reg(struct msm_pinctrl *pctrl,
 #define MSM_KEEPER		2
 #define MSM_PULL_UP_NO_KEEPER	2
 #define MSM_PULL_UP		3
+#define MSM_I2C_STRONG_PULL_UP	2200
 
 static unsigned msm_regval_to_drive(u32 val)
 {
@@ -387,6 +390,8 @@  static int msm_config_group_get(struct pinctrl_dev *pctldev,
 	case PIN_CONFIG_BIAS_PULL_UP:
 		if (pctrl->soc->pull_no_keeper)
 			arg = arg == MSM_PULL_UP_NO_KEEPER;
+		else if (arg & BIT(g->i2c_pull_bit))
+			arg = MSM_I2C_STRONG_PULL_UP;
 		else
 			arg = arg == MSM_PULL_UP;
 		if (!arg)
@@ -467,6 +472,8 @@  static int msm_config_group_set(struct pinctrl_dev *pctldev,
 		case PIN_CONFIG_BIAS_PULL_UP:
 			if (pctrl->soc->pull_no_keeper)
 				arg = MSM_PULL_UP_NO_KEEPER;
+			else if (g->i2c_pull_bit && arg == MSM_I2C_STRONG_PULL_UP)
+				arg = BIT(g->i2c_pull_bit) | MSM_PULL_UP;
 			else
 				arg = MSM_PULL_UP;
 			break;
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h
index 05a1209bf9ae..985eceda2517 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.h
+++ b/drivers/pinctrl/qcom/pinctrl-msm.h
@@ -80,6 +80,7 @@  struct msm_pingroup {
 
 	unsigned pull_bit:5;
 	unsigned drv_bit:5;
+	unsigned i2c_pull_bit:5;
 
 	unsigned od_bit:5;
 	unsigned egpio_enable:5;
diff --git a/drivers/pinctrl/qcom/pinctrl-sm8550.c b/drivers/pinctrl/qcom/pinctrl-sm8550.c
index 0b7db7d4054a..c9d038098f2c 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm8550.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm8550.c
@@ -47,6 +47,7 @@ 
 		.mux_bit = 2,			\
 		.pull_bit = 0,			\
 		.drv_bit = 6,			\
+		.i2c_pull_bit = 13,		\
 		.egpio_enable = 12,		\
 		.egpio_present = 11,		\
 		.oe_bit = 9,			\