set_power() enabled the ext_clock on power-on and called clk_stop() on
power-off. This was wrong in three ways:
- clk_stop() is not the counterpart of clk_enable() (it KASSERTs enable_cnt == 0), so it panics once the clock has been enabled.
- set_power() is driven by the MMC power_mode IOS and is called repeatedly for the same state during probing and tuning, so the enable/disable refcount over- or underflows and panics.
- The ext_clock may be a shared PMIC output (e.g. rk808-clkout2 on the RockPro64, also feeding the companion Bluetooth controller), so gating it here disturbs the other consumers.
The external clock is a free-running low-power oscillator the device
needs for its whole lifetime, so enable it once at attach and leave it
running. Only act on real power-mode transitions in set_power() and
limit it to driving the reset line, which is what actually sequences the
device.
Tested on a RockPro64 (Broadcom BCM4359 SDIO Wi-Fi): the SDIO function
now enumerates and the module is reachable from userspace.
MFC after: 1 week