clk: samsung: Introduce Exynos850 SoC clock driver
Subsystems (5)
Sam Protsenko
maintainerv2 cover clk: samsung: Introduce Exynos850 SoC clock driver
This patch series provides the implementation for Exynos850 clock driver, its documentation and corresponding changes for Samsung clock infrastructure (adds new PLL types used in Exynos850 SoC, following TRM).
I tried to follow already established design for Samsung clock drivers (getting most insights from Exynos5433 clock driver), and integrate the driver into existing infrastructure. The whole driver was implemented from scratch, using mostly TRM and downstream kernel for clock dependencies/hierarchy info.
For now only basic clocks are implemented, including next blocks:
- CMU_TOP
- CMU_PERI
- CMU_CORE
- CMU_HSI
- CMU_DPU
Some CMUs are still not implemented, but that can be added in future, when the need arises. The driver also lacks CLKOUT support, PM ops and automatic clocks control (using Q-Channel protocol). All that can be added independently later.
Implemented clock tree was tested via UART and MMC drivers, and using DebugFS clk support (e.g. using 'clk_summary' file). In order to keep all clocks running I added 'clk_ignore_unused' kernel param in my local tree, and defined CLOCK_ALLOW_WRITE_DEBUGFS in clk.c for actually testing the clocks via DebugFS.
Changes in v2:
- Added CMU_DPU implementation
- Moved bus clock enablement to clk-exynos850.c
- See also "v2 changes" list in each particular patch
Sam Protsenko (5):
clk: samsung: clk-pll: Implement pll0822x PLL type
clk: samsung: clk-pll: Implement pll0831x PLL type
dt-bindings: clock: Add bindings definitions for Exynos850 CMU
dt-bindings: clock: Document Exynos850 CMU bindings
clk: samsung: Introduce Exynos850 clock driver
.../clock/samsung,exynos850-clock.yaml | 185 ++++ drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos850.c | 835 ++++++++++++++++++ drivers/clk/samsung/clk-pll.c | 196 ++++ drivers/clk/samsung/clk-pll.h | 2 + include/dt-bindings/clock/exynos850.h | 141 +++ 6 files changed, 1360 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml create mode 100644 drivers/clk/samsung/clk-exynos850.c create mode 100644 include/dt-bindings/clock/exynos850.h
Signature · 1 line
2.30.2
Sam Protsenko
maintainerPATCH v2 1/5 clk: samsung: clk-pll: Implement pll0822x PLL type
pll0822x PLL is used in Exynos850 SoC for top-level integer PLLs. The code was derived from very similar pll35xx type, with next differences:
1. Lock time for pll0822x is 150*P_DIV, when for pll35xx it's 270*P_DIV
2. It's not suggested in Exynos850 TRM that S_DIV change doesn't require performing PLL lock procedure (which is done in pll35xx implementation)
When defining pll0822x type, CON3 register offset should be provided as a "con" parameter of PLL() macro, like this:
PLL(pll_0822x, 0, "fout_shared0_pll", "oscclk",
PLL_LOCKTIME_PLL_SHARED0, PLL_CON3_PLL_SHARED0,
exynos850_shared0_pll_rates),To define PLL rates table, one can use PLL_35XX_RATE() macro, e.g.:
PLL_35XX_RATE(26 * MHZ, 1600 * MHZ, 800, 13, 0)
as it's completely appropriate for pl0822x type and there is no sense in duplicating that.
If bit #1 (MANUAL_PLL_CTRL) is not set in CON1 register, it won't be possible to set new rate, with next error showing in kernel log:
Could not lock PLL fout_shared1_pll
That can happen for example if bootloader clears that bit beforehand. PLL driver doesn't account for that, so if MANUAL_PLL_CTRL bit was cleared, it's assumed it was done for a reason and it shouldn't be possible to change that PLL's rate at all.
---
Changes in v2:
- Added R-b tag by Krzysztof Kozlowski
- Added Ack tag by Chanwoo Choi
drivers/clk/samsung/clk-pll.c | 91 +++++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk-pll.h | 1 + 2 files changed, 92 insertions(+)
drivers/clk/samsung/clk-pll.c +91 -0
@@ -415,6 +415,89 @@ static const struct clk_ops samsung_pll36xx_clk_min_ops = { .recalc_rate = samsung_pll36xx_recalc_rate, }; +/* +* PLL0822x Clock Type +*/ +/* Maximum lock time can be 150 * PDIV cycles */ +#define PLL0822X_LOCK_FACTOR (150) + +#define PLL0822X_MDIV_MASK (0x3FF) +#define PLL0822X_PDIV_MASK (0x3F) +#define PLL0822X_SDIV_MASK (0x7) +#define PLL0822X_MDIV_SHIFT (16) +#define PLL0822X_PDIV_SHIFT (8) +#define PLL0822X_SDIV_SHIFT (0) +#define PLL0822X_LOCK_STAT_SHIFT (29) +#define PLL0822X_ENABLE_SHIFT (31) + +static unsigned long samsung_pll0822x_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct samsung_clk_pll *pll =to_clk_pll (hw); +u32 mdiv, pdiv, sdiv, pll_con3; +u64 fvco = parent_rate; + + pll_con3 =readl_relaxed (pll->con_reg); + mdiv = (pll_con3 >>PLL0822X_MDIV_SHIFT ) &PLL0822X_MDIV_MASK ; + pdiv = (pll_con3 >>PLL0822X_PDIV_SHIFT ) &PLL0822X_PDIV_MASK ; + sdiv = (pll_con3 >>PLL0822X_SDIV_SHIFT ) &PLL0822X_SDIV_MASK ; + + fvco *= mdiv; +do_div (fvco, (pdiv << sdiv)); + +return (unsigned long )fvco; +} + +static int samsung_pll0822x_set_rate (struct clk_hw *hw,unsigned long drate, +unsigned long prate) +{ +const struct samsung_pll_rate_table *rate; +struct samsung_clk_pll *pll =to_clk_pll (hw); +u32 pll_con3; + +/* Get required rate settings from table */ + rate =samsung_get_pll_settings (pll, drate); +if (!rate) { +pr_err ("%s: Invalid rate : %lu for pll clk %s\n" , __func__, + drate,clk_hw_get_name (hw)); +return -EINVAL ; + } + +/* Change PLL PMS values */ + pll_con3 =readl_relaxed (pll->con_reg); + pll_con3 &= ~((PLL0822X_MDIV_MASK <<PLL0822X_MDIV_SHIFT ) | + (PLL0822X_PDIV_MASK <<PLL0822X_PDIV_SHIFT ) | + (PLL0822X_SDIV_MASK <<PLL0822X_SDIV_SHIFT )); + pll_con3 |= (rate->mdiv <<PLL0822X_MDIV_SHIFT ) | + (rate->pdiv <<PLL0822X_PDIV_SHIFT ) | + (rate->sdiv <<PLL0822X_SDIV_SHIFT ); + +/* Set PLL lock time */ +writel_relaxed (rate->pdiv *PLL0822X_LOCK_FACTOR , + pll->lock_reg); + +/* Write PMS values */ +writel_relaxed (pll_con3, pll->con_reg); + +/* Wait for PLL lock if the PLL is enabled */ +if (pll_con3 &BIT (pll->enable_offs)) +return samsung_pll_lock_wait (pll,BIT (pll->lock_offs)); + +return 0 ; +} + +static const struct clk_ops samsung_pll0822x_clk_ops = { + .recalc_rate = samsung_pll0822x_recalc_rate, + .round_rate = samsung_pll_round_rate, + .set_rate = samsung_pll0822x_set_rate, + .enable = samsung_pll3xxx_enable, + .disable = samsung_pll3xxx_disable, +}; + +static const struct clk_ops samsung_pll0822x_clk_min_ops = { + .recalc_rate = samsung_pll0822x_recalc_rate, +}; +/* * PLL45xx Clock Type */
@@ -1296,6 +1379,14 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,else init.ops = &samsung_pll35xx_clk_ops;break ; +case pll_0822x: + pll->enable_offs =PLL0822X_ENABLE_SHIFT ; + pll->lock_offs =PLL0822X_LOCK_STAT_SHIFT ; +if (!pll->rate_table) + init.ops = &samsung_pll0822x_clk_min_ops; +else + init.ops = &samsung_pll0822x_clk_ops; +break ;case pll_4500: init.ops = &samsung_pll45xx_clk_min_ops;break ;
drivers/clk/samsung/clk-pll.h +1 -0
@@ -36,6 +36,7 @@ enum samsung_pll_type { pll_1451x, pll_1452x, pll_1460x, + pll_0822x, };#define PLL_RATE (_fin, _m, _p, _s, _k, _ks) \
Signature · 1 line
2.30.2
Sam Protsenko
maintainerPATCH v2 2/5 clk: samsung: clk-pll: Implement pll0831x PLL type
In reply to Sam Protsenkopll0831x PLL is used in Exynos850 SoC for top-level fractional PLLs. The code was derived from very similar pll36xx type, with next differences:
1. Lock time for pll0831x is 500*P_DIV, when for pll36xx it's 3000*P_DIV
2. It's not suggested in Exynos850 TRM that S_DIV change doesn't require performing PLL lock procedure (which is done in pll36xx implementation)
3. The offset from PMS-values register to K-value register is 0x8 for pll0831x, when for pll36xx it's 0x4
When defining pll0831x type, CON3 register offset should be provided as a "con" parameter of PLL() macro, like this:
PLL(pll_0831x, 0, "fout_mmc_pll", "oscclk",
PLL_LOCKTIME_PLL_MMC, PLL_CON3_PLL_MMC, pll0831x_26mhz_tbl),To define PLL rates table, one can use PLL_36XX_RATE() macro, e.g.:
PLL_36XX_RATE(26 * MHZ, 799999877, 31, 1, 0, -15124)
as it's completely appropriate for pl0831x type and there is no sense in duplicating that.
If bit #1 (MANUAL_PLL_CTRL) is not set in CON1 register, it won't be possible to set new rate, with next error showing in kernel log:
Could not lock PLL fout_mmc_pll
That can happen for example if bootloader clears that bit beforehand. PLL driver doesn't account for that, so if MANUAL_PLL_CTRL bit was cleared, it's assumed it was done for a reason and it shouldn't be possible to change that PLL's rate at all.
---
Changes in v2:
- Added R-b tag by Krzysztof Kozlowski
- Added Ack tag by Chanwoo Choi
drivers/clk/samsung/clk-pll.c | 105 ++++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk-pll.h | 1 + 2 files changed, 106 insertions(+)
drivers/clk/samsung/clk-pll.c +105 -0
@@ -498,6 +498,103 @@ static const struct clk_ops samsung_pll0822x_clk_min_ops = { .recalc_rate = samsung_pll0822x_recalc_rate, }; +/* +* PLL0831x Clock Type +*/ +/* Maximum lock time can be 500 * PDIV cycles */ +#define PLL0831X_LOCK_FACTOR (500) + +#define PLL0831X_KDIV_MASK (0xFFFF) +#define PLL0831X_MDIV_MASK (0x1FF) +#define PLL0831X_PDIV_MASK (0x3F) +#define PLL0831X_SDIV_MASK (0x7) +#define PLL0831X_MDIV_SHIFT (16) +#define PLL0831X_PDIV_SHIFT (8) +#define PLL0831X_SDIV_SHIFT (0) +#define PLL0831X_KDIV_SHIFT (0) +#define PLL0831X_LOCK_STAT_SHIFT (29) +#define PLL0831X_ENABLE_SHIFT (31) + +static unsigned long samsung_pll0831x_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct samsung_clk_pll *pll =to_clk_pll (hw); +u32 mdiv, pdiv, sdiv, pll_con3, pll_con5; +s16 kdiv; +u64 fvco = parent_rate; + + pll_con3 =readl_relaxed (pll->con_reg); + pll_con5 =readl_relaxed (pll->con_reg +8 ); + mdiv = (pll_con3 >>PLL0831X_MDIV_SHIFT ) &PLL0831X_MDIV_MASK ; + pdiv = (pll_con3 >>PLL0831X_PDIV_SHIFT ) &PLL0831X_PDIV_MASK ; + sdiv = (pll_con3 >>PLL0831X_SDIV_SHIFT ) &PLL0831X_SDIV_MASK ; + kdiv = (s16)((pll_con5 >>PLL0831X_KDIV_SHIFT ) &PLL0831X_KDIV_MASK ); + + fvco *= (mdiv <<16 ) + kdiv; +do_div (fvco, (pdiv << sdiv)); + fvco >>=16 ; + +return (unsigned long )fvco; +} + +static int samsung_pll0831x_set_rate (struct clk_hw *hw,unsigned long drate, +unsigned long parent_rate) +{ +const struct samsung_pll_rate_table *rate; +struct samsung_clk_pll *pll =to_clk_pll (hw); +u32 pll_con3, pll_con5; + +/* Get required rate settings from table */ + rate =samsung_get_pll_settings (pll, drate); +if (!rate) { +pr_err ("%s: Invalid rate : %lu for pll clk %s\n" , __func__, + drate,clk_hw_get_name (hw)); +return -EINVAL ; + } + + pll_con3 =readl_relaxed (pll->con_reg); + pll_con5 =readl_relaxed (pll->con_reg +8 ); + +/* Change PLL PMSK values */ + pll_con3 &= ~((PLL0831X_MDIV_MASK <<PLL0831X_MDIV_SHIFT ) | + (PLL0831X_PDIV_MASK <<PLL0831X_PDIV_SHIFT ) | + (PLL0831X_SDIV_MASK <<PLL0831X_SDIV_SHIFT )); + pll_con3 |= (rate->mdiv <<PLL0831X_MDIV_SHIFT ) | + (rate->pdiv <<PLL0831X_PDIV_SHIFT ) | + (rate->sdiv <<PLL0831X_SDIV_SHIFT ); + pll_con5 &= ~(PLL0831X_KDIV_MASK <<PLL0831X_KDIV_SHIFT ); +/* +* kdiv is 16-bit 2's complement (s16), but stored as unsigned int. +* Cast it to u16 to avoid leading 0xffff's in case of negative value. +*/ + pll_con5 |= ((u16 )rate->kdiv <<PLL0831X_KDIV_SHIFT ); + +/* Set PLL lock time */ +writel_relaxed (rate->pdiv *PLL0831X_LOCK_FACTOR , pll->lock_reg); + +/* Write PMSK values */ +writel_relaxed (pll_con3, pll->con_reg); +writel_relaxed (pll_con5, pll->con_reg +8 ); + +/* Wait for PLL lock if the PLL is enabled */ +if (pll_con3 &BIT (pll->enable_offs)) +return samsung_pll_lock_wait (pll,BIT (pll->lock_offs)); + +return 0 ; +} + +static const struct clk_ops samsung_pll0831x_clk_ops = { + .recalc_rate = samsung_pll0831x_recalc_rate, + .set_rate = samsung_pll0831x_set_rate, + .round_rate = samsung_pll_round_rate, + .enable = samsung_pll3xxx_enable, + .disable = samsung_pll3xxx_disable, +}; + +static const struct clk_ops samsung_pll0831x_clk_min_ops = { + .recalc_rate = samsung_pll0831x_recalc_rate, +}; +/* * PLL45xx Clock Type */
@@ -1407,6 +1504,14 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,else init.ops = &samsung_pll36xx_clk_ops;break ; +case pll_0831x: + pll->enable_offs =PLL0831X_ENABLE_SHIFT ; + pll->lock_offs =PLL0831X_LOCK_STAT_SHIFT ; +if (!pll->rate_table) + init.ops = &samsung_pll0831x_clk_min_ops; +else + init.ops = &samsung_pll0831x_clk_ops; +break ;case pll_6552:case pll_6552_s3c2416: init.ops = &samsung_pll6552_clk_ops;
drivers/clk/samsung/clk-pll.h +1 -0
@@ -37,6 +37,7 @@ enum samsung_pll_type { pll_1452x, pll_1460x, pll_0822x, + pll_0831x, };#define PLL_RATE (_fin, _m, _p, _s, _k, _ks) \
Signature · 1 line
2.30.2
Sam Protsenko
maintainerPATCH v2 3/5 dt-bindings: clock: Add bindings definitions for Exynos850 CMU
In reply to Sam ProtsenkoClock controller driver is designed to have separate instances for each particular CMU. So clock IDs in this bindings header also start from 1 for each CMU.
---
Changes in v2:
- Added all clock ids
- Added CLK_ prefix for all clock constants
- Added R-b tag by Krzysztof Kozlowski
- Added Ack tag by Rob Herring
include/dt-bindings/clock/exynos850.h | 141 ++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 include/dt-bindings/clock/exynos850.h
include/dt-bindings/clock/exynos850.h new file +141 -0
@@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2021 Linaro Ltd. +* Author: Sam Protsenko <[email protected]> +* +* Device Tree binding constants for Exynos850 clock controller. +*/ + +#ifndef _DT_BINDINGS_CLOCK_EXYNOS_850_H +#define _DT_BINDINGS_CLOCK_EXYNOS_850_H + +/* CMU_TOP */ +#define CLK_FOUT_SHARED0_PLL 1 +#define CLK_FOUT_SHARED1_PLL 2 +#define CLK_FOUT_MMC_PLL 3 +#define CLK_MOUT_SHARED0_PLL 4 +#define CLK_MOUT_SHARED1_PLL 5 +#define CLK_MOUT_MMC_PLL 6 +#define CLK_MOUT_CORE_BUS 7 +#define CLK_MOUT_CORE_CCI 8 +#define CLK_MOUT_CORE_MMC_EMBD 9 +#define CLK_MOUT_CORE_SSS 10 +#define CLK_MOUT_DPU 11 +#define CLK_MOUT_HSI_BUS 12 +#define CLK_MOUT_HSI_MMC_CARD 13 +#define CLK_MOUT_HSI_USB20DRD 14 +#define CLK_MOUT_PERI_BUS 15 +#define CLK_MOUT_PERI_UART 16 +#define CLK_MOUT_PERI_IP 17 +#define CLK_DOUT_SHARED0_DIV3 18 +#define CLK_DOUT_SHARED0_DIV2 19 +#define CLK_DOUT_SHARED1_DIV3 20 +#define CLK_DOUT_SHARED1_DIV2 21 +#define CLK_DOUT_SHARED0_DIV4 22 +#define CLK_DOUT_SHARED1_DIV4 23 +#define CLK_DOUT_CORE_BUS 24 +#define CLK_DOUT_CORE_CCI 25 +#define CLK_DOUT_CORE_MMC_EMBD 26 +#define CLK_DOUT_CORE_SSS 27 +#define CLK_DOUT_DPU 28 +#define CLK_DOUT_HSI_BUS 29 +#define CLK_DOUT_HSI_MMC_CARD 30 +#define CLK_DOUT_HSI_USB20DRD 31 +#define CLK_DOUT_PERI_BUS 32 +#define CLK_DOUT_PERI_UART 33 +#define CLK_DOUT_PERI_IP 34 +#define CLK_GOUT_CORE_BUS 35 +#define CLK_GOUT_CORE_CCI 36 +#define CLK_GOUT_CORE_MMC_EMBD 37 +#define CLK_GOUT_CORE_SSS 38 +#define CLK_GOUT_DPU 39 +#define CLK_GOUT_HSI_BUS 40 +#define CLK_GOUT_HSI_MMC_CARD 41 +#define CLK_GOUT_HSI_USB20DRD 42 +#define CLK_GOUT_PERI_BUS 43 +#define CLK_GOUT_PERI_UART 44 +#define CLK_GOUT_PERI_IP 45 +#define TOP_NR_CLK 46 + +/* CMU_HSI */ +#define CLK_MOUT_HSI_BUS_USER 1 +#define CLK_MOUT_HSI_MMC_CARD_USER 2 +#define CLK_MOUT_HSI_USB20DRD_USER 3 +#define CLK_MOUT_HSI_RTC 4 +#define CLK_GOUT_USB_RTC_CLK 5 +#define CLK_GOUT_USB_REF_CLK 6 +#define CLK_GOUT_USB_PHY_REF_CLK 7 +#define CLK_GOUT_USB_PHY_ACLK 8 +#define CLK_GOUT_USB_BUS_EARLY_CLK 9 +#define CLK_GOUT_GPIO_HSI_PCLK 10 +#define CLK_GOUT_MMC_CARD_ACLK 11 +#define CLK_GOUT_MMC_CARD_SDCLKIN 12 +#define CLK_GOUT_SYSREG_HSI_PCLK 13 +#define HSI_NR_CLK 14 + +/* CMU_PERI */ +#define CLK_MOUT_PERI_BUS_USER 1 +#define CLK_MOUT_PERI_UART_USER 2 +#define CLK_MOUT_PERI_HSI2C_USER 3 +#define CLK_MOUT_PERI_SPI_USER 4 +#define CLK_DOUT_PERI_HSI2C0 5 +#define CLK_DOUT_PERI_HSI2C1 6 +#define CLK_DOUT_PERI_HSI2C2 7 +#define CLK_DOUT_PERI_SPI0 8 +#define CLK_GOUT_PERI_HSI2C0 9 +#define CLK_GOUT_PERI_HSI2C1 10 +#define CLK_GOUT_PERI_HSI2C2 11 +#define CLK_GOUT_GPIO_PERI_PCLK 12 +#define CLK_GOUT_HSI2C0_IPCLK 13 +#define CLK_GOUT_HSI2C0_PCLK 14 +#define CLK_GOUT_HSI2C1_IPCLK 15 +#define CLK_GOUT_HSI2C1_PCLK 16 +#define CLK_GOUT_HSI2C2_IPCLK 17 +#define CLK_GOUT_HSI2C2_PCLK 18 +#define CLK_GOUT_I2C0_PCLK 19 +#define CLK_GOUT_I2C1_PCLK 20 +#define CLK_GOUT_I2C2_PCLK 21 +#define CLK_GOUT_I2C3_PCLK 22 +#define CLK_GOUT_I2C4_PCLK 23 +#define CLK_GOUT_I2C5_PCLK 24 +#define CLK_GOUT_I2C6_PCLK 25 +#define CLK_GOUT_MCT_PCLK 26 +#define CLK_GOUT_PWM_MOTOR_PCLK 27 +#define CLK_GOUT_SPI0_IPCLK 28 +#define CLK_GOUT_SPI0_PCLK 29 +#define CLK_GOUT_SYSREG_PERI_PCLK 30 +#define CLK_GOUT_UART_IPCLK 31 +#define CLK_GOUT_UART_PCLK 32 +#define CLK_GOUT_WDT0_PCLK 33 +#define CLK_GOUT_WDT1_PCLK 34 +#define PERI_NR_CLK 35 + +/* CMU_CORE */ +#define CLK_MOUT_CORE_BUS_USER 1 +#define CLK_MOUT_CORE_CCI_USER 2 +#define CLK_MOUT_CORE_MMC_EMBD_USER 3 +#define CLK_MOUT_CORE_SSS_USER 4 +#define CLK_MOUT_CORE_GIC 5 +#define CLK_DOUT_CORE_BUSP 6 +#define CLK_GOUT_CCI_ACLK 7 +#define CLK_GOUT_GIC_CLK 8 +#define CLK_GOUT_MMC_EMBD_ACLK 9 +#define CLK_GOUT_MMC_EMBD_SDCLKIN 10 +#define CLK_GOUT_SSS_ACLK 11 +#define CLK_GOUT_SSS_PCLK 12 +#define CORE_NR_CLK 13 + +/* CMU_DPU */ +#define CLK_MOUT_DPU_USER 1 +#define CLK_DOUT_DPU_BUSP 2 +#define CLK_GOUT_DPU_CMU_DPU_PCLK 3 +#define CLK_GOUT_DPU_DECON0_ACLK 4 +#define CLK_GOUT_DPU_DMA_ACLK 5 +#define CLK_GOUT_DPU_DPP_ACLK 6 +#define CLK_GOUT_DPU_PPMU_ACLK 7 +#define CLK_GOUT_DPU_PPMU_PCLK 8 +#define CLK_GOUT_DPU_SMMU_CLK 9 +#define CLK_GOUT_DPU_SYSREG_PCLK 10 +#define DPU_NR_CLK 11 + +#endif /* _DT_BINDINGS_CLOCK_EXYNOS_850_H */
Signature · 1 line
2.30.2
Re: [PATCH v2 3/5] dt-bindings: clock: Add bindings definitions for Exynos850 CMU
Quoted 24 lines · Sam Protsenko
Clock controller driver is designed to have separate instances for each particular CMU. So clock IDs in this bindings header also start from 1 for each CMU.
Signed-off-by Sam Protsenko <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>Acked-by Rob Herring <[email protected]>---
Changes in v2:
- Added all clock ids
- AddedCLK_prefix for all clock constants
- Added R-b tag by Krzysztof Kozlowski
- Added Ack tag by Rob Herringinclude/dt-bindings/clock/exynos850.h | 141 ++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 include/dt-bindings/clock/exynos850.hinclude/dt-bindings/clock/exynos850.h new file +0
-0
include/dt-bindings/clock/exynos850.h line 1
Quoted 1 line
include/dt-bindings/clock/exynos850.h new file +1
-0@@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: GPL-2.0-only */
The bindings are preferred to be under GPL-2.0+BSD. I don't know about such policy for the headers but it seems reasonable - allows re-usage in other systems. Do you mind licensing it under:
GPL-2.0-only or BSD-2-Clause
?
Best regards,
Krzysztof
Quoted 11 lines
include/dt-bindings/clock/exynos850.h new file +11
-0+/* +* Copyright (C) 2021 Linaro Ltd. +* Author: Sam Protsenko <[email protected]> +* +* Device Tree binding constants for Exynos850 clock controller. +*/ + +#ifndef _DT_BINDINGS_CLOCK_EXYNOS_850_H +#define _DT_BINDINGS_CLOCK_EXYNOS_850_H + +/* CMU_TOP */
Sam Protsenko
maintainerRe: [PATCH v2 3/5] dt-bindings: clock: Add bindings definitions for Exynos850 CMU
Quoted 20 lines · Krzysztof Kozlowski
Quoted 18 lines · Sam Protsenko
Clock controller driver is designed to have separate instances for each particular CMU. So clock IDs in this bindings header also start from 1 for each CMU.
Signed-off-by Sam Protsenko <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>Acked-by Rob Herring <[email protected]>---
Changes in v2:
- Added all clock ids
- AddedCLK_prefix for all clock constants
- Added R-b tag by Krzysztof Kozlowski
- Added Ack tag by Rob Herringinclude/dt-bindings/clock/exynos850.h | 141 ++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 include/dt-bindings/clock/exynos850.h
Quoted 14 lines
include/dt-bindings/clock/exynos850.h line 1
Quoted 7 lines
include/dt-bindings/clock/exynos850.h new file +1
-0@@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ The bindings are preferred to be under GPL-2.0+BSD. I don't know about such policy for the headers but it seems reasonable - allows re-usage in other systems. Do you mind licensing it under:
GPL-2.0-only or BSD-2-Clause
?
Sure, will do in v3.
Quoted 14 lines
Best regards,
KrzysztofQuoted 11 lines
include/dt-bindings/clock/exynos850.h new file +11
-0+/* +* Copyright (C) 2021 Linaro Ltd. +* Author: Sam Protsenko <[email protected]> +* +* Device Tree binding constants for Exynos850 clock controller. +*/ + +#ifndef _DT_BINDINGS_CLOCK_EXYNOS_850_H +#define _DT_BINDINGS_CLOCK_EXYNOS_850_H + +/* CMU_TOP */
Re: [PATCH v2 3/5] dt-bindings: clock: Add bindings definitions for Exynos850 CMU
In reply to Sam ProtsenkoQuoted 156 lines · Sam Protsenko
Clock controller driver is designed to have separate instances for each particular CMU. So clock IDs in this bindings header also start from 1 for each CMU.
Signed-off-by Sam Protsenko <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>Acked-by Rob Herring <[email protected]>---
Changes in v2:
- Added all clock ids
- AddedCLK_prefix for all clock constants
- Added R-b tag by Krzysztof Kozlowski
- Added Ack tag by Rob Herringinclude/dt-bindings/clock/exynos850.h | 141 ++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 include/dt-bindings/clock/exynos850.hinclude/dt-bindings/clock/exynos850.h new file +131
-0@@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2021 Linaro Ltd. +* Author: Sam Protsenko <[email protected]> +* +* Device Tree binding constants for Exynos850 clock controller. +*/ + +#ifndef _DT_BINDINGS_CLOCK_EXYNOS_850_H +#define _DT_BINDINGS_CLOCK_EXYNOS_850_H + +/* CMU_TOP */ +#define CLK_FOUT_SHARED0_PLL 1 +#define CLK_FOUT_SHARED1_PLL 2 +#define CLK_FOUT_MMC_PLL 3 +#define CLK_MOUT_SHARED0_PLL 4 +#define CLK_MOUT_SHARED1_PLL 5 +#define CLK_MOUT_MMC_PLL 6 +#define CLK_MOUT_CORE_BUS 7 +#define CLK_MOUT_CORE_CCI 8 +#define CLK_MOUT_CORE_MMC_EMBD 9 +#define CLK_MOUT_CORE_SSS 10 +#define CLK_MOUT_DPU 11 +#define CLK_MOUT_HSI_BUS 12 +#define CLK_MOUT_HSI_MMC_CARD 13 +#define CLK_MOUT_HSI_USB20DRD 14 +#define CLK_MOUT_PERI_BUS 15 +#define CLK_MOUT_PERI_UART 16 +#define CLK_MOUT_PERI_IP 17 +#define CLK_DOUT_SHARED0_DIV3 18 +#define CLK_DOUT_SHARED0_DIV2 19 +#define CLK_DOUT_SHARED1_DIV3 20 +#define CLK_DOUT_SHARED1_DIV2 21 +#define CLK_DOUT_SHARED0_DIV4 22 +#define CLK_DOUT_SHARED1_DIV4 23 +#define CLK_DOUT_CORE_BUS 24 +#define CLK_DOUT_CORE_CCI 25 +#define CLK_DOUT_CORE_MMC_EMBD 26 +#define CLK_DOUT_CORE_SSS 27 +#define CLK_DOUT_DPU 28 +#define CLK_DOUT_HSI_BUS 29 +#define CLK_DOUT_HSI_MMC_CARD 30 +#define CLK_DOUT_HSI_USB20DRD 31 +#define CLK_DOUT_PERI_BUS 32 +#define CLK_DOUT_PERI_UART 33 +#define CLK_DOUT_PERI_IP 34 +#define CLK_GOUT_CORE_BUS 35 +#define CLK_GOUT_CORE_CCI 36 +#define CLK_GOUT_CORE_MMC_EMBD 37 +#define CLK_GOUT_CORE_SSS 38 +#define CLK_GOUT_DPU 39 +#define CLK_GOUT_HSI_BUS 40 +#define CLK_GOUT_HSI_MMC_CARD 41 +#define CLK_GOUT_HSI_USB20DRD 42 +#define CLK_GOUT_PERI_BUS 43 +#define CLK_GOUT_PERI_UART 44 +#define CLK_GOUT_PERI_IP 45 +#define TOP_NR_CLK 46 + +/* CMU_HSI */ +#define CLK_MOUT_HSI_BUS_USER 1 +#define CLK_MOUT_HSI_MMC_CARD_USER 2 +#define CLK_MOUT_HSI_USB20DRD_USER 3 +#define CLK_MOUT_HSI_RTC 4 +#define CLK_GOUT_USB_RTC_CLK 5 +#define CLK_GOUT_USB_REF_CLK 6 +#define CLK_GOUT_USB_PHY_REF_CLK 7 +#define CLK_GOUT_USB_PHY_ACLK 8 +#define CLK_GOUT_USB_BUS_EARLY_CLK 9 +#define CLK_GOUT_GPIO_HSI_PCLK 10 +#define CLK_GOUT_MMC_CARD_ACLK 11 +#define CLK_GOUT_MMC_CARD_SDCLKIN 12 +#define CLK_GOUT_SYSREG_HSI_PCLK 13 +#define HSI_NR_CLK 14 + +/* CMU_PERI */ +#define CLK_MOUT_PERI_BUS_USER 1 +#define CLK_MOUT_PERI_UART_USER 2 +#define CLK_MOUT_PERI_HSI2C_USER 3 +#define CLK_MOUT_PERI_SPI_USER 4 +#define CLK_DOUT_PERI_HSI2C0 5 +#define CLK_DOUT_PERI_HSI2C1 6 +#define CLK_DOUT_PERI_HSI2C2 7 +#define CLK_DOUT_PERI_SPI0 8 +#define CLK_GOUT_PERI_HSI2C0 9 +#define CLK_GOUT_PERI_HSI2C1 10 +#define CLK_GOUT_PERI_HSI2C2 11 +#define CLK_GOUT_GPIO_PERI_PCLK 12 +#define CLK_GOUT_HSI2C0_IPCLK 13 +#define CLK_GOUT_HSI2C0_PCLK 14 +#define CLK_GOUT_HSI2C1_IPCLK 15 +#define CLK_GOUT_HSI2C1_PCLK 16 +#define CLK_GOUT_HSI2C2_IPCLK 17 +#define CLK_GOUT_HSI2C2_PCLK 18 +#define CLK_GOUT_I2C0_PCLK 19 +#define CLK_GOUT_I2C1_PCLK 20 +#define CLK_GOUT_I2C2_PCLK 21 +#define CLK_GOUT_I2C3_PCLK 22 +#define CLK_GOUT_I2C4_PCLK 23 +#define CLK_GOUT_I2C5_PCLK 24 +#define CLK_GOUT_I2C6_PCLK 25 +#define CLK_GOUT_MCT_PCLK 26 +#define CLK_GOUT_PWM_MOTOR_PCLK 27 +#define CLK_GOUT_SPI0_IPCLK 28 +#define CLK_GOUT_SPI0_PCLK 29 +#define CLK_GOUT_SYSREG_PERI_PCLK 30 +#define CLK_GOUT_UART_IPCLK 31 +#define CLK_GOUT_UART_PCLK 32 +#define CLK_GOUT_WDT0_PCLK 33 +#define CLK_GOUT_WDT1_PCLK 34 +#define PERI_NR_CLK 35 + +/* CMU_CORE */ +#define CLK_MOUT_CORE_BUS_USER 1 +#define CLK_MOUT_CORE_CCI_USER 2 +#define CLK_MOUT_CORE_MMC_EMBD_USER 3 +#define CLK_MOUT_CORE_SSS_USER 4 +#define CLK_MOUT_CORE_GIC 5 +#define CLK_DOUT_CORE_BUSP 6 +#define CLK_GOUT_CCI_ACLK 7 +#define CLK_GOUT_GIC_CLK 8 +#define CLK_GOUT_MMC_EMBD_ACLK 9 +#define CLK_GOUT_MMC_EMBD_SDCLKIN 10 +#define CLK_GOUT_SSS_ACLK 11 +#define CLK_GOUT_SSS_PCLK 12 +#define CORE_NR_CLK 13 + +/* CMU_DPU */ +#define CLK_MOUT_DPU_USER 1 +#define CLK_DOUT_DPU_BUSP 2 +#define CLK_GOUT_DPU_CMU_DPU_PCLK 3
include/dt-bindings/clock/exynos850.h line 141
Quoted 10 lines
include/dt-bindings/clock/exynos850.h new file +10
-0+#define CLK_GOUT_DPU_DECON0_ACLK 4 +#define CLK_GOUT_DPU_DMA_ACLK 5 +#define CLK_GOUT_DPU_DPP_ACLK 6 +#define CLK_GOUT_DPU_PPMU_ACLK 7 +#define CLK_GOUT_DPU_PPMU_PCLK 8 +#define CLK_GOUT_DPU_SMMU_CLK 9 +#define CLK_GOUT_DPU_SYSREG_PCLK 10 +#define DPU_NR_CLK 11 + +#endif /* _DT_BINDINGS_CLOCK_EXYNOS_850_H */
Thanks for your work.
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Sam Protsenko
maintainerPATCH v2 4/5 dt-bindings: clock: Document Exynos850 CMU bindings
In reply to Sam ProtsenkoProvide dt-schema documentation for Exynos850 SoC clock controller.
---
Changes in v2:
- Dropped OSCCLK node declaration example
- Dropped UART node declaration example
- Added Ack tag by Chanwoo Choi
.../clock/samsung,exynos850-clock.yaml | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml
Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml new file +185 -0
@@ -0,0 +1,185 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/samsung,exynos850-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung Exynos850 SoC clock controller + +maintainers: + - Sam Protsenko <[email protected]> + - Chanwoo Choi <[email protected]> + - Krzysztof Kozlowski <[email protected]> + - Sylwester Nawrocki <[email protected]> + - Tomasz Figa <[email protected]> + +description: | + Exynos850 clock controller is comprised of several CMU units, generating + clocks for different domains. Those CMU units are modeled as separate device + tree nodes, and might depend on each other. Root clocks in that clock tree are + two external clocks:: OSCCLK (26 MHz) and RTCCLK (32768 Hz). Those external + clocks must be defined as fixed-rate clocks in dts. + + CMU_TOP is a top-level CMU, where all base clocks are prepared using PLLs and + dividers; all other leaf clocks (other CMUs) are usually derived from CMU_TOP. + + Each clock is assigned an identifier and client nodes can use this identifier + to specify the clock which they consume. All clocks that available for usage + in clock consumer nodes are defined as preprocessor macros in + 'dt-bindings/clock/exynos850.h' header. + +properties: + compatible: + enum: + - samsung,exynos850-cmu-top + - samsung,exynos850-cmu-core + - samsung,exynos850-cmu-dpu + - samsung,exynos850-cmu-hsi + - samsung,exynos850-cmu-peri + + clocks: + minItems: 1 + maxItems: 5 + + clock-names: + minItems: 1 + maxItems: 5 + + "#clock-cells": + const: 1 + + reg: + maxItems: 1 + +allOf: + - if: + properties: + compatible: + contains: + const: samsung,exynos850-cmu-top + + then: + properties: + clocks: + items: + - description: External reference clock (26 MHz) + + clock-names: + items: + - const: oscclk + + - if: + properties: + compatible: + contains: + const: samsung,exynos850-cmu-core + + then: + properties: + clocks: + items: + - description: External reference clock (26 MHz) + - description: CMU_CORE bus clock (from CMU_TOP) + - description: CCI clock (from CMU_TOP) + - description: eMMC clock (from CMU_TOP) + - description: SSS clock (from CMU_TOP) + + clock-names: + items: + - const: oscclk + - const: dout_core_bus + - const: dout_core_cci + - const: dout_core_mmc_embd + - const: dout_core_sss + + - if: + properties: + compatible: + contains: + const: samsung,exynos850-cmu-dpu + + then: + properties: + clocks: + items: + - description: External reference clock (26 MHz) + - description: DPU clock (from CMU_TOP) + + clock-names: + items: + - const: oscclk + - const: dout_dpu + + - if: + properties: + compatible: + contains: + const: samsung,exynos850-cmu-hsi + + then: + properties: + clocks: + items: + - description: External reference clock (26 MHz) + - description: External RTC clock (32768 Hz) + - description: CMU_HSI bus clock (from CMU_TOP) + - description: SD card clock (from CMU_TOP) + - description: "USB 2.0 DRD clock (from CMU_TOP)" + + clock-names: + items: + - const: oscclk + - const: rtcclk + - const: dout_hsi_bus + - const: dout_hsi_mmc_card + - const: dout_hsi_usb20drd + + - if: + properties: + compatible: + contains: + const: samsung,exynos850-cmu-peri + + then: + properties: + clocks: + items: + - description: External reference clock (26 MHz) + - description: CMU_PERI bus clock (from CMU_TOP) + - description: UART clock (from CMU_TOP) + - description: Parent clock for HSI2C and SPI (from CMU_TOP) + + clock-names: + items: + - const: oscclk + - const: dout_peri_bus + - const: dout_peri_uart + - const: dout_peri_ip + +required: + - compatible + - "#clock-cells" + - clocks + - clock-names + - reg + +additionalProperties: false + +examples: + # Clock controller node for CMU_PERI + - | + #include <dt-bindings/clock/exynos850.h> + + cmu_peri: clock-controller@10030000 { + compatible = "samsung,exynos850-cmu-peri"; + reg = <0x10030000 0x8000>; + #clock-cells = <1>; + + clocks = <&oscclk>, <&cmu_top CLK_DOUT_PERI_BUS>, + <&cmu_top CLK_DOUT_PERI_UART>, + <&cmu_top CLK_DOUT_PERI_IP>; + clock-names = "oscclk", "dout_peri_bus", + "dout_peri_uart", "dout_peri_ip"; + }; + +...
Signature · 1 line
2.30.2
Re: [PATCH v2 4/5] dt-bindings: clock: Document Exynos850 CMU bindings
Quoted 40 lines · Sam Protsenko
Provide dt-schema documentation for Exynos850 SoC clock controller.
Signed-off-by Sam Protsenko <[email protected]>Acked-by Chanwoo Choi <[email protected]>---
Changes in v2:
- Dropped OSCCLK node declaration example
- Dropped UART node declaration example
- Added Ack tag by Chanwoo Choi.../clock/samsung,exynos850-clock.yaml | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yamlDocumentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml new file +20
-0@@ -0,0 +1,185 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/samsung,exynos850-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung Exynos850 SoC clock controller + +maintainers: + - Sam Protsenko <[email protected]> + - Chanwoo Choi <[email protected]> + - Krzysztof Kozlowski <[email protected]> + - Sylwester Nawrocki <[email protected]> + - Tomasz Figa <[email protected]> + +description: | + Exynos850 clock controller is comprised of several CMU units, generating + clocks for different domains. Those CMU units are modeled as separate device + tree nodes, and might depend on each other. Root clocks in that clock tree are + two external clocks:: OSCCLK (26 MHz) and RTCCLK (32768 Hz). Those external
Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml line 30
Quoted 10 lines
Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml new file +10
-0+ clocks must be defined as fixed-rate clocks in dts. + + CMU_TOP is a top-level CMU, where all base clocks are prepared using PLLs and + dividers; all other leaf clocks (other CMUs) are usually derived from CMU_TOP. + + Each clock is assigned an identifier and client nodes can use this identifier + to specify the clock which they consume. All clocks that available for usage + in clock consumer nodes are defined as preprocessor macros in + 'dt-bindings/clock/exynos850.h' header. +
Best regards,
Krzysztof
Sam Protsenko
maintainerPATCH v2 5/5 clk: samsung: Introduce Exynos850 clock driver
In reply to Sam ProtsenkoThis is the initial implementation adding only basic clocks like UART, MMC, I2C and corresponding parent clocks. Design is influenced by Exynos5433 clock driver.
Bus clock is enabled by default (in probe function) for all CMUs except CMU_TOP, the reasoning is as follows. By default if bus clock has no users its "enable count" value is 0. It might be actually running if it's already enabled in bootloader, but then in some cases it can be disabled by mistake. For example, such case was observed when dw_mci_probe() enabled the bus clock, then failed to do something and disabled that bus clock on error path. After that, even the attempt to read the 'clk_summary' file in DebugFS freezed forever, as CMU bus clock ended up being disabled and it wasn't possible to access CMU registers anymore.
To avoid such cases, CMU driver must increment the ref count for that bus clock by running clk_prepare_enable(). There is already existing '.clk_name' field in struct samsung_cmu_info, exactly for that reason. It was added in commit 523d3de41f02 ("clk: samsung: exynos5433: Add support for runtime PM"), with next mentioning in commit message:
Quoted 2 lines
Also for each CMU there is one special parent clock, which has to be enabled all the time when any access to CMU registers is being done.
But that clock is actually only enabled in Exynos5433 clock driver right now. So the same code is added to exynos850_cmu_probe() function, As was described above, it might be helpful not only for PM reasons, but also to prevent possible erroneous clock gating on error paths.
Another way to workaround that issue would be to use CLOCK_IS_CRITICAL flag for corresponding gate clocks. But that might be not very good design decision, as we might still want to disable that bus clock, e.g. on PM suspend.
---
Changes in v2:
- Used of_iomap() for the whole CMU range instead of ioremap() in
exynos850_init_clocks()
- Used readl/writel functions in exynos850_init_clocks() for consistency with other drivers
- Added all clock ids
- Added CMU_DPU
- Implemented platform_driver for all Power Domain capable CMUs
- Moved bus clock enablement code here to probe function
- Used clk_get() instead of __clk_lookup()
drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos850.c | 835 ++++++++++++++++++++++++++++ 2 files changed, 836 insertions(+) create mode 100644 drivers/clk/samsung/clk-exynos850.c
drivers/clk/samsung/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos5433.o obj-$(CONFIG_EXYNOS_AUDSS_CLK_CON) += clk-exynos-audss.o obj-$(CONFIG_EXYNOS_CLKOUT) += clk-exynos-clkout.o obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos7.o +obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos850.o obj-$(CONFIG_S3C2410_COMMON_CLK)+= clk-s3c2410.o obj-$(CONFIG_S3C2410_COMMON_DCLK)+= clk-s3c2410-dclk.o obj-$(CONFIG_S3C2412_COMMON_CLK)+= clk-s3c2412.o
drivers/clk/samsung/clk-exynos850.c new file +835 -0
835 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH v2 5/5] clk: samsung: Introduce Exynos850 clock driver
Quoted 47 lines · Sam Protsenko
This is the initial implementation adding only basic clocks like UART, MMC, I2C and corresponding parent clocks. Design is influenced by Exynos5433 clock driver.
Bus clock is enabled by default (in probe function) for all CMUs except
CMU_TOP, the reasoning is as follows. By default if bus clock has no users its "enable count" value is 0. It might be actually running if it's already enabled in bootloader, but then in some cases it can be disabled by mistake. For example, such case was observed whendw_mci_probe()enabled the bus clock, then failed to do something and disabled that bus clock on error path. After that, even the attempt to read the 'clk_summary' file in DebugFS freezed forever, as CMU bus clock ended up being disabled and it wasn't possible to access CMU registers anymore.To avoid such cases, CMU driver must increment the ref count for that bus clock by running
clk_prepare_enable(). There is already existing '.clk_name' field in structsamsung_cmu_info, exactly for that reason. It was added in commit523d3de41f02("clk: samsung: exynos5433: Add support for runtime PM"), with next mentioning in commit message:Quoted 2 lines
Also for each CMU there is one special parent clock, which has to be enabled all the time when any access to CMU registers is being done.
But that clock is actually only enabled in Exynos5433 clock driver right now. So the same code is added to
exynos850_cmu_probe()function, As was described above, it might be helpful not only for PM reasons, but also to prevent possible erroneous clock gating on error paths.Another way to workaround that issue would be to use
CLOCK_IS_CRITICALflag for corresponding gate clocks. But that might be not very good design decision, as we might still want to disable that bus clock, e.g. on PM suspend.Signed-off-by Sam Protsenko <[email protected]>---
Changes in v2:
- Usedof_iomap()for the whole CMU range instead ofioremap()inexynos850_init_clocks()- Used readl/writel functions in
exynos850_init_clocks()for consistency with other drivers
- Added all clock ids
- AddedCMU_DPU
- Implementedplatform_driverfor all Power Domain capable CMUs
- Moved bus clock enablement code here to probe function
- Usedclk_get()instead of__clk_lookup()
Quoted 5 lines
drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos850.c | 835 ++++++++++++++++++++++++++++ 2 files changed, 836 insertions(+) create mode 100644 drivers/clk/samsung/clk-exynos850.c
Thanks for the changes, awesome work, I appreciate it.
Best regards,
Krzysztof
Sam Protsenko
maintainerRe: [PATCH v2 5/5] clk: samsung: Introduce Exynos850 clock driver
Quoted 49 lines · Krzysztof Kozlowski
Quoted 47 lines · Sam Protsenko
This is the initial implementation adding only basic clocks like UART, MMC, I2C and corresponding parent clocks. Design is influenced by Exynos5433 clock driver.
Bus clock is enabled by default (in probe function) for all CMUs except
CMU_TOP, the reasoning is as follows. By default if bus clock has no users its "enable count" value is 0. It might be actually running if it's already enabled in bootloader, but then in some cases it can be disabled by mistake. For example, such case was observed whendw_mci_probe()enabled the bus clock, then failed to do something and disabled that bus clock on error path. After that, even the attempt to read the 'clk_summary' file in DebugFS freezed forever, as CMU bus clock ended up being disabled and it wasn't possible to access CMU registers anymore.To avoid such cases, CMU driver must increment the ref count for that bus clock by running
clk_prepare_enable(). There is already existing '.clk_name' field in structsamsung_cmu_info, exactly for that reason. It was added in commit523d3de41f02("clk: samsung: exynos5433: Add support for runtime PM"), with next mentioning in commit message:Quoted 2 lines
Also for each CMU there is one special parent clock, which has to be enabled all the time when any access to CMU registers is being done.
But that clock is actually only enabled in Exynos5433 clock driver right now. So the same code is added to
exynos850_cmu_probe()function, As was described above, it might be helpful not only for PM reasons, but also to prevent possible erroneous clock gating on error paths.Another way to workaround that issue would be to use
CLOCK_IS_CRITICALflag for corresponding gate clocks. But that might be not very good design decision, as we might still want to disable that bus clock, e.g. on PM suspend.Signed-off-by Sam Protsenko <[email protected]>---
Changes in v2:
- Usedof_iomap()for the whole CMU range instead ofioremap()inexynos850_init_clocks()- Used readl/writel functions in
exynos850_init_clocks()for consistency with other drivers
- Added all clock ids
- AddedCMU_DPU
- Implementedplatform_driverfor all Power Domain capable CMUs
- Moved bus clock enablement code here to probe function
- Usedclk_get()instead of__clk_lookup()
Quoted 8 lines
Quoted 5 lines
drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos850.c | 835 ++++++++++++++++++++++++++++ 2 files changed, 836 insertions(+) create mode 100644 drivers/clk/samsung/clk-exynos850.cThanks for the changes, awesome work, I appreciate it.
Thank you for review, Krzysztof! I'll send v3 soon. Hope this series can be applied before next merge window.
Quoted 4 lines
Reviewed-by Krzysztof Kozlowski <[email protected]>Best regards,
Krzysztof