[PATCH v3 0/2] fix dw-mmc-rockchip rk356x clock rates

From: Peter Geis
Date: Sat Mar 05 2022 - 16:58:48 EST


cc: Jaehoon Chung <jh80.chung@xxxxxxxxxxx>
cc: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
cc: Heiko Stuebner <heiko@xxxxxxxxx>
cc: linux-mmc@xxxxxxxxxxxxxxx
cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
cc: linux-rockchip@xxxxxxxxxxxxxxxxxxx
cc: linux-kernel@xxxxxxxxxxxxxxx

While lighting off support for the SoQuartz module, it was discoved the
dw-mmc-rockchip driver has tremendous log spam when the cd-broken flag
is enabled and no card is inserted.
The SoQuart requires the cd-broken flag as the CM4 module pinout it
follows has no card-detect pin.
These errors occur during card initialization on all rk356x chips, but
are amplified by cd-broken as the function is called multiple times each
poll cycle.

It was discovered the lowest possible clock rate the rk356x cru can
provide for the ciu clock in the default configuration is 750khz. There
is an internal clock divider that makes the final minimum clock 375khz.
We could hardcode this, but it is possible it could change if the
default clock configuration changes.

To fix this, we must make two changes:
First, the dw-mmc core needs to be updated to allow a host driver to
save its requested minimum frequency. This is necessary as the mmc_host
struct isn't available when the host drivers initialization code is
called. The dw-mmc core can then apply the f_min later when the struct
is available.
Second, the dw-mmc-rockchip driver is extended to test the frequencies
mmc core will use during card initialization. It finds the lowest
supported frequency from the cru and saves it for later use by dw-mmc
core.


Changelog:
v3:
- add support in dw_mmc core for saving the minimum frequency (fixes
setting f_min)
- add test for the lowest supported frequency to avoid clamping configs
that don't have an error

v2:
- change from muting the error to attempting to fix the underlying issue
by setting f_min in driver initialization

Peter Geis (2):
mmc: host: dw_mmc: support setting f_min from host drivers
mmc: host: dw-mmc-rockchip: fix handling invalid clock rates

drivers/mmc/host/dw_mmc-rockchip.c | 27 +++++++++++++++++++++++----
drivers/mmc/host/dw_mmc.c | 7 ++++++-
drivers/mmc/host/dw_mmc.h | 2 ++
3 files changed, 31 insertions(+), 5 deletions(-)

--
2.25.1