[PATCH] arm64: dts: rockchip: Add CD GPIO to Orange Pi 5/5B/5Pro

Alexey Charkov alchark at flipper.net
Tue Dec 1 03:32:37 PST 2026


On Thu, Nov 26, 2026 at 1:56 PM Quentin Schulz <quentin.schulz at cherry.de> wrote:
>
> Hi Dang,
>
> On 11/21/26 8:03 AM, Dang Huynh wrote:
> > CD GPIO is currently not defined in Orange Pi 5, this breaks
> > SD card hotplugging.
>
> That's not the issue. The issue is that the card detect signal is muxed
> in the SDMMC_DET function (c.f. sdmmc_det in rk3588-base.dtsi) and that
> relies on the SDMMC controller being powered on to detect such an event.
> This cannot work when the controller is in runtime suspend, so we have a
> chicken and the egg problem. The card detect should resume the
> controller, but it can only work when the controller is running. Hence
> why we now go for the gpio function (via cd-gpios) instead. See
> c7a9549ce46e ("arm64: dts: rockchip: Switch microSD card detect to gpio
> on Radxa ROCK 5 ITX/5C") for an example.> > The SDMMC_DET_L pin is
> connected to GPIO0_A4 on both OPi 5[0],

FWIW, I've done some testing on RK3576, which I believe uses the same
IP block for the SDMMC controller. Long story short:

- Native card detection via the controller itself works only as long
as the PD_SDGMAC power domain is on (on RK3576 either of the two GMACs
keep it on, so it only can go off if both of them are disabled and the
SDMMC controller is runtime suspended)
- To have the controller enumerate the card after detection, I needed
to add `card-detect-delay` of 200ms, in line with what cd-gpios does
on Linux. Without it the detection bit is latched but the card doesn't
show up in the system
- If the power domain is off, the controller doesn't get CD events,
and after PD_SDGMAC is powered back on its INTMASK, CTRL and PWEN come
back as all zeros
- The TRM specifies another card detection mechanism ("method 3") via
the always-on PMU1_GRF (SD_DETECT_CON/STS/CLR/CNT at 0x26026110–0x11c,
IRQ 282 irq_sdmmc_detectn_grf), and it latches just fine when the
controller is suspended with its power domain off. But frankly I don't
see any benefit in using this method over cd-gpios, given that at
least on RK3576 the pin in question is part of the GPIO0 domain, which
is always-on just as well.

So cd-gpios with matching pinctrl sounds like the right way to go for
all boards.

Best regards,
Alexey



More information about the Linux-rockchip mailing list