Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * Copyright (C) 2012 ST Microelectronics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Viresh Kumar <vireshk@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * This file is licensed under the terms of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * License version 2. This program is licensed "as is" without any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * warranty of any kind, whether express or implied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * SPEAr clk - Common routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/clk-provider.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "clk.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) long clk_round_rate_index(struct clk_hw *hw, unsigned long drate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		unsigned long parent_rate, clk_calc_rate calc_rate, u8 rtbl_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		int *index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	unsigned long prev_rate, rate = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	for (*index = 0; *index < rtbl_cnt; (*index)++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		prev_rate = rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		rate = calc_rate(hw, parent_rate, *index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		if (drate < rate) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 			/* previous clock was best */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 			if (*index) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 				rate = prev_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 				(*index)--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	if ((*index) == rtbl_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		(*index)--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	return rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }