• Marek Vasut's avatar
    net: stmmac: dwmac-stm32: Separate out external clock selector · 63b0aa8e
    Marek Vasut authored
    Pull the external clock selector into a separate function, to avoid
    conflating it with external clock rate validation and clock mux
    register configuration. This should make the code easier to read and
    understand.
    
    The dwmac->enable_eth_ck variable in the end indicates whether the MAC
    clock are supplied by external oscillator (true) or internal RCC clock
    IP (false). The dwmac->enable_eth_ck value is set based on multiple DT
    properties, some of them deprecated, some of them specific to bus mode.
    
    The following DT properties and variables are taken into account. In
    each case, if the property is present or true, MAC clock is supplied
    by external oscillator.
    - "st,ext-phyclk", assigned to variable dwmac->ext_phyclk
      - Used in any mode (MII/RMII/GMII/RGMII)
      - The only non-deprecated DT property of the three
    - "st,eth-clk-sel", assigned to variable dwmac->eth_clk_sel_reg
      - Valid only in GMII/RGMII mode
      - Deprecated property, backward compatibility only
    - "st,eth-ref-clk-sel", assigned to variable dwmac->eth_ref_clk_sel_reg
      - Valid only in RMII mode
      - Deprecated property, backward compatibility only
    
    The stm32mp1_select_ethck_external() function handles the aforementioned
    DT properties and sets dwmac->enable_eth_ck accordingly.
    
    The stm32mp1_set_mode() is adjusted to call stm32mp1_select_ethck_external()
    first and then only use dwmac->enable_eth_ck to determine hardware clock mux
    settings.
    
    No functional change intended.
    Signed-off-by: default avatarMarek Vasut <marex@denx.de>
    Signed-off-by: default avatarChristophe Roullier <christophe.roullier@foss.st.com>
    Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    63b0aa8e
dwmac-stm32.c 15.5 KB