hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/clk/rockchip/clk-mmc-phase.c
....@@ -1,16 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright 2014 Google, Inc
34 * Author: Alexandru M Stan <amstan@chromium.org>
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
145 */
156
167 #include <linux/slab.h>
....@@ -55,27 +46,27 @@
5546 static int rockchip_mmc_get_phase(struct clk_hw *hw)
5647 {
5748 struct rockchip_mmc_clock *mmc_clock = to_mmc_clock(hw);
58
- unsigned long rate = clk_get_rate(hw->clk);
49
+ unsigned long rate = clk_hw_get_rate(hw);
5950 u32 raw_value;
6051 u16 degrees;
6152 u32 delay_num = 0;
6253
63
- /* See the comment for rockchip_mmc_set_phase below */
54
+ /* Constant signal, no measurable phase shift */
6455 if (!rate)
65
- return -EINVAL;
56
+ return 0;
6657
6758 raw_value = readl(mmc_clock->reg) >> (mmc_clock->shift);
6859
6960 degrees = (raw_value & ROCKCHIP_MMC_DEGREE_MASK) * 90;
7061
7162 if (raw_value & ROCKCHIP_MMC_DELAY_SEL) {
72
- /* degrees/delaynum * 10000 */
63
+ /* degrees/delaynum * 1000000 */
7364 unsigned long factor = (ROCKCHIP_MMC_DELAY_ELEMENT_PSEC / 10) *
74
- 36 * (rate / 1000000);
65
+ 36 * (rate / 10000);
7566
7667 delay_num = (raw_value & ROCKCHIP_MMC_DELAYNUM_MASK);
7768 delay_num >>= ROCKCHIP_MMC_DELAYNUM_OFFSET;
78
- degrees += DIV_ROUND_CLOSEST(delay_num * factor, 10000);
69
+ degrees += DIV_ROUND_CLOSEST(delay_num * factor, 1000000);
7970 }
8071
8172 return degrees % 360;
....@@ -84,7 +75,7 @@
8475 static int rockchip_mmc_set_phase(struct clk_hw *hw, int degrees)
8576 {
8677 struct rockchip_mmc_clock *mmc_clock = to_mmc_clock(hw);
87
- unsigned long rate = clk_get_rate(hw->clk);
78
+ unsigned long rate = clk_hw_get_rate(hw);
8879 u8 nineties, remainder;
8980 u8 delay_num;
9081 u32 raw_value;
....@@ -201,7 +192,7 @@
201192 const char *const *parent_names, u8 num_parents,
202193 void __iomem *reg, int shift)
203194 {
204
- struct clk_init_data init = {};
195
+ struct clk_init_data init;
205196 struct rockchip_mmc_clock *mmc_clock;
206197 struct clk *clk;
207198 int ret;