| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2016 Maxime Ripard. All rights reserved. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This software is licensed under the terms of the GNU General Public |
|---|
| 5 | | - * License version 2, as published by the Free Software Foundation, and |
|---|
| 6 | | - * may be copied, distributed, and modified under those terms. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | | - * GNU General Public License for more details. |
|---|
| 12 | 4 | */ |
|---|
| 13 | 5 | |
|---|
| 14 | 6 | #include <linux/clk-provider.h> |
|---|
| 7 | +#include <linux/io.h> |
|---|
| 15 | 8 | #include <linux/of_address.h> |
|---|
| 16 | 9 | |
|---|
| 17 | 10 | #include "ccu_common.h" |
|---|
| .. | .. |
|---|
| 69 | 62 | BIT(28), /* lock */ |
|---|
| 70 | 63 | CLK_SET_RATE_UNGATE); |
|---|
| 71 | 64 | |
|---|
| 72 | | -static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN(pll_video_clk, "pll-video", |
|---|
| 73 | | - "osc24M", 0x0010, |
|---|
| 74 | | - 192000000, /* Minimum rate */ |
|---|
| 75 | | - 8, 7, /* N */ |
|---|
| 76 | | - 0, 4, /* M */ |
|---|
| 77 | | - BIT(24), /* frac enable */ |
|---|
| 78 | | - BIT(25), /* frac select */ |
|---|
| 79 | | - 270000000, /* frac rate 0 */ |
|---|
| 80 | | - 297000000, /* frac rate 1 */ |
|---|
| 81 | | - BIT(31), /* gate */ |
|---|
| 82 | | - BIT(28), /* lock */ |
|---|
| 83 | | - CLK_SET_RATE_UNGATE); |
|---|
| 65 | +static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video_clk, "pll-video", |
|---|
| 66 | + "osc24M", 0x0010, |
|---|
| 67 | + 192000000, /* Minimum rate */ |
|---|
| 68 | + 912000000, /* Maximum rate */ |
|---|
| 69 | + 8, 7, /* N */ |
|---|
| 70 | + 0, 4, /* M */ |
|---|
| 71 | + BIT(24), /* frac enable */ |
|---|
| 72 | + BIT(25), /* frac select */ |
|---|
| 73 | + 270000000, /* frac rate 0 */ |
|---|
| 74 | + 297000000, /* frac rate 1 */ |
|---|
| 75 | + BIT(31), /* gate */ |
|---|
| 76 | + BIT(28), /* lock */ |
|---|
| 77 | + CLK_SET_RATE_UNGATE); |
|---|
| 84 | 78 | |
|---|
| 85 | 79 | static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve", |
|---|
| 86 | 80 | "osc24M", 0x0018, |
|---|
| .. | .. |
|---|
| 481 | 475 | 0x134, 0, 5, 8, 3, BIT(15), 0); |
|---|
| 482 | 476 | |
|---|
| 483 | 477 | static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve", |
|---|
| 484 | | - 0x13c, 16, 3, BIT(31), 0); |
|---|
| 478 | + 0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT); |
|---|
| 485 | 479 | |
|---|
| 486 | 480 | static SUNXI_CCU_GATE(ac_dig_clk, "ac-dig", "pll-audio", |
|---|
| 487 | 481 | 0x140, BIT(31), CLK_SET_RATE_PARENT); |
|---|
| .. | .. |
|---|
| 724 | 718 | &gpu_clk.common, |
|---|
| 725 | 719 | }; |
|---|
| 726 | 720 | |
|---|
| 721 | +static const struct clk_hw *clk_parent_pll_audio[] = { |
|---|
| 722 | + &pll_audio_base_clk.common.hw |
|---|
| 723 | +}; |
|---|
| 724 | + |
|---|
| 727 | 725 | /* We hardcode the divider to 1 for now */ |
|---|
| 728 | | -static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio", |
|---|
| 729 | | - "pll-audio-base", 1, 1, CLK_SET_RATE_PARENT); |
|---|
| 730 | | -static CLK_FIXED_FACTOR(pll_audio_2x_clk, "pll-audio-2x", |
|---|
| 731 | | - "pll-audio-base", 2, 1, CLK_SET_RATE_PARENT); |
|---|
| 732 | | -static CLK_FIXED_FACTOR(pll_audio_4x_clk, "pll-audio-4x", |
|---|
| 733 | | - "pll-audio-base", 1, 1, CLK_SET_RATE_PARENT); |
|---|
| 734 | | -static CLK_FIXED_FACTOR(pll_audio_8x_clk, "pll-audio-8x", |
|---|
| 735 | | - "pll-audio-base", 1, 2, CLK_SET_RATE_PARENT); |
|---|
| 736 | | -static CLK_FIXED_FACTOR(pll_periph0_2x_clk, "pll-periph0-2x", |
|---|
| 737 | | - "pll-periph0", 1, 2, 0); |
|---|
| 726 | +static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio", |
|---|
| 727 | + clk_parent_pll_audio, |
|---|
| 728 | + 1, 1, CLK_SET_RATE_PARENT); |
|---|
| 729 | +static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x", |
|---|
| 730 | + clk_parent_pll_audio, |
|---|
| 731 | + 2, 1, CLK_SET_RATE_PARENT); |
|---|
| 732 | +static CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x", |
|---|
| 733 | + clk_parent_pll_audio, |
|---|
| 734 | + 1, 1, CLK_SET_RATE_PARENT); |
|---|
| 735 | +static CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x", |
|---|
| 736 | + clk_parent_pll_audio, |
|---|
| 737 | + 1, 2, CLK_SET_RATE_PARENT); |
|---|
| 738 | +static CLK_FIXED_FACTOR_HW(pll_periph0_2x_clk, "pll-periph0-2x", |
|---|
| 739 | + &pll_periph0_clk.common.hw, |
|---|
| 740 | + 1, 2, 0); |
|---|
| 738 | 741 | |
|---|
| 739 | 742 | static struct clk_hw_onecell_data sun8i_h3_hw_clks = { |
|---|
| 740 | 743 | .hws = { |
|---|