U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Junhui Liu" <junhui.liu@pigmoral.tech>
To: "Eric Chung" <eric.chung@riscstar.com>,
	<u-boot-spacemit@groups.io>, <u-boot@lists.denx.de>,
	<u-boot@lists.u-boot-project.org>
Cc: "Tom Rini" <trini@konsulko.com>, "Peng Fan" <peng.fan@nxp.com>,
	"Huan Zhou" <pericycle.cc@gmail.com>,
	"Raymond Mao" <raymond.mao@riscstar.com>,
	"Jaehoon Chung" <jh80.chung@samsung.com>,
	"Bhimeswararao Matsa" <bhimeswararao.matsa@gmail.com>,
	"Tanmay Kathpalia" <tanmay.kathpalia@altera.com>,
	"Kaustabh Chakraborty" <kauschluss@disroot.org>,
	"Han Xu" <han.xu@nxp.com>,
	"Yanir Levin" <yanir.levin@tandemg.com>,
	"Christoph Stoidner" <c.stoidner@phytec.de>,
	"Balsundar Ponnusamy" <balsundar.ponnusamy@altera.com>,
	"Daniel Palmer" <daniel@thingy.jp>,
	"Anshul Dalal" <anshuld@ti.com>,
	"Bastien Curutchet" <bastien.curutchet@bootlin.com>,
	"Angelo Dureghello" <angelo@kernel-space.org>,
	"Johan Jonker" <jbx6244@gmail.com>,
	"Rick Chen" <rick@andestech.com>, "Leo" <ycliang@andestech.com>,
	"Sam Protsenko" <semen.protsenko@linaro.org>,
	"Guodong Xu" <guodong.xu@riscstar.com>,
	"Tim Ouyang" <tim609@andestech.com>,
	"Leo Liang" <leo.liang@sifive.com>,
	"U-Boot" <u-boot-bounces@lists.denx.de>,
	"Yixun Lan" <dlan@kernel.org>, "Yao Zi" <me@ziyao.cc>
Subject: Re: [PATCH v4 02/10] pinctrl: k1: add IO power domain configuration support
Date: Fri, 24 Jul 2026 00:50:31 +0800	[thread overview]
Message-ID: <DK63T7X6VF21.7PVRSS31IVWQ@pigmoral.tech> (raw)
In-Reply-To: <20260707-m4-v4-2-dbd01185f911@riscstar.com>

Hi Eric,

Thanks for your patch. However, I found a couple of issues while
testing.

On Tue Jul 7, 2026 at 11:21 PM CST, Eric Chung wrote:
> Dual-voltage GPIO banks default to 3.3V, but when externally supplied
> with 1.8V the internal logic must be explicitly reconfigured to match.
>
> Add the ability to program IO power domain control registers through the
> APBC block. These registers require unlocking the AIB Secure Access
> Register (ASAR) before every read/write, since configuring a 1.8V domain
> while 3.3V is externally supplied can cause back-powering and pin damage.
>
> Signed-off-by: Eric Chung <eric.chung@riscstar.com>
>
> ---
> v3:
> - Add SYSCON dependency in Kconfig.
> - Fix not sorted issue in the driver.
> ---
>  drivers/pinctrl/spacemit/Kconfig      |  2 +-
>  drivers/pinctrl/spacemit/pinctrl-k1.c | 83 ++++++++++++++++++++++++++++++++++-
>  2 files changed, 82 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pinctrl/spacemit/Kconfig b/drivers/pinctrl/spacemit/Kconfig
> index 6aab89e160c..ff754f5839c 100644
> --- a/drivers/pinctrl/spacemit/Kconfig
> +++ b/drivers/pinctrl/spacemit/Kconfig
> @@ -1,6 +1,6 @@
>  config PINCTRL_SPACEMIT_K1
>  	bool "Spacemit K1 SoC pinctrl driver"
> -	depends on PINCTRL_GENERIC && DM
> +	depends on PINCTRL_GENERIC && DM && SYSCON
>  	help
>  	  Supports pin multiplexing control on Spacemit K1 SoCs.
>  
> diff --git a/drivers/pinctrl/spacemit/pinctrl-k1.c b/drivers/pinctrl/spacemit/pinctrl-k1.c
> index 3ebc397213b..95344f4ec72 100644
> --- a/drivers/pinctrl/spacemit/pinctrl-k1.c
> +++ b/drivers/pinctrl/spacemit/pinctrl-k1.c

[...]

> +
>  static int spacemit_pinconf_set(struct udevice *dev, unsigned int pin_selector,
>  				unsigned int param, unsigned int argument)
>  {
> @@ -456,6 +526,9 @@ static int spacemit_pinconf_set(struct udevice *dev, unsigned int pin_selector,
>  			dev_err(dev, "Invalid power source (%d)\n", argument);
>  			return -EINVAL;
>  		}
> +		if (found)
> +			spacemit_set_io_power_domain(dev, pin_selector,

CONFIG_PINCONF is not enabled in spacemit_k1_defconfig. Therefore, with
the default configuration, the generic pinctrl code skips pin
configuration properties and spacemit_pinconf_set() is never called.
Consequently, the IO power domain configuration added here is not
exercised when building with spacemit_k1_defconfig.

> +						     priv->io_pins[i].io_type);
>  		break;
>  	default:
>  		return -EOPNOTSUPP;
> @@ -485,6 +558,11 @@ static int spacemit_pinctrl_probe(struct udevice *dev)
>  		dev_err(dev, "Fail to allocate memory\n");
>  		return -ENOMEM;
>  	}
> +	priv->regmap = syscon_regmap_lookup_by_phandle(dev, "spacemit,apbc");
> +	if (IS_ERR(priv->regmap)) {
> +		dev_warn(dev, "no syscon found, disable IO power domain switching\n");
> +		priv->regmap = NULL;
> +	}

The APBC node with compatible "spacemit,k1-syscon-apbc" is bound by
drivers/clk/spacemit/clk-k1.c as a UCLASS_CLK device. It is not
registered as a UCLASS_SYSCON device, and the node does not have the
"syscon" compatible required by the fallback path in
syscon_regmap_lookup_by_phandle(). Therefore, this lookup fails and
priv->regmap is set to NULL.

I added a direct MMIO write to the UART registers here to confirm the
failure path. The original dev_warn() is not visible because this probe
happens before the normal console is initialized.

To fix this, I suggest either making the clock driver register or expose
the APBC regmap through the syscon infrastructure, or avoiding syscon
here and obtaining the regmap directly using dev_read_phandle_with_args()
followed by regmap_init_mem().

>  
>  	ret = clk_get_bulk(dev, &clks);
>  	if (ret) {
> @@ -512,6 +590,7 @@ static const struct spacemit_pinctrl_data k1_pinctrl_data = {
>  	.get_pins	= k1_get_pins,
>  	.get_functions	= k1_get_functions,
>  	.get_io_type	= k1_get_io_type,
> +	.pin_to_io_pd_offset = spacemit_k1_pin_to_io_pd_offset,
>  };
>  
>  static const struct udevice_id spacemit_pinctrl_ids[] = {

-- 
Best regards,
Junhui Liu


  parent reply	other threads:[~2026-07-23 16:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 15:21 [PATCH v4 00/10] spacemit mmc driver Eric Chung
2026-07-07 15:21 ` [PATCH v4 01/10] spacemit: k1: select boot device via config registers Eric Chung
2026-07-19 16:55   ` Yao Zi
2026-07-07 15:21 ` [PATCH v4 02/10] pinctrl: k1: add IO power domain configuration support Eric Chung
2026-07-19 17:01   ` Yao Zi
2026-07-23 16:50   ` Junhui Liu [this message]
2026-07-23 23:48     ` Eric Chung
2026-07-07 15:21 ` [PATCH v4 03/10] mmc: enable CMD23 for multi-block transfers Eric Chung
2026-07-19 17:12   ` Yao Zi
2026-07-20 10:42     ` Eric Chung
2026-07-20 10:44       ` Eric Chung
2026-07-20 11:54         ` Kathpalia, Tanmay
2026-07-22 15:23           ` Eric Chung via U-Boot
2026-07-07 15:21 ` [PATCH v4 04/10] mmc: k1: add sdhci platform driver Eric Chung
2026-07-19 17:46   ` Yao Zi
2026-07-22 15:22     ` Eric Chung via U-Boot
2026-07-07 15:21 ` [PATCH v4 05/10] dts: k1: add SD card support in u-boot overlay Eric Chung
2026-07-19 17:53   ` Yao Zi
2026-07-07 15:21 ` [PATCH v4 06/10] configs: k1: enable SD and eMMC support Eric Chung
2026-07-07 15:21 ` [PATCH v4 07/10] MAINTAINER: update Spacemit K1 entry Eric Chung
2026-07-07 15:21 ` [PATCH v4 08/10] doc: spacemit: flash on K1 SoC based boards Eric Chung
2026-07-07 15:21 ` [PATCH v4 09/10] config: k1: enable ENV support for eMMC Eric Chung
2026-07-07 15:21 ` [PATCH v4 10/10] spacemit: k1: load product name from environment variable Eric Chung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DK63T7X6VF21.7PVRSS31IVWQ@pigmoral.tech \
    --to=junhui.liu@pigmoral.tech \
    --cc=angelo@kernel-space.org \
    --cc=anshuld@ti.com \
    --cc=balsundar.ponnusamy@altera.com \
    --cc=bastien.curutchet@bootlin.com \
    --cc=bhimeswararao.matsa@gmail.com \
    --cc=c.stoidner@phytec.de \
    --cc=daniel@thingy.jp \
    --cc=dlan@kernel.org \
    --cc=eric.chung@riscstar.com \
    --cc=guodong.xu@riscstar.com \
    --cc=han.xu@nxp.com \
    --cc=jbx6244@gmail.com \
    --cc=jh80.chung@samsung.com \
    --cc=kauschluss@disroot.org \
    --cc=leo.liang@sifive.com \
    --cc=me@ziyao.cc \
    --cc=peng.fan@nxp.com \
    --cc=pericycle.cc@gmail.com \
    --cc=raymond.mao@riscstar.com \
    --cc=rick@andestech.com \
    --cc=semen.protsenko@linaro.org \
    --cc=tanmay.kathpalia@altera.com \
    --cc=tim609@andestech.com \
    --cc=trini@konsulko.com \
    --cc=u-boot-bounces@lists.denx.de \
    --cc=u-boot-spacemit@groups.io \
    --cc=u-boot@lists.denx.de \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=yanir.levin@tandemg.com \
    --cc=ycliang@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox