1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2012 ST Microelectronics
6 * SPEAr clk - Common routines
9 #include <linux/clk-provider.h>
10 #include <linux/types.h>
13 long clk_round_rate_index(struct clk_hw *hw, unsigned long drate,
14 unsigned long parent_rate, clk_calc_rate calc_rate, u8 rtbl_cnt,
17 unsigned long prev_rate, rate = 0;
19 for (*index = 0; *index < rtbl_cnt; (*index)++) {
21 rate = calc_rate(hw, parent_rate, *index);
23 /* previous clock was best */
32 if ((*index) == rtbl_cnt)