lkml.org 
[lkml]   [2022]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v1 12/19] reset: npcm: Add NPCM8XX support
On Sun, May 22, 2022 at 5:50 PM Tomer Maimon <tmaimon77@gmail.com> wrote:

> static const struct of_device_id npcm_rc_match[] = {
> { .compatible = "nuvoton,npcm750-reset"},
> + { .compatible = "nuvoton,npcm845-reset"},
> { }
> };
> +/*
> + * The following procedure should be observed in USB PHY, USB device and
> + * USB host initialization at BMC boot
> + */
> +static int npcm_usb_reset(struct platform_device *pdev, struct npcm_rc_data *rc)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct device *dev = &pdev->dev;
> +
> + rc->gcr_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
> + if (IS_ERR(rc->gcr_regmap)) {
> + dev_err(&pdev->dev, "Failed to find gcr syscon");
> + return PTR_ERR(rc->gcr_regmap);
> + }
> +
> + if (of_device_is_compatible(np, "nuvoton,npcm750-reset"))
> + npcm_usb_reset_npcm7xx(rc);
> + else if (of_device_is_compatible(np, "nuvoton,npcm845-reset"))
> + npcm_usb_reset_npcm8xx(rc);
> + else
> + return -ENODEV;
>

In place of the string comparison in of_device_is_compatible(), maybe just use
the .data field of the of_device_id structure to point to the actual
reset function.

Alternatively, register two separate platform_driver instances here and
use separate probe functions that do the soc specific bits and call into
shared functions for the bits that are the same.

Arnd

\
 
 \ /
  Last update: 2022-05-23 12:47    [W:0.208 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site