Lines Matching +full:stm32f469 +full:- +full:qspi
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Inspired by clk-asm9260.c .
8 #include <linux/clk-provider.h>
25 #include <dt-bindings/clock/stm32fx-clock.h>
42 #define NONE -1
168 { STM32F4_RCC_AHB3ENR, 1, "qspi", "ahb_div",
250 { STM32F4_RCC_AHB3ENR, 1, "qspi", "ahb_div",
326 { STM32F4_RCC_AHB3ENR, 1, "qspi", "ahb_div",
407 * The APBx dividers are power-of-two dividers and, if *not* running in 1:1
424 if (readl(base + STM32F4_RCC_CFGR) & BIT(am->bit_idx)) in clk_apb_mul_recalc_rate()
436 if (readl(base + STM32F4_RCC_CFGR) & BIT(am->bit_idx)) in clk_apb_mul_round_rate()
476 return ERR_PTR(-ENOMEM); in clk_register_apb_mul()
478 am->bit_idx = bit_idx; in clk_register_apb_mul()
479 am->hw.init = &init; in clk_register_apb_mul()
487 clk = clk_register(dev, &am->hw); in clk_register_apb_mul()
549 { "vco-i2s", STM32F4_RCC_PLLI2SCFGR, 26, 27 },
550 { "vco-sai", STM32F4_RCC_PLLSAICFGR, 28, 29 },
560 { CLK_I2SQ_PDIV, PLL_I2S, "plli2s-q-div", "plli2s-q",
563 { CLK_SAIQ_PDIV, PLL_SAI, "pllsai-q-div", "pllsai-q",
566 { NO_IDX, PLL_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT,
592 { PLL_I2S, 192, { NULL, "plli2s-q", "plli2s-r" } },
593 { PLL_SAI, 49, { NULL, "pllsai-q", "pllsai-r" } },
597 { PLL, 50, { "pll", "pll-q", "pll-r" } },
598 { PLL_I2S, 50, { "plli2s-p", "plli2s-q", "plli2s-r" } },
599 { PLL_SAI, 50, { "pllsai-p", "pllsai-q", "pllsai-r" } },
622 bit_status = !(readl(gate->reg) & BIT(pll->bit_rdy_idx)); in stm32f4_pll_enable()
624 } while (bit_status && --timeout); in stm32f4_pll_enable()
641 n = (readl(base + pll->offset) >> 6) & 0x1ff; in stm32f4_pll_recalc()
655 if (n < pll->n_start) in stm32f4_pll_round_rate()
656 n = pll->n_start; in stm32f4_pll_round_rate()
680 val = readl(base + pll->offset) & ~(0x1ff << 6); in stm32f4_pll_set_rate()
682 writel(val | ((n & 0x1ff) << 6), base + pll->offset); in stm32f4_pll_set_rate()
726 pll_state = stm32f4_pll_is_enabled(pll_div->hw_pll); in stm32f4_pll_div_set_rate()
729 stm32f4_pll_disable(pll_div->hw_pll); in stm32f4_pll_div_set_rate()
734 stm32f4_pll_enable(pll_div->hw_pll); in stm32f4_pll_div_set_rate()
759 return ERR_PTR(-ENOMEM); in clk_register_pll_div()
768 pll_div->div.reg = reg; in clk_register_pll_div()
769 pll_div->div.shift = shift; in clk_register_pll_div()
770 pll_div->div.width = width; in clk_register_pll_div()
771 pll_div->div.flags = clk_divider_flags; in clk_register_pll_div()
772 pll_div->div.lock = lock; in clk_register_pll_div()
773 pll_div->div.table = table; in clk_register_pll_div()
774 pll_div->div.hw.init = &init; in clk_register_pll_div()
776 pll_div->hw_pll = pll_hw; in clk_register_pll_div()
779 hw = &pll_div->div.hw; in clk_register_pll_div()
803 return ERR_PTR(-ENOMEM); in stm32f4_rcc_register_pll()
805 vco = &vco_data[data->pll_num]; in stm32f4_rcc_register_pll()
807 init.name = vco->vco_name; in stm32f4_rcc_register_pll()
813 pll->gate.lock = lock; in stm32f4_rcc_register_pll()
814 pll->gate.reg = base + STM32F4_RCC_CR; in stm32f4_rcc_register_pll()
815 pll->gate.bit_idx = vco->bit_idx; in stm32f4_rcc_register_pll()
816 pll->gate.hw.init = &init; in stm32f4_rcc_register_pll()
818 pll->offset = vco->offset; in stm32f4_rcc_register_pll()
819 pll->n_start = data->n_start; in stm32f4_rcc_register_pll()
820 pll->bit_rdy_idx = vco->bit_rdy_idx; in stm32f4_rcc_register_pll()
821 pll->status = (readl(base + STM32F4_RCC_CR) >> vco->bit_idx) & 0x1; in stm32f4_rcc_register_pll()
823 reg = base + pll->offset; in stm32f4_rcc_register_pll()
825 pll_hw = &pll->gate.hw; in stm32f4_rcc_register_pll()
833 if (data->div_name[i]) in stm32f4_rcc_register_pll()
834 clk_register_pll_div(data->div_name[i], in stm32f4_rcc_register_pll()
835 vco->vco_name, in stm32f4_rcc_register_pll()
857 return -EINVAL; in stm32f4_rcc_lookup_clk_idx()
867 return -EINVAL; in stm32f4_rcc_lookup_clk_idx()
873 return stm32fx_end_primary_clk - 1 + hweight64(table[0]) + in stm32f4_rcc_lookup_clk_idx()
881 int i = stm32f4_rcc_lookup_clk_idx(clkspec->args[0], clkspec->args[1]); in stm32f4_rcc_lookup_clk()
884 return ERR_PTR(-EINVAL); in stm32f4_rcc_lookup_clk()
934 bit_status = !(readl(gate->reg) & BIT(rgate->bit_rdy_idx)); in rgclk_enable()
938 } while (bit_status && --timeout); in rgclk_enable()
973 return ERR_PTR(-ENOMEM); in clk_register_rgate()
981 rgate->bit_rdy_idx = bit_rdy_idx; in clk_register_rgate()
983 rgate->gate.lock = lock; in clk_register_rgate()
984 rgate->gate.reg = reg; in clk_register_rgate()
985 rgate->gate.bit_idx = bit_idx; in clk_register_rgate()
986 rgate->gate.hw.init = &init; in clk_register_rgate()
988 hw = &rgate->gate.hw; in clk_register_rgate()
1067 hw = ERR_PTR(-EINVAL); in stm32_register_cclk()
1074 hw = ERR_PTR(-EINVAL); in stm32_register_cclk()
1078 gate->reg = reg; in stm32_register_cclk()
1079 gate->bit_idx = bit_idx; in stm32_register_cclk()
1080 gate->flags = 0; in stm32_register_cclk()
1081 gate->lock = lock; in stm32_register_cclk()
1083 mux->reg = reg; in stm32_register_cclk()
1084 mux->shift = shift; in stm32_register_cclk()
1085 mux->mask = 3; in stm32_register_cclk()
1086 mux->flags = 0; in stm32_register_cclk()
1089 &mux->hw, &cclk_mux_ops, in stm32_register_cclk()
1091 &gate->hw, &cclk_gate_ops, in stm32_register_cclk()
1120 "no-clock", "lse", "lsi", "hse-rtc"
1123 static const char *pll_src = "pll-src";
1127 static const char *dsi_parent[2] = { NULL, "pll-r" };
1129 static const char *lcd_parent[1] = { "pllsai-r-div" };
1131 static const char *i2s_parents[2] = { "plli2s-r", NULL };
1133 static const char *sai_parents[4] = { "pllsai-q-div", "plli2s-q-div", NULL,
1134 "no-clock" };
1136 static const char *pll48_parents[2] = { "pll-q", "pllsai-p" };
1142 static const char *spdif_parent[1] = { "plli2s-p" };
1149 static const char *i2c_parents[4] = { "apb1_div", "sys", "hsi", "no-clock" };
1179 CLK_LCD, "lcd-tft", lcd_parent, ARRAY_SIZE(lcd_parent),
1191 CLK_SAI1, "sai1-a", sai_parents, ARRAY_SIZE(sai_parents),
1197 CLK_SAI2, "sai1-b", sai_parents, ARRAY_SIZE(sai_parents),
1206 CLK_LCD, "lcd-tft", lcd_parent, ARRAY_SIZE(lcd_parent),
1218 CLK_SAI1, "sai1-a", sai_parents, ARRAY_SIZE(sai_parents),
1224 CLK_SAI2, "sai1-b", sai_parents, ARRAY_SIZE(sai_parents),
1251 CLK_LCD, "lcd-tft", lcd_parent, ARRAY_SIZE(lcd_parent),
1287 CLK_HDMI_CEC, "hdmi-cec",
1294 CLK_SPDIF, "spdif-rx",
1397 CLK_LCD, "lcd-tft", lcd_parent, ARRAY_SIZE(lcd_parent),
1439 CLK_HDMI_CEC, "hdmi-cec",
1446 CLK_SPDIF, "spdif-rx",
1608 .compatible = "st,stm32f42xx-rcc",
1612 .compatible = "st,stm32f469-rcc",
1616 .compatible = "st,stm32f746-rcc",
1620 .compatible = "st,stm32f769-rcc",
1641 hw = ERR_PTR(-EINVAL); in stm32_register_aux_clk()
1645 gate->reg = base + offset_gate; in stm32_register_aux_clk()
1646 gate->bit_idx = bit_idx; in stm32_register_aux_clk()
1647 gate->flags = 0; in stm32_register_aux_clk()
1648 gate->lock = lock; in stm32_register_aux_clk()
1649 gate_hw = &gate->hw; in stm32_register_aux_clk()
1656 hw = ERR_PTR(-EINVAL); in stm32_register_aux_clk()
1660 mux->reg = base + offset_mux; in stm32_register_aux_clk()
1661 mux->shift = shift; in stm32_register_aux_clk()
1662 mux->mask = mask; in stm32_register_aux_clk()
1663 mux->flags = 0; in stm32_register_aux_clk()
1664 mux_hw = &mux->hw; in stm32_register_aux_clk()
1669 hw = ERR_PTR(-EINVAL); in stm32_register_aux_clk()
1713 data = match->data; in stm32f4_rcc_init()
1715 stm32fx_end_primary_clk = data->end_primary; in stm32f4_rcc_init()
1717 clks = kmalloc_array(data->gates_num + stm32fx_end_primary_clk, in stm32f4_rcc_init()
1722 stm32f4_gate_map = data->gates_map; in stm32f4_rcc_init()
1733 if (of_device_is_compatible(np, "st,stm32f769-rcc")) { in stm32f4_rcc_init()
1754 stm32f4_rcc_register_pll("vco_in", &data->pll_data[0], in stm32f4_rcc_init()
1758 &data->pll_data[1], &stm32f4_clk_lock); in stm32f4_rcc_init()
1761 &data->pll_data[2], &stm32f4_clk_lock); in stm32f4_rcc_init()
1769 hw = clk_register_pll_div(post_div->name, in stm32f4_rcc_init()
1770 post_div->parent, in stm32f4_rcc_init()
1771 post_div->flag, in stm32f4_rcc_init()
1772 base + post_div->offset, in stm32f4_rcc_init()
1773 post_div->shift, in stm32f4_rcc_init()
1774 post_div->width, in stm32f4_rcc_init()
1775 post_div->flag_div, in stm32f4_rcc_init()
1776 post_div->div_table, in stm32f4_rcc_init()
1777 clks[post_div->pll_num], in stm32f4_rcc_init()
1780 if (post_div->idx != NO_IDX) in stm32f4_rcc_init()
1781 clks[post_div->idx] = hw; in stm32f4_rcc_init()
1811 for (n = 0; n < data->gates_num; n++) { in stm32f4_rcc_init()
1816 gd = &data->gates_data[n]; in stm32f4_rcc_init()
1817 secondary = 8 * (gd->offset - STM32F4_RCC_AHB1ENR) + in stm32f4_rcc_init()
1818 gd->bit_idx; in stm32f4_rcc_init()
1825 NULL, gd->name, gd->parent_name, gd->flags, in stm32f4_rcc_init()
1826 base + gd->offset, gd->bit_idx, 0, &stm32f4_clk_lock); in stm32f4_rcc_init()
1830 np, gd->name); in stm32f4_rcc_init()
1835 clks[CLK_LSI] = clk_register_rgate(NULL, "lsi", "clk-lsi", 0, in stm32f4_rcc_init()
1843 clks[CLK_LSE] = clk_register_rgate(NULL, "lse", "clk-lse", 0, in stm32f4_rcc_init()
1851 clks[CLK_HSE_RTC] = clk_hw_register_divider(NULL, "hse-rtc", "clk-hse", in stm32f4_rcc_init()
1856 pr_err("Unable to register hse-rtc clock\n"); in stm32f4_rcc_init()
1868 for (n = 0; n < data->aux_clk_num; n++) { in stm32f4_rcc_init()
1872 aux_clk = &data->aux_clk[n]; in stm32f4_rcc_init()
1874 hw = stm32_register_aux_clk(aux_clk->name, in stm32f4_rcc_init()
1875 aux_clk->parent_names, aux_clk->num_parents, in stm32f4_rcc_init()
1876 aux_clk->offset_mux, aux_clk->shift, in stm32f4_rcc_init()
1877 aux_clk->mask, aux_clk->offset_gate, in stm32f4_rcc_init()
1878 aux_clk->bit_idx, aux_clk->flags, in stm32f4_rcc_init()
1882 pr_warn("Unable to register %s clk\n", aux_clk->name); in stm32f4_rcc_init()
1886 if (aux_clk->idx != NO_IDX) in stm32f4_rcc_init()
1887 clks[aux_clk->idx] = hw; in stm32f4_rcc_init()
1890 if (of_device_is_compatible(np, "st,stm32f746-rcc")) { in stm32f4_rcc_init()
1905 CLK_OF_DECLARE_DRIVER(stm32f42xx_rcc, "st,stm32f42xx-rcc", stm32f4_rcc_init);
1906 CLK_OF_DECLARE_DRIVER(stm32f46xx_rcc, "st,stm32f469-rcc", stm32f4_rcc_init);
1907 CLK_OF_DECLARE_DRIVER(stm32f746_rcc, "st,stm32f746-rcc", stm32f4_rcc_init);
1908 CLK_OF_DECLARE_DRIVER(stm32f769_rcc, "st,stm32f769-rcc", stm32f4_rcc_init);