| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2014 Google, Inc |
|---|
| 3 | 4 | * 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. |
|---|
| 14 | 5 | */ |
|---|
| 15 | 6 | |
|---|
| 16 | 7 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 55 | 46 | static int rockchip_mmc_get_phase(struct clk_hw *hw) |
|---|
| 56 | 47 | { |
|---|
| 57 | 48 | 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); |
|---|
| 59 | 50 | u32 raw_value; |
|---|
| 60 | 51 | u16 degrees; |
|---|
| 61 | 52 | u32 delay_num = 0; |
|---|
| 62 | 53 | |
|---|
| 63 | | - /* See the comment for rockchip_mmc_set_phase below */ |
|---|
| 54 | + /* Constant signal, no measurable phase shift */ |
|---|
| 64 | 55 | if (!rate) |
|---|
| 65 | | - return -EINVAL; |
|---|
| 56 | + return 0; |
|---|
| 66 | 57 | |
|---|
| 67 | 58 | raw_value = readl(mmc_clock->reg) >> (mmc_clock->shift); |
|---|
| 68 | 59 | |
|---|
| 69 | 60 | degrees = (raw_value & ROCKCHIP_MMC_DEGREE_MASK) * 90; |
|---|
| 70 | 61 | |
|---|
| 71 | 62 | if (raw_value & ROCKCHIP_MMC_DELAY_SEL) { |
|---|
| 72 | | - /* degrees/delaynum * 10000 */ |
|---|
| 63 | + /* degrees/delaynum * 1000000 */ |
|---|
| 73 | 64 | unsigned long factor = (ROCKCHIP_MMC_DELAY_ELEMENT_PSEC / 10) * |
|---|
| 74 | | - 36 * (rate / 1000000); |
|---|
| 65 | + 36 * (rate / 10000); |
|---|
| 75 | 66 | |
|---|
| 76 | 67 | delay_num = (raw_value & ROCKCHIP_MMC_DELAYNUM_MASK); |
|---|
| 77 | 68 | delay_num >>= ROCKCHIP_MMC_DELAYNUM_OFFSET; |
|---|
| 78 | | - degrees += DIV_ROUND_CLOSEST(delay_num * factor, 10000); |
|---|
| 69 | + degrees += DIV_ROUND_CLOSEST(delay_num * factor, 1000000); |
|---|
| 79 | 70 | } |
|---|
| 80 | 71 | |
|---|
| 81 | 72 | return degrees % 360; |
|---|
| .. | .. |
|---|
| 84 | 75 | static int rockchip_mmc_set_phase(struct clk_hw *hw, int degrees) |
|---|
| 85 | 76 | { |
|---|
| 86 | 77 | 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); |
|---|
| 88 | 79 | u8 nineties, remainder; |
|---|
| 89 | 80 | u8 delay_num; |
|---|
| 90 | 81 | u32 raw_value; |
|---|
| .. | .. |
|---|
| 201 | 192 | const char *const *parent_names, u8 num_parents, |
|---|
| 202 | 193 | void __iomem *reg, int shift) |
|---|
| 203 | 194 | { |
|---|
| 204 | | - struct clk_init_data init = {}; |
|---|
| 195 | + struct clk_init_data init; |
|---|
| 205 | 196 | struct rockchip_mmc_clock *mmc_clock; |
|---|
| 206 | 197 | struct clk *clk; |
|---|
| 207 | 198 | int ret; |
|---|