• Tudor Ambarus's avatar
    clk: samsung: gs101: propagate PERIC1 USI SPI clock rate · 7cf0324b
    Tudor Ambarus authored
    When SPI transfer is being prepared, the spi-s3c64xx driver will call
    clk_set_rate() to change the rate of SPI source clock (IPCLK). But IPCLK
    is a gate (leaf) clock, so it must propagate the rate change up the
    clock tree, so that corresponding MUX/DIV clocks can actually change
    their values. Add CLK_SET_RATE_PARENT flag to corresponding clocks for
    all USI instances in GS101 PERIC1: USI{0, 9, 10, 11, 12, 13}. This change
    involves the following clocks:
    
    PERIC1 USI*:
    
        Clock                              Div range    MUX Selection
        -------------------------------------------------------------------
        gout_peric1_peric1_top0_ipclk_*    -            -
        dout_peric1_usi*_usi               /1..16       -
        mout_peric1_usi*_usi_user          -            {24.5 MHz, 400 MHz}
    
    With input clock of 400 MHz this scheme provides the following IPCLK
    rate range, for each USI block:
    
        PERIC1 USI*:       1.5 MHz ... 400 MHz
    
    Accounting for internal /4 divider in SPI blocks, and because the max
    SPI frequency is limited at 50 MHz, it gives us next SPI SCK rates:
    
        PERIC1 USI_SPI*:   384 KHz ... 49.9 MHz
    
    Which shall be fine for the applications of the SPI bus.
    
    Note that with this we allow the reparenting of the MUX_USIx clocks to
    OSCCLK. Each instance of the USI IP has its own MUX_USI clock, thus the
    reparenting of a MUX_USI clock corresponds to a single instance of the
    USI IP. The datasheet mentions OSCCLK just in the low-power mode
    context, but the downstream driver reparents too the MUX_USI clocks to
    OSCCLK. Follow the downstream driver and do the same.
    
    Fixes: 2999e786
    
     ("clk: samsung: gs101: add support for cmu_peric1")
    Reviewed-by: default avatarPeter Griffin <peter.griffin@linaro.org>
    Acked-by: default avatarAndré Draszik <andre.draszik@linaro.org>
    Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
    Link: https://lore.kernel.org/r/20240419100915.2168573-3-tudor.ambarus@linaro.org
    
    Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    7cf0324b
clk-gs101.c 162 KB