• Quanyang Wang's avatar
    spi: spi-zynqmp-gqspi: fix clk_enable/disable imbalance issue · c6bdae08
    Quanyang Wang authored
    The clks "pclk" and "ref_clk" are enabled twice during the probe. The
    first time is in the function zynqmp_qspi_probe and the second time is
    in zynqmp_qspi_setup_op which is called by devm_spi_register_controller.
    Then calling zynqmp_qspi_remove (rmmod this module) to disable these clks
    will trigger a warning as below:
    
    [  309.124604] Unpreparing enabled qspi_ref
    [  309.128641] WARNING: CPU: 1 PID: 537 at drivers/clk/clk.c:824 clk_core_unprepare+0x108/0x110
    
    Since pm_runtime works now, clks can be enabled/disabled by calling
    zynqmp_runtime_suspend/resume. So we don't need to enable these clks
    explicitly in zynqmp_qspi_setup_op. Remove them to fix this issue.
    
    And remove clk enabling/disabling in zynqmp_qspi_resume because there is
    no spi transfer operation so enabling ref_clk is redundant meanwhile pclk
    is not disabled for it is shared with other peripherals.
    
    Furthermore replace clk_enable/disable with clk_prepare_enable and
    clk_disable_unprepare in runtime_suspend/resume functions.
    
    Fixes: 1c26372e ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework")
    Signed-off-by: default avatarQuanyang Wang <quanyang.wang@windriver.com>
    Link: https://lore.kernel.org/r/20210416004652.2975446-2-quanyang.wang@windriver.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    c6bdae08
spi-zynqmp-gqspi.c 36.7 KB