* [PATCH v2 01/13] dt-bindings: pci: apple,pcie: Add t6020 compatible string
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
@ 2025-03-25 10:25 ` Marc Zyngier
2025-03-25 10:50 ` Mark Kettenis
2025-03-25 10:25 ` [PATCH v2 02/13] PCI: host-generic: Extract an ecam bridge creation helper from pci_host_common_probe() Marc Zyngier
` (14 subsequent siblings)
15 siblings, 1 reply; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:25 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
From: Alyssa Rosenzweig <alyssa@rosenzweig.io>
t6020 adds some register ranges compared to t8103, so requires
a new compatible as well as the new PHY registers themselves.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
[maz: added PHY registers]
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
Documentation/devicetree/bindings/pci/apple,pcie.yaml | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/pci/apple,pcie.yaml b/Documentation/devicetree/bindings/pci/apple,pcie.yaml
index c8775f9cb0713..77554899b9420 100644
--- a/Documentation/devicetree/bindings/pci/apple,pcie.yaml
+++ b/Documentation/devicetree/bindings/pci/apple,pcie.yaml
@@ -17,6 +17,10 @@ description: |
implements its root ports. But the ATU found on most DesignWare
PCIe host bridges is absent.
+ On systems derived from T602x, the PHY registers are in a region
+ separate from the port registers. In that case, there is one PHY
+ register range per port register range.
+
All root ports share a single ECAM space, but separate GPIOs are
used to take the PCI devices on those ports out of reset. Therefore
the standard "reset-gpios" and "max-link-speed" properties appear on
@@ -35,11 +39,12 @@ properties:
- apple,t8103-pcie
- apple,t8112-pcie
- apple,t6000-pcie
+ - apple,t6020-pcie
- const: apple,pcie
reg:
minItems: 3
- maxItems: 6
+ maxItems: 10
reg-names:
minItems: 3
@@ -50,6 +55,10 @@ properties:
- const: port1
- const: port2
- const: port3
+ - const: phy0
+ - const: phy1
+ - const: phy2
+ - const: phy3
ranges:
minItems: 2
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v2 01/13] dt-bindings: pci: apple,pcie: Add t6020 compatible string
2025-03-25 10:25 ` [PATCH v2 01/13] dt-bindings: pci: apple,pcie: Add t6020 compatible string Marc Zyngier
@ 2025-03-25 10:50 ` Mark Kettenis
2025-03-25 11:02 ` Marc Zyngier
0 siblings, 1 reply; 23+ messages in thread
From: Mark Kettenis @ 2025-03-25 10:50 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi,
alyssa, j, marcan, sven, bhelgaas, lpieralisi, kw,
manivannan.sadhasivam, robh, krzk+dt
> From: Marc Zyngier <maz@kernel.org>
> Date: Tue, 25 Mar 2025 10:25:58 +0000
Hi Marc,
Sorry for not spotting this in the earlier versions, but:
> From: Alyssa Rosenzweig <alyssa@rosenzweig.io>
>
> t6020 adds some register ranges compared to t8103, so requires
> a new compatible as well as the new PHY registers themselves.
>
> Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
> [maz: added PHY registers]
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
> Documentation/devicetree/bindings/pci/apple,pcie.yaml | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/pci/apple,pcie.yaml b/Documentation/devicetree/bindings/pci/apple,pcie.yaml
> index c8775f9cb0713..77554899b9420 100644
> --- a/Documentation/devicetree/bindings/pci/apple,pcie.yaml
> +++ b/Documentation/devicetree/bindings/pci/apple,pcie.yaml
> @@ -17,6 +17,10 @@ description: |
> implements its root ports. But the ATU found on most DesignWare
> PCIe host bridges is absent.
>
> + On systems derived from T602x, the PHY registers are in a region
> + separate from the port registers. In that case, there is one PHY
> + register range per port register range.
> +
> All root ports share a single ECAM space, but separate GPIOs are
> used to take the PCI devices on those ports out of reset. Therefore
> the standard "reset-gpios" and "max-link-speed" properties appear on
> @@ -35,11 +39,12 @@ properties:
> - apple,t8103-pcie
> - apple,t8112-pcie
> - apple,t6000-pcie
> + - apple,t6020-pcie
> - const: apple,pcie
Since the T602x PCIe controller has a different register layout, it
isn't compatible with the others, so it should not include the
"apple,pcie" compatible. The "downstream" device trees for
T602x-based devices do indeed not list "apple,pcie" as a compatible.
So I think this needs to be written as:
compatible:
oneOf:
- items:
- enum:
- apple,t8103-pcie
- apple,t8112-pcie
- apple,t6000-pcie
- const: apple,pcie
- const: apple,t6020-pcie
>
> reg:
> minItems: 3
> - maxItems: 6
> + maxItems: 10
>
> reg-names:
> minItems: 3
> @@ -50,6 +55,10 @@ properties:
> - const: port1
> - const: port2
> - const: port3
> + - const: phy0
> + - const: phy1
> + - const: phy2
> + - const: phy3
>
> ranges:
> minItems: 2
> --
> 2.39.2
>
>
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v2 01/13] dt-bindings: pci: apple,pcie: Add t6020 compatible string
2025-03-25 10:50 ` Mark Kettenis
@ 2025-03-25 11:02 ` Marc Zyngier
2025-03-25 15:41 ` Mark Kettenis
0 siblings, 1 reply; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 11:02 UTC (permalink / raw)
To: Mark Kettenis
Cc: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi,
alyssa, j, marcan, sven, bhelgaas, lpieralisi, kw,
manivannan.sadhasivam, robh, krzk+dt
Hi Mark,
On Tue, 25 Mar 2025 10:50:18 +0000,
Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>
> > From: Marc Zyngier <maz@kernel.org>
> > Date: Tue, 25 Mar 2025 10:25:58 +0000
>
> Hi Marc,
>
> Sorry for not spotting this in the earlier versions, but:
No worries -- I expected issues in that department.
>
> > From: Alyssa Rosenzweig <alyssa@rosenzweig.io>
> >
> > t6020 adds some register ranges compared to t8103, so requires
> > a new compatible as well as the new PHY registers themselves.
> >
> > Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
> > [maz: added PHY registers]
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > ---
> > Documentation/devicetree/bindings/pci/apple,pcie.yaml | 11 ++++++++++-
> > 1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/pci/apple,pcie.yaml b/Documentation/devicetree/bindings/pci/apple,pcie.yaml
> > index c8775f9cb0713..77554899b9420 100644
> > --- a/Documentation/devicetree/bindings/pci/apple,pcie.yaml
> > +++ b/Documentation/devicetree/bindings/pci/apple,pcie.yaml
> > @@ -17,6 +17,10 @@ description: |
> > implements its root ports. But the ATU found on most DesignWare
> > PCIe host bridges is absent.
> >
> > + On systems derived from T602x, the PHY registers are in a region
> > + separate from the port registers. In that case, there is one PHY
> > + register range per port register range.
> > +
> > All root ports share a single ECAM space, but separate GPIOs are
> > used to take the PCI devices on those ports out of reset. Therefore
> > the standard "reset-gpios" and "max-link-speed" properties appear on
> > @@ -35,11 +39,12 @@ properties:
> > - apple,t8103-pcie
> > - apple,t8112-pcie
> > - apple,t6000-pcie
> > + - apple,t6020-pcie
> > - const: apple,pcie
>
> Since the T602x PCIe controller has a different register layout, it
> isn't compatible with the others, so it should not include the
> "apple,pcie" compatible. The "downstream" device trees for
> T602x-based devices do indeed not list "apple,pcie" as a compatible.
> So I think this needs to be written as:
>
> compatible:
> oneOf:
> - items:
> - enum:
> - apple,t8103-pcie
> - apple,t8112-pcie
> - apple,t6000-pcie
> - const: apple,pcie
> - const: apple,t6020-pcie
Ah, indeed, that's a good point. Thanks for that.
Whilst I have your attention, how about my question below:
>
> >
> > reg:
> > minItems: 3
> > - maxItems: 6
> > + maxItems: 10
> >
> > reg-names:
> > minItems: 3
> > @@ -50,6 +55,10 @@ properties:
> > - const: port1
> > - const: port2
> > - const: port3
> > + - const: phy0
> > + - const: phy1
> > + - const: phy2
> > + - const: phy3
Do we need to make this t6020 specific?
Obviously, separate PHY registers do not make much sense before t6020,
but I couldn't find a way to describe that. I don't even know if
that's a desirable outcome.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v2 01/13] dt-bindings: pci: apple,pcie: Add t6020 compatible string
2025-03-25 11:02 ` Marc Zyngier
@ 2025-03-25 15:41 ` Mark Kettenis
2025-03-25 16:48 ` Marc Zyngier
0 siblings, 1 reply; 23+ messages in thread
From: Mark Kettenis @ 2025-03-25 15:41 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi,
alyssa, j, marcan, sven, bhelgaas, lpieralisi, kw,
manivannan.sadhasivam, robh, krzk+dt
> Date: Tue, 25 Mar 2025 11:02:30 +0000
> From: Marc Zyngier <maz@kernel.org>
Hi Marc,
> Hi Mark,
>
> On Tue, 25 Mar 2025 10:50:18 +0000,
> Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> >
> > > From: Marc Zyngier <maz@kernel.org>
> > > Date: Tue, 25 Mar 2025 10:25:58 +0000
> >
> > Hi Marc,
> >
> > Sorry for not spotting this in the earlier versions, but:
>
> No worries -- I expected issues in that department.
>
> >
> > > From: Alyssa Rosenzweig <alyssa@rosenzweig.io>
> > >
> > > t6020 adds some register ranges compared to t8103, so requires
> > > a new compatible as well as the new PHY registers themselves.
> > >
> > > Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
> > > [maz: added PHY registers]
> > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > > ---
> > > Documentation/devicetree/bindings/pci/apple,pcie.yaml | 11 ++++++++++-
> > > 1 file changed, 10 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/Documentation/devicetree/bindings/pci/apple,pcie.yaml b/Documentation/devicetree/bindings/pci/apple,pcie.yaml
> > > index c8775f9cb0713..77554899b9420 100644
> > > --- a/Documentation/devicetree/bindings/pci/apple,pcie.yaml
> > > +++ b/Documentation/devicetree/bindings/pci/apple,pcie.yaml
> > > @@ -17,6 +17,10 @@ description: |
> > > implements its root ports. But the ATU found on most DesignWare
> > > PCIe host bridges is absent.
> > >
> > > + On systems derived from T602x, the PHY registers are in a region
> > > + separate from the port registers. In that case, there is one PHY
> > > + register range per port register range.
> > > +
> > > All root ports share a single ECAM space, but separate GPIOs are
> > > used to take the PCI devices on those ports out of reset. Therefore
> > > the standard "reset-gpios" and "max-link-speed" properties appear on
> > > @@ -35,11 +39,12 @@ properties:
> > > - apple,t8103-pcie
> > > - apple,t8112-pcie
> > > - apple,t6000-pcie
> > > + - apple,t6020-pcie
> > > - const: apple,pcie
> >
> > Since the T602x PCIe controller has a different register layout, it
> > isn't compatible with the others, so it should not include the
> > "apple,pcie" compatible. The "downstream" device trees for
> > T602x-based devices do indeed not list "apple,pcie" as a compatible.
> > So I think this needs to be written as:
> >
> > compatible:
> > oneOf:
> > - items:
> > - enum:
> > - apple,t8103-pcie
> > - apple,t8112-pcie
> > - apple,t6000-pcie
> > - const: apple,pcie
> > - const: apple,t6020-pcie
>
> Ah, indeed, that's a good point. Thanks for that.
>
> Whilst I have your attention, how about my question below:
>
> >
> > >
> > > reg:
> > > minItems: 3
> > > - maxItems: 6
> > > + maxItems: 10
> > >
> > > reg-names:
> > > minItems: 3
> > > @@ -50,6 +55,10 @@ properties:
> > > - const: port1
> > > - const: port2
> > > - const: port3
> > > + - const: phy0
> > > + - const: phy1
> > > + - const: phy2
> > > + - const: phy3
>
> Do we need to make this t6020 specific?
>
> Obviously, separate PHY registers do not make much sense before t6020,
> but I couldn't find a way to describe that. I don't even know if
> that's a desirable outcome.
I don't think there is a way to do that other than creating a separate
binding for t6020. But I'm far from a dt-schema expert. Maybe robh
has some advice here.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v2 01/13] dt-bindings: pci: apple,pcie: Add t6020 compatible string
2025-03-25 15:41 ` Mark Kettenis
@ 2025-03-25 16:48 ` Marc Zyngier
2025-03-26 19:51 ` Rob Herring
0 siblings, 1 reply; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 16:48 UTC (permalink / raw)
To: Mark Kettenis
Cc: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi,
alyssa, j, marcan, sven, bhelgaas, lpieralisi, kw,
manivannan.sadhasivam, robh, krzk+dt
On Tue, 25 Mar 2025 15:41:15 +0000,
Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>
> > Date: Tue, 25 Mar 2025 11:02:30 +0000
> > From: Marc Zyngier <maz@kernel.org>
>
> Hi Marc,
>
> > Hi Mark,
> >
> > On Tue, 25 Mar 2025 10:50:18 +0000,
> > Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> > >
> > > > From: Marc Zyngier <maz@kernel.org>
> > > > Date: Tue, 25 Mar 2025 10:25:58 +0000
> > >
> > > > @@ -50,6 +55,10 @@ properties:
> > > > - const: port1
> > > > - const: port2
> > > > - const: port3
> > > > + - const: phy0
> > > > + - const: phy1
> > > > + - const: phy2
> > > > + - const: phy3
> >
> > Do we need to make this t6020 specific?
> >
> > Obviously, separate PHY registers do not make much sense before t6020,
> > but I couldn't find a way to describe that. I don't even know if
> > that's a desirable outcome.
>
> I don't think there is a way to do that other than creating a separate
> binding for t6020. But I'm far from a dt-schema expert. Maybe robh
> has some advice here.
Huh, I'd rather not create another binding. The only thing this would
buy us is a stricter checking of the register ranges. But it isn't
like this block is going to find its way in random HW, and this is
only described in a handful of core dtsi files anyway.
Unless someone screams (and provides a reasonable alternative), I will
leave it as is.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v2 01/13] dt-bindings: pci: apple,pcie: Add t6020 compatible string
2025-03-25 16:48 ` Marc Zyngier
@ 2025-03-26 19:51 ` Rob Herring
0 siblings, 0 replies; 23+ messages in thread
From: Rob Herring @ 2025-03-26 19:51 UTC (permalink / raw)
To: Marc Zyngier
Cc: Mark Kettenis, linux-arm-kernel, linux-pci, devicetree,
linux-kernel, asahi, alyssa, j, marcan, sven, bhelgaas,
lpieralisi, kw, manivannan.sadhasivam, krzk+dt
On Tue, Mar 25, 2025 at 11:49 AM Marc Zyngier <maz@kernel.org> wrote:
>
> On Tue, 25 Mar 2025 15:41:15 +0000,
> Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> >
> > > Date: Tue, 25 Mar 2025 11:02:30 +0000
> > > From: Marc Zyngier <maz@kernel.org>
> >
> > Hi Marc,
> >
> > > Hi Mark,
> > >
> > > On Tue, 25 Mar 2025 10:50:18 +0000,
> > > Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> > > >
> > > > > From: Marc Zyngier <maz@kernel.org>
> > > > > Date: Tue, 25 Mar 2025 10:25:58 +0000
> > > >
> > > > > @@ -50,6 +55,10 @@ properties:
> > > > > - const: port1
> > > > > - const: port2
> > > > > - const: port3
> > > > > + - const: phy0
> > > > > + - const: phy1
> > > > > + - const: phy2
> > > > > + - const: phy3
> > >
> > > Do we need to make this t6020 specific?
> > >
> > > Obviously, separate PHY registers do not make much sense before t6020,
> > > but I couldn't find a way to describe that. I don't even know if
> > > that's a desirable outcome.
> >
> > I don't think there is a way to do that other than creating a separate
> > binding for t6020. But I'm far from a dt-schema expert. Maybe robh
> > has some advice here.
>
> Huh, I'd rather not create another binding. The only thing this would
> buy us is a stricter checking of the register ranges. But it isn't
> like this block is going to find its way in random HW, and this is
> only described in a handful of core dtsi files anyway.
>
> Unless someone screams (and provides a reasonable alternative), I will
> leave it as is.
The simplest thing to do here is (under the 'allOf'):
if:
properties:
compatible:
contains:
const: apple,t6020-pcie
then:
properties:
reg-names:
minItems: 10
If/when we start having different number of ports with phy entries,
then it gets messy and each variant has to list out the names or we
give up on defining the order.
Rob
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v2 02/13] PCI: host-generic: Extract an ecam bridge creation helper from pci_host_common_probe()
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
2025-03-25 10:25 ` [PATCH v2 01/13] dt-bindings: pci: apple,pcie: Add t6020 compatible string Marc Zyngier
@ 2025-03-25 10:25 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 03/13] PCI: ecam: Allow cfg->priv to be pre-populated from the root port device Marc Zyngier
` (13 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:25 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
pci_host_common_probe() is an extremely userful helper, as it
abstracts away most of the gunk that a "mostly-ECAM-compliant"
device driver needs.
However, it is structured as a probe function, meaning that a lot
of the driver-specific setup has to happen in a .init() callback,
after the bridge and config space have been instantiated.
This is a bit awkward, and results in a number of convolutions
that could be avoided if the host-common code was more like
a library.
Introduce a pci_host_common_init() helper that does exactly that,
taking the platform device and a struct pci_ecam_op as parameters.
This can then be called from the probe routine, and a lot of the
code that isn't relevant to PCI setup moved away from the .init()
callback. This also removes the dependency on the device match
data, which is an oddity.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pci-host-common.c | 24 ++++++++++++++++--------
include/linux/pci-ecam.h | 2 ++
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
index f441bfd6f96a8..466a1e6a7ffcd 100644
--- a/drivers/pci/controller/pci-host-common.c
+++ b/drivers/pci/controller/pci-host-common.c
@@ -49,23 +49,17 @@ static struct pci_config_window *gen_pci_init(struct device *dev,
return cfg;
}
-int pci_host_common_probe(struct platform_device *pdev)
+int pci_host_common_init(struct platform_device *pdev,
+ const struct pci_ecam_ops *ops)
{
struct device *dev = &pdev->dev;
struct pci_host_bridge *bridge;
struct pci_config_window *cfg;
- const struct pci_ecam_ops *ops;
-
- ops = of_device_get_match_data(&pdev->dev);
- if (!ops)
- return -ENODEV;
bridge = devm_pci_alloc_host_bridge(dev, 0);
if (!bridge)
return -ENOMEM;
- platform_set_drvdata(pdev, bridge);
-
of_pci_check_probe_only();
/* Parse and map our Configuration Space windows */
@@ -73,6 +67,8 @@ int pci_host_common_probe(struct platform_device *pdev)
if (IS_ERR(cfg))
return PTR_ERR(cfg);
+ platform_set_drvdata(pdev, bridge);
+
bridge->sysdata = cfg;
bridge->ops = (struct pci_ops *)&ops->pci_ops;
bridge->enable_device = ops->enable_device;
@@ -81,6 +77,18 @@ int pci_host_common_probe(struct platform_device *pdev)
return pci_host_probe(bridge);
}
+EXPORT_SYMBOL_GPL(pci_host_common_init);
+
+int pci_host_common_probe(struct platform_device *pdev)
+{
+ const struct pci_ecam_ops *ops;
+
+ ops = of_device_get_match_data(&pdev->dev);
+ if (!ops)
+ return -ENODEV;
+
+ return pci_host_common_init(pdev, ops);
+}
EXPORT_SYMBOL_GPL(pci_host_common_probe);
void pci_host_common_remove(struct platform_device *pdev)
diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h
index 3a10f8cfc3ad5..bc2ca2c72ee23 100644
--- a/include/linux/pci-ecam.h
+++ b/include/linux/pci-ecam.h
@@ -97,6 +97,8 @@ extern const struct pci_ecam_ops loongson_pci_ecam_ops; /* Loongson PCIe */
#if IS_ENABLED(CONFIG_PCI_HOST_COMMON)
/* for DT-based PCI controllers that support ECAM */
int pci_host_common_probe(struct platform_device *pdev);
+int pci_host_common_init(struct platform_device *pdev,
+ const struct pci_ecam_ops *ops);
void pci_host_common_remove(struct platform_device *pdev);
#endif
#endif
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 03/13] PCI: ecam: Allow cfg->priv to be pre-populated from the root port device
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
2025-03-25 10:25 ` [PATCH v2 01/13] dt-bindings: pci: apple,pcie: Add t6020 compatible string Marc Zyngier
2025-03-25 10:25 ` [PATCH v2 02/13] PCI: host-generic: Extract an ecam bridge creation helper from pci_host_common_probe() Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 04/13] PCI: apple: Move over to standalone probing Marc Zyngier
` (12 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
In order to decouple ecam config space creation from probing via
pci_host_common_probe(), allow the private pointer to be populated
via the device drvdata pointer.
Crucially, this is set before calling ops->init(), allowing that
particular callback to have access to probe data.
This should have no impact on existing code which ignores the
current value of cfg->priv.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/ecam.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/ecam.c b/drivers/pci/ecam.c
index 260b7de2dbd57..2c5e6446e00ee 100644
--- a/drivers/pci/ecam.c
+++ b/drivers/pci/ecam.c
@@ -84,6 +84,8 @@ struct pci_config_window *pci_ecam_create(struct device *dev,
goto err_exit_iomap;
}
+ cfg->priv = dev_get_drvdata(dev);
+
if (ops->init) {
err = ops->init(cfg);
if (err)
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 04/13] PCI: apple: Move over to standalone probing
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (2 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 03/13] PCI: ecam: Allow cfg->priv to be pre-populated from the root port device Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 05/13] PCI: apple: Dynamically allocate RID-to_SID bitmap Marc Zyngier
` (11 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
Now that we have the required infrastructure, split the Apple PCIe
setup into two categories:
- stuff that has to do with PCI setup stays in the .init() callback
- stuff that is just driver gunk (such as MSI setup) goes into a
probe routine, which will eventually call into the host-common
code
The result is a far more logical setup process.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 54 ++++++++++++++++-------------
1 file changed, 30 insertions(+), 24 deletions(-)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index a7e51bc1c2fe8..9c3103d0d1174 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -730,35 +730,15 @@ static void apple_pcie_disable_device(struct pci_host_bridge *bridge, struct pci
static int apple_pcie_init(struct pci_config_window *cfg)
{
+ struct apple_pcie *pcie = cfg->priv;
struct device *dev = cfg->parent;
- struct platform_device *platform = to_platform_device(dev);
struct device_node *of_port;
- struct apple_pcie *pcie;
int ret;
- pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
- if (!pcie)
- return -ENOMEM;
-
- pcie->dev = dev;
-
- mutex_init(&pcie->lock);
-
- pcie->base = devm_platform_ioremap_resource(platform, 1);
- if (IS_ERR(pcie->base))
- return PTR_ERR(pcie->base);
-
- cfg->priv = pcie;
- INIT_LIST_HEAD(&pcie->ports);
-
- ret = apple_msi_init(pcie);
- if (ret)
- return ret;
-
for_each_child_of_node(dev->of_node, of_port) {
ret = apple_pcie_setup_port(pcie, of_port);
if (ret) {
- dev_err(pcie->dev, "Port %pOF setup fail: %d\n", of_port, ret);
+ dev_err(dev, "Port %pOF setup fail: %d\n", of_port, ret);
of_node_put(of_port);
return ret;
}
@@ -778,14 +758,40 @@ static const struct pci_ecam_ops apple_pcie_cfg_ecam_ops = {
}
};
+static int apple_pcie_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct apple_pcie *pcie;
+ int ret;
+
+ pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
+ if (!pcie)
+ return -ENOMEM;
+
+ pcie->dev = dev;
+ pcie->base = devm_platform_ioremap_resource(pdev, 1);
+ if (IS_ERR(pcie->base))
+ return PTR_ERR(pcie->base);
+
+ mutex_init(&pcie->lock);
+ INIT_LIST_HEAD(&pcie->ports);
+ dev_set_drvdata(dev, pcie);
+
+ ret = apple_msi_init(pcie);
+ if (ret)
+ return ret;
+
+ return pci_host_common_init(pdev, &apple_pcie_cfg_ecam_ops);
+}
+
static const struct of_device_id apple_pcie_of_match[] = {
- { .compatible = "apple,pcie", .data = &apple_pcie_cfg_ecam_ops },
+ { .compatible = "apple,pcie" },
{ }
};
MODULE_DEVICE_TABLE(of, apple_pcie_of_match);
static struct platform_driver apple_pcie_driver = {
- .probe = pci_host_common_probe,
+ .probe = apple_pcie_probe,
.driver = {
.name = "pcie-apple",
.of_match_table = apple_pcie_of_match,
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 05/13] PCI: apple: Dynamically allocate RID-to_SID bitmap
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (3 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 04/13] PCI: apple: Move over to standalone probing Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 06/13] PCI: apple: Move away from INTMSK{SET,CLR} for INTx and private interrupts Marc Zyngier
` (10 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
As we move towards supporting SoCs with varying RID-to-SID mapping
capabilities, turn the static SID tracking bitmap into a dynamically
allocated one. The current allocation size is still the same, but
that's about to change.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 9c3103d0d1174..1f6c55e4b5d68 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -147,7 +147,7 @@ struct apple_pcie_port {
void __iomem *base;
struct irq_domain *domain;
struct list_head entry;
- DECLARE_BITMAP(sid_map, MAX_RID2SID);
+ unsigned long *sid_map;
int sid_map_sz;
int idx;
};
@@ -524,6 +524,10 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
if (!port)
return -ENOMEM;
+ port->sid_map = devm_bitmap_zalloc(pcie->dev, MAX_RID2SID, GFP_KERNEL);
+ if (!port->sid_map)
+ return -ENOMEM;
+
ret = of_property_read_u32_index(np, "reg", 0, &idx);
if (ret)
return ret;
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 06/13] PCI: apple: Move away from INTMSK{SET,CLR} for INTx and private interrupts
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (4 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 05/13] PCI: apple: Dynamically allocate RID-to_SID bitmap Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 07/13] PCI: apple: Fix missing OF node reference in apple_pcie_setup_port Marc Zyngier
` (9 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
T602x seems to have dropped the rather useful SET/CLR accessors
to the masking register.
Instead, let's use the mask register directly, and wrap it with
a brand new spinlock. No, this isn't moving in the right direction.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 1f6c55e4b5d68..63ceb5e3debaf 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -142,6 +142,7 @@ struct apple_pcie {
};
struct apple_pcie_port {
+ raw_spinlock_t lock;
struct apple_pcie *pcie;
struct device_node *np;
void __iomem *base;
@@ -261,14 +262,16 @@ static void apple_port_irq_mask(struct irq_data *data)
{
struct apple_pcie_port *port = irq_data_get_irq_chip_data(data);
- writel_relaxed(BIT(data->hwirq), port->base + PORT_INTMSKSET);
+ guard(raw_spinlock_irqsave)(&port->lock);
+ rmw_set(BIT(data->hwirq), port->base + PORT_INTMSK);
}
static void apple_port_irq_unmask(struct irq_data *data)
{
struct apple_pcie_port *port = irq_data_get_irq_chip_data(data);
- writel_relaxed(BIT(data->hwirq), port->base + PORT_INTMSKCLR);
+ guard(raw_spinlock_irqsave)(&port->lock);
+ rmw_clear(BIT(data->hwirq), port->base + PORT_INTMSK);
}
static bool hwirq_is_intx(unsigned int hwirq)
@@ -387,7 +390,7 @@ static int apple_pcie_port_setup_irq(struct apple_pcie_port *port)
return -ENOMEM;
/* Disable all interrupts */
- writel_relaxed(~0, port->base + PORT_INTMSKSET);
+ writel_relaxed(~0, port->base + PORT_INTMSK);
writel_relaxed(~0, port->base + PORT_INTSTAT);
irq_set_chained_handler_and_data(irq, apple_port_irq_handler, port);
@@ -537,6 +540,8 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
port->pcie = pcie;
port->np = np;
+ raw_spin_lock_init(&port->lock);
+
port->base = devm_platform_ioremap_resource(platform, port->idx + 2);
if (IS_ERR(port->base))
return PTR_ERR(port->base);
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 07/13] PCI: apple: Fix missing OF node reference in apple_pcie_setup_port
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (5 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 06/13] PCI: apple: Move away from INTMSK{SET,CLR} for INTx and private interrupts Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 08/13] PCI: apple: Set only available ports up Marc Zyngier
` (8 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
From: Hector Martin <marcan@marcan.st>
In the success path, we hang onto a reference to the node, so make sure
to grab one. The caller iterator puts our borrowed reference when we
return.
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 63ceb5e3debaf..6271533f1b042 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -593,6 +593,9 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
list_add_tail(&port->entry, &pcie->ports);
init_completion(&pcie->event);
+ /* In the success path, we keep a reference to np around */
+ of_node_get(np);
+
ret = apple_pcie_port_register_irqs(port);
WARN_ON(ret);
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 08/13] PCI: apple: Set only available ports up
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (6 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 07/13] PCI: apple: Fix missing OF node reference in apple_pcie_setup_port Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 13:25 ` Rob Herring
2025-03-25 10:26 ` [PATCH v2 09/13] PCI: apple: Move port PHY registers to their own reg items Marc Zyngier
` (7 subsequent siblings)
15 siblings, 1 reply; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski, stable
From: Janne Grunau <j@jannau.net>
Iterating over disabled ports results in of_irq_parse_raw() parsing
the wrong "interrupt-map" entries, as it takes the status of the node
into account.
Switching from for_each_child_of_node() to for_each_available_child_of_node()
solves this issue.
This became apparent after disabling unused PCIe ports in the Apple
Silicon device trees instead of deleting them.
Link: https://lore.kernel.org/asahi/20230214-apple_dts_pcie_disable_unused-v1-0-5ea0d3ddcde3@jannau.net/
Link: https://lore.kernel.org/asahi/1ea2107a-bb86-8c22-0bbc-82c453ab08ce@linaro.org/
Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
Cc: stable@vger.kernel.org
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 6271533f1b042..23d9f62bd2ad4 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -747,7 +747,7 @@ static int apple_pcie_init(struct pci_config_window *cfg)
struct device_node *of_port;
int ret;
- for_each_child_of_node(dev->of_node, of_port) {
+ for_each_available_child_of_node(dev->of_node, of_port) {
ret = apple_pcie_setup_port(pcie, of_port);
if (ret) {
dev_err(dev, "Port %pOF setup fail: %d\n", of_port, ret);
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v2 08/13] PCI: apple: Set only available ports up
2025-03-25 10:26 ` [PATCH v2 08/13] PCI: apple: Set only available ports up Marc Zyngier
@ 2025-03-25 13:25 ` Rob Herring
0 siblings, 0 replies; 23+ messages in thread
From: Rob Herring @ 2025-03-25 13:25 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi,
Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Krzysztof Kozlowski, stable
On Tue, Mar 25, 2025 at 10:26:05AM +0000, Marc Zyngier wrote:
> From: Janne Grunau <j@jannau.net>
>
> Iterating over disabled ports results in of_irq_parse_raw() parsing
> the wrong "interrupt-map" entries, as it takes the status of the node
> into account.
>
> Switching from for_each_child_of_node() to for_each_available_child_of_node()
> solves this issue.
I really wish "available" was the default iterator...
>
> This became apparent after disabling unused PCIe ports in the Apple
> Silicon device trees instead of deleting them.
>
> Link: https://lore.kernel.org/asahi/20230214-apple_dts_pcie_disable_unused-v1-0-5ea0d3ddcde3@jannau.net/
> Link: https://lore.kernel.org/asahi/1ea2107a-bb86-8c22-0bbc-82c453ab08ce@linaro.org/
> Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
> Cc: stable@vger.kernel.org
Fixes especially for stable should go first in the series.
> Signed-off-by: Janne Grunau <j@jannau.net>
> Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
> drivers/pci/controller/pcie-apple.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> index 6271533f1b042..23d9f62bd2ad4 100644
> --- a/drivers/pci/controller/pcie-apple.c
> +++ b/drivers/pci/controller/pcie-apple.c
> @@ -747,7 +747,7 @@ static int apple_pcie_init(struct pci_config_window *cfg)
> struct device_node *of_port;
> int ret;
>
> - for_each_child_of_node(dev->of_node, of_port) {
> + for_each_available_child_of_node(dev->of_node, of_port) {
> ret = apple_pcie_setup_port(pcie, of_port);
> if (ret) {
> dev_err(dev, "Port %pOF setup fail: %d\n", of_port, ret);
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v2 09/13] PCI: apple: Move port PHY registers to their own reg items
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (7 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 08/13] PCI: apple: Set only available ports up Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 10/13] PCI: apple: Drop poll for CORE_RC_PHYIF_STAT_REFCLK Marc Zyngier
` (6 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
From: Hector Martin <marcan@marcan.st>
T602x PCIe cores move these registers around. Instead of hardcoding in
another offset, let's move them into their own reg entries. This matches
what Apple does on macOS device trees too.
Maintains backwards compatibility with old DTs by using the old offsets.
Note that we open code devm_platform_ioremap_resource_byname() to avoid
error messages on older platforms with missing resources in the pcie
node. ("pcie-apple 590000000.pcie: invalid resource (null)" on probe)
Co-developed-by: Janne Grunau <j@jannau.net>
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 55 +++++++++++++++++++----------
1 file changed, 37 insertions(+), 18 deletions(-)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 23d9f62bd2ad4..94c49611b74df 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -39,14 +39,18 @@
#define CORE_RC_STAT_READY BIT(0)
#define CORE_FABRIC_STAT 0x04000
#define CORE_FABRIC_STAT_MASK 0x001F001F
-#define CORE_LANE_CFG(port) (0x84000 + 0x4000 * (port))
-#define CORE_LANE_CFG_REFCLK0REQ BIT(0)
-#define CORE_LANE_CFG_REFCLK1REQ BIT(1)
-#define CORE_LANE_CFG_REFCLK0ACK BIT(2)
-#define CORE_LANE_CFG_REFCLK1ACK BIT(3)
-#define CORE_LANE_CFG_REFCLKEN (BIT(9) | BIT(10))
-#define CORE_LANE_CTL(port) (0x84004 + 0x4000 * (port))
-#define CORE_LANE_CTL_CFGACC BIT(15)
+
+#define CORE_PHY_DEFAULT_BASE(port) (0x84000 + 0x4000 * (port))
+
+#define PHY_LANE_CFG 0x00000
+#define PHY_LANE_CFG_REFCLK0REQ BIT(0)
+#define PHY_LANE_CFG_REFCLK1REQ BIT(1)
+#define PHY_LANE_CFG_REFCLK0ACK BIT(2)
+#define PHY_LANE_CFG_REFCLK1ACK BIT(3)
+#define PHY_LANE_CFG_REFCLKEN (BIT(9) | BIT(10))
+#define PHY_LANE_CFG_REFCLKCGEN (BIT(30) | BIT(31))
+#define PHY_LANE_CTL 0x00004
+#define PHY_LANE_CTL_CFGACC BIT(15)
#define PORT_LTSSMCTL 0x00080
#define PORT_LTSSMCTL_START BIT(0)
@@ -146,6 +150,7 @@ struct apple_pcie_port {
struct apple_pcie *pcie;
struct device_node *np;
void __iomem *base;
+ void __iomem *phy;
struct irq_domain *domain;
struct list_head entry;
unsigned long *sid_map;
@@ -476,26 +481,26 @@ static int apple_pcie_setup_refclk(struct apple_pcie *pcie,
if (res < 0)
return res;
- rmw_set(CORE_LANE_CTL_CFGACC, pcie->base + CORE_LANE_CTL(port->idx));
- rmw_set(CORE_LANE_CFG_REFCLK0REQ, pcie->base + CORE_LANE_CFG(port->idx));
+ rmw_set(PHY_LANE_CTL_CFGACC, port->phy + PHY_LANE_CTL);
+ rmw_set(PHY_LANE_CFG_REFCLK0REQ, port->phy + PHY_LANE_CFG);
- res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx),
- stat, stat & CORE_LANE_CFG_REFCLK0ACK,
+ res = readl_relaxed_poll_timeout(port->phy + PHY_LANE_CFG,
+ stat, stat & PHY_LANE_CFG_REFCLK0ACK,
100, 50000);
if (res < 0)
return res;
- rmw_set(CORE_LANE_CFG_REFCLK1REQ, pcie->base + CORE_LANE_CFG(port->idx));
- res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx),
- stat, stat & CORE_LANE_CFG_REFCLK1ACK,
+ rmw_set(PHY_LANE_CFG_REFCLK1REQ, port->phy + PHY_LANE_CFG);
+ res = readl_relaxed_poll_timeout(port->phy + PHY_LANE_CFG,
+ stat, stat & PHY_LANE_CFG_REFCLK1ACK,
100, 50000);
if (res < 0)
return res;
- rmw_clear(CORE_LANE_CTL_CFGACC, pcie->base + CORE_LANE_CTL(port->idx));
+ rmw_clear(PHY_LANE_CTL_CFGACC, port->phy + PHY_LANE_CTL);
- rmw_set(CORE_LANE_CFG_REFCLKEN, pcie->base + CORE_LANE_CFG(port->idx));
+ rmw_set(PHY_LANE_CFG_REFCLKEN, port->phy + PHY_LANE_CFG);
rmw_set(PORT_REFCLK_EN, port->base + PORT_REFCLK);
return 0;
@@ -515,6 +520,8 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
struct platform_device *platform = to_platform_device(pcie->dev);
struct apple_pcie_port *port;
struct gpio_desc *reset;
+ struct resource *res;
+ char name[16];
u32 stat, idx;
int ret, i;
@@ -542,10 +549,22 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
raw_spin_lock_init(&port->lock);
- port->base = devm_platform_ioremap_resource(platform, port->idx + 2);
+ snprintf(name, sizeof(name), "port%d", port->idx);
+ res = platform_get_resource_byname(platform, IORESOURCE_MEM, name);
+ if (!res)
+ res = platform_get_resource(platform, IORESOURCE_MEM, port->idx + 2);
+
+ port->base = devm_ioremap_resource(&platform->dev, res);
if (IS_ERR(port->base))
return PTR_ERR(port->base);
+ snprintf(name, sizeof(name), "phy%d", port->idx);
+ res = platform_get_resource_byname(platform, IORESOURCE_MEM, name);
+ if (res)
+ port->phy = devm_ioremap_resource(&platform->dev, res);
+ else
+ port->phy = pcie->base + CORE_PHY_DEFAULT_BASE(port->idx);
+
rmw_set(PORT_APPCLK_EN, port->base + PORT_APPCLK);
/* Assert PERST# before setting up the clock */
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 10/13] PCI: apple: Drop poll for CORE_RC_PHYIF_STAT_REFCLK
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (8 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 09/13] PCI: apple: Move port PHY registers to their own reg items Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 11/13] PCI: apple: Use gpiod_set_value_cansleep in probe flow Marc Zyngier
` (5 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
From: Hector Martin <marcan@marcan.st>
This is checking a core refclk in per-port setup which doesn't make a
lot of sense, and the bootloader needs to have gone through this anyway.
It doesn't work on T602x, so just drop it across the board.
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 94c49611b74df..c00ec0781fabc 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -475,12 +475,6 @@ static int apple_pcie_setup_refclk(struct apple_pcie *pcie,
u32 stat;
int res;
- res = readl_relaxed_poll_timeout(pcie->base + CORE_RC_PHYIF_STAT, stat,
- stat & CORE_RC_PHYIF_STAT_REFCLK,
- 100, 50000);
- if (res < 0)
- return res;
-
rmw_set(PHY_LANE_CTL_CFGACC, port->phy + PHY_LANE_CTL);
rmw_set(PHY_LANE_CFG_REFCLK0REQ, port->phy + PHY_LANE_CFG);
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 11/13] PCI: apple: Use gpiod_set_value_cansleep in probe flow
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (9 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 10/13] PCI: apple: Drop poll for CORE_RC_PHYIF_STAT_REFCLK Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 12/13] PCI: apple: Abstract register offsets via a SoC-specific structure Marc Zyngier
` (4 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
From: Hector Martin <marcan@marcan.st>
We're allowed to sleep here, so tell the GPIO core by using
gpiod_set_value_cansleep instead of gpiod_set_value.
Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index c00ec0781fabc..505adf64bd66d 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -562,7 +562,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
rmw_set(PORT_APPCLK_EN, port->base + PORT_APPCLK);
/* Assert PERST# before setting up the clock */
- gpiod_set_value(reset, 1);
+ gpiod_set_value_cansleep(reset, 1);
ret = apple_pcie_setup_refclk(pcie, port);
if (ret < 0)
@@ -573,7 +573,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
/* Deassert PERST# */
rmw_set(PORT_PERST_OFF, port->base + PORT_PERST);
- gpiod_set_value(reset, 0);
+ gpiod_set_value_cansleep(reset, 0);
/* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
msleep(100);
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 12/13] PCI: apple: Abstract register offsets via a SoC-specific structure
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (10 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 11/13] PCI: apple: Use gpiod_set_value_cansleep in probe flow Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 10:26 ` [PATCH v2 13/13] PCI: apple: Add T602x PCIe support Marc Zyngier
` (3 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
From: Hector Martin <marcan@marcan.st>
Newer versions of the Apple PCIe block have a bunch of small, but
annoying differences.
In order to embrace this diversity of implementations, move the
currently hardcoded offsets into a hw_info structure. Future SoCs
will provide their own structure describing the applicable offsets.
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
[maz: split from original patch to only address T8103]
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 89 +++++++++++++++++++++++------
1 file changed, 72 insertions(+), 17 deletions(-)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 505adf64bd66d..847cba753d28d 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -18,6 +18,7 @@
* Author: Marc Zyngier <maz@kernel.org>
*/
+#include <linux/bitfield.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/iopoll.h>
@@ -29,6 +30,7 @@
#include <linux/of_irq.h>
#include <linux/pci-ecam.h>
+/* T8103 (original M1) and related SoCs */
#define CORE_RC_PHYIF_CTL 0x00024
#define CORE_RC_PHYIF_CTL_RUN BIT(0)
#define CORE_RC_PHYIF_STAT 0x00028
@@ -104,7 +106,7 @@
#define PORT_REFCLK_CGDIS BIT(8)
#define PORT_PERST 0x00814
#define PORT_PERST_OFF BIT(0)
-#define PORT_RID2SID(i16) (0x00828 + 4 * (i16))
+#define PORT_RID2SID 0x00828
#define PORT_RID2SID_VALID BIT(31)
#define PORT_RID2SID_SID_SHIFT 16
#define PORT_RID2SID_BUS_SHIFT 8
@@ -122,7 +124,8 @@
#define PORT_TUNSTAT_PERST_ACK_PEND BIT(1)
#define PORT_PREFMEM_ENABLE 0x00994
-#define MAX_RID2SID 64
+#define PORT_MSIMAP_ENABLE BIT(31)
+#define PORT_MSIMAP_TARGET GENMASK(7, 0)
/*
* The doorbell address is set to 0xfffff000, which by convention
@@ -133,10 +136,33 @@
*/
#define DOORBELL_ADDR CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
+struct hw_info {
+ u32 phy_lane_ctl;
+ u32 port_msiaddr;
+ u32 port_msiaddr_hi;
+ u32 port_refclk;
+ u32 port_perst;
+ u32 port_rid2sid;
+ u32 port_msimap;
+ u32 max_rid2sid;
+};
+
+static const struct hw_info t8103_hw = {
+ .phy_lane_ctl = PHY_LANE_CTL,
+ .port_msiaddr = PORT_MSIADDR,
+ .port_msiaddr_hi = 0,
+ .port_refclk = PORT_REFCLK,
+ .port_perst = PORT_PERST,
+ .port_rid2sid = PORT_RID2SID,
+ .port_msimap = 0,
+ .max_rid2sid = 64,
+};
+
struct apple_pcie {
struct mutex lock;
struct device *dev;
void __iomem *base;
+ const struct hw_info *hw;
struct irq_domain *domain;
unsigned long *bitmap;
struct list_head ports;
@@ -380,7 +406,9 @@ static void apple_port_irq_handler(struct irq_desc *desc)
static int apple_pcie_port_setup_irq(struct apple_pcie_port *port)
{
struct fwnode_handle *fwnode = &port->np->fwnode;
+ struct apple_pcie *pcie = port->pcie;
unsigned int irq;
+ u32 val = 0;
/* FIXME: consider moving each interrupt under each port */
irq = irq_of_parse_and_map(to_of_node(dev_fwnode(port->pcie->dev)),
@@ -402,13 +430,23 @@ static int apple_pcie_port_setup_irq(struct apple_pcie_port *port)
/* Configure MSI base address */
BUILD_BUG_ON(upper_32_bits(DOORBELL_ADDR));
- writel_relaxed(lower_32_bits(DOORBELL_ADDR), port->base + PORT_MSIADDR);
+ writel_relaxed(lower_32_bits(DOORBELL_ADDR),
+ port->base + pcie->hw->port_msiaddr);
+ if (pcie->hw->port_msiaddr_hi)
+ writel_relaxed(0, port->base + pcie->hw->port_msiaddr_hi);
/* Enable MSIs, shared between all ports */
- writel_relaxed(0, port->base + PORT_MSIBASE);
- writel_relaxed((ilog2(port->pcie->nvecs) << PORT_MSICFG_L2MSINUM_SHIFT) |
- PORT_MSICFG_EN, port->base + PORT_MSICFG);
+ if (pcie->hw->port_msimap) {
+ for (int i = 0; i < pcie->nvecs; i++)
+ writel_relaxed(FIELD_PREP(PORT_MSIMAP_TARGET, i) |
+ PORT_MSIMAP_ENABLE,
+ port->base + pcie->hw->port_msimap + 4 * i);
+ } else {
+ writel_relaxed(0, port->base + PORT_MSIBASE);
+ val = ilog2(pcie->nvecs) << PORT_MSICFG_L2MSINUM_SHIFT;
+ }
+ writel_relaxed(val | PORT_MSICFG_EN, port->base + PORT_MSICFG);
return 0;
}
@@ -475,7 +513,9 @@ static int apple_pcie_setup_refclk(struct apple_pcie *pcie,
u32 stat;
int res;
- rmw_set(PHY_LANE_CTL_CFGACC, port->phy + PHY_LANE_CTL);
+ if (pcie->hw->phy_lane_ctl)
+ rmw_set(PHY_LANE_CTL_CFGACC, port->phy + pcie->hw->phy_lane_ctl);
+
rmw_set(PHY_LANE_CFG_REFCLK0REQ, port->phy + PHY_LANE_CFG);
res = readl_relaxed_poll_timeout(port->phy + PHY_LANE_CFG,
@@ -492,20 +532,28 @@ static int apple_pcie_setup_refclk(struct apple_pcie *pcie,
if (res < 0)
return res;
- rmw_clear(PHY_LANE_CTL_CFGACC, port->phy + PHY_LANE_CTL);
+ if (pcie->hw->phy_lane_ctl)
+ rmw_clear(PHY_LANE_CTL_CFGACC, port->phy + pcie->hw->phy_lane_ctl);
rmw_set(PHY_LANE_CFG_REFCLKEN, port->phy + PHY_LANE_CFG);
- rmw_set(PORT_REFCLK_EN, port->base + PORT_REFCLK);
+
+ if (pcie->hw->port_refclk)
+ rmw_set(PORT_REFCLK_EN, port->base + pcie->hw->port_refclk);
return 0;
}
+static void __iomem *port_rid2sid_addr(struct apple_pcie_port *port, int idx)
+{
+ return port->base + port->pcie->hw->port_rid2sid + 4 * idx;
+}
+
static u32 apple_pcie_rid2sid_write(struct apple_pcie_port *port,
int idx, u32 val)
{
- writel_relaxed(val, port->base + PORT_RID2SID(idx));
+ writel_relaxed(val, port_rid2sid_addr(port, idx));
/* Read back to ensure completion of the write */
- return readl_relaxed(port->base + PORT_RID2SID(idx));
+ return readl_relaxed(port_rid2sid_addr(port, idx));
}
static int apple_pcie_setup_port(struct apple_pcie *pcie,
@@ -528,7 +576,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
if (!port)
return -ENOMEM;
- port->sid_map = devm_bitmap_zalloc(pcie->dev, MAX_RID2SID, GFP_KERNEL);
+ port->sid_map = devm_bitmap_zalloc(pcie->dev, pcie->hw->max_rid2sid, GFP_KERNEL);
if (!port->sid_map)
return -ENOMEM;
@@ -572,7 +620,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
usleep_range(100, 200);
/* Deassert PERST# */
- rmw_set(PORT_PERST_OFF, port->base + PORT_PERST);
+ rmw_set(PORT_PERST_OFF, port->base + pcie->hw->port_perst);
gpiod_set_value_cansleep(reset, 0);
/* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
@@ -585,7 +633,11 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
return ret;
}
- rmw_clear(PORT_REFCLK_CGDIS, port->base + PORT_REFCLK);
+ if (pcie->hw->port_refclk)
+ rmw_clear(PORT_REFCLK_CGDIS, port->base + pcie->hw->port_refclk);
+ else
+ rmw_set(PHY_LANE_CFG_REFCLKCGEN, port->phy + PHY_LANE_CFG);
+
rmw_clear(PORT_APPCLK_CGDIS, port->base + PORT_APPCLK);
ret = apple_pcie_port_setup_irq(port);
@@ -593,7 +645,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
return ret;
/* Reset all RID/SID mappings, and check for RAZ/WI registers */
- for (i = 0; i < MAX_RID2SID; i++) {
+ for (i = 0; i < pcie->hw->max_rid2sid; i++) {
if (apple_pcie_rid2sid_write(port, i, 0xbad1d) != 0xbad1d)
break;
apple_pcie_rid2sid_write(port, i, 0);
@@ -741,7 +793,7 @@ static void apple_pcie_disable_device(struct pci_host_bridge *bridge, struct pci
for_each_set_bit(idx, port->sid_map, port->sid_map_sz) {
u32 val;
- val = readl_relaxed(port->base + PORT_RID2SID(idx));
+ val = readl_relaxed(port_rid2sid_addr(port, idx));
if ((val & 0xffff) == rid) {
apple_pcie_rid2sid_write(port, idx, 0);
bitmap_release_region(port->sid_map, idx, 0);
@@ -794,6 +846,9 @@ static int apple_pcie_probe(struct platform_device *pdev)
return -ENOMEM;
pcie->dev = dev;
+ pcie->hw = of_device_get_match_data(dev);
+ if (!pcie->hw)
+ return -ENODEV;
pcie->base = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(pcie->base))
return PTR_ERR(pcie->base);
@@ -810,7 +865,7 @@ static int apple_pcie_probe(struct platform_device *pdev)
}
static const struct of_device_id apple_pcie_of_match[] = {
- { .compatible = "apple,pcie" },
+ { .compatible = "apple,pcie", .data = &t8103_hw },
{ }
};
MODULE_DEVICE_TABLE(of, apple_pcie_of_match);
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 13/13] PCI: apple: Add T602x PCIe support
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (11 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 12/13] PCI: apple: Abstract register offsets via a SoC-specific structure Marc Zyngier
@ 2025-03-25 10:26 ` Marc Zyngier
2025-03-25 13:31 ` [PATCH v2 00/13] PCI: apple: Add support for t6020 Rob Herring
` (2 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-03-25 10:26 UTC (permalink / raw)
To: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi
Cc: Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
From: Hector Martin <marcan@marcan.st>
This version of the hardware moved around a bunch of registers, so we
avoid the old compatible for these and introduce register offset
structures to handle the differences.
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/pci/controller/pcie-apple.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 847cba753d28d..5b85d9497070c 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -124,6 +124,13 @@
#define PORT_TUNSTAT_PERST_ACK_PEND BIT(1)
#define PORT_PREFMEM_ENABLE 0x00994
+/* T602x (M2-pro and co) */
+#define PORT_T602X_MSIADDR 0x016c
+#define PORT_T602X_MSIADDR_HI 0x0170
+#define PORT_T602X_PERST 0x082c
+#define PORT_T602X_RID2SID 0x3000
+#define PORT_T602X_MSIMAP 0x3800
+
#define PORT_MSIMAP_ENABLE BIT(31)
#define PORT_MSIMAP_TARGET GENMASK(7, 0)
@@ -158,6 +165,18 @@ static const struct hw_info t8103_hw = {
.max_rid2sid = 64,
};
+static const struct hw_info t602x_hw = {
+ .phy_lane_ctl = 0,
+ .port_msiaddr = PORT_T602X_MSIADDR,
+ .port_msiaddr_hi = PORT_T602X_MSIADDR_HI,
+ .port_refclk = 0,
+ .port_perst = PORT_T602X_PERST,
+ .port_rid2sid = PORT_T602X_RID2SID,
+ .port_msimap = PORT_T602X_MSIMAP,
+ /* 16 on t602x, guess for autodetect on future HW */
+ .max_rid2sid = 512,
+};
+
struct apple_pcie {
struct mutex lock;
struct device *dev;
@@ -425,6 +444,7 @@ static int apple_pcie_port_setup_irq(struct apple_pcie_port *port)
/* Disable all interrupts */
writel_relaxed(~0, port->base + PORT_INTMSK);
writel_relaxed(~0, port->base + PORT_INTSTAT);
+ writel_relaxed(~0, port->base + PORT_LINKCMDSTS);
irq_set_chained_handler_and_data(irq, apple_port_irq_handler, port);
@@ -865,6 +885,7 @@ static int apple_pcie_probe(struct platform_device *pdev)
}
static const struct of_device_id apple_pcie_of_match[] = {
+ { .compatible = "apple,t6020-pcie", .data = &t602x_hw },
{ .compatible = "apple,pcie", .data = &t8103_hw },
{ }
};
--
2.39.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v2 00/13] PCI: apple: Add support for t6020
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (12 preceding siblings ...)
2025-03-25 10:26 ` [PATCH v2 13/13] PCI: apple: Add T602x PCIe support Marc Zyngier
@ 2025-03-25 13:31 ` Rob Herring
2025-03-25 14:50 ` Alyssa Rosenzweig
2025-03-31 11:28 ` Janne Grunau
15 siblings, 0 replies; 23+ messages in thread
From: Rob Herring @ 2025-03-25 13:31 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi,
Alyssa Rosenzweig, Janne Grunau, Hector Martin, Sven Peter,
Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Krzysztof Kozlowski
On Tue, Mar 25, 2025 at 10:25:57AM +0000, Marc Zyngier wrote:
> As Alyssa didn't have the bandwidth to deal with this series, I have
> taken it over. All bugs are therefore mine.
>
> The initial series [1] stated:
>
> "This series adds T6020 support to the Apple PCIe controller. Mostly
> Apple shuffled registers around (presumably to accommodate the larger
> configurations on those machines). So there's a bit of churn here but
> not too much in the way of functional changes."
>
> The biggest change is affecting the ECAM layer, allowing an ECAM
> driver to provide its own probe function instead of relying on the
> .init() callback to do the work. The ECAM layer can therefore be used
> as a library instead of a convoluted driver.
>
> The rest is a mix of bug fixes, cleanups, and required abstraction.
>
> This has been tested on T6020 (M2-Pro mini) and T8102 (M1 mini).
>
> * From v1[1]:
>
> - Described the PHY registers in the DT binding
>
> - Extracted a ecam bridge creation helper from the host-common layer
>
> - Moved probing into its own function instead of pci_host_common_probe()
>
> - Moved host-specific data to the of_device_id[] table
>
> - Added dynamic allocation of the RID/SID bitmap
>
> - Fixed latent bug in RC-generated interrupts
>
> - Renamed reg_info to hw_info
>
> - Dropped useless max_msimap
>
> - Dropped code being moved around without justification
>
> - Re-split some of the patches to follow a more logical progression
>
> - General cleanup to fit my own taste
>
> [1] https://lore.kernel.org/r/20250211-pcie-t6-v1-0-b60e6d2501bb@rosenzweig.io
>
> Alyssa Rosenzweig (1):
> dt-bindings: pci: apple,pcie: Add t6020 compatible string
>
> Hector Martin (6):
> PCI: apple: Fix missing OF node reference in apple_pcie_setup_port
> PCI: apple: Move port PHY registers to their own reg items
> PCI: apple: Drop poll for CORE_RC_PHYIF_STAT_REFCLK
> PCI: apple: Use gpiod_set_value_cansleep in probe flow
> PCI: apple: Abstract register offsets via a SoC-specific structure
> PCI: apple: Add T602x PCIe support
>
> Janne Grunau (1):
> PCI: apple: Set only available ports up
>
> Marc Zyngier (5):
> PCI: host-generic: Extract an ecam bridge creation helper from
> pci_host_common_probe()
> PCI: ecam: Allow cfg->priv to be pre-populated from the root port
> device
> PCI: apple: Move over to standalone probing
> PCI: apple: Dynamically allocate RID-to_SID bitmap
> PCI: apple: Move away from INTMSK{SET,CLR} for INTx and private
> interrupts
>
> .../devicetree/bindings/pci/apple,pcie.yaml | 11 +-
> drivers/pci/controller/pci-host-common.c | 24 +-
> drivers/pci/controller/pcie-apple.c | 241 +++++++++++++-----
> drivers/pci/ecam.c | 2 +
> include/linux/pci-ecam.h | 2 +
> 5 files changed, 204 insertions(+), 76 deletions(-)
For the series,
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v2 00/13] PCI: apple: Add support for t6020
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (13 preceding siblings ...)
2025-03-25 13:31 ` [PATCH v2 00/13] PCI: apple: Add support for t6020 Rob Herring
@ 2025-03-25 14:50 ` Alyssa Rosenzweig
2025-03-31 11:28 ` Janne Grunau
15 siblings, 0 replies; 23+ messages in thread
From: Alyssa Rosenzweig @ 2025-03-25 14:50 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi,
Janne Grunau, Hector Martin, Sven Peter, Bjorn Helgaas,
Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Thanks maz!
Everything here looks good to me aside from the dt-bindings that I
screwed up (sorry!). But I didn't do a thorough review.
Le Tue , Mar 25, 2025 at 10:25:57AM +0000, Marc Zyngier a écrit :
> As Alyssa didn't have the bandwidth to deal with this series, I have
> taken it over. All bugs are therefore mine.
>
> The initial series [1] stated:
>
> "This series adds T6020 support to the Apple PCIe controller. Mostly
> Apple shuffled registers around (presumably to accommodate the larger
> configurations on those machines). So there's a bit of churn here but
> not too much in the way of functional changes."
>
> The biggest change is affecting the ECAM layer, allowing an ECAM
> driver to provide its own probe function instead of relying on the
> .init() callback to do the work. The ECAM layer can therefore be used
> as a library instead of a convoluted driver.
>
> The rest is a mix of bug fixes, cleanups, and required abstraction.
>
> This has been tested on T6020 (M2-Pro mini) and T8102 (M1 mini).
>
> * From v1[1]:
>
> - Described the PHY registers in the DT binding
>
> - Extracted a ecam bridge creation helper from the host-common layer
>
> - Moved probing into its own function instead of pci_host_common_probe()
>
> - Moved host-specific data to the of_device_id[] table
>
> - Added dynamic allocation of the RID/SID bitmap
>
> - Fixed latent bug in RC-generated interrupts
>
> - Renamed reg_info to hw_info
>
> - Dropped useless max_msimap
>
> - Dropped code being moved around without justification
>
> - Re-split some of the patches to follow a more logical progression
>
> - General cleanup to fit my own taste
>
> [1] https://lore.kernel.org/r/20250211-pcie-t6-v1-0-b60e6d2501bb@rosenzweig.io
>
> Alyssa Rosenzweig (1):
> dt-bindings: pci: apple,pcie: Add t6020 compatible string
>
> Hector Martin (6):
> PCI: apple: Fix missing OF node reference in apple_pcie_setup_port
> PCI: apple: Move port PHY registers to their own reg items
> PCI: apple: Drop poll for CORE_RC_PHYIF_STAT_REFCLK
> PCI: apple: Use gpiod_set_value_cansleep in probe flow
> PCI: apple: Abstract register offsets via a SoC-specific structure
> PCI: apple: Add T602x PCIe support
>
> Janne Grunau (1):
> PCI: apple: Set only available ports up
>
> Marc Zyngier (5):
> PCI: host-generic: Extract an ecam bridge creation helper from
> pci_host_common_probe()
> PCI: ecam: Allow cfg->priv to be pre-populated from the root port
> device
> PCI: apple: Move over to standalone probing
> PCI: apple: Dynamically allocate RID-to_SID bitmap
> PCI: apple: Move away from INTMSK{SET,CLR} for INTx and private
> interrupts
>
> .../devicetree/bindings/pci/apple,pcie.yaml | 11 +-
> drivers/pci/controller/pci-host-common.c | 24 +-
> drivers/pci/controller/pcie-apple.c | 241 +++++++++++++-----
> drivers/pci/ecam.c | 2 +
> include/linux/pci-ecam.h | 2 +
> 5 files changed, 204 insertions(+), 76 deletions(-)
>
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v2 00/13] PCI: apple: Add support for t6020
2025-03-25 10:25 [PATCH v2 00/13] PCI: apple: Add support for t6020 Marc Zyngier
` (14 preceding siblings ...)
2025-03-25 14:50 ` Alyssa Rosenzweig
@ 2025-03-31 11:28 ` Janne Grunau
15 siblings, 0 replies; 23+ messages in thread
From: Janne Grunau @ 2025-03-31 11:28 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-arm-kernel, linux-pci, devicetree, linux-kernel, asahi,
Alyssa Rosenzweig, Hector Martin, Sven Peter, Bjorn Helgaas,
Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski
On Tue, Mar 25, 2025 at 10:25:57AM +0000, Marc Zyngier wrote:
> As Alyssa didn't have the bandwidth to deal with this series, I have
> taken it over. All bugs are therefore mine.
>
> The initial series [1] stated:
>
> "This series adds T6020 support to the Apple PCIe controller. Mostly
> Apple shuffled registers around (presumably to accommodate the larger
> configurations on those machines). So there's a bit of churn here but
> not too much in the way of functional changes."
>
> The biggest change is affecting the ECAM layer, allowing an ECAM
> driver to provide its own probe function instead of relying on the
> .init() callback to do the work. The ECAM layer can therefore be used
> as a library instead of a convoluted driver.
>
> The rest is a mix of bug fixes, cleanups, and required abstraction.
>
> This has been tested on T6020 (M2-Pro mini) and T8102 (M1 mini).
>
> * From v1[1]:
>
> - Described the PHY registers in the DT binding
>
> - Extracted a ecam bridge creation helper from the host-common layer
>
> - Moved probing into its own function instead of pci_host_common_probe()
>
> - Moved host-specific data to the of_device_id[] table
>
> - Added dynamic allocation of the RID/SID bitmap
>
> - Fixed latent bug in RC-generated interrupts
>
> - Renamed reg_info to hw_info
>
> - Dropped useless max_msimap
>
> - Dropped code being moved around without justification
>
> - Re-split some of the patches to follow a more logical progression
>
> - General cleanup to fit my own taste
>
> [1] https://lore.kernel.org/r/20250211-pcie-t6-v1-0-b60e6d2501bb@rosenzweig.io
>
> Alyssa Rosenzweig (1):
> dt-bindings: pci: apple,pcie: Add t6020 compatible string
>
> Hector Martin (6):
> PCI: apple: Fix missing OF node reference in apple_pcie_setup_port
> PCI: apple: Move port PHY registers to their own reg items
> PCI: apple: Drop poll for CORE_RC_PHYIF_STAT_REFCLK
> PCI: apple: Use gpiod_set_value_cansleep in probe flow
> PCI: apple: Abstract register offsets via a SoC-specific structure
> PCI: apple: Add T602x PCIe support
>
> Janne Grunau (1):
> PCI: apple: Set only available ports up
>
> Marc Zyngier (5):
> PCI: host-generic: Extract an ecam bridge creation helper from
> pci_host_common_probe()
> PCI: ecam: Allow cfg->priv to be pre-populated from the root port
> device
> PCI: apple: Move over to standalone probing
> PCI: apple: Dynamically allocate RID-to_SID bitmap
> PCI: apple: Move away from INTMSK{SET,CLR} for INTx and private
> interrupts
>
> .../devicetree/bindings/pci/apple,pcie.yaml | 11 +-
> drivers/pci/controller/pci-host-common.c | 24 +-
> drivers/pci/controller/pcie-apple.c | 241 +++++++++++++-----
> drivers/pci/ecam.c | 2 +
> include/linux/pci-ecam.h | 2 +
> 5 files changed, 204 insertions(+), 76 deletions(-)
Whole series is
Tested-by: Janne Grunau <j@jannau.net>
on t6020 and t8103 based Apple silicon devices.
ciao
Janne
^ permalink raw reply [flat|nested] 23+ messages in thread