linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] PCI: apple: PWREN GPIO support & related fixes
@ 2022-05-02  9:38 Hector Martin
  2022-05-02  9:38 ` [PATCH 1/3] PCI: apple: GPIO handling nitfixes Hector Martin
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Hector Martin @ 2022-05-02  9:38 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Hector Martin, Lorenzo Pieralisi, Rob Herring,
	Krzysztof Wilczyński, Bjorn Helgaas, Alyssa Rosenzweig,
	Sven Peter, linux-pci, linux-kernel

Hi all,

This short series adds support for the PWREN GPIO to the Apple PCIe
controller driver, and along the way fixes some GPIO handling issues
which cropped up.

Since the PWREN GPIO is provided by SMC which is a fairly high level
driver, PCI can probe before it is ready. Worse, only some devices
need PWREN, which can make the probe fail halfway through with some
ports initialized and not others, which the driver cannot recover
gracefully from. The second patch fixes this situation, so probe
deferral works properly in these cases. The third patch adds PWREN
support per se, and the first one is just related stuff I noticed
while writing this.

Hector Martin (3):
  PCI: apple: GPIO handling nitfixes
  PCI: apple: Probe all GPIOs for availability first
  PCI: apple: Add support for optional PWREN GPIO

 drivers/pci/controller/pcie-apple.c | 67 ++++++++++++++++++++++++++---
 1 file changed, 60 insertions(+), 7 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] PCI: apple: Add support for optional PWREN GPIO
@ 2022-05-02 20:59 Mark Kettenis
  0 siblings, 0 replies; 17+ messages in thread
From: Mark Kettenis @ 2022-05-02 20:59 UTC (permalink / raw)
  To: Rob Herring
  Cc: Marc Zyngier, Lorenzo Pieralisi, kw, Bjorn Helgaas,
	Alyssa Rosenzweig, Sven Peter, PCI, linux-kernel

Hi Rob (& Hector),

On 03/05/2022 00.14, Rob Herring wrote:
> On Mon, May 2, 2022 at 4:39 AM Hector Martin <marcan@marcan.st> wrote:
>>
>> WiFi and SD card devices on M1 Macs have a separate power enable GPIO.
>> Add support for this to the PCIe controller. This is modeled after how
>> pcie-fu740 does it.
> 
> It did, but it's not ideal really. The problem is the GPIO is really
> associated with the device (WiFi/SD) rather than the PCI host and
> therefore should be part of a WiFi or SD node. You probably don't have
> one (yet), but I would suspect that SD will need one for all the
> standard MMC/SD DT properties.

Not really.  The SD card controller is a "standard" GL9755 PCIe SDHC
controller that is already supported by Linux.

It does indeed get a DT node though because the card detect and write
protect signals are inverted and the driver needs to initialize some
PCIe config space registers to compensate for that.

> The secondary issue is we'll end up adding more power sequencing
> properties to control ordering and timing for different devices.

That isn't obvious.  Even though there isn't an actual PCIe slot these
still are PCIe compliant devices and therefore governed by the PCIe
standard power up sequencing.

> The exception here is standard PCI slot properties like perst#,
> clkreq, and standard voltage rails can go in the host bridge (and
> for new bindings, those should really be in the root port node). For
> a complicated example, see Hikey960 or 970.

I don't think there is a fundamental difference between having a GPIO
that controls the standard voltage rails of a PCIe slot (like on the
HiFive Unmatched board) and a GPIO that controls the power to a chip
soldered onto the motherboard (like the ASM2824 soldered onto the
HiFive Unmatched board and WiFi/SD on these Apple M1 systems).  I
don't think it makes sense to describe this in different ways just
because in one case there is a physical connector present.

Note that the proposed patch does add the "pwren-gpio" property on the
root port node as you suggest.

> Of course with power control related properties there's a chicken or
> egg issue that the PCI device is not discoverable until the device is
> powered on. This issue comes up over and over with various hacky
> solutions in the bindings. The PCI subsystem needs to solve this. My
> suggestion is that if the firmware says there is a device on the bus
> and it wasn't probed, then we should force probing (or add a pre-probe
> hook for drivers). That is what MDIO bus does for example.

But in the case of an actual PCIe slot firmware can't really describe
the PCIe device itself in the DT since it might not be there.

And your suggestion would be quite painful in other contexts where the
device tree will be used (U-Boot, *BSD), which all assume that a PCI
bus can be enumerated.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-05-05 15:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02  9:38 [PATCH 0/3] PCI: apple: PWREN GPIO support & related fixes Hector Martin
2022-05-02  9:38 ` [PATCH 1/3] PCI: apple: GPIO handling nitfixes Hector Martin
2022-05-02 10:20   ` Marc Zyngier
2022-05-02 12:16     ` Hector Martin
2022-05-02 11:39   ` Greg KH
2022-05-02  9:38 ` [PATCH 2/3] PCI: apple: Probe all GPIOs for availability first Hector Martin
2022-05-02 10:23   ` Marc Zyngier
2022-05-02  9:38 ` [PATCH 3/3] PCI: apple: Add support for optional PWREN GPIO Hector Martin
2022-05-02 10:31   ` Marc Zyngier
2022-05-02 12:15     ` Hector Martin
2022-05-02 15:14   ` Rob Herring
2022-05-02 15:32     ` Hector Martin
2022-05-03  3:20       ` Hector Martin
2022-05-04  0:33         ` Rob Herring
2022-05-04  3:36           ` Hector Martin
2022-05-05 15:38             ` Marc Zyngier
2022-05-02 20:59 Mark Kettenis

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).