U-boot Archive mirror
 help / color / mirror / Atom feed
From: Jonas Karlman <jonas@kwiboo.se>
To: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Michal Simek <michal.simek@amd.com>,
	Tom Rini <trini@konsulko.com>,
	Daniel Schwierzeck <daniel.schwierzeck@gmail.com>,
	Paul Burton <paulburton@kernel.org>,
	Simon Glass <sjg@chromium.org>, Lukasz Majewski <lukma@denx.de>,
	Sean Anderson <seanga2@gmail.com>,
	Sumit Garg <sumit.garg@linaro.org>,
	u-boot@lists.denx.de
Subject: Re: [PATCH v2 09/12] clk: boston: Allow to get regmap from parent device
Date: Thu, 16 May 2024 16:00:18 +0200	[thread overview]
Message-ID: <b6ba47d2-be93-40e8-a1b7-1bd593a933b7@kwiboo.se> (raw)
In-Reply-To: <20240516-boston-v2-9-77938800d1dd@flygoat.com>

Hi Jiaxun,

On 2024-05-16 13:40, Jiaxun Yang wrote:
> In upstream devicetree, clk_boston is a child of syscon node
> and there is no "regmap" property for clk_boston node.
> 
> Try to check parent device first to look for syscon.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> v2: Move syscon_get_regmap to probe
> ---
>  drivers/clk/clk_boston.c | 37 +++++++++++++++++++++++++------------
>  1 file changed, 25 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/clk/clk_boston.c b/drivers/clk/clk_boston.c
> index 030ff7cc58ec..1985bb0ec334 100644
> --- a/drivers/clk/clk_boston.c
> +++ b/drivers/clk/clk_boston.c
> @@ -12,6 +12,7 @@
>  #include <linux/printk.h>
>  
>  struct clk_boston {
> +	struct udevice *syscon;
>  	struct regmap *regmap;
>  };
>  
> @@ -58,23 +59,33 @@ const struct clk_ops clk_boston_ops = {
>  	.get_rate = clk_boston_get_rate,
>  };
>  
> -static int clk_boston_of_to_plat(struct udevice *dev)
> +static int clk_boston_probe(struct udevice *dev)
>  {
>  	struct clk_boston *state = dev_get_plat(dev);
> -	struct udevice *syscon;
> -	int err;
>  
> -	err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
> -					   "regmap", &syscon);
> -	if (err) {
> -		pr_err("unable to find syscon device\n");
> -		return err;
> +	state->regmap = syscon_get_regmap(state->syscon);
> +	if (IS_ERR(state->regmap)) {
> +		pr_err("unable to find regmap\n");
> +		return PTR_ERR(state->regmap);
>  	}
>  
> -	state->regmap = syscon_get_regmap(syscon);
> -	if (!state->regmap) {
> -		pr_err("unable to find regmap\n");
> -		return -ENODEV;
> +	return 0;
> +}
> +
> +static int clk_boston_of_to_plat(struct udevice *dev)
> +{
> +	struct clk_boston *state = dev_get_plat(dev);
> +	int err;
> +
> +	if (dev->parent && device_get_uclass_id(dev->parent) == UCLASS_SYSCON) {
> +		state->syscon = dev->parent;
> +	} else {
> +		err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
> +						   "regmap", &state->syscon);

This will trigger a probe of the referenced regmap phandle. To simplify
and avoid probing devices at of_to_plat() stage, you can probably just
rename of_to_plat() to probe() and skip of_to_plat() stage completely.

Regards,
Jonas

> +		if (err) {
> +			pr_err("unable to find syscon device\n");
> +			return err;
> +		}
>  	}
>  
>  	return 0;
> @@ -92,6 +103,8 @@ U_BOOT_DRIVER(clk_boston) = {
>  	.id = UCLASS_CLK,
>  	.of_match = clk_boston_match,
>  	.of_to_plat = clk_boston_of_to_plat,
> +	.probe = clk_boston_probe,
>  	.plat_auto	= sizeof(struct clk_boston),
>  	.ops = &clk_boston_ops,
> +	.flags = DM_FLAG_PRE_RELOC,
>  };
> 


  reply	other threads:[~2024-05-16 14:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 11:40 [PATCH v2 00/12] MIPS: Boston: Various enhancements Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 01/12] pci: xilinx: Handle size of ecam region properly Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 02/12] pci: auto: Reduce bridge mem alignment boundary for boston Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 03/12] pci: Enable PCI_MAP_SYSTEM_MEMORY when ARCH_MAP_SYSMEM is not set Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 04/12] ahci: DMA addressing fixes Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 05/12] ahci: dwc_ahsata: Generalize the driver Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 06/12] MIPS: Provide dummy acpi_table.h Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 07/12] MIPS: boston: Imply various options Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 08/12] MIPS: boston: Provide default env vars Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 09/12] clk: boston: Allow to get regmap from parent device Jiaxun Yang
2024-05-16 14:00   ` Jonas Karlman [this message]
2024-05-16 15:06     ` Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 10/12] dts/upstream: Add Makefile for MIPS Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 11/12] MIPS: boston: Migrate to OF_UPSTREAM Jiaxun Yang
2024-05-16 11:40 ` [PATCH v2 12/12] mailmap: Update email for Paul Burton Jiaxun Yang

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=b6ba47d2-be93-40e8-a1b7-1bd593a933b7@kwiboo.se \
    --to=jonas@kwiboo.se \
    --cc=daniel.schwierzeck@gmail.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=lukma@denx.de \
    --cc=michal.simek@amd.com \
    --cc=paulburton@kernel.org \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).