Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (c) 2019 Western Digital Corporation or its affiliates. |
| 4 | * |
| 5 | * Copyright (C) 2018 SiFive, Inc. |
| 6 | * Wesley Terpstra |
| 7 | * Paul Walmsley |
Green Wan | ecefa5f | 2021-05-27 06:52:08 -0700 | [diff] [blame] | 8 | * Zong Li |
| 9 | * Pragnesh Patel |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License version 2 as |
| 13 | * published by the Free Software Foundation. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 20 | * References: |
| 21 | * - SiFive FU540-C000 manual v1p0, Chapter 7 "Clocking and Reset" |
| 22 | */ |
| 23 | |
Sean Anderson | 1f4d206 | 2020-10-04 21:39:42 -0400 | [diff] [blame] | 24 | #include <dt-bindings/clock/sifive-fu540-prci.h> |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 25 | |
Green Wan | ecefa5f | 2021-05-27 06:52:08 -0700 | [diff] [blame] | 26 | #include "sifive-prci.h" |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 27 | |
Green Wan | ecefa5f | 2021-05-27 06:52:08 -0700 | [diff] [blame] | 28 | /* PRCI integration data for each WRPLL instance */ |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 29 | static struct __prci_wrpll_data __prci_corepll_data = { |
| 30 | .cfg0_offs = PRCI_COREPLLCFG0_OFFSET, |
Pragnesh Patel | 54ce0e0 | 2020-05-29 11:33:29 +0530 | [diff] [blame] | 31 | .cfg1_offs = PRCI_COREPLLCFG1_OFFSET, |
Green Wan | ecefa5f | 2021-05-27 06:52:08 -0700 | [diff] [blame] | 32 | .enable_bypass = sifive_prci_coreclksel_use_hfclk, |
| 33 | .disable_bypass = sifive_prci_coreclksel_use_corepll, |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | static struct __prci_wrpll_data __prci_ddrpll_data = { |
| 37 | .cfg0_offs = PRCI_DDRPLLCFG0_OFFSET, |
Pragnesh Patel | 54ce0e0 | 2020-05-29 11:33:29 +0530 | [diff] [blame] | 38 | .cfg1_offs = PRCI_DDRPLLCFG1_OFFSET, |
Green Wan | ecefa5f | 2021-05-27 06:52:08 -0700 | [diff] [blame] | 39 | .release_reset = sifive_prci_ddr_release_reset, |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | static struct __prci_wrpll_data __prci_gemgxlpll_data = { |
| 43 | .cfg0_offs = PRCI_GEMGXLPLLCFG0_OFFSET, |
Pragnesh Patel | 54ce0e0 | 2020-05-29 11:33:29 +0530 | [diff] [blame] | 44 | .cfg1_offs = PRCI_GEMGXLPLLCFG1_OFFSET, |
Green Wan | ecefa5f | 2021-05-27 06:52:08 -0700 | [diff] [blame] | 45 | .release_reset = sifive_prci_ethernet_release_reset, |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
Green Wan | ecefa5f | 2021-05-27 06:52:08 -0700 | [diff] [blame] | 48 | /* Linux clock framework integration */ |
| 49 | static const struct __prci_clock_ops sifive_fu540_prci_wrpll_clk_ops = { |
| 50 | .set_rate = sifive_prci_wrpll_set_rate, |
| 51 | .round_rate = sifive_prci_wrpll_round_rate, |
| 52 | .recalc_rate = sifive_prci_wrpll_recalc_rate, |
| 53 | .enable_clk = sifive_prci_clock_enable, |
| 54 | }; |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 55 | |
Green Wan | ecefa5f | 2021-05-27 06:52:08 -0700 | [diff] [blame] | 56 | static const struct __prci_clock_ops sifive_fu540_prci_tlclksel_clk_ops = { |
| 57 | .recalc_rate = sifive_prci_tlclksel_recalc_rate, |
| 58 | }; |
| 59 | |
| 60 | /* List of clock controls provided by the PRCI */ |
| 61 | struct __prci_clock __prci_init_clocks_fu540[] = { |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 62 | [PRCI_CLK_COREPLL] = { |
| 63 | .name = "corepll", |
| 64 | .parent_name = "hfclk", |
| 65 | .ops = &sifive_fu540_prci_wrpll_clk_ops, |
| 66 | .pwd = &__prci_corepll_data, |
| 67 | }, |
| 68 | [PRCI_CLK_DDRPLL] = { |
| 69 | .name = "ddrpll", |
| 70 | .parent_name = "hfclk", |
Pragnesh Patel | 1790bce | 2020-05-29 11:33:30 +0530 | [diff] [blame] | 71 | .ops = &sifive_fu540_prci_wrpll_clk_ops, |
Anup Patel | 42fdf08 | 2019-02-25 08:14:49 +0000 | [diff] [blame] | 72 | .pwd = &__prci_ddrpll_data, |
| 73 | }, |
| 74 | [PRCI_CLK_GEMGXLPLL] = { |
| 75 | .name = "gemgxlpll", |
| 76 | .parent_name = "hfclk", |
| 77 | .ops = &sifive_fu540_prci_wrpll_clk_ops, |
| 78 | .pwd = &__prci_gemgxlpll_data, |
| 79 | }, |
| 80 | [PRCI_CLK_TLCLK] = { |
| 81 | .name = "tlclk", |
| 82 | .parent_name = "corepll", |
| 83 | .ops = &sifive_fu540_prci_tlclksel_clk_ops, |
| 84 | }, |
| 85 | }; |