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) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/interconnect-provider.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * of_icc_bulk_get() - get interconnect paths
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * @dev: the device requesting the path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * @num_paths: the number of icc_bulk_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * @paths: the table with the paths we want to get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * Returns 0 on success or negative errno otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) int __must_check of_icc_bulk_get(struct device *dev, int num_paths,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 				 struct icc_bulk_data *paths)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	for (i = 0; i < num_paths; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 		paths[i].path = of_icc_get(dev, paths[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		if (IS_ERR(paths[i].path)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 			ret = PTR_ERR(paths[i].path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 			if (ret != -EPROBE_DEFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 				dev_err(dev, "of_icc_get() failed on path %s (%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 					paths[i].name, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 			paths[i].path = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 			goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	icc_bulk_put(i, paths);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) EXPORT_SYMBOL_GPL(of_icc_bulk_get);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * icc_bulk_put() - put a list of interconnect paths
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * @num_paths: the number of icc_bulk_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * @paths: the icc_bulk_data table with the paths being put
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) void icc_bulk_put(int num_paths, struct icc_bulk_data *paths)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	while (--num_paths >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		icc_put(paths[num_paths].path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		paths[num_paths].path = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) EXPORT_SYMBOL_GPL(icc_bulk_put);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * icc_bulk_set() - set bandwidth to a set of paths
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * @num_paths: the number of icc_bulk_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * @paths: the icc_bulk_data table containing the paths and bandwidth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * Returns 0 on success or negative errno otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) int icc_bulk_set_bw(int num_paths, const struct icc_bulk_data *paths)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	for (i = 0; i < num_paths; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		ret = icc_set_bw(paths[i].path, paths[i].avg_bw, paths[i].peak_bw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			pr_err("icc_set_bw() failed on path %s (%d)\n", paths[i].name, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) EXPORT_SYMBOL_GPL(icc_bulk_set_bw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * icc_bulk_enable() - enable a previously disabled set of paths
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * @num_paths: the number of icc_bulk_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * @paths: the icc_bulk_data table containing the paths and bandwidth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * Returns 0 on success or negative errno otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) int icc_bulk_enable(int num_paths, const struct icc_bulk_data *paths)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	for (i = 0; i < num_paths; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		ret = icc_enable(paths[i].path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			pr_err("icc_enable() failed on path %s (%d)\n", paths[i].name, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	icc_bulk_disable(i, paths);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) EXPORT_SYMBOL_GPL(icc_bulk_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * icc_bulk_disable() - disable a set of interconnect paths
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * @num_paths: the number of icc_bulk_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * @paths: the icc_bulk_data table containing the paths and bandwidth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	while (--num_paths >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		icc_disable(paths[num_paths].path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) EXPORT_SYMBOL_GPL(icc_bulk_disable);