Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: sifive: Add pcie_aux clock in prci driver for PCIe driver

We add pcie_aux clock in this patch so that pcie driver can use
clk_prepare_enable() and clk_disable_unprepare() to enable and disable
pcie_aux clock.

Link: https://lore.kernel.org/r/20210504105940.100004-2-greentime.hu@sifive.com
Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>

authored by

Greentime Hu and committed by
Lorenzo Pieralisi
c61287bf a38fd874

+63 -1
+11
drivers/clk/sifive/fu740-prci.c
··· 72 72 .recalc_rate = sifive_prci_hfpclkplldiv_recalc_rate, 73 73 }; 74 74 75 + static const struct clk_ops sifive_fu740_prci_pcie_aux_clk_ops = { 76 + .enable = sifive_prci_pcie_aux_clock_enable, 77 + .disable = sifive_prci_pcie_aux_clock_disable, 78 + .is_enabled = sifive_prci_pcie_aux_clock_is_enabled, 79 + }; 80 + 75 81 /* List of clock controls provided by the PRCI */ 76 82 struct __prci_clock __prci_init_clocks_fu740[] = { 77 83 [PRCI_CLK_COREPLL] = { ··· 125 119 .name = "pclk", 126 120 .parent_name = "hfpclkpll", 127 121 .ops = &sifive_fu740_prci_hfpclkplldiv_clk_ops, 122 + }, 123 + [PRCI_CLK_PCIE_AUX] = { 124 + .name = "pcie_aux", 125 + .parent_name = "hfclk", 126 + .ops = &sifive_fu740_prci_pcie_aux_clk_ops, 128 127 }, 129 128 };
+1 -1
drivers/clk/sifive/fu740-prci.h
··· 9 9 10 10 #include "sifive-prci.h" 11 11 12 - #define NUM_CLOCK_FU740 8 12 + #define NUM_CLOCK_FU740 9 13 13 14 14 extern struct __prci_clock __prci_init_clocks_fu740[NUM_CLOCK_FU740]; 15 15
+41
drivers/clk/sifive/sifive-prci.c
··· 453 453 r = __prci_readl(pd, PRCI_HFPCLKPLLSEL_OFFSET); /* barrier */ 454 454 } 455 455 456 + /* PCIE AUX clock APIs for enable, disable. */ 457 + int sifive_prci_pcie_aux_clock_is_enabled(struct clk_hw *hw) 458 + { 459 + struct __prci_clock *pc = clk_hw_to_prci_clock(hw); 460 + struct __prci_data *pd = pc->pd; 461 + u32 r; 462 + 463 + r = __prci_readl(pd, PRCI_PCIE_AUX_OFFSET); 464 + 465 + if (r & PRCI_PCIE_AUX_EN_MASK) 466 + return 1; 467 + else 468 + return 0; 469 + } 470 + 471 + int sifive_prci_pcie_aux_clock_enable(struct clk_hw *hw) 472 + { 473 + struct __prci_clock *pc = clk_hw_to_prci_clock(hw); 474 + struct __prci_data *pd = pc->pd; 475 + u32 r __maybe_unused; 476 + 477 + if (sifive_prci_pcie_aux_clock_is_enabled(hw)) 478 + return 0; 479 + 480 + __prci_writel(1, PRCI_PCIE_AUX_OFFSET, pd); 481 + r = __prci_readl(pd, PRCI_PCIE_AUX_OFFSET); /* barrier */ 482 + 483 + return 0; 484 + } 485 + 486 + void sifive_prci_pcie_aux_clock_disable(struct clk_hw *hw) 487 + { 488 + struct __prci_clock *pc = clk_hw_to_prci_clock(hw); 489 + struct __prci_data *pd = pc->pd; 490 + u32 r __maybe_unused; 491 + 492 + __prci_writel(0, PRCI_PCIE_AUX_OFFSET, pd); 493 + r = __prci_readl(pd, PRCI_PCIE_AUX_OFFSET); /* barrier */ 494 + 495 + } 496 + 456 497 /** 457 498 * __prci_register_clocks() - register clock controls in the PRCI 458 499 * @dev: Linux struct device
+9
drivers/clk/sifive/sifive-prci.h
··· 67 67 #define PRCI_DDRPLLCFG1_CKE_SHIFT 31 68 68 #define PRCI_DDRPLLCFG1_CKE_MASK (0x1 << PRCI_DDRPLLCFG1_CKE_SHIFT) 69 69 70 + /* PCIEAUX */ 71 + #define PRCI_PCIE_AUX_OFFSET 0x14 72 + #define PRCI_PCIE_AUX_EN_SHIFT 0 73 + #define PRCI_PCIE_AUX_EN_MASK (0x1 << PRCI_PCIE_AUX_EN_SHIFT) 74 + 70 75 /* GEMGXLPLLCFG0 */ 71 76 #define PRCI_GEMGXLPLLCFG0_OFFSET 0x1c 72 77 #define PRCI_GEMGXLPLLCFG0_DIVR_SHIFT 0 ··· 300 295 unsigned long parent_rate); 301 296 unsigned long sifive_prci_hfpclkplldiv_recalc_rate(struct clk_hw *hw, 302 297 unsigned long parent_rate); 298 + 299 + int sifive_prci_pcie_aux_clock_is_enabled(struct clk_hw *hw); 300 + int sifive_prci_pcie_aux_clock_enable(struct clk_hw *hw); 301 + void sifive_prci_pcie_aux_clock_disable(struct clk_hw *hw); 303 302 304 303 #endif /* __SIFIVE_CLK_SIFIVE_PRCI_H */
+1
include/dt-bindings/clock/sifive-fu740-prci.h
··· 19 19 #define PRCI_CLK_CLTXPLL 5 20 20 #define PRCI_CLK_TLCLK 6 21 21 #define PRCI_CLK_PCLK 7 22 + #define PRCI_CLK_PCIE_AUX 8 22 23 23 24 #endif /* __DT_BINDINGS_CLOCK_SIFIVE_FU740_PRCI_H */