* [PATCH V2 1/3] soc/tegra: pmc: Update address mapping sequence for PMC apertures
@ 2024-01-17 20:25 Petlozu Pravareshwar
2024-01-17 20:25 ` [PATCH V2 2/3] dt-bindings: tegra: pmc: Update scratch as an optional aperture Petlozu Pravareshwar
2024-01-17 20:25 ` [PATCH V2 3/3] soc/tegra: " Petlozu Pravareshwar
0 siblings, 2 replies; 5+ messages in thread
From: Petlozu Pravareshwar @ 2024-01-17 20:25 UTC (permalink / raw)
To: thierry.reding, jonathanh, robh+dt, krzysztof.kozlowski+dt,
conor+dt, p.zabel, dmitry.osipenko, ulf.hansson, kkartik,
cai.huoqing, spatra, linux-tegra, linux-kernel, devicetree
Cc: petlozup
On Tegra SoCs prior to Tegra186, PMC has single address range only.
Starting from and after Tegra186, PMC has additional address ranges
apart from base address range. Currently in PMC driver, we try to
map these additional address ranges on all SoCs and if we fail then
we assume that the range is not valid for an SoC. This change makes
it more explicit on which address ranges are expected to be present
on which SoCs and maps the additional address ranges only on SoCs
from and after Tegra186.
Signed-off-by: Petlozu Pravareshwar <petlozup@nvidia.com>
---
drivers/soc/tegra/pmc.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 6dfcc7f50ece..0bc983f6b088 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -384,6 +384,7 @@ struct tegra_pmc_soc {
bool has_blink_output;
bool has_usb_sleepwalk;
bool supports_core_domain;
+ bool has_single_mmio_aperture;
};
/**
@@ -2885,31 +2886,28 @@ static int tegra_pmc_probe(struct platform_device *pdev)
if (IS_ERR(base))
return PTR_ERR(base);
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wake");
- if (res) {
+ if (pmc->soc->has_single_mmio_aperture) {
+ pmc->wake = base;
+ pmc->aotag = base;
+ pmc->scratch = base;
+ } else {
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+ "wake");
pmc->wake = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(pmc->wake))
return PTR_ERR(pmc->wake);
- } else {
- pmc->wake = base;
- }
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "aotag");
- if (res) {
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+ "aotag");
pmc->aotag = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(pmc->aotag))
return PTR_ERR(pmc->aotag);
- } else {
- pmc->aotag = base;
- }
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "scratch");
- if (res) {
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+ "scratch");
pmc->scratch = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(pmc->scratch))
return PTR_ERR(pmc->scratch);
- } else {
- pmc->scratch = base;
}
pmc->clk = devm_clk_get_optional(&pdev->dev, "pclk");
@@ -3300,6 +3298,7 @@ static const struct tegra_pmc_soc tegra20_pmc_soc = {
.num_pmc_clks = 0,
.has_blink_output = true,
.has_usb_sleepwalk = true,
+ .has_single_mmio_aperture = true,
};
static const char * const tegra30_powergates[] = {
@@ -3361,6 +3360,7 @@ static const struct tegra_pmc_soc tegra30_pmc_soc = {
.num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data),
.has_blink_output = true,
.has_usb_sleepwalk = true,
+ .has_single_mmio_aperture = true,
};
static const char * const tegra114_powergates[] = {
@@ -3418,6 +3418,7 @@ static const struct tegra_pmc_soc tegra114_pmc_soc = {
.num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data),
.has_blink_output = true,
.has_usb_sleepwalk = true,
+ .has_single_mmio_aperture = true,
};
static const char * const tegra124_powergates[] = {
@@ -3562,6 +3563,7 @@ static const struct tegra_pmc_soc tegra124_pmc_soc = {
.num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data),
.has_blink_output = true,
.has_usb_sleepwalk = true,
+ .has_single_mmio_aperture = true,
};
static const char * const tegra210_powergates[] = {
@@ -3725,6 +3727,7 @@ static const struct tegra_pmc_soc tegra210_pmc_soc = {
.num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data),
.has_blink_output = true,
.has_usb_sleepwalk = true,
+ .has_single_mmio_aperture = true,
};
static const struct tegra_io_pad_soc tegra186_io_pads[] = {
@@ -3922,6 +3925,7 @@ static const struct tegra_pmc_soc tegra186_pmc_soc = {
.num_pmc_clks = 0,
.has_blink_output = false,
.has_usb_sleepwalk = false,
+ .has_single_mmio_aperture = false,
};
static const struct tegra_io_pad_soc tegra194_io_pads[] = {
@@ -4107,6 +4111,7 @@ static const struct tegra_pmc_soc tegra194_pmc_soc = {
.num_pmc_clks = 0,
.has_blink_output = false,
.has_usb_sleepwalk = false,
+ .has_single_mmio_aperture = false,
};
static const struct tegra_io_pad_soc tegra234_io_pads[] = {
@@ -4235,6 +4240,7 @@ static const struct tegra_pmc_soc tegra234_pmc_soc = {
.pmc_clks_data = NULL,
.num_pmc_clks = 0,
.has_blink_output = false,
+ .has_single_mmio_aperture = false,
};
static const struct of_device_id tegra_pmc_match[] = {
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V2 2/3] dt-bindings: tegra: pmc: Update scratch as an optional aperture
2024-01-17 20:25 [PATCH V2 1/3] soc/tegra: pmc: Update address mapping sequence for PMC apertures Petlozu Pravareshwar
@ 2024-01-17 20:25 ` Petlozu Pravareshwar
2024-01-30 17:19 ` Rob Herring
2024-01-17 20:25 ` [PATCH V2 3/3] soc/tegra: " Petlozu Pravareshwar
1 sibling, 1 reply; 5+ messages in thread
From: Petlozu Pravareshwar @ 2024-01-17 20:25 UTC (permalink / raw)
To: thierry.reding, jonathanh, robh+dt, krzysztof.kozlowski+dt,
conor+dt, p.zabel, dmitry.osipenko, ulf.hansson, kkartik,
cai.huoqing, spatra, linux-tegra, linux-kernel, devicetree
Cc: petlozup
Scratch address space register is used to store reboot reason. For
some Tegra234 systems, the scratch space is not available to store
the reboot reason. This is because scratch region on these systems
is not accessible by the kernel as restricted by the Hypervisor.
Such systems would delist scratch aperture from PMC DT node.
Accordingly, this change makes "scratch" as an optional aperture for
Tegra234 in PMC dt-binding document.
Signed-off-by: Petlozu Pravareshwar <petlozup@nvidia.com>
---
Changes in v2:
- Fix dt_binding_check indentation warning.
- Update 'reg-names' property items list.
.../arm/tegra/nvidia,tegra186-pmc.yaml | 78 ++++++++++++++-----
1 file changed, 58 insertions(+), 20 deletions(-)
diff --git a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-pmc.yaml b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-pmc.yaml
index 0faa403f68c8..79928824005d 100644
--- a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-pmc.yaml
+++ b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-pmc.yaml
@@ -27,7 +27,7 @@ properties:
- const: pmc
- const: wake
- const: aotag
- - const: scratch
+ - enum: [ scratch, misc ]
- const: misc
interrupt-controller: true
@@ -41,25 +41,63 @@ properties:
description: If present, inverts the PMU interrupt signal.
$ref: /schemas/types.yaml#/definitions/flag
-if:
- properties:
- compatible:
- contains:
- const: nvidia,tegra186-pmc
-then:
- properties:
- reg:
- maxItems: 4
-
- reg-names:
- maxItems: 4
-else:
- properties:
- reg:
- minItems: 5
-
- reg-names:
- minItems: 5
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: nvidia,tegra186-pmc
+ then:
+ properties:
+ reg:
+ maxItems: 4
+ reg-names:
+ items:
+ - const: pmc
+ - const: wake
+ - const: aotag
+ - const: scratch
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: nvidia,tegra194-pmc
+ then:
+ properties:
+ reg:
+ minItems: 5
+ reg-names:
+ items:
+ - const: pmc
+ - const: wake
+ - const: aotag
+ - const: scratch
+ - const: misc
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: nvidia,tegra234-pmc
+ then:
+ properties:
+ reg:
+ minItems: 4
+ maxItems: 5
+ reg-names:
+ anyOf:
+ - items:
+ - const: pmc
+ - const: wake
+ - const: aotag
+ - const: misc
+ - items:
+ - const: pmc
+ - const: wake
+ - const: aotag
+ - const: scratch
+ - const: misc
patternProperties:
"^[a-z0-9]+-[a-z0-9]+$":
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V2 3/3] soc/tegra: pmc: Update scratch as an optional aperture
2024-01-17 20:25 [PATCH V2 1/3] soc/tegra: pmc: Update address mapping sequence for PMC apertures Petlozu Pravareshwar
2024-01-17 20:25 ` [PATCH V2 2/3] dt-bindings: tegra: pmc: Update scratch as an optional aperture Petlozu Pravareshwar
@ 2024-01-17 20:25 ` Petlozu Pravareshwar
1 sibling, 0 replies; 5+ messages in thread
From: Petlozu Pravareshwar @ 2024-01-17 20:25 UTC (permalink / raw)
To: thierry.reding, jonathanh, robh+dt, krzysztof.kozlowski+dt,
conor+dt, p.zabel, dmitry.osipenko, ulf.hansson, kkartik,
cai.huoqing, spatra, linux-tegra, linux-kernel, devicetree
Cc: petlozup
Scratch address space register is used to store reboot reason. For
some Tegra234 systems, the scratch space is not available to store
the reboot reason. This is because scratch region on these systems
is not accessible by the kernel as restricted by the Hypervisor.
Such systems would delist scratch aperture from PMC DT node.
Hence this change makes scratch as optional aperture and also avoids
registering reboot notifier if scratch address space isn't mapped.
Signed-off-by: Petlozu Pravareshwar <petlozup@nvidia.com>
---
drivers/soc/tegra/pmc.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 0bc983f6b088..6948f78c7a4a 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -2903,11 +2903,16 @@ static int tegra_pmc_probe(struct platform_device *pdev)
if (IS_ERR(pmc->aotag))
return PTR_ERR(pmc->aotag);
+ /* "scratch" is an optional aperture */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
"scratch");
- pmc->scratch = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(pmc->scratch))
- return PTR_ERR(pmc->scratch);
+ if (res) {
+ pmc->scratch = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(pmc->scratch))
+ return PTR_ERR(pmc->scratch);
+ } else {
+ pmc->scratch = NULL;
+ }
}
pmc->clk = devm_clk_get_optional(&pdev->dev, "pclk");
@@ -2919,12 +2924,15 @@ static int tegra_pmc_probe(struct platform_device *pdev)
* PMC should be last resort for restarting since it soft-resets
* CPU without resetting everything else.
*/
- err = devm_register_reboot_notifier(&pdev->dev,
- &tegra_pmc_reboot_notifier);
- if (err) {
- dev_err(&pdev->dev, "unable to register reboot notifier, %d\n",
- err);
- return err;
+ if (pmc->scratch) {
+ err = devm_register_reboot_notifier(&pdev->dev,
+ &tegra_pmc_reboot_notifier);
+ if (err) {
+ dev_err(&pdev->dev,
+ "unable to register reboot notifier, %d\n",
+ err);
+ return err;
+ }
}
err = devm_register_sys_off_handler(&pdev->dev,
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH V2 2/3] dt-bindings: tegra: pmc: Update scratch as an optional aperture
2024-01-17 20:25 ` [PATCH V2 2/3] dt-bindings: tegra: pmc: Update scratch as an optional aperture Petlozu Pravareshwar
@ 2024-01-30 17:19 ` Rob Herring
2024-02-11 17:07 ` Petlozu Pravareshwar
0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring @ 2024-01-30 17:19 UTC (permalink / raw)
To: Petlozu Pravareshwar
Cc: thierry.reding, jonathanh, krzysztof.kozlowski+dt, conor+dt,
p.zabel, dmitry.osipenko, ulf.hansson, kkartik, cai.huoqing,
spatra, linux-tegra, linux-kernel, devicetree
On Wed, Jan 17, 2024 at 08:25:03PM +0000, Petlozu Pravareshwar wrote:
> Scratch address space register is used to store reboot reason. For
> some Tegra234 systems, the scratch space is not available to store
> the reboot reason. This is because scratch region on these systems
> is not accessible by the kernel as restricted by the Hypervisor.
> Such systems would delist scratch aperture from PMC DT node.
>
> Accordingly, this change makes "scratch" as an optional aperture for
> Tegra234 in PMC dt-binding document.
>
> Signed-off-by: Petlozu Pravareshwar <petlozup@nvidia.com>
> ---
> Changes in v2:
> - Fix dt_binding_check indentation warning.
> - Update 'reg-names' property items list.
>
> .../arm/tegra/nvidia,tegra186-pmc.yaml | 78 ++++++++++++++-----
> 1 file changed, 58 insertions(+), 20 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-pmc.yaml b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-pmc.yaml
> index 0faa403f68c8..79928824005d 100644
> --- a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-pmc.yaml
> +++ b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-pmc.yaml
> @@ -27,7 +27,7 @@ properties:
> - const: pmc
> - const: wake
> - const: aotag
> - - const: scratch
> + - enum: [ scratch, misc ]
> - const: misc
>
> interrupt-controller: true
> @@ -41,25 +41,63 @@ properties:
> description: If present, inverts the PMU interrupt signal.
> $ref: /schemas/types.yaml#/definitions/flag
>
> -if:
> - properties:
> - compatible:
> - contains:
> - const: nvidia,tegra186-pmc
> -then:
> - properties:
> - reg:
> - maxItems: 4
> -
> - reg-names:
> - maxItems: 4
> -else:
> - properties:
> - reg:
> - minItems: 5
> -
> - reg-names:
> - minItems: 5
> +allOf:
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: nvidia,tegra186-pmc
> + then:
> + properties:
> + reg:
> + maxItems: 4
> + reg-names:
> + items:
> + - const: pmc
> + - const: wake
> + - const: aotag
> + - const: scratch
There is no need to define the names and order again. Just this is
sufficient:
maxItems: 4
contains:
const: scratch
> +
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: nvidia,tegra194-pmc
> + then:
> + properties:
> + reg:
> + minItems: 5
> + reg-names:
> + items:
> + - const: pmc
> + - const: wake
> + - const: aotag
> + - const: scratch
> + - const: misc
Just 'minItems: 5' is sufficient here.
> +
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: nvidia,tegra234-pmc
> + then:
> + properties:
> + reg:
> + minItems: 4
> + maxItems: 5
That should already be the top-level constraint.
> + reg-names:
> + anyOf:
> + - items:
> + - const: pmc
> + - const: wake
> + - const: aotag
> + - const: misc
> + - items:
> + - const: pmc
> + - const: wake
> + - const: aotag
> + - const: scratch
> + - const: misc
Only need:
contains:
const: misc
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH V2 2/3] dt-bindings: tegra: pmc: Update scratch as an optional aperture
2024-01-30 17:19 ` Rob Herring
@ 2024-02-11 17:07 ` Petlozu Pravareshwar
0 siblings, 0 replies; 5+ messages in thread
From: Petlozu Pravareshwar @ 2024-02-11 17:07 UTC (permalink / raw)
To: Rob Herring
Cc: thierry.reding@gmail.com, Jonathan Hunter,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
p.zabel@pengutronix.de, dmitry.osipenko@collabora.com,
ulf.hansson@linaro.org, Kartik Rajput, cai.huoqing@linux.dev,
Sandipan Patra, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
> On Wed, Jan 17, 2024 at 08:25:03PM +0000, Petlozu Pravareshwar wrote:
> > Scratch address space register is used to store reboot reason. For
> > some Tegra234 systems, the scratch space is not available to store the
> > reboot reason. This is because scratch region on these systems is not
> > accessible by the kernel as restricted by the Hypervisor.
> > Such systems would delist scratch aperture from PMC DT node.
> >
> > Accordingly, this change makes "scratch" as an optional aperture for
> > Tegra234 in PMC dt-binding document.
> >
> > Signed-off-by: Petlozu Pravareshwar <petlozup@nvidia.com>
> > ---
> > Changes in v2:
> > - Fix dt_binding_check indentation warning.
> > - Update 'reg-names' property items list.
> >
> > .../arm/tegra/nvidia,tegra186-pmc.yaml | 78 ++++++++++++++-----
> > 1 file changed, 58 insertions(+), 20 deletions(-)
> >
> > diff --git
> > a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-
> pmc.yaml
> > b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-
> pmc.yaml
> > index 0faa403f68c8..79928824005d 100644
> > ---
> > a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-
> pmc.yaml
> > +++ b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra186-
> pmc.
> > +++ yaml
> > @@ -27,7 +27,7 @@ properties:
> > - const: pmc
> > - const: wake
> > - const: aotag
> > - - const: scratch
> > + - enum: [ scratch, misc ]
> > - const: misc
> >
> > interrupt-controller: true
> > @@ -41,25 +41,63 @@ properties:
> > description: If present, inverts the PMU interrupt signal.
> > $ref: /schemas/types.yaml#/definitions/flag
> >
> > -if:
> > - properties:
> > - compatible:
> > - contains:
> > - const: nvidia,tegra186-pmc
> > -then:
> > - properties:
> > - reg:
> > - maxItems: 4
> > -
> > - reg-names:
> > - maxItems: 4
> > -else:
> > - properties:
> > - reg:
> > - minItems: 5
> > -
> > - reg-names:
> > - minItems: 5
> > +allOf:
> > + - if:
> > + properties:
> > + compatible:
> > + contains:
> > + const: nvidia,tegra186-pmc
> > + then:
> > + properties:
> > + reg:
> > + maxItems: 4
> > + reg-names:
> > + items:
> > + - const: pmc
> > + - const: wake
> > + - const: aotag
> > + - const: scratch
>
> There is no need to define the names and order again. Just this is
> sufficient:
>
> maxItems: 4
> contains:
> const: scratch
>
Agree. Will address this in the next patch.
> > +
> > + - if:
> > + properties:
> > + compatible:
> > + contains:
> > + const: nvidia,tegra194-pmc
> > + then:
> > + properties:
> > + reg:
> > + minItems: 5
> > + reg-names:
> > + items:
> > + - const: pmc
> > + - const: wake
> > + - const: aotag
> > + - const: scratch
> > + - const: misc
>
> Just 'minItems: 5' is sufficient here.
>
Will address this in the next patch.
> > +
> > + - if:
> > + properties:
> > + compatible:
> > + contains:
> > + const: nvidia,tegra234-pmc
> > + then:
> > + properties:
> > + reg:
> > + minItems: 4
> > + maxItems: 5
>
> That should already be the top-level constraint.
>
Will address this in the next patch.
> > + reg-names:
> > + anyOf:
> > + - items:
> > + - const: pmc
> > + - const: wake
> > + - const: aotag
> > + - const: misc
> > + - items:
> > + - const: pmc
> > + - const: wake
> > + - const: aotag
> > + - const: scratch
> > + - const: misc
>
> Only need:
>
> contains:
> const: misc
Will address this in the next patch.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-11 17:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-17 20:25 [PATCH V2 1/3] soc/tegra: pmc: Update address mapping sequence for PMC apertures Petlozu Pravareshwar
2024-01-17 20:25 ` [PATCH V2 2/3] dt-bindings: tegra: pmc: Update scratch as an optional aperture Petlozu Pravareshwar
2024-01-30 17:19 ` Rob Herring
2024-02-11 17:07 ` Petlozu Pravareshwar
2024-01-17 20:25 ` [PATCH V2 3/3] soc/tegra: " Petlozu Pravareshwar
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 NNTP newsgroup(s).