summaryrefslogtreecommitdiffstats
path: root/drivers/clk/stm32/clk-stm32mp13.c
diff options
context:
space:
mode:
authorGabriel Fernandez <gabriel.fernandez@foss.st.com>2022-05-16 09:05:56 +0200
committerStephen Boyd <sboyd@kernel.org>2022-05-20 21:07:49 -0700
commitffa2d04d859e99d69d0c89d3dc50067022544354 (patch)
treef2a746bd38a4d4375154c6bbbca8f7d77bb53be9 /drivers/clk/stm32/clk-stm32mp13.c
parentbfad377983565358c8259e48693331b327535335 (diff)
downloadlinux-ffa2d04d859e99d69d0c89d3dc50067022544354.tar.gz
linux-ffa2d04d859e99d69d0c89d3dc50067022544354.tar.bz2
linux-ffa2d04d859e99d69d0c89d3dc50067022544354.zip
clk: stm32mp13: add multi mux function
Some RCC muxes can manages two output clocks with same register. Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com> Link: https://lore.kernel.org/r/20220516070600.7692-11-gabriel.fernandez@foss.st.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/stm32/clk-stm32mp13.c')
-rw-r--r--drivers/clk/stm32/clk-stm32mp13.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/clk/stm32/clk-stm32mp13.c b/drivers/clk/stm32/clk-stm32mp13.c
index 9edd32018f8f..08e3fe05d6d0 100644
--- a/drivers/clk/stm32/clk-stm32mp13.c
+++ b/drivers/clk/stm32/clk-stm32mp13.c
@@ -1469,6 +1469,35 @@ static int stm32mp13_clock_is_provided_by_secure(void __iomem *base,
return 0;
}
+struct multi_mux {
+ struct clk_hw *hw1;
+ struct clk_hw *hw2;
+};
+
+static struct multi_mux *stm32_mp13_multi_mux[MUX_NB] = {
+ [MUX_SPI23] = &(struct multi_mux){ &spi2_k.hw, &spi3_k.hw },
+ [MUX_I2C12] = &(struct multi_mux){ &i2c1_k.hw, &i2c2_k.hw },
+ [MUX_LPTIM45] = &(struct multi_mux){ &lptim4_k.hw, &lptim5_k.hw },
+ [MUX_UART35] = &(struct multi_mux){ &usart3_k.hw, &uart5_k.hw },
+ [MUX_UART78] = &(struct multi_mux){ &uart7_k.hw, &uart8_k.hw },
+ [MUX_SAI1] = &(struct multi_mux){ &sai1_k.hw, &adfsdm_k.hw },
+};
+
+static struct clk_hw *stm32mp13_is_multi_mux(struct clk_hw *hw)
+{
+ struct clk_stm32_composite *composite = to_clk_stm32_composite(hw);
+ struct multi_mux *mmux = stm32_mp13_multi_mux[composite->mux_id];
+
+ if (mmux) {
+ if (!(mmux->hw1 == hw))
+ return mmux->hw1;
+ else
+ return mmux->hw2;
+ }
+
+ return NULL;
+}
+
static u16 stm32mp13_cpt_gate[GATE_NB];
static struct clk_stm32_clock_data stm32mp13_clock_data = {
@@ -1476,6 +1505,7 @@ static struct clk_stm32_clock_data stm32mp13_clock_data = {
.gates = stm32mp13_gates,
.muxes = stm32mp13_muxes,
.dividers = stm32mp13_dividers,
+ .is_multi_mux = stm32mp13_is_multi_mux,
};
static const struct stm32_rcc_match_data stm32mp13_data = {