Skip to contentSkip to conversation

Fix broken SET/CLR mode of a certain number of pins for MediaTek MT8385 SoC

PATCH In review [email protected] 3 participants 7 messages Oct 21, 2022 – Nov 16, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Fix broken SET/CLR mode of a certain number of pins for MediaTek MT8385 SoC

From: Balsam CHIHI <[email protected]>

On MT8365, the SET/CLR of the mode is broken and some pins won't set or clear the modes correctly. To fix this issue, we add a specific callback mt8365_set_clr_mode() for this specific SoC. This callback uses the main R/W register to read/update/write the modes instead of using the SET/CLR register.

This is the original patch series proposed by Fabien Parent <[email protected]>. "https://lore.kernel.org/linux-arm-kernel/[email protected]/"

Changelog:
Changes in v2 :
- Rebase on top of 6.1.0-rc1-next-20221020
- Delete MTK_PINCTRL_MODE_SET_CLR_BROKEN quirk
- Add mt8365_set_clr_mode() callback

Changes in v1 :
- "https://lore.kernel.org/linux-arm-kernel/[email protected]/"

Balsam CHIHI (2):
pinctrl: mediatek: common: add mt8365_set_clr_mode() callback for
broken SET/CLR modes
pinctrl: mediatek: mt8365: use mt8365_set_clr_mode() callback

 drivers/pinctrl/mediatek/pinctrl-mt8365.c     | 18 ++++++++++++++++++
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 15 +++++++++++++++
 drivers/pinctrl/mediatek/pinctrl-mtk-common.h |  8 +++++++-
 3 files changed, 40 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/2 pinctrl: mediatek: common: add mt8365_set_clr_mode() callback for broken SET/CLR modes

From: Balsam CHIHI <[email protected]>

On MT8365, the SET/CLR of the mode is broken and some pin modes won't be set correctly.
Add mt8365_set_clr_mode() callback for such SoCs, so that instead of using the SET/CLR register, use the main R/W register to read/update/write the modes.

---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 15 +++++++++++++++
 drivers/pinctrl/mediatek/pinctrl-mtk-common.h |  8 +++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +15 -0
index f25b3e09386b..076ae0b38e3d 100644
@@ -330,6 +330,21 @@ static int mtk_pconf_set_pull_select(struct mtk_pinctrl *pctl,
 		return -EINVAL;
 	}
 
+	if (pctl->devdata->mt8365_set_clr_mode) {
+		bit = pin & pctl->devdata->mode_mask;
+		reg_pullen = mtk_get_port(pctl, pin) +
+			pctl->devdata->pullen_offset;
+		reg_pullsel = mtk_get_port(pctl, pin) +
+			pctl->devdata->pullsel_offset;
+		ret = pctl->devdata->mt8365_set_clr_mode(mtk_get_regmap(pctl, pin),
+			bit, reg_pullen, reg_pullsel,
+			enable, isup);
+		if (ret)
+			return -EINVAL;
+
+		return 0;
+	}
+
 	bit = BIT(pin & pctl->devdata->mode_mask);
 	if (enable)
 		reg_pullen = SET_ADDR(mtk_get_port(pctl, pin) +
drivers/pinctrl/mediatek/pinctrl-mtk-common.h +7 -1
index 6fe8564334c9..11afa12a96cb 100644
@@ -216,7 +216,10 @@ struct mtk_eint_offsets {
  * @spec_dir_set: In very few SoCs, direction control registers are not
  * arranged continuously, they may be cut to parts. So they need special
  * dir setting.
-
+ * @mt8365_set_clr_mode: In mt8365, some pins won't set correcty because they
+ * need to use the main R/W register to read/update/write the modes instead of
+ * the SET/CLR register.
+ *
  * @dir_offset: The direction register offset.
  * @pullen_offset: The pull-up/pull-down enable register offset.
  * @pinmux_offset: The pinmux register offset.
@@ -252,6 +255,9 @@ struct mtk_pinctrl_devdata {
 	void (*spec_pinmux_set)(struct regmap *reg, unsigned int pin,
 			unsigned int mode);
 	void (*spec_dir_set)(unsigned int *reg_addr, unsigned int pin);
+	int (*mt8365_set_clr_mode)(struct regmap *regmap,
+			unsigned int bit, unsigned int reg_pullen, unsigned int reg_pullsel,
+			bool enable, bool isup);
 	unsigned int dir_offset;
 	unsigned int ies_offset;
 	unsigned int smt_offset;
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/2 pinctrl: mediatek: mt8365: use mt8365_set_clr_mode() callback

In reply to [email protected]

From: Balsam CHIHI <[email protected]>

On MT8365, the SET/CLR of the mode is broken and some pin modes won't be set correctly.
Use the mt8365_set_clr_mode() callback to fix the issue.

---
 drivers/pinctrl/mediatek/pinctrl-mt8365.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/pinctrl/mediatek/pinctrl-mt8365.c +18 -0
index 57f37a294063..42b48136ab77 100644
@@ -416,6 +416,23 @@ static const struct mtk_pin_ies_smt_set mt8365_smt_set[] = {
 	MTK_PIN_IES_SMT_SPEC(144, 144, 0x480, 22),
 };
 
+static int mt8365_set_clr_mode(struct regmap *regmap,
+		unsigned int bit, unsigned int reg_pullen, unsigned int reg_pullsel,
+		bool enable, bool isup)
+{
+	int ret;
+
+	ret = regmap_update_bits(regmap, reg_pullen, BIT(bit), enable << bit);
+	if (ret)
+		return -EINVAL;
+
+	ret = regmap_update_bits(regmap, reg_pullsel, BIT(bit), isup << bit);
+	if (ret)
+		return -EINVAL;
+
+	return 0;
+}
+
 static const struct mtk_pinctrl_devdata mt8365_pinctrl_data = {
 	.pins = mtk_pins_mt8365,
 	.npins = ARRAY_SIZE(mtk_pins_mt8365),
@@ -431,6 +448,7 @@ static const struct mtk_pinctrl_devdata mt8365_pinctrl_data = {
 	.n_spec_pupd = ARRAY_SIZE(mt8365_spec_pupd),
 	.spec_pull_set = mtk_pctrl_spec_pull_set_samereg,
 	.spec_ies_smt_set = mtk_pconf_spec_set_ies_smt_range,
+	.mt8365_set_clr_mode = mt8365_set_clr_mode,
 	.dir_offset = 0x0140,
 	.dout_offset = 0x00A0,
 	.din_offset = 0x0000,
Signature · 1 line
2.34.1
#3 lore raw
In reply to [email protected]

Hi Balsam,

Quoted 6 lines · [email protected] writes:

From: Balsam CHIHI <[email protected]>

On MT8365, the SET/CLR of the mode is broken and some pins won't set or clear the modes correctly. To fix this issue, we add a specific callback mt8365_set_clr_mode() for this specific SoC. This callback uses the main R/W register to read/update/write the modes instead of using the SET/CLR register.

Quoted 8 lines

This is the original patch series proposed by Fabien Parent <[email protected]>. "https://lore.kernel.org/linux-arm-kernel/[email protected]/"

Changelog:
Changes in v2 :
- Rebase on top of 6.1.0-rc1-next-20221020
- Delete MTK_PINCTRL_MODE_SET_CLR_BROKEN quirk
- Add mt8365_set_clr_mode() callback

nit: subject of cover letter should also include "pinctrl: mediatek:" prefix. Also note that you're missing the word "PATCH" in all of the subjects.

Tip: If you use git format-patch, you can just pass -v2 on the cmdline and it will create the prefixes for you automatically.

Kevin

#4 lore raw
Quoted 21 lines · Kevin Hilman

Hi Balsam,

Quoted 6 lines · [email protected] writes:

From: Balsam CHIHI <[email protected]>

On MT8365, the SET/CLR of the mode is broken and some pins won't set or clear the modes correctly. To fix this issue, we add a specific callback mt8365_set_clr_mode() for this specific SoC. This callback uses the main R/W register to read/update/write the modes instead of using the SET/CLR register.

Quoted 8 lines

This is the original patch series proposed by Fabien Parent <[email protected]>. "https://lore.kernel.org/linux-arm-kernel/[email protected]/"

Changelog:
Changes in v2 :
- Rebase on top of 6.1.0-rc1-next-20221020
- Delete MTK_PINCTRL_MODE_SET_CLR_BROKEN quirk
- Add mt8365_set_clr_mode() callback

Quoted 7 lines

nit: subject of cover letter should also include "pinctrl: mediatek:" prefix. Also note that you're missing the word "PATCH" in all of the subjects.

Tip: If you use git format-patch, you can just pass -v2 on the cmdline and it will create the prefixes for you automatically.

Hi Kevin,

Well received.
I will fix these issues in the next version/resend. Thank you so much for the review!

Balsam.

Quoted 1 line

Kevin

#5 lore raw
In reply to [email protected]
Quoted 6 lines · On Fri, Oct 21, 2022 at 10:47 AM <[email protected]> wrote:

From: Balsam CHIHI <[email protected]>

On MT8365, the SET/CLR of the mode is broken and some pins won't set or clear the modes correctly. To fix this issue, we add a specific callback mt8365_set_clr_mode() for this specific SoC. This callback uses the main R/W register to read/update/write the modes instead of using the SET/CLR register.

Quoted 8 lines

This is the original patch series proposed by Fabien Parent <[email protected]>. "https://lore.kernel.org/linux-arm-kernel/[email protected]/"

Changelog:
Changes in v2 :
- Rebase on top of 6.1.0-rc1-next-20221020
- Delete MTK_PINCTRL_MODE_SET_CLR_BROKEN quirk
- Add mt8365_set_clr_mode() callback

Patches applied, no need to resend for small issues.

Sorry for taking so long, I wanted some feedback from the Mediatek maintainers but haven't heard anything, so I just applied them.

Yours,
Linus Walleij

#6 lore raw
Quoted 18 lines · Linus Walleij
Quoted 6 lines · On Fri, Oct 21, 2022 at 10:47 AM <[email protected]> wrote:

From: Balsam CHIHI <[email protected]>

On MT8365, the SET/CLR of the mode is broken and some pins won't set or clear the modes correctly. To fix this issue, we add a specific callback mt8365_set_clr_mode() for this specific SoC. This callback uses the main R/W register to read/update/write the modes instead of using the SET/CLR register.

Quoted 8 lines

This is the original patch series proposed by Fabien Parent <[email protected]>. "https://lore.kernel.org/linux-arm-kernel/[email protected]/"

Changelog:
Changes in v2 :
- Rebase on top of 6.1.0-rc1-next-20221020
- Delete MTK_PINCTRL_MODE_SET_CLR_BROKEN quirk
- Add mt8365_set_clr_mode() callback

Quoted 5 lines

Patches applied, no need to resend for small issues.

Sorry for taking so long, I wanted some feedback from the Mediatek maintainers but haven't heard anything, so I just applied them.

Hi Linus,

I'm sorry for the delay.
Thank you very much.

Best regards,
Balsam.

Quoted 2 lines

Yours,
Linus Walleij