On 9/16/26 9:58 AM, Julien Stephan wrote:
> The scpsys bus protection so far only drove the infracfg register block.
> Some SoCs, such as the MT8365, also gate power domains through the SMI
> common space and acknowledge their way-enable protections via the
> read-only infracfg "nao" mirror.
> 
> Extend the bus protection descriptor with a target register block and a
> separate status block, add the inverted (way-enable) set/clear polarity,
> and retrieve the additional "mediatek,smi" and "mediatek,infracfg-nao"
> regmaps per domain. Existing SoC tables are updated to select the
> default infracfg block.
> 
> This mirrors the Linux driver available upstream at commit Fixes:
> 1b78070aaef6 ("Merge tag 'net-7.3-rc1' of 
> git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")

This reference looks wrong. s/Fixes:// and use the actual commit, not a
merge commit.


> diff --git a/drivers/power/domain/mtk-power-domain.c 
> b/drivers/power/domain/mtk-power-domain.c
> index 24b4991e469..768ab8bab9c 100644
> --- a/drivers/power/domain/mtk-power-domain.c
> +++ b/drivers/power/domain/mtk-power-domain.c
> @@ -43,32 +43,57 @@ static int mtk_infracfg_clear_bus_protection(void __iomem 
> *infracfg,
>                                 !(val & mask), 100);
>  }
>  
> -static int _scpsys_bus_protect_enable(const struct mtk_scpsys_bus_prot_data 
> *bpd,
> -                                   void __iomem *reg)
> +static void __iomem *scpsys_bus_prot_reg(struct mtk_scpsys *scpsys,
> +                                      struct mtk_scp_domain *domain, u8 
> block)
>  {
> +     switch (block) {
> +     case BUS_PROT_BLOCK_INFRA_NAO:
> +             return domain->infracfg_nao;
> +     case BUS_PROT_BLOCK_SMI:
> +             return domain->smi;
> +     case BUS_PROT_BLOCK_INFRA:
> +     default:
> +             return domain->infracfg ? domain->infracfg : scpsys->infracfg;

can just be domain->infracfg ?: scpsys->infracfg;

> +     }
> +}
> +

...

> @@ -396,6 +425,33 @@ static int mtk_scpsys_add_one_domain(struct udevice 
> *dev, ofnode node, int paren
>               domain->infracfg = regmap_get_range(regmap, 0);
>       }

Probably worth a comment saying these are deprecated but we need to support
devicetrees that contain them (e.g. upstream is still using them in mt8365.dtsi)

Also wondering if we should consider these required instead of optional for
mt8365, otherwise we could end up with null pointer problems. Or go ahead
and implement the replacement, which looks like getting the register address
from the power controller itself.

e.g. if reg-names contains 

>  
> +     if (ofnode_read_bool(node, "mediatek,infracfg-nao")) {
> +             ret = ofnode_parse_phandle_with_args(node, 
> "mediatek,infracfg-nao",
> +                                                  NULL, 0, 0, &args);
> +             if (ret)
> +                     return ret;
> +
> +             regmap = syscon_node_to_regmap(args.node);
> +             if (IS_ERR(regmap))
> +                     return PTR_ERR(regmap);
> +
> +             domain->infracfg_nao = regmap_get_range(regmap, 0);

It looks like we aren't acutally using the regmap. Could we just use
ofnode_get_addr() instead? Or do we need the regmap code to do extra setup/
checking for us?

> +     }
> +
> +     if (ofnode_read_bool(node, "mediatek,smi")) {
> +             ret = ofnode_parse_phandle_with_args(node, "mediatek,smi",
> +                                                  NULL, 0, 0, &args);
> +             if (ret)
> +                     return ret;
> +
> +             /* The SMI common node is not a syscon, map its registers 
> directly. */
> +             ret = regmap_init_mem(args.node, &regmap);
> +             if (ret)
> +                     return ret;
> +
> +             domain->smi = regmap_get_range(regmap, 0);
> +     }
> +
>       num_clks = ofnode_read_string_count(node, "clock-names");
>       for (i = 0; i < num_clks; i++) {
>               ret = ofnode_read_string_index(node, "clock-names", i, 
> &clk_name);

Reply via email to